diff --git a/e2e/cli-e2e/tests/__snapshots__/help.e2e.test.ts.snap b/e2e/cli-e2e/tests/__snapshots__/help.e2e.test.ts.snap index 6d0973eca..1ca5a9802 100644 --- a/e2e/cli-e2e/tests/__snapshots__/help.e2e.test.ts.snap +++ b/e2e/cli-e2e/tests/__snapshots__/help.e2e.test.ts.snap @@ -18,9 +18,9 @@ Commands: Global Options: - --verbose When true creates more verbose output. This is helpful w - hen debugging. You may also set CP_VERBOSE env variable - instead. [boolean] [default: false] + --verbose Toggles whether to print debug logs. The default value i + s derived from the CP_VERBOSE environment variable (fals + e if not set). [boolean] --config Path to config file. By default it loads code-pushup.con fig.(ts|mjs|js). [string] --tsconfig Path to a TypeScript config, to be used when loading con diff --git a/e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts b/e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts index c7f911a2e..2b98174a1 100644 --- a/e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts +++ b/e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts @@ -179,8 +179,6 @@ describe('nx-plugin', () => { // Run CLI executor expect(cleanStdout).toContain('DryRun execution of:'); expect(cleanStdout).toContain('npx @code-pushup/cli'); - expect(cleanStdout).not.toContain('--verbose'); - expect(cleanStdout).toContain('CP_VERBOSE="true"'); }); it('should consider plugin option bin in executor target', async () => { diff --git a/packages/cli/README.md b/packages/cli/README.md index 7d7e264aa..333de6d82 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -195,11 +195,11 @@ Each example is fully tested to demonstrate best practices for plugin testing as ### Global Options -| Option | Type | Default | Description | -| ---------------- | --------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | -| **`--verbose`** | `boolean` | `false` | When true creates more verbose output. This is helpful when debugging. You may also set `CP_VERBOSE` env variable instead. | -| **`--config`** | `string` | looks for `code-pushup.config.{ts\|mjs\|js}` | Path to config file. | -| **`--tsconfig`** | `string` | n/a | Path to a TypeScript config, used to load config file. | +| Option | Type | Default | Description | +| ---------------- | --------- | ----------------------------------------------------- | ------------------------------------------------------ | +| **`--verbose`** | `boolean` | `process.env['CP_VERBOSE']` if set, otherwise `false` | Toggles whether to print debug logs. | +| **`--config`** | `string` | looks for `code-pushup.config.{ts\|mjs\|js}` | Path to config file. | +| **`--tsconfig`** | `string` | n/a | Path to a TypeScript config, used to load config file. | > [!NOTE] > By default, the CLI loads `code-pushup.config.(ts|mjs|js)` if no config path is provided with `--config`. diff --git a/packages/cli/src/lib/implementation/global.options.ts b/packages/cli/src/lib/implementation/global.options.ts index 4340c1f1d..4691b18ec 100644 --- a/packages/cli/src/lib/implementation/global.options.ts +++ b/packages/cli/src/lib/implementation/global.options.ts @@ -8,9 +8,8 @@ export function yargsGlobalOptionsDefinition(): Record< return { verbose: { describe: - 'When true creates more verbose output. This is helpful when debugging. You may also set CP_VERBOSE env variable instead.', + 'Toggles whether to print debug logs. The default value is derived from the CP_VERBOSE environment variable (false if not set).', type: 'boolean', - default: false, }, config: { describe: diff --git a/packages/cli/src/lib/yargs-cli.int.test.ts b/packages/cli/src/lib/yargs-cli.int.test.ts index cfa097488..e34a04b8b 100644 --- a/packages/cli/src/lib/yargs-cli.int.test.ts +++ b/packages/cli/src/lib/yargs-cli.int.test.ts @@ -16,13 +16,6 @@ import { options } from './options.js'; import { yargsCli } from './yargs-cli.js'; describe('yargsCli', () => { - it('should provide correct default values for global options', async () => { - const parsedArgv = await yargsCli([], { - options, - }).parseAsync(); - expect(parsedArgv.verbose).toBe(false); - }); - it('should parse an empty array as a default onlyPlugins option', async () => { const parsedArgv = await yargsCli([], { options: { ...options, ...yargsFilterOptionsDefinition() }, @@ -144,7 +137,8 @@ describe('yargsCli', () => { expect(parsedArgv).toEqual( expect.objectContaining({ // default values - verbose: false, + onlyCategories: [], + skipCategories: [], // overridden arguments persist: expect.objectContaining({ outputDir: 'code-pushdown/output/dir',