-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(models): add global options (#76)
This PR includes a small refactoring to align with #73
- Loading branch information
Showing
13 changed files
with
88 additions
and
54 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { yargsCli } from './lib/cli'; | ||
import { yargsGlobalOptionsDefinition } from './lib/options'; | ||
import { options } from './lib/options'; | ||
import { middlewares } from './lib/middlewares'; | ||
import { commands } from './lib/commands'; | ||
|
||
export { options } from './lib/options'; | ||
export { middlewares } from './lib/middlewares'; | ||
export { commands } from './lib/commands'; | ||
|
||
export const cli = (args: string[]) => | ||
yargsCli(args, { | ||
usageMessage: 'Code PushUp CLI', | ||
scriptName: 'code-pushup', | ||
options: yargsGlobalOptionsDefinition(), | ||
options, | ||
middlewares, | ||
commands, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
packages/cli/src/lib/implementation/base-command-config.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { GlobalOptions } from '../model'; | ||
import { Options } from 'yargs'; | ||
|
||
export function yargsGlobalOptionsDefinition(): Record< | ||
keyof GlobalOptions, | ||
Options | ||
> { | ||
return { | ||
interactive: { | ||
describe: 'When false disables interactive input prompts for options.', | ||
type: 'boolean', | ||
default: true, | ||
}, | ||
verbose: { | ||
describe: | ||
'When true creates more verbose output. This is helpful when debugging.', | ||
type: 'boolean', | ||
default: false, | ||
}, | ||
configPath: { | ||
describe: 'Path the the config file, e.g. code-pushup.config.js', | ||
type: 'string', | ||
default: 'code-pushup.config.js', | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { | ||
globalOptionsSchema as coreGlobalOptionsSchema, | ||
refineCoreConfig, | ||
unrefinedCoreConfigSchema, | ||
} from '@quality-metrics/models'; | ||
import { z } from 'zod'; | ||
|
||
export const globalOptionsSchema = coreGlobalOptionsSchema.merge( | ||
z.object({ | ||
interactive: z | ||
.boolean({ | ||
description: | ||
'flag if interactivity should be considered. Useful for CI runs.', | ||
}) | ||
.default(true), | ||
}), | ||
); | ||
|
||
export type GlobalOptions = z.infer<typeof globalOptionsSchema>; | ||
|
||
export const commandBaseSchema = refineCoreConfig( | ||
globalOptionsSchema.merge(unrefinedCoreConfigSchema), | ||
); | ||
export type CommandBase = z.infer<typeof commandBaseSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { globalOptionsSchema as coreGlobalOptionsSchema } from '@quality-metrics/models'; | ||
import { z } from 'zod'; | ||
|
||
export const globalOptionsSchema = coreGlobalOptionsSchema.merge( | ||
z.object({ | ||
interactive: z | ||
.boolean({ | ||
description: | ||
'flag if interactivity should be considered. Useful for CI runs.', | ||
}) | ||
.default(true), | ||
}), | ||
); | ||
|
||
export type GlobalOptions = z.infer<typeof globalOptionsSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,5 @@ | ||
import { Options } from 'yargs'; | ||
import { yargsGlobalOptionsDefinition } from './implementation/global-options'; | ||
|
||
export function yargsGlobalOptionsDefinition(): Record<string, Options> { | ||
return { | ||
interactive: { | ||
describe: 'When false disables interactive input prompts for options.', | ||
type: 'boolean', | ||
default: true, | ||
}, | ||
verbose: { | ||
describe: | ||
'When true creates more verbose output. This is helpful when debugging.', | ||
type: 'boolean', | ||
default: false, | ||
}, | ||
configPath: { | ||
describe: 'Path the the config file, e.g. code-pushup.config.js', | ||
type: 'string', | ||
default: 'code-pushup.config.js', | ||
}, | ||
}; | ||
} | ||
export const options = { | ||
...yargsGlobalOptionsDefinition(), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters