feat: list mode, fix version option
This commit is contained in:
parent
79c7e71796
commit
8efbd992df
|
@ -23,6 +23,7 @@ export default {
|
||||||
delimiters: ['{{ ', ' }}'],
|
delimiters: ['{{ ', ' }}'],
|
||||||
values: {
|
values: {
|
||||||
APP_NAME: metadata.name,
|
APP_NAME: metadata.name,
|
||||||
|
APP_VERSION: metadata.version,
|
||||||
BUILD_JOB: process.env['CI_JOB_ID'],
|
BUILD_JOB: process.env['CI_JOB_ID'],
|
||||||
BUILD_RUNNER: process.env['CI_ENVIRONMENT_SLUG'],
|
BUILD_RUNNER: process.env['CI_ENVIRONMENT_SLUG'],
|
||||||
GIT_BRANCH: process.env['CI_COMMIT_REF_SLUG'],
|
GIT_BRANCH: process.env['CI_COMMIT_REF_SLUG'],
|
||||||
|
|
12
src/index.ts
12
src/index.ts
|
@ -13,7 +13,7 @@ import { VisitorContext } from 'src/visitor/context';
|
||||||
const CONFIG_ARGS_NAME = 'config-name';
|
const CONFIG_ARGS_NAME = 'config-name';
|
||||||
const CONFIG_ARGS_PATH = 'config-path';
|
const CONFIG_ARGS_PATH = 'config-path';
|
||||||
|
|
||||||
const MODES = ['check', 'fix'];
|
const MODES = ['check', 'fix', 'list'];
|
||||||
|
|
||||||
const RULE_OPTION: Options = {
|
const RULE_OPTION: Options = {
|
||||||
default: [],
|
default: [],
|
||||||
|
@ -54,7 +54,7 @@ const MAIN_ARGS = usage(`Usage: salty-dog <mode> [options]`)
|
||||||
})
|
})
|
||||||
.option('mode', {
|
.option('mode', {
|
||||||
alias: ['m'],
|
alias: ['m'],
|
||||||
choices: ['check', 'fix'],
|
choices: MODES,
|
||||||
default: 'check',
|
default: 'check',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
})
|
})
|
||||||
|
@ -78,7 +78,8 @@ const MAIN_ARGS = usage(`Usage: salty-dog <mode> [options]`)
|
||||||
...RULE_OPTION,
|
...RULE_OPTION,
|
||||||
alias: ['t', 'tag'],
|
alias: ['t', 'tag'],
|
||||||
})
|
})
|
||||||
.help();
|
.help()
|
||||||
|
.version(VERSION_INFO.app.version);
|
||||||
|
|
||||||
const STATUS_SUCCESS = 0;
|
const STATUS_SUCCESS = 0;
|
||||||
const STATUS_ERROR = 1;
|
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 rules = await loadRules(args.rules, ctx.ajv);
|
||||||
const activeRules = await resolveRules(rules, args as any);
|
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 data of docs) {
|
||||||
for (const rule of activeRules) {
|
for (const rule of activeRules) {
|
||||||
const items = await rule.pick(ctx, data);
|
const items = await rule.pick(ctx, data);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
export const VERSION_INFO = {
|
export const VERSION_INFO = {
|
||||||
app: {
|
app: {
|
||||||
name: '{{ APP_NAME }}',
|
name: '{{ APP_NAME }}',
|
||||||
|
version: '{{ APP_VERSION }}',
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
job: '{{ BUILD_JOB }}',
|
job: '{{ BUILD_JOB }}',
|
||||||
|
|
Loading…
Reference in New Issue