Skip to content

Commit daf548d

Browse files
authored
refactor(cli): rename configPath to config (#109)
1 parent fff1ae2 commit daf548d

File tree

9 files changed

+32
-32
lines changed

9 files changed

+32
-32
lines changed

examples/cli-e2e/tests/cli.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ const execCli = (argObj: Partial<CliArgsObject>) =>
2020

2121
describe('cli', () => {
2222
it('should load .js config file', async () => {
23-
await execCli({ configPath: configFile('js') });
23+
await execCli({ config: configFile('js') });
2424
});
2525

2626
it('should load .mjs config file', async () => {
27-
await execCli({ configPath: configFile('mjs') });
27+
await execCli({ config: configFile('mjs') });
2828
});
2929

3030
it('should load .ts config file', async () => {
31-
await execCli({ configPath: configFile('ts') });
31+
await execCli({ config: configFile('ts') });
3232
});
3333
});

packages/cli/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependsOn": ["build"]
2121
},
2222
"exec": {
23-
"command": "npx dist/packages/cli --configPath=./packages/cli/code-pushup.config.ts",
23+
"command": "npx dist/packages/cli --config=./packages/cli/code-pushup.config.ts",
2424
"dependsOn": ["build"]
2525
},
2626
"lint": {

packages/cli/src/lib/collect/command-object.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { yargsCollectCommandObject } from './command-object';
99
const baseArgs = [
1010
...objectToCliArgs({
1111
verbose: true,
12-
configPath: join(
12+
config: join(
1313
fileURLToPath(dirname(import.meta.url)),
1414
'..',
1515
'..',

packages/cli/src/lib/implementation/config-middleware.spec.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,42 @@ import { getDirname } from './helper.mock';
66
const __dirname = getDirname(import.meta.url);
77

88
const withDirName = (path: string) => join(__dirname, path);
9-
const configPath = (ext: string) =>
9+
const config = (ext: string) =>
1010
`${withDirName('../../../test/config.mock.')}${ext}`;
1111

1212
describe('applyConfigMiddleware', () => {
1313
it('should load valid .mjs config', async () => {
14-
const configPathMjs = configPath('mjs');
15-
const config = await configMiddleware({ configPath: configPathMjs });
16-
expect(config.upload.project).toContain('mjs');
17-
expect(config.persist.outputDir).toContain('tmp');
14+
const configPathMjs = config('mjs');
15+
const _config = await configMiddleware({ config: configPathMjs });
16+
expect(_config.upload.project).toContain('mjs');
17+
expect(_config.persist.outputDir).toContain('tmp');
1818
});
1919

2020
it('should load valid .cjs config', async () => {
21-
const configPathCjs = configPath('cjs');
22-
const config = await configMiddleware({ configPath: configPathCjs });
23-
expect(config.upload.project).toContain('cjs');
24-
expect(config.persist.outputDir).toContain('tmp');
21+
const configPathCjs = config('cjs');
22+
const _config = await configMiddleware({ config: configPathCjs });
23+
expect(_config.upload.project).toContain('cjs');
24+
expect(_config.persist.outputDir).toContain('tmp');
2525
});
2626

2727
it('should load valid .js config', async () => {
28-
const configPathJs = configPath('js');
29-
const config = await configMiddleware({ configPath: configPathJs });
30-
expect(config.upload.project).toContain('js');
31-
expect(config.persist.outputDir).toContain('tmp');
28+
const configPathJs = config('js');
29+
const _config = await configMiddleware({ config: configPathJs });
30+
expect(_config.upload.project).toContain('js');
31+
expect(_config.persist.outputDir).toContain('tmp');
3232
});
3333

34-
it('should throw with invalid configPath', async () => {
35-
const configPath = 'wrong/path/to/config';
34+
it('should throw with invalid config', async () => {
35+
const config = 'wrong/path/to/config';
3636
let error: Error = new Error();
37-
await configMiddleware({ configPath }).catch(e => (error = e));
38-
expect(error?.message).toContain(configPath);
37+
await configMiddleware({ config }).catch(e => (error = e));
38+
expect(error?.message).toContain(config);
3939
});
4040

41-
it('should provide default configPath', async () => {
41+
it('should provide default config', async () => {
4242
const defaultConfigPath = 'code-pushup.config.js';
4343
let error: Error = new Error();
44-
await configMiddleware({ configPath: undefined }).catch(e => (error = e));
44+
await configMiddleware({ config: undefined }).catch(e => (error = e));
4545
expect(error?.message).toContain(defaultConfigPath);
4646
});
4747
});

packages/cli/src/lib/implementation/config-middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { ArgsCliObj, CommandBase } from './model';
44

55
export async function configMiddleware<T extends ArgsCliObj>(processArgs: T) {
66
const args = processArgs as T;
7-
const { configPath, ...cliOptions }: GlobalOptions =
7+
const { config, ...cliOptions }: GlobalOptions =
88
globalOptionsSchema.parse(args);
9-
const importedRc = await readCodePushupConfig(configPath);
9+
const importedRc = await readCodePushupConfig(config);
1010
const cliConfigArgs = readCoreConfigFromCliArgs(processArgs);
1111
const parsedProcessArgs: CommandBase = {
1212
...cliOptions,

packages/cli/src/lib/implementation/global-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function yargsGlobalOptionsDefinition(): Record<
1717
type: 'boolean',
1818
default: false,
1919
},
20-
configPath: {
20+
config: {
2121
describe: 'Path the the config file, e.g. code-pushup.config.js',
2222
type: 'string',
2323
default: 'code-pushup.config.js',

packages/cli/src/lib/upload/command-object.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const baseArgs = [
3131
'upload',
3232
'--verbose',
3333
...objectToCliArgs({
34-
configPath: join(
34+
config: join(
3535
fileURLToPath(dirname(import.meta.url)),
3636
'..',
3737
'..',

packages/cli/src/lib/yargs-cli.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const demandCommand: [number, string] = [0, 'no command required'];
1414
function middleware<T extends Record<string, unknown>>(processArgs: T) {
1515
return {
1616
...processArgs,
17-
configPath: '42',
17+
config: '42',
1818
};
1919
}
2020

@@ -41,7 +41,7 @@ describe('yargsCli', () => {
4141

4242
it('global options and middleware handle argument overrides correctly', async () => {
4343
const args: string[] = objectToCliArgs({
44-
configPath: 'validConfigPath',
44+
config: 'validConfigPath',
4545
});
4646
const parsedArgv = await yargsCli(args, {
4747
options,
@@ -52,6 +52,6 @@ describe('yargsCli', () => {
5252
},
5353
],
5454
}).parseAsync();
55-
expect(parsedArgv.configPath).toContain(42);
55+
expect(parsedArgv.config).toContain(42);
5656
});
5757
});

packages/models/src/lib/global-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const globalOptionsSchema = z.object({
77
description: 'Outputs additional information for a run',
88
})
99
.default(false),
10-
configPath: filePathSchema(
10+
config: filePathSchema(
1111
"Path to config file in format `ts` or `mjs`. defaults to 'code-pushup.config.js'",
1212
)
1313
.optional()

0 commit comments

Comments
 (0)