Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
09ec54b
chore: add plugin to nx.json
BioPhoton Aug 27, 2025
a449ca5
chore: add plugin to nx.json plugins
BioPhoton Aug 27, 2025
a2c3278
refactor: test use latest version
BioPhoton Aug 28, 2025
5ec4034
refactor: test use latest version 2
BioPhoton Aug 28, 2025
57bfc00
Merge branch 'main' into use-cp-nx-plugin
BioPhoton Aug 29, 2025
add0f3a
Merge branch 'main' into use-cp-nx-plugin
BioPhoton Sep 1, 2025
93e20e8
refactor: fix lint
BioPhoton Sep 1, 2025
3cb3a8d
refactor: wip
BioPhoton Sep 1, 2025
00e6fae
refactor: wip 2
BioPhoton Sep 1, 2025
2e8a05c
Merge branch 'main' into use-cp-nx-plugin
BioPhoton Sep 2, 2025
99d988a
refactor: update packages
BioPhoton Sep 2, 2025
0e66ac8
chore: update packages
BioPhoton Sep 3, 2025
f402ecb
refactor: use process.stdout.write
BioPhoton Sep 3, 2025
41bce2b
refactor: test pkg new
BioPhoton Sep 3, 2025
59a3f83
refactor: add output arg handling to nx-plugin args
BioPhoton Sep 3, 2025
06c94d9
docs: add release steps
BioPhoton Sep 4, 2025
e355699
Merge branch 'main' into use-cp-nx-plugin
BioPhoton Sep 4, 2025
e7da7ef
chore: update packages
BioPhoton Sep 4, 2025
8f69a5e
docs: update release section
BioPhoton Sep 4, 2025
8dced0b
docs: update release section
BioPhoton Sep 4, 2025
0049a64
chore: update packags
BioPhoton Sep 4, 2025
39d2357
Merge branch 'main' into use-cp-nx-plugin
BioPhoton Sep 5, 2025
8aa17d1
Merge branch 'main' into use-cp-nx-plugin
Nov 9, 2025
06f0b65
refactor: move plugin default exports
Nov 9, 2025
55c022b
refactor: remove bin option from config
Nov 9, 2025
e419189
refactor: update packages
Nov 9, 2025
3fb6747
refactor: remove bin options for config generator
Nov 9, 2025
4ba05a6
refactor: add env options and correct bin
Nov 10, 2025
d61fa16
Merge branch 'main' into use-cp-nx-plugin
Nov 10, 2025
71779ae
refactor: refactor plugin options
Nov 11, 2025
45e33a3
refactor: packages update
Nov 11, 2025
c8ab27c
refactor: fix text
Nov 11, 2025
4dcbedb
refactor: fix import
Nov 11, 2025
2d12182
refactor: fix logger spacing
Nov 11, 2025
804319b
refactor: add logger helper unit tests
Nov 11, 2025
a54e5dc
refactor: add env and cwd to logger in execProcess
Nov 11, 2025
0a8af75
refactor: fix unit tests
Nov 11, 2025
50d9f2c
refactor: wip
Nov 11, 2025
256ea00
refactor: wip revert
Nov 11, 2025
2b05307
refactor: wip 1
Nov 11, 2025
cbf9d19
refactor: move objToCliArgs parts and reuse
Nov 11, 2025
5559d5f
refactor: fix unit tests
Nov 11, 2025
0a5170f
refactor: wip
Nov 11, 2025
9a1558e
refactor: wip
Nov 11, 2025
b8c4659
refactor: wip
Nov 11, 2025
e326512
Merge branch 'main' into use-cp-nx-plugin
Dec 1, 2025
eff86ed
refactor: wip
Dec 1, 2025
521ef30
refactor: fix file not found of for uninstalled packages
Dec 1, 2025
27859c4
refactor: fix build
Dec 1, 2025
9fc52be
refactor: wip
Dec 1, 2025
be0b7fd
refactor: cleanup
Dec 1, 2025
b5bd0ad
refactor: fix lint
Dec 1, 2025
441fccc
refactor: wip
Dec 1, 2025
4ed9e62
Merge remote-tracking branch 'refs/remotes/origin/main' into use-cp-n…
Dec 1, 2025
fb28d0a
refactor: fix unit tests
Dec 1, 2025
52ad389
refactor: fix unit tests 2
Dec 1, 2025
ab96ed9
refactor: fix lint
Dec 1, 2025
1c4619c
refactor: remove logic
Dec 1, 2025
4824b91
refactor: fix lint
Dec 1, 2025
37f7cff
refactor: fix e2e
Dec 1, 2025
56a87fc
refactor: fix e2e
Dec 1, 2025
52e5d46
refactor: wip
Dec 1, 2025
b8f27b6
refactor: use nx-plugin in nx.json
Dec 1, 2025
924cf94
refactor: remove nx-plugin in nx.json
Dec 1, 2025
0e5d7a8
refactor: remove nx-plugin in nx.json
Dec 1, 2025
a58cfee
refactor: wip
Dec 1, 2025
6d12f6c
refactor: wip
Dec 2, 2025
d748bc0
refactor: wip
Dec 2, 2025
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
4 changes: 3 additions & 1 deletion e2e/nx-plugin-e2e/tests/executor-cli.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ describe('executor command', () => {
expect(cleanStdout).toContain('Code PushUp CLI');

await expect(
readJsonFile(path.join(cwd, '.reports', 'terminal-report.json')),
readJsonFile(
path.join(cwd, '.code-pushup', project, 'terminal-report.json'),
),
).resolves.not.toThrow();
});

Expand Down
10 changes: 3 additions & 7 deletions packages/nx-plugin/src/executors/cli/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../internal/cli.js';
import { normalizeContext } from '../internal/context.js';
import type { AutorunCommandExecutorOptions } from './schema.js';
import { mergeExecutorOptions, parseAutorunExecutorOptions } from './utils.js';
import { parseAutorunExecutorOptions } from './utils.js';

export type ExecutorOutput = {
success: boolean;
Expand All @@ -19,15 +19,11 @@ export default async function runAutorunExecutor(
context: ExecutorContext,
): Promise<ExecutorOutput> {
const normalizedContext = normalizeContext(context);
const mergedOptions = mergeExecutorOptions(
context.target?.options,
terminalAndExecutorOptions,
);
const cliArgumentObject = parseAutorunExecutorOptions(
mergedOptions,
terminalAndExecutorOptions,
normalizedContext,
);
const { dryRun, verbose, command, bin } = mergedOptions;
const { dryRun, verbose, command, bin } = terminalAndExecutorOptions;
const commandString = createCliCommandString({
command,
args: cliArgumentObject,
Expand Down
41 changes: 2 additions & 39 deletions packages/nx-plugin/src/executors/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function parseAutorunExecutorOptions(
options: Partial<AutorunCommandExecutorOptions>,
normalizedContext: NormalizedExecutorContext,
): AutorunCommandExecutorOptions {
const { projectPrefix, persist, upload, command } = options;
const { projectPrefix, persist, upload, command, output } = options;
const needsUploadParams =
command === 'upload' || command === 'autorun' || command === undefined;
const uploadCfg = uploadConfig(
Expand All @@ -46,48 +46,11 @@ export function parseAutorunExecutorOptions(
...parsePrintConfigExecutorOptions(options),
...parseAutorunExecutorOnlyOptions(options),
...globalConfig(options, normalizedContext),
...(output ? { output } : {}),
persist: persistConfig({ projectPrefix, ...persist }, normalizedContext),
// @TODO This is a hack to avoid validation errors of upload config for commands that dont need it.
// Fix: use utils and execute the core logic directly
// Blocked by Nx plugins can't compile to es6
...(needsUploadParams && hasApiToken ? { upload: uploadCfg } : {}),
};
}

/**
* Deeply merges executor options.
*
* @param targetOptions - The original options from the target configuration.
* @param cliOptions - The options from Nx, combining target options and CLI arguments.
* @returns A new object with deeply merged properties.
*
* Nx performs a shallow merge by default, where command-line arguments can override entire objects
* (e.g., `--persist.filename` replaces the entire `persist` object).
* This function ensures that nested properties are deeply merged,
* preserving the original target options where CLI arguments are not provided.
*/
export function mergeExecutorOptions(
targetOptions: Partial<AutorunCommandExecutorOptions>,
cliOptions: Partial<AutorunCommandExecutorOptions>,
): AutorunCommandExecutorOptions {
return {
...targetOptions,
...cliOptions,
...(targetOptions?.persist || cliOptions?.persist
? {
persist: {
...targetOptions?.persist,
...cliOptions?.persist,
},
}
: {}),
...(targetOptions?.upload || cliOptions?.upload
? {
upload: {
...targetOptions?.upload,
...cliOptions?.upload,
},
}
: {}),
};
}
24 changes: 0 additions & 24 deletions packages/nx-plugin/src/executors/cli/utils.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
import { osAgnosticPath } from '@code-pushup/test-utils';
import type { Command } from '../internal/types.js';
import {
mergeExecutorOptions,
parseAutorunExecutorOnlyOptions,
parseAutorunExecutorOptions,
parsePrintConfigExecutorOptions,
} from './utils.js';

describe('parsePrintConfigExecutorOptions', () => {

Check failure on line 10 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
it('should provide NO default output path', () => {

Check failure on line 11 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
expect(parsePrintConfigExecutorOptions({})).toStrictEqual(
expect.not.objectContaining({ output: expect.anything() }),
);
});

it('should process given output path', () => {

Check failure on line 17 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
expect(
parsePrintConfigExecutorOptions({ output: 'code-pushup.config.json' }),
).toStrictEqual(
Expand All @@ -24,38 +23,38 @@
});
});

describe('parseAutorunExecutorOnlyOptions', () => {

Check failure on line 26 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
it('should provide NO default projectPrefix', () => {

Check failure on line 27 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
expect(parseAutorunExecutorOnlyOptions({})).toStrictEqual(
expect.not.objectContaining({ projectPrefix: expect.anything() }),
);
});

it('should process given projectPrefix', () => {

Check failure on line 33 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
expect(
parseAutorunExecutorOnlyOptions({ projectPrefix: 'cli' }),
).toStrictEqual(expect.objectContaining({ projectPrefix: 'cli' }));
});

it('should provide NO default dryRun', () => {

Check failure on line 39 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
expect(parseAutorunExecutorOnlyOptions({})).toStrictEqual(
expect.not.objectContaining({ dryRun: expect.anything() }),
);
});

it('should process given dryRun', () => {

Check failure on line 45 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
expect(parseAutorunExecutorOnlyOptions({ dryRun: false })).toStrictEqual(
expect.objectContaining({ dryRun: false }),
);
});

it('should provide default onlyPlugins', () => {

Check failure on line 51 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
expect(parseAutorunExecutorOnlyOptions({})).toStrictEqual(
expect.not.objectContaining({ onlyPlugins: ['json'] }),
);
});

it('should process given onlyPlugins', () => {

Check failure on line 57 in packages/nx-plugin/src/executors/cli/utils.unit.test.ts

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
expect(
parseAutorunExecutorOnlyOptions({ onlyPlugins: ['md', 'json'] }),
).toStrictEqual(expect.objectContaining({ onlyPlugins: ['md', 'json'] }));
Expand Down Expand Up @@ -170,26 +169,3 @@
},
);
});

describe('mergeExecutorOptions', () => {
it('should deeply merge target and CLI options', () => {
const targetOptions = {
persist: {
outputDir: '.reports',
filename: 'report',
},
};
const cliOptions = {
persist: {
filename: 'report-file',
},
};
const expected = {
persist: {
outputDir: '.reports',
filename: 'report-file',
},
};
expect(mergeExecutorOptions(targetOptions, cliOptions)).toEqual(expected);
});
});