Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/ci-e2e/mocks/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { simpleGit } from 'simple-git';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
initGitRepo,
simulateGitFetch,
teardownTestFolder,
} from '@code-pushup/test-utils';

export type TestRepo = Awaited<ReturnType<typeof setupTestRepo>>;
Expand Down
9 changes: 5 additions & 4 deletions e2e/cli-e2e/tests/__snapshots__/help.e2e.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Global Options:
--progress Show progress bar in stdout.
[boolean] [default: true]
--verbose When true creates more verbose output. This is helpful w
hen debugging. [boolean] [default: false]
hen debugging. You may also set CP_VERBOSE env variable
instead. [boolean] [default: false]
--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
Expand Down Expand Up @@ -65,9 +66,9 @@ Examples:
code-pushup collect --onlyPlugins=covera Run collect with only coverage plugi
ge n, other plugins from config file wi
ll be skipped.
code-pushup collect --skipPlugins=covera Run collect skiping the coverage plu
ge gin, other plugins from config file
will be included.
code-pushup collect --skipPlugins=covera Run collect skipping the coverage pl
ge ugin, other plugins from config file
will be included.
code-pushup upload --persist.outputDir=d Upload dist/report.json to portal us
ist --upload.apiKey=$CP_API_KEY ing API key from environment variabl
e
Expand Down
7 changes: 5 additions & 2 deletions e2e/cli-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { cp } from 'node:fs/promises';
import path from 'node:path';
import { afterEach, beforeAll, describe, expect, it } from 'vitest';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import { E2E_ENVIRONMENTS_DIR, TEST_OUTPUT_DIR } from '@code-pushup/test-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readTextFile } from '@code-pushup/utils';

describe('CLI collect', () => {
Expand Down
7 changes: 5 additions & 2 deletions e2e/cli-e2e/tests/compare.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import path from 'node:path';
import { beforeAll } from 'vitest';
import type { ReportsDiff } from '@code-pushup/models';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import { E2E_ENVIRONMENTS_DIR, TEST_OUTPUT_DIR } from '@code-pushup/test-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile, readTextFile } from '@code-pushup/utils';

describe('CLI compare', () => {
Expand Down
1 change: 1 addition & 0 deletions e2e/cli-e2e/tests/help.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('CLI help', () => {
const helpArgResult = await executeProcess({
command: 'npx',
args: ['@code-pushup/cli', 'help'],
cwd: envRoot,
});
const helpCommandResult = await executeProcess({
command: 'npx',
Expand Down
7 changes: 5 additions & 2 deletions e2e/cli-e2e/tests/print-config.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { cp } from 'node:fs/promises';
import path from 'node:path';
import { beforeAll, expect } from 'vitest';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import { E2E_ENVIRONMENTS_DIR, TEST_OUTPUT_DIR } from '@code-pushup/test-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess } from '@code-pushup/utils';

describe('CLI print-config', () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/create-cli-e2e/tests/init.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import path from 'node:path';
import { afterEach, expect } from 'vitest';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
createNpmWorkspace,
removeColorCodes,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile, readTextFile } from '@code-pushup/utils';

Expand Down
2 changes: 1 addition & 1 deletion e2e/nx-plugin-e2e/tests/executor-cli.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import {
materializeTree,
nxTargetProject,
} from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
removeColorCodes,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
import { INLINE_PLUGIN } from './inline-plugin.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
materializeTree,
nxTargetProject,
} from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
removeColorCodes,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess } from '@code-pushup/utils';

Expand Down
2 changes: 1 addition & 1 deletion e2e/nx-plugin-e2e/tests/generator-init.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
materializeTree,
nxTargetProject,
} from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
removeColorCodes,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess } from '@code-pushup/utils';

Expand Down
2 changes: 1 addition & 1 deletion e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
nxTargetProject,
registerPluginInWorkspace,
} from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
removeColorCodes,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readTextFile } from '@code-pushup/utils';
import { INLINE_PLUGIN } from './inline-plugin.js';
Expand Down
2 changes: 1 addition & 1 deletion e2e/plugin-coverage-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import path from 'node:path';
import { afterAll, afterEach, beforeAll } from 'vitest';
import { type Report, reportSchema } from '@code-pushup/models';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
omitVariableReportData,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';

Expand Down
2 changes: 1 addition & 1 deletion e2e/plugin-eslint-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import path from 'node:path';
import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest';
import { type Report, reportSchema } from '@code-pushup/models';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
omitVariableReportData,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';

Expand Down
2 changes: 1 addition & 1 deletion e2e/plugin-jsdocs-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import path from 'node:path';
import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest';
import { type Report, reportSchema } from '@code-pushup/models';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
omitVariableReportData,
removeColorCodes,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';

Expand Down
2 changes: 1 addition & 1 deletion e2e/plugin-lighthouse-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import path from 'node:path';
import { afterAll, beforeAll, expect } from 'vitest';
import { type Report, reportSchema } from '@code-pushup/models';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import { teardownTestFolder } from '@code-pushup/test-setup';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
omitVariableReportData,
removeColorCodes,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';

Expand Down
8 changes: 6 additions & 2 deletions packages/ci/src/lib/run.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import { fileURLToPath } from 'node:url';
import { type SimpleGit, simpleGit } from 'simple-git';
import type { MockInstance } from 'vitest';
import type { CoreConfig } from '@code-pushup/models';
import { cleanTestFolder, teardownTestFolder } from '@code-pushup/test-setup';
import { initGitRepo, simulateGitFetch } from '@code-pushup/test-utils';
import {
cleanTestFolder,
initGitRepo,
simulateGitFetch,
teardownTestFolder,
} from '@code-pushup/test-utils';
import * as utils from '@code-pushup/utils';
import type {
Comment,
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ Each example is fully tested to demonstrate best practices for plugin testing as

### Global Options

| Option | Type | Default | Description |
| ---------------- | --------- | -------------------------------------------- | ---------------------------------------------------------------------- |
| **`--progress`** | `boolean` | `true` | Show progress bar in stdout. |
| **`--verbose`** | `boolean` | `false` | When true creates more verbose output. This is helpful when debugging. |
| **`--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 |
| ---------------- | --------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| **`--progress`** | `boolean` | `true` | Show progress bar in stdout. |
| **`--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. |

> [!NOTE]
> By default, the CLI loads `code-pushup.config.(ts|mjs|js)` if no config path is provided with `--config`.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const cli = (args: string[]) =>
],
[
'code-pushup collect --skipPlugins=coverage',
'Run collect skiping the coverage plugin, other plugins from config file will be included.',
'Run collect skipping the coverage plugin, other plugins from config file will be included.',
],
[
'code-pushup upload --persist.outputDir=dist --upload.apiKey=$CP_API_KEY',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const configDirPath = path.join(
describe('coreConfigMiddleware', () => {
const CLI_DEFAULTS = {
progress: true,
verbose: false,
plugins: [],
onlyPlugins: [],
skipPlugins: [],
};
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/lib/implementation/core-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type UploadConfigCliOptions = {
export type ConfigCliOptions = {
config?: string;
tsconfig?: string;
verbose?: string;
};

export type CoreConfigCliOptions = Pick<CoreConfig, 'persist'> & {
Expand Down
23 changes: 11 additions & 12 deletions packages/cli/src/lib/implementation/filter.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function filterMiddleware<T extends FilterOptions>(
onlyCategories = [],
skipPlugins = [],
onlyPlugins = [],
verbose = false,
} = originalProcessArgs;

const plugins = filterSkippedInPlugins(rcPlugins);
Expand All @@ -43,7 +42,7 @@ export function filterMiddleware<T extends FilterOptions>(
onlyPlugins.length === 0
) {
if (rcCategories && categories) {
validateSkippedCategories(rcCategories, categories, verbose);
validateSkippedCategories(rcCategories, categories);
}
return {
...originalProcessArgs,
Expand All @@ -61,12 +60,12 @@ export function filterMiddleware<T extends FilterOptions>(
const filteredCategories = applyCategoryFilters(
{ categories, plugins },
skippedCategories,
{ skipCategories, onlyCategories, verbose },
{ skipCategories, onlyCategories },
);
const filteredPlugins = applyPluginFilters(
{ categories: filteredCategories, plugins },
skippedPlugins,
{ skipPlugins, onlyPlugins, verbose },
{ skipPlugins, onlyPlugins },
);
const finalCategories = filteredCategories
? filterItemRefsBy(filteredCategories, ref =>
Expand All @@ -89,9 +88,9 @@ export function filterMiddleware<T extends FilterOptions>(
function applyCategoryFilters(
{ categories, plugins }: Filterables,
skippedCategories: string[],
options: Pick<FilterOptions, 'skipCategories' | 'onlyCategories' | 'verbose'>,
options: Pick<FilterOptions, 'skipCategories' | 'onlyCategories'>,
): CoreConfig['categories'] {
const { skipCategories = [], onlyCategories = [], verbose = false } = options;
const { skipCategories = [], onlyCategories = [] } = options;
if (
(skipCategories.length === 0 && onlyCategories.length === 0) ||
((!categories || categories.length === 0) && skippedCategories.length === 0)
Expand All @@ -101,22 +100,22 @@ function applyCategoryFilters(
validateFilterOption(
'skipCategories',
{ plugins, categories },
{ itemsToFilter: skipCategories, skippedItems: skippedCategories, verbose },
{ itemsToFilter: skipCategories, skippedItems: skippedCategories },
);
validateFilterOption(
'onlyCategories',
{ plugins, categories },
{ itemsToFilter: onlyCategories, skippedItems: skippedCategories, verbose },
{ itemsToFilter: onlyCategories, skippedItems: skippedCategories },
);
return applyFilters(categories ?? [], skipCategories, onlyCategories, 'slug');
}

function applyPluginFilters(
{ categories, plugins }: Filterables,
skippedPlugins: string[],
options: Pick<FilterOptions, 'skipPlugins' | 'onlyPlugins' | 'verbose'>,
options: Pick<FilterOptions, 'skipPlugins' | 'onlyPlugins'>,
): CoreConfig['plugins'] {
const { skipPlugins = [], onlyPlugins = [], verbose = false } = options;
const { skipPlugins = [], onlyPlugins = [] } = options;
const filteredPlugins = filterPluginsFromCategories({
categories,
plugins,
Expand All @@ -127,12 +126,12 @@ function applyPluginFilters(
validateFilterOption(
'skipPlugins',
{ plugins: filteredPlugins, categories },
{ itemsToFilter: skipPlugins, skippedItems: skippedPlugins, verbose },
{ itemsToFilter: skipPlugins, skippedItems: skippedPlugins },
);
validateFilterOption(
'onlyPlugins',
{ plugins: filteredPlugins, categories },
{ itemsToFilter: onlyPlugins, skippedItems: skippedPlugins, verbose },
{ itemsToFilter: onlyPlugins, skippedItems: skippedPlugins },
);
return applyFilters(filteredPlugins, skipPlugins, onlyPlugins, 'slug');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ describe('filterMiddleware', () => {
);

it('should trigger verbose logging when skipPlugins or onlyPlugins removes categories', () => {
vi.stubEnv('CP_VERBOSE', 'true');

filterMiddleware({
onlyPlugins: ['p1'],
skipPlugins: ['p2'],
Expand All @@ -311,7 +313,6 @@ describe('filterMiddleware', () => {
refs: [{ type: 'audit', plugin: 'p2', slug: 'a1-p2', weight: 1 }],
},
] as CategoryConfig[],
verbose: true,
});

expect(ui()).toHaveNthLogged(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/implementation/global.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function yargsGlobalOptionsDefinition(): Record<
},
verbose: {
describe:
'When true creates more verbose output. This is helpful when debugging.',
'When true creates more verbose output. This is helpful when debugging. You may also set CP_VERBOSE env variable instead.',
type: 'boolean',
default: false,
},
Expand Down
Loading
Loading