1
0
Fork 0

feat: list mode, fix version option

This commit is contained in:
ssube 2019-06-24 23:47:12 -05:00
parent 79c7e71796
commit 8efbd992df
3 changed files with 11 additions and 3 deletions

View File

@ -23,6 +23,7 @@ export default {
delimiters: ['{{ ', ' }}'],
values: {
APP_NAME: metadata.name,
APP_VERSION: metadata.version,
BUILD_JOB: process.env['CI_JOB_ID'],
BUILD_RUNNER: process.env['CI_ENVIRONMENT_SLUG'],
GIT_BRANCH: process.env['CI_COMMIT_REF_SLUG'],

View File

@ -13,7 +13,7 @@ import { VisitorContext } from 'src/visitor/context';
const CONFIG_ARGS_NAME = 'config-name';
const CONFIG_ARGS_PATH = 'config-path';
const MODES = ['check', 'fix'];
const MODES = ['check', 'fix', 'list'];
const RULE_OPTION: Options = {
default: [],
@ -54,7 +54,7 @@ const MAIN_ARGS = usage(`Usage: salty-dog <mode> [options]`)
})
.option('mode', {
alias: ['m'],
choices: ['check', 'fix'],
choices: MODES,
default: 'check',
type: 'string',
})
@ -78,7 +78,8 @@ const MAIN_ARGS = usage(`Usage: salty-dog <mode> [options]`)
...RULE_OPTION,
alias: ['t', 'tag'],
})
.help();
.help()
.version(VERSION_INFO.app.version);
const STATUS_SUCCESS = 0;
const STATUS_ERROR = 1;
@ -116,6 +117,11 @@ export async function main(argv: Array<string>): Promise<number> {
const rules = await loadRules(args.rules, ctx.ajv);
const activeRules = await resolveRules(rules, args as any);
if (args.mode === 'list') {
logger.info({rules: activeRules}, 'listing active rules');
return STATUS_SUCCESS;
}
for (const data of docs) {
for (const rule of activeRules) {
const items = await rule.pick(ctx, data);

View File

@ -1,6 +1,7 @@
export const VERSION_INFO = {
app: {
name: '{{ APP_NAME }}',
version: '{{ APP_VERSION }}',
},
build: {
job: '{{ BUILD_JOB }}',