Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 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
fba5f15
refactor: use dynamic imports, delete duplicated code
Dec 1, 2025
6c48309
refactor: use dynamic imports, delete duplicated code
Dec 1, 2025
d400fa0
refactor: wip
Dec 1, 2025
222ebda
refactor: wip
Dec 1, 2025
5219bea
refactor: wip
Dec 1, 2025
ed75f3c
refactor: wip
Dec 2, 2025
3fbfcd7
refactor: wip
Dec 2, 2025
7e5a223
refactor: wip
Dec 2, 2025
21eab84
refactor: wip
Dec 2, 2025
315461d
refactor: wip
Dec 2, 2025
89d37e0
refactor: wip
Dec 2, 2025
d3fe1f3
refactor: wip
Dec 2, 2025
6e64a0b
refactor: wip
Dec 2, 2025
a35f427
refactor: wip
Dec 2, 2025
f2cfdcc
refactor: wip
Dec 2, 2025
acc2395
refactor: wip
Dec 2, 2025
7b50f22
refactor: wip
Dec 2, 2025
3a4b5b1
refactor: wip
Dec 2, 2025
0c052cb
Merge branch 'main' into use-utils-in-nx-plugin
Dec 2, 2025
798363f
refactor: wip
Dec 2, 2025
7d36180
refactor: wip
Dec 2, 2025
7c573c7
refactor: wip debug
Dec 2, 2025
e6087e8
refactor: wip debug
Dec 2, 2025
f1e3746
refactor: wip debug
Dec 2, 2025
e646270
refactor: move commandLog
Dec 2, 2025
a3df06e
refactor: wip
Dec 2, 2025
457b002
refactor: wip
Dec 2, 2025
20f9ffd
refactor: wip
Dec 2, 2025
4649c98
refactor: wip
Dec 2, 2025
4dc27c3
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
29 changes: 4 additions & 25 deletions e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,29 +103,6 @@ describe('nx-plugin', () => {
});
});

it('should consider plugin option bin in configuration target', async () => {
const cwd = path.join(testFileDir, 'configuration-option-bin');
registerPluginInWorkspace(tree, {
plugin: '@code-pushup/nx-plugin',
options: {
bin: 'XYZ',
},
});
await materializeTree(tree, cwd);

const { code, projectJson } = await nxShowProjectJson(cwd, project);

expect(code).toBe(0);

expect(projectJson.targets).toStrictEqual({
'code-pushup--configuration': expect.objectContaining({
options: {
command: `nx g XYZ:configuration --project="${project}"`,
},
}),
});
});

it('should NOT add config targets dynamically if the project is configured', async () => {
const cwd = path.join(testFileDir, 'configuration-already-configured');
registerPluginInWorkspace(tree, '@code-pushup/nx-plugin');
Expand Down Expand Up @@ -199,8 +176,10 @@ describe('nx-plugin', () => {
// Nx command
expect(cleanStdout).toContain('nx run my-lib:code-pushup');
// Run CLI executor
expect(cleanStdout).toContain('Command: npx @code-pushup/cli');
expect(cleanStdout).toContain('--dryRun --verbose');
expect(cleanStdout).toContain('Command:');
expect(cleanStdout).toContain('npx @code-pushup/cli');
expect(cleanStdout).toContain('--verbose');
expect(cleanStdout).toContain('--dryRun ');
});

it('should consider plugin option bin in executor target', async () => {
Expand Down
28 changes: 19 additions & 9 deletions packages/nx-plugin/src/executors/cli/executor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { type ExecutorContext, logger } from '@nx/devkit';
import { executeProcess } from '../../internal/execute-process.js';
import {
createCliCommandObject,
createCliCommandString,
} from '../internal/cli.js';
import { normalizeContext } from '../internal/context.js';
import type { AutorunCommandExecutorOptions } from './schema.js';
import { parseAutorunExecutorOptions } from './utils.js';
Expand All @@ -14,20 +10,33 @@ export type ExecutorOutput = {
error?: Error;
};

/* eslint-disable-next-line max-lines-per-function */
export default async function runAutorunExecutor(
terminalAndExecutorOptions: AutorunCommandExecutorOptions,
context: ExecutorContext,
): Promise<ExecutorOutput> {
const { objectToCliArgs, formatCommandStatus } = await import(
'@code-pushup/utils'
);
const normalizedContext = normalizeContext(context);
const cliArgumentObject = parseAutorunExecutorOptions(
terminalAndExecutorOptions,
normalizedContext,
);
const { dryRun, verbose, command, bin } = terminalAndExecutorOptions;
const commandString = createCliCommandString({
command,
args: cliArgumentObject,
const {
dryRun,
verbose,
command: cliCommand,
bin,
} = terminalAndExecutorOptions;
const command = bin ? `node` : 'npx';
const positionals = [
bin ?? '@code-pushup/cli',
...(cliCommand ? [cliCommand] : []),
];
const args = [...positionals, ...objectToCliArgs(cliArgumentObject)];
const commandString = formatCommandStatus([command, ...args].join(' '), {
cwd: context.cwd,
});
if (verbose) {
logger.info(`Run CLI executor ${command ?? ''}`);
Expand All @@ -38,7 +47,8 @@ export default async function runAutorunExecutor(
} else {
try {
await executeProcess({
...createCliCommandObject({ command, args: cliArgumentObject, bin }),
command,
args,
...(context.cwd ? { cwd: context.cwd } : {}),
});
} catch (error) {
Expand Down
6 changes: 2 additions & 4 deletions packages/nx-plugin/src/executors/cli/executor.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as executeProcessModule from '../../internal/execute-process.js';
import runAutorunExecutor from './executor.js';

describe('runAutorunExecutor', () => {

Check failure on line 8 in packages/nx-plugin/src/executors/cli/executor.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`.
const processEnvCP = Object.fromEntries(
Object.entries(process.env).filter(([k]) => k.startsWith('CP_')),
);
Expand All @@ -13,7 +13,7 @@
const loggerWarnSpy = vi.spyOn(logger, 'warn');
const executeProcessSpy = vi.spyOn(executeProcessModule, 'executeProcess');

beforeAll(() => {

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

View workflow job for this annotation

GitHub Actions / Standalone mode

<✓> TypeScript | Semantic errors

TS2304: Cannot find name 'beforeAll'.
Object.entries(process.env)
.filter(([k]) => k.startsWith('CP_'))
.forEach(([k]) => Reflect.deleteProperty(process.env, k));
Expand Down Expand Up @@ -42,7 +42,7 @@
executeProcessSpy.mockReset();
});

it('should call executeProcess with return result', async () => {

Check failure on line 45 in packages/nx-plugin/src/executors/cli/executor.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`.
const output = await runAutorunExecutor({}, executorContext('utils'));
expect(output.success).toBe(true);
expect(output.command).toMatch('npx @code-pushup/cli');
Expand All @@ -53,7 +53,7 @@
});
});

it('should normalize context', async () => {

Check failure on line 56 in packages/nx-plugin/src/executors/cli/executor.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`.
const output = await runAutorunExecutor(
{},
{
Expand All @@ -70,7 +70,7 @@
});
});

it('should process executorOptions', async () => {

Check failure on line 73 in packages/nx-plugin/src/executors/cli/executor.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`.
const output = await runAutorunExecutor(
{ output: 'code-pushup.config.json', persist: { filename: 'REPORT' } },
executorContext('testing-utils'),
Expand All @@ -80,7 +80,7 @@
expect(output.command).toContain('--persist.filename="REPORT"');
});

it('should create command from context and options if no api key is set', async () => {

Check failure on line 83 in packages/nx-plugin/src/executors/cli/executor.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`.
const output = await runAutorunExecutor(
{ persist: { filename: 'REPORT', format: ['md', 'json'] } },
executorContext('core'),
Expand All @@ -91,7 +91,7 @@
);
});

it('should create command from context, options and arguments if api key is set', async () => {

Check failure on line 94 in packages/nx-plugin/src/executors/cli/executor.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`.
vi.stubEnv('CP_API_KEY', 'cp_1234567');
const output = await runAutorunExecutor(
{
Expand All @@ -108,7 +108,7 @@
expect(output.command).toMatch('--upload.project="CLI"');
});

it('should log information if verbose is set', async () => {

Check failure on line 111 in packages/nx-plugin/src/executors/cli/executor.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`.
const output = await runAutorunExecutor(
{ verbose: true },
{ ...executorContext('github-action'), cwd: '<CWD>' },
Expand All @@ -122,19 +122,17 @@
expect.stringContaining(`Run CLI executor`),
);
expect(loggerInfoSpy).toHaveBeenCalledWith(
expect.stringContaining('Command: npx @code-pushup/cli'),
expect.stringContaining('Command:'),
);
});

it('should log command if dryRun is set', async () => {

Check failure on line 129 in packages/nx-plugin/src/executors/cli/executor.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`.
await runAutorunExecutor({ dryRun: true }, executorContext('utils'));

expect(loggerInfoSpy).toHaveBeenCalledTimes(0);
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
expect(loggerWarnSpy).toHaveBeenCalledWith(
expect.stringContaining(
'DryRun execution of: npx @code-pushup/cli --dryRun',
),
expect.stringContaining('DryRun execution of'),
);
});
});
77 changes: 0 additions & 77 deletions packages/nx-plugin/src/executors/internal/cli.ts

This file was deleted.

136 changes: 0 additions & 136 deletions packages/nx-plugin/src/executors/internal/cli.unit.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/nx-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const plugin = {
export default plugin;

export type { AutorunCommandExecutorOptions } from './executors/cli/schema.js';
export { objectToCliArgs } from './executors/internal/cli.js';
export { generateCodePushupConfig } from './generators/configuration/code-pushup-config.js';
export { configurationGenerator } from './generators/configuration/generator.js';
export type { ConfigurationGeneratorOptions } from './generators/configuration/schema.js';
Expand Down
14 changes: 6 additions & 8 deletions packages/nx-plugin/src/plugin/target/configuration-target.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import type { TargetConfiguration } from '@nx/devkit';
import type { RunCommandsOptions } from 'nx/src/executors/run-commands/run-commands.impl';
import { objectToCliArgs } from '../../executors/internal/cli.js';
import { PACKAGE_NAME } from '../../internal/constants.js';

export function createConfigurationTarget(options?: {
export async function createConfigurationTarget(options?: {
projectName?: string;
bin?: string;
}): TargetConfiguration<RunCommandsOptions> {
const { projectName, bin = PACKAGE_NAME } = options ?? {};
}): Promise<TargetConfiguration<RunCommandsOptions>> {
const { projectName } = options ?? {};
const { objectToCliArgs } = await import('@code-pushup/utils');
const args = objectToCliArgs({
...(projectName ? { project: projectName } : {}),
});
const argsString = args.length > 0 ? args.join(' ') : '';
const baseCommand = `nx g ${bin}:configuration`;
const argsString = args.length > 0 ? ` ${args.join(' ')}` : '';
return {
command: argsString ? `${baseCommand} ${argsString}` : baseCommand,
command: `nx g ${PACKAGE_NAME}:configuration${argsString}`,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
import { PACKAGE_NAME } from '../../internal/constants.js';
import { createConfigurationTarget } from './configuration-target.js';

describe('createConfigurationTarget', () => {

Check failure on line 5 in packages/nx-plugin/src/plugin/target/configuration.target.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 return code-pushup--configuration target for given project', () => {
expect(
it('should return code-pushup--configuration target for given project', async () => {
await expect(
createConfigurationTarget({ projectName: 'my-project' }),
).toStrictEqual({
).resolves.toStrictEqual({
command: `nx g ${PACKAGE_NAME}:configuration --project="my-project"`,
});
});

it('should return code-pushup--configuration target without project name', () => {
expect(createConfigurationTarget()).toStrictEqual({
it('should return code-pushup--configuration target without project name', async () => {
await expect(createConfigurationTarget()).resolves.toStrictEqual({
command: `nx g ${PACKAGE_NAME}:configuration`,
});
});
Expand Down
Loading