From 348246c3ce61d47ac193e7813517f113a9261e7f Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 14:19:08 +0100 Subject: [PATCH 01/28] refactor: set env vars if verbose is given --- .../nx-plugin/src/executors/cli/executor.ts | 17 ++++++++++------- .../src/executors/cli/executor.unit.test.ts | 14 ++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index be932a35d..b4b32a170 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -23,23 +23,26 @@ export default async function runAutorunExecutor( terminalAndExecutorOptions, normalizedContext, ); - const { dryRun, verbose, command, bin } = terminalAndExecutorOptions; + const { dryRun, verbose, command, bin, ...args } = cliArgumentObject; + const executorEnvVariables = { + ...(verbose && { CP_VERBOSE: 'true' }), + }; const commandString = createCliCommandString({ command, - args: cliArgumentObject, + args: args, bin, }); - if (verbose) { - logger.info(`Run CLI executor ${command ?? ''}`); - logger.info(`Command: ${commandString}`); - } + if (dryRun) { logger.warn(`DryRun execution of: ${commandString}`); } else { try { await executeProcess({ - ...createCliCommandObject({ command, args: cliArgumentObject, bin }), + ...createCliCommandObject({ command, args, bin }), ...(context.cwd ? { cwd: context.cwd } : {}), + ...(Object.keys(executorEnvVariables).length + ? { env: executorEnvVariables } + : {}), }); } catch (error) { logger.error(error); diff --git a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts index bcac3e153..6b7a38e2c 100644 --- a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts @@ -108,21 +108,17 @@ describe('runAutorunExecutor', () => { expect(output.command).toMatch('--upload.project="CLI"'); }); - it('should log information if verbose is set', async () => { + it('should set env var information if verbose is set', async () => { const output = await runAutorunExecutor( { verbose: true }, { ...executorContext('github-action'), cwd: '' }, ); expect(executeProcessSpy).toHaveBeenCalledTimes(1); - expect(output.command).toMatch('--verbose'); + expect(output.command).not.toContain('--verbose'); expect(loggerWarnSpy).toHaveBeenCalledTimes(0); - expect(loggerInfoSpy).toHaveBeenCalledTimes(2); expect(loggerInfoSpy).toHaveBeenCalledWith( - expect.stringContaining(`Run CLI executor`), - ); - expect(loggerInfoSpy).toHaveBeenCalledWith( - expect.stringContaining('Command: npx @code-pushup/cli'), + expect.stringContaining('CP_VERBOSE=true'), ); }); @@ -132,9 +128,7 @@ describe('runAutorunExecutor', () => { 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'), ); }); }); From 2dcfb6587d240244743ea14d98a0c8bac01a2eb9 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 14:23:11 +0100 Subject: [PATCH 02/28] refactor: fix int test --- packages/nx-plugin/src/executors/cli/executor.int.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/nx-plugin/src/executors/cli/executor.int.test.ts b/packages/nx-plugin/src/executors/cli/executor.int.test.ts index fee1e59d8..b504ae830 100644 --- a/packages/nx-plugin/src/executors/cli/executor.int.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.int.test.ts @@ -47,6 +47,9 @@ describe('runAutorunExecutor', () => { command: 'npx', args: expect.arrayContaining(['@code-pushup/cli']), cwd: process.cwd(), + env: { + CP_VERBOSE: 'true', + }, }); }); }); From 1106a36fa8ec7cd5bfbf2009c6b6a65e6b45d442 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 14:46:47 +0100 Subject: [PATCH 03/28] refactor: fix lint --- e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts | 3 ++- packages/nx-plugin/src/executors/cli/executor.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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 fb5408812..2184172ce 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 @@ -199,7 +199,8 @@ 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 execution of:'); + expect(cleanStdout).toContain('npx @code-pushup/cli'); expect(cleanStdout).toContain('--dryRun --verbose'); }); diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index b4b32a170..122eadd53 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -29,7 +29,7 @@ export default async function runAutorunExecutor( }; const commandString = createCliCommandString({ command, - args: args, + args, bin, }); @@ -40,7 +40,7 @@ export default async function runAutorunExecutor( await executeProcess({ ...createCliCommandObject({ command, args, bin }), ...(context.cwd ? { cwd: context.cwd } : {}), - ...(Object.keys(executorEnvVariables).length + ...(Object.keys(executorEnvVariables).length > 0 ? { env: executorEnvVariables } : {}), }); From 21511d47ed64dbc7fb5be2bb1482521285dfc318 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 15:46:11 +0100 Subject: [PATCH 04/28] refactor: wip --- e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 2184172ce..9bd89c5e8 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 @@ -1,5 +1,6 @@ import type { Tree } from '@nx/devkit'; import path from 'node:path'; +import * as process from 'node:process'; import { readProjectConfiguration } from 'nx/src/generators/utils/project-configuration'; import { afterEach, expect } from 'vitest'; import { generateCodePushupConfig } from '@code-pushup/nx-plugin'; @@ -197,11 +198,14 @@ describe('nx-plugin', () => { const cleanStdout = removeColorCodes(stdout); // Nx command + process.stdout.write(cleanStdout); // For easier debugging expect(cleanStdout).toContain('nx run my-lib:code-pushup'); // Run CLI executor expect(cleanStdout).toContain('DryRun execution of:'); expect(cleanStdout).toContain('npx @code-pushup/cli'); - expect(cleanStdout).toContain('--dryRun --verbose'); + expect(cleanStdout).toContain('--dryRun'); + expect(cleanStdout).not.toContain('--verbose'); + expect(cleanStdout).toContain('CP_VERBOSE=true'); }); it('should consider plugin option bin in executor target', async () => { From e120e3b32484a5932c1ce3bde98638e24906df9d Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 15:49:32 +0100 Subject: [PATCH 05/28] refactor: wip --- e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9bd89c5e8..656c8bf9e 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 @@ -198,7 +198,7 @@ describe('nx-plugin', () => { const cleanStdout = removeColorCodes(stdout); // Nx command - process.stdout.write(cleanStdout); // For easier debugging + throw new Error(cleanStdout); // For easier debugging expect(cleanStdout).toContain('nx run my-lib:code-pushup'); // Run CLI executor expect(cleanStdout).toContain('DryRun execution of:'); From 5bab88e2357794dff165223022707f37aa32fb4b Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 16:06:23 +0100 Subject: [PATCH 06/28] refactor: wip --- packages/nx-plugin/src/executors/cli/executor.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index 122eadd53..2f0af998b 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -25,6 +25,7 @@ export default async function runAutorunExecutor( ); const { dryRun, verbose, command, bin, ...args } = cliArgumentObject; const executorEnvVariables = { + ...process.env, ...(verbose && { CP_VERBOSE: 'true' }), }; const commandString = createCliCommandString({ From bf78e82545335311d09a709f9c2efb67c196220d Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 16:13:06 +0100 Subject: [PATCH 07/28] refactor: wip --- packages/nx-plugin/src/executors/cli/executor.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index 2f0af998b..dbb9c10f2 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -1,4 +1,4 @@ -import { type ExecutorContext, logger } from '@nx/devkit'; +import { type ExecutorContext } from '@nx/devkit'; import { executeProcess } from '../../internal/execute-process.js'; import { createCliCommandObject, @@ -18,6 +18,7 @@ export default async function runAutorunExecutor( terminalAndExecutorOptions: AutorunCommandExecutorOptions, context: ExecutorContext, ): Promise { + const { logger, stringifyError } = await import('@code-pushup/utils'); const normalizedContext = normalizeContext(context); const cliArgumentObject = parseAutorunExecutorOptions( terminalAndExecutorOptions, @@ -41,12 +42,10 @@ export default async function runAutorunExecutor( await executeProcess({ ...createCliCommandObject({ command, args, bin }), ...(context.cwd ? { cwd: context.cwd } : {}), - ...(Object.keys(executorEnvVariables).length > 0 - ? { env: executorEnvVariables } - : {}), + ...(verbose ? { env: executorEnvVariables } : {}), }); } catch (error) { - logger.error(error); + logger.error(stringifyError(error)); return { success: false, command: commandString, From 676b88c228aa5db53f1a1f61eaa849071661f93f Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 16:16:39 +0100 Subject: [PATCH 08/28] refactor: wip --- packages/nx-plugin/src/executors/cli/executor.int.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.int.test.ts b/packages/nx-plugin/src/executors/cli/executor.int.test.ts index b504ae830..99e02c018 100644 --- a/packages/nx-plugin/src/executors/cli/executor.int.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.int.test.ts @@ -47,9 +47,9 @@ describe('runAutorunExecutor', () => { command: 'npx', args: expect.arrayContaining(['@code-pushup/cli']), cwd: process.cwd(), - env: { + env: expect.objectContaining({ CP_VERBOSE: 'true', - }, + }), }); }); }); From 5ff36274eeb97c2ca4d107f56e69ef577bae3802 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 16:19:23 +0100 Subject: [PATCH 09/28] refactor: wip --- e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 656c8bf9e..715f37b0d 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 @@ -198,12 +198,10 @@ describe('nx-plugin', () => { const cleanStdout = removeColorCodes(stdout); // Nx command - throw new Error(cleanStdout); // For easier debugging - expect(cleanStdout).toContain('nx run my-lib:code-pushup'); + expect(cleanStdout).toContain('nx run my-lib:code-pushup --dryRun'); // Run CLI executor expect(cleanStdout).toContain('DryRun execution of:'); expect(cleanStdout).toContain('npx @code-pushup/cli'); - expect(cleanStdout).toContain('--dryRun'); expect(cleanStdout).not.toContain('--verbose'); expect(cleanStdout).toContain('CP_VERBOSE=true'); }); From f270316bf0f86f72c49c50891b25d5688eb2c135 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 16:51:34 +0100 Subject: [PATCH 10/28] refactor: intro evn options to cli executor --- .../nx-plugin/src/executors/cli/executor.ts | 9 ++++++- .../src/executors/cli/executor.unit.test.ts | 27 +++++++++++-------- .../src/generators/configuration/schema.d.ts | 1 - packages/nx-plugin/src/internal/types.ts | 1 + .../src/plugin/target/executor-target.ts | 10 ++++--- .../target/executor.target.unit.test.ts | 19 +++++++++++++ .../nx-plugin/src/plugin/target/targets.ts | 6 ++--- 7 files changed, 54 insertions(+), 19 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index be932a35d..c99a54405 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -23,7 +23,13 @@ export default async function runAutorunExecutor( terminalAndExecutorOptions, normalizedContext, ); - const { dryRun, verbose, command, bin } = terminalAndExecutorOptions; + const { + dryRun, + verbose, + command, + bin, + env: targetEnv, + } = terminalAndExecutorOptions; const commandString = createCliCommandString({ command, args: cliArgumentObject, @@ -40,6 +46,7 @@ export default async function runAutorunExecutor( await executeProcess({ ...createCliCommandObject({ command, args: cliArgumentObject, bin }), ...(context.cwd ? { cwd: context.cwd } : {}), + ...(targetEnv ? { env: targetEnv } : {}), }); } catch (error) { logger.error(error); diff --git a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts index bcac3e153..04aff5fe5 100644 --- a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts @@ -46,11 +46,13 @@ describe('runAutorunExecutor', () => { const output = await runAutorunExecutor({}, executorContext('utils')); expect(output.success).toBe(true); expect(output.command).toMatch('npx @code-pushup/cli'); - expect(executeProcessSpy).toHaveBeenCalledWith({ - command: 'npx', - args: expect.arrayContaining(['@code-pushup/cli']), - cwd: MEMFS_VOLUME, - }); + expect(executeProcessSpy).toHaveBeenCalledWith( + expect.objectContaining({ + command: 'npx', + args: expect.arrayContaining(['@code-pushup/cli']), + cwd: MEMFS_VOLUME, + }), + ); }); it('should normalize context', async () => { @@ -62,12 +64,15 @@ describe('runAutorunExecutor', () => { }, ); expect(output.success).toBe(true); - expect(output.command).toMatch('utils'); - expect(executeProcessSpy).toHaveBeenCalledWith({ - command: 'npx', - args: expect.arrayContaining(['@code-pushup/cli']), - cwd: 'cwd-form-context', - }); + expect(output.command).toMatch('npx @code-pushup/cli'); + expect(output.command).toContain('cwd-form-context'); + expect(executeProcessSpy).toHaveBeenCalledWith( + expect.objectContaining({ + command: 'npx', + args: expect.arrayContaining(['@code-pushup/cli']), + cwd: 'cwd-form-context', + }), + ); }); it('should process executorOptions', async () => { diff --git a/packages/nx-plugin/src/generators/configuration/schema.d.ts b/packages/nx-plugin/src/generators/configuration/schema.d.ts index b105270c6..0f0cb7b79 100644 --- a/packages/nx-plugin/src/generators/configuration/schema.d.ts +++ b/packages/nx-plugin/src/generators/configuration/schema.d.ts @@ -2,7 +2,6 @@ import type { DynamicTargetOptions } from '../../internal/types.js'; export type ConfigurationGeneratorOptions = { project: string; - bin?: string; skipTarget?: boolean; skipConfig?: boolean; skipFormat?: boolean; diff --git a/packages/nx-plugin/src/internal/types.ts b/packages/nx-plugin/src/internal/types.ts index bf3a2d047..3a34d86d7 100644 --- a/packages/nx-plugin/src/internal/types.ts +++ b/packages/nx-plugin/src/internal/types.ts @@ -1,4 +1,5 @@ export type DynamicTargetOptions = { targetName?: string; bin?: string; + env?: Record; }; diff --git a/packages/nx-plugin/src/plugin/target/executor-target.ts b/packages/nx-plugin/src/plugin/target/executor-target.ts index d8cfab569..df968154b 100644 --- a/packages/nx-plugin/src/plugin/target/executor-target.ts +++ b/packages/nx-plugin/src/plugin/target/executor-target.ts @@ -5,13 +5,17 @@ import type { ProjectPrefixOptions } from '../types.js'; export function createExecutorTarget(options?: { bin?: string; projectPrefix?: string; -}): TargetConfiguration { - const { bin, projectPrefix } = options ?? {}; + env?: Record; +}): TargetConfiguration< + ProjectPrefixOptions & { env?: Record } +> { + const { bin, projectPrefix, env } = options ?? {}; const executor = `${PACKAGE_NAME}:cli`; - const executorOptions = (bin || projectPrefix) && { + const executorOptions = (bin || projectPrefix || env) && { ...(bin && { bin }), ...(projectPrefix && { projectPrefix }), + ...(env && { env }), }; return { executor, ...(executorOptions && { options: executorOptions }) }; } diff --git a/packages/nx-plugin/src/plugin/target/executor.target.unit.test.ts b/packages/nx-plugin/src/plugin/target/executor.target.unit.test.ts index 2926d3367..baec99a6d 100644 --- a/packages/nx-plugin/src/plugin/target/executor.target.unit.test.ts +++ b/packages/nx-plugin/src/plugin/target/executor.target.unit.test.ts @@ -27,4 +27,23 @@ describe('createExecutorTarget', () => { }, }); }); + + it('should use env if provided', () => { + expect( + createExecutorTarget({ + env: { + NODE_OPTIONS: '--import tsx', + TSX_TSCONFIG_PATH: 'tsconfig.base.json', + }, + }), + ).toStrictEqual({ + executor: '@code-pushup/nx-plugin:cli', + options: { + env: { + NODE_OPTIONS: '--import tsx', + TSX_TSCONFIG_PATH: 'tsconfig.base.json', + }, + }, + }); + }); }); diff --git a/packages/nx-plugin/src/plugin/target/targets.ts b/packages/nx-plugin/src/plugin/target/targets.ts index ae192ffd8..8037c2e98 100644 --- a/packages/nx-plugin/src/plugin/target/targets.ts +++ b/packages/nx-plugin/src/plugin/target/targets.ts @@ -19,17 +19,17 @@ export async function createTargets(normalizedContext: CreateTargetsOptions) { targetName = CP_TARGET_NAME, bin, projectPrefix, + env, } = normalizedContext.createOptions; const rootFiles = await readdir(normalizedContext.projectRoot); return rootFiles.some(filename => filename.match(CODE_PUSHUP_CONFIG_REGEX)) ? { - [targetName]: createExecutorTarget({ bin, projectPrefix }), + [targetName]: createExecutorTarget({ bin, projectPrefix, env }), } : // if NO code-pushup.config.*.(ts|js|mjs) is present return configuration target { - [`${targetName}--configuration`]: createConfigurationTarget({ + [`${targetName}--configuration`]: await createConfigurationTarget({ projectName: normalizedContext.projectJson.name, - bin, }), }; } From be536024183412c29a268ba197a727ca816635cc Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 18:11:30 +0100 Subject: [PATCH 11/28] refactor: fix unit test --- .../nx-plugin/src/executors/cli/executor.ts | 13 +++++++--- .../src/executors/cli/executor.unit.test.ts | 26 +++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index e9562434d..038736d03 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -1,4 +1,4 @@ -import { type ExecutorContext } from '@nx/devkit'; +import type { ExecutorContext } from '@nx/devkit'; import { executeProcess } from '../../internal/execute-process.js'; import { normalizeContext } from '../internal/context.js'; import type { AutorunCommandExecutorOptions } from './schema.js'; @@ -36,11 +36,11 @@ export default async function runAutorunExecutor( ]; const args = [...positionals, ...objectToCliArgs(restArgs)]; const executorEnvVariables = { - ...process.env, ...(verbose && { CP_VERBOSE: 'true' }), }; const commandString = formatCommandStatus([command, ...args].join(' '), { cwd: context.cwd, + env: executorEnvVariables, }); if (dryRun) { @@ -51,7 +51,14 @@ export default async function runAutorunExecutor( command, args, ...(context.cwd ? { cwd: context.cwd } : {}), - ...(verbose ? { env: executorEnvVariables } : {}), + ...(verbose + ? { + env: { + ...process.env, + ...executorEnvVariables, + }, + } + : {}), }); } catch (error) { logger.error(stringifyError(error)); diff --git a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts index 6b7a38e2c..39ad3c75e 100644 --- a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts @@ -1,7 +1,7 @@ -import { logger } from '@nx/devkit'; import { afterAll, afterEach, beforeEach, expect, vi } from 'vitest'; import { executorContext } from '@code-pushup/test-nx-utils'; import { MEMFS_VOLUME } from '@code-pushup/test-utils'; +import { logger } from '@code-pushup/utils'; import * as executeProcessModule from '../../internal/execute-process.js'; import runAutorunExecutor from './executor.js'; @@ -9,8 +9,6 @@ describe('runAutorunExecutor', () => { const processEnvCP = Object.fromEntries( Object.entries(process.env).filter(([k]) => k.startsWith('CP_')), ); - const loggerInfoSpy = vi.spyOn(logger, 'info'); - const loggerWarnSpy = vi.spyOn(logger, 'warn'); const executeProcessSpy = vi.spyOn(executeProcessModule, 'executeProcess'); beforeAll(() => { @@ -37,8 +35,6 @@ describe('runAutorunExecutor', () => { }); afterEach(() => { - loggerWarnSpy.mockReset(); - loggerInfoSpy.mockReset(); executeProcessSpy.mockReset(); }); @@ -110,24 +106,28 @@ describe('runAutorunExecutor', () => { it('should set env var information if verbose is set', async () => { const output = await runAutorunExecutor( - { verbose: true }, + { + dryRun: true, // here to produce log + verbose: true, + }, { ...executorContext('github-action'), cwd: '' }, ); - expect(executeProcessSpy).toHaveBeenCalledTimes(1); + + expect(executeProcessSpy).toHaveBeenCalledTimes(0); expect(output.command).not.toContain('--verbose'); - expect(loggerWarnSpy).toHaveBeenCalledTimes(0); - expect(loggerInfoSpy).toHaveBeenCalledWith( - expect.stringContaining('CP_VERBOSE=true'), + expect(logger.warn).toHaveBeenCalledTimes(1); + expect(logger.warn).toHaveBeenCalledWith( + expect.stringContaining('CP_VERBOSE=\"true\"'), ); }); it('should log command if dryRun is set', async () => { await runAutorunExecutor({ dryRun: true }, executorContext('utils')); - expect(loggerInfoSpy).toHaveBeenCalledTimes(0); - expect(loggerWarnSpy).toHaveBeenCalledTimes(1); - expect(loggerWarnSpy).toHaveBeenCalledWith( + expect(logger.command).toHaveBeenCalledTimes(0); + expect(logger.warn).toHaveBeenCalledTimes(1); + expect(logger.warn).toHaveBeenCalledWith( expect.stringContaining('DryRun execution of'), ); }); From f3a92315e920bce7d395845d3e4822a54e2b1d71 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 18:25:33 +0100 Subject: [PATCH 12/28] refactor: wip --- e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts | 1 + packages/nx-plugin/src/executors/cli/executor.unit.test.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 af80803fe..86e183921 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 @@ -173,6 +173,7 @@ describe('nx-plugin', () => { }); const cleanStdout = removeColorCodes(stdout); + throw new Error(cleanStdout); // Nx command expect(cleanStdout).toContain('nx run my-lib:code-pushup --dryRun'); // Run CLI executor diff --git a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts index 39ad3c75e..00370ecf3 100644 --- a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts @@ -118,7 +118,7 @@ describe('runAutorunExecutor', () => { expect(output.command).not.toContain('--verbose'); expect(logger.warn).toHaveBeenCalledTimes(1); expect(logger.warn).toHaveBeenCalledWith( - expect.stringContaining('CP_VERBOSE=\"true\"'), + expect.stringContaining('CP_VERBOSE="true"'), ); }); From 13a6340eca6def7b01b7e48a02347cbb406dcce8 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 18:26:07 +0100 Subject: [PATCH 13/28] refactor: wip --- e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 86e183921..9ba3aba90 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 @@ -173,14 +173,13 @@ describe('nx-plugin', () => { }); const cleanStdout = removeColorCodes(stdout); - throw new Error(cleanStdout); // Nx command expect(cleanStdout).toContain('nx run my-lib:code-pushup --dryRun'); // 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'); + expect(cleanStdout).toContain('CP_VERBOSE="true"'); }); it('should consider plugin option bin in executor target', async () => { From f5b950ba117f7c91c592a70ba5f2dde627ac4cda Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 18:39:53 +0100 Subject: [PATCH 14/28] refactor: wip --- e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts | 1 + packages/nx-plugin/src/executors/cli/executor.ts | 1 + 2 files changed, 2 insertions(+) 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 9ba3aba90..1d4153a77 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 @@ -173,6 +173,7 @@ describe('nx-plugin', () => { }); const cleanStdout = removeColorCodes(stdout); + throw new Error(cleanStdout); // Nx command expect(cleanStdout).toContain('nx run my-lib:code-pushup --dryRun'); // Run CLI executor diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index 038736d03..2dc773934 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -47,6 +47,7 @@ export default async function runAutorunExecutor( logger.warn(`DryRun execution of: ${commandString}`); } else { try { + logger.debug(`With env vars: ${executorEnvVariables}`); await executeProcess({ command, args, From aea384b0bde13e3dd3a41cd0cc75f3a2792ce9da Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 18:44:26 +0100 Subject: [PATCH 15/28] refactor: wip --- e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1d4153a77..c7f911a2e 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 @@ -173,7 +173,7 @@ describe('nx-plugin', () => { }); const cleanStdout = removeColorCodes(stdout); - throw new Error(cleanStdout); + // Nx command expect(cleanStdout).toContain('nx run my-lib:code-pushup --dryRun'); // Run CLI executor From 4e02f79dc71e84eb172e9a8d176805ab0e3bc140 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 18:53:39 +0100 Subject: [PATCH 16/28] refactor: wip --- packages/nx-plugin/src/executors/cli/executor.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index 2dc773934..de838edb9 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -22,13 +22,8 @@ export default async function runAutorunExecutor( terminalAndExecutorOptions, normalizedContext, ); - const { - dryRun, - verbose, - command: cliCommand, - bin, - ...restArgs - } = cliArgumentObject; + const { command: cliCommand } = terminalAndExecutorOptions; + const { dryRun, verbose, bin, ...restArgs } = cliArgumentObject; const command = bin ? `node` : 'npx'; const positionals = [ bin ?? '@code-pushup/cli', From 986ce0edccca633e9c73f22fa4602b5b3446ab33 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 19:04:26 +0100 Subject: [PATCH 17/28] refactor: fix lint --- .../src/executors/cli/executor.unit.test.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts index 00370ecf3..d99408155 100644 --- a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts @@ -1,7 +1,6 @@ import { afterAll, afterEach, beforeEach, expect, vi } from 'vitest'; import { executorContext } from '@code-pushup/test-nx-utils'; import { MEMFS_VOLUME } from '@code-pushup/test-utils'; -import { logger } from '@code-pushup/utils'; import * as executeProcessModule from '../../internal/execute-process.js'; import runAutorunExecutor from './executor.js'; @@ -10,6 +9,7 @@ describe('runAutorunExecutor', () => { Object.entries(process.env).filter(([k]) => k.startsWith('CP_')), ); const executeProcessSpy = vi.spyOn(executeProcessModule, 'executeProcess'); + let loggerSpy: Awaited['logger']; beforeAll(() => { Object.entries(process.env) @@ -23,7 +23,9 @@ describe('runAutorunExecutor', () => { ); }); - beforeEach(() => { + beforeEach(async () => { + const { logger } = await import('@code-pushup/utils'); + loggerSpy = logger; vi.unstubAllEnvs(); executeProcessSpy.mockResolvedValue({ bin: 'npx ...', @@ -116,8 +118,8 @@ describe('runAutorunExecutor', () => { expect(executeProcessSpy).toHaveBeenCalledTimes(0); expect(output.command).not.toContain('--verbose'); - expect(logger.warn).toHaveBeenCalledTimes(1); - expect(logger.warn).toHaveBeenCalledWith( + expect(loggerSpy.warn).toHaveBeenCalledTimes(1); + expect(loggerSpy.warn).toHaveBeenCalledWith( expect.stringContaining('CP_VERBOSE="true"'), ); }); @@ -125,9 +127,9 @@ describe('runAutorunExecutor', () => { it('should log command if dryRun is set', async () => { await runAutorunExecutor({ dryRun: true }, executorContext('utils')); - expect(logger.command).toHaveBeenCalledTimes(0); - expect(logger.warn).toHaveBeenCalledTimes(1); - expect(logger.warn).toHaveBeenCalledWith( + expect(loggerSpy.command).toHaveBeenCalledTimes(0); + expect(loggerSpy.warn).toHaveBeenCalledTimes(1); + expect(loggerSpy.warn).toHaveBeenCalledWith( expect.stringContaining('DryRun execution of'), ); }); From 15418dfdfaa1cc204bbedd98248da917cf850c49 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 2 Dec 2025 19:14:40 +0100 Subject: [PATCH 18/28] refactor: wip --- .../nx-plugin/src/executors/cli/executor.ts | 19 +++++++++++++------ .../nx-plugin/src/executors/internal/types.ts | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index de838edb9..226c4b749 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -23,35 +23,42 @@ export default async function runAutorunExecutor( normalizedContext, ); const { command: cliCommand } = terminalAndExecutorOptions; - const { dryRun, verbose, bin, ...restArgs } = cliArgumentObject; + const { + dryRun, + verbose, + env: executorEnv, + bin, + ...restArgs + } = cliArgumentObject; const command = bin ? `node` : 'npx'; const positionals = [ bin ?? '@code-pushup/cli', ...(cliCommand ? [cliCommand] : []), ]; const args = [...positionals, ...objectToCliArgs(restArgs)]; - const executorEnvVariables = { + const env = { + ...executorEnv, ...(verbose && { CP_VERBOSE: 'true' }), }; const commandString = formatCommandStatus([command, ...args].join(' '), { cwd: context.cwd, - env: executorEnvVariables, + env, }); if (dryRun) { logger.warn(`DryRun execution of: ${commandString}`); } else { try { - logger.debug(`With env vars: ${executorEnvVariables}`); + logger.debug(`With env vars: ${env}`); await executeProcess({ command, args, ...(context.cwd ? { cwd: context.cwd } : {}), - ...(verbose + ...(Object.keys(env).length > 0 ? { env: { ...process.env, - ...executorEnvVariables, + ...env, }, } : {}), diff --git a/packages/nx-plugin/src/executors/internal/types.ts b/packages/nx-plugin/src/executors/internal/types.ts index cb630cc0a..cb206f4ee 100644 --- a/packages/nx-plugin/src/executors/internal/types.ts +++ b/packages/nx-plugin/src/executors/internal/types.ts @@ -30,6 +30,7 @@ export type Command = export type GlobalExecutorOptions = { command?: Command; bin?: string; + env?: Record; verbose?: boolean; config?: string; }; From e8033d3347b6eea7e058dae414f6991a16b6e2db Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Thu, 4 Dec 2025 13:41:17 +0100 Subject: [PATCH 19/28] refactor: wip --- packages/nx-plugin/src/executors/cli/executor.unit.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts index 30ea077fc..dfe34b385 100644 --- a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts @@ -110,7 +110,6 @@ describe('runAutorunExecutor', () => { it('should set env var information if verbose is set', async () => { const output = await runAutorunExecutor( { - dryRun: true, // here to produce log verbose: true, }, { ...executorContext('github-action'), cwd: '' }, From 8c1e35cc1025e67fada33ca2771ab4a7673dfd5b Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Thu, 4 Dec 2025 18:11:59 +0100 Subject: [PATCH 20/28] refactor: wip --- .../src/executors/cli/executor.int.test.ts | 24 +++++++++++--- .../nx-plugin/src/executors/cli/executor.ts | 2 +- .../src/executors/cli/executor.unit.test.ts | 2 +- packages/nx-plugin/src/executors/cli/utils.ts | 3 +- .../src/executors/cli/utils.unit.test.ts | 32 ++++++++++++++++++- .../src/executors/internal/config.ts | 3 +- .../executors/internal/config.unit.test.ts | 14 ++++++++ .../nx-plugin/src/executors/internal/types.ts | 1 + 8 files changed, 71 insertions(+), 10 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.int.test.ts b/packages/nx-plugin/src/executors/cli/executor.int.test.ts index 56962d49c..40cc755ca 100644 --- a/packages/nx-plugin/src/executors/cli/executor.int.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.int.test.ts @@ -22,7 +22,7 @@ describe('runAutorunExecutor', () => { }); afterEach(() => { - parseAutorunExecutorOptionsSpy.mockReset(); + parseAutorunExecutorOptionsSpy.mockRestore(); executeProcessSpy.mockReset(); }); @@ -48,11 +48,25 @@ describe('runAutorunExecutor', () => { command: 'npx', args: expect.arrayContaining(['@code-pushup/cli']), cwd: process.cwd(), - env: expect.objectContaining({ - CP_VERBOSE: 'true', - }), }); + }); - expect(process.env).toHaveProperty('CP_VERBOSE', 'true'); + it('should forward env options to executeProcess', async () => { + const output = await runAutorunExecutor( + { + verbose: true, + env: { TEST_VALUE: '42' }, + }, + executorContext('utils'), + ); + expect(output.success).toBe(true); + expect(executeProcessSpy).toHaveBeenCalledTimes(1); + expect(executeProcessSpy).toHaveBeenCalledWith( + expect.objectContaining({ + env: expect.objectContaining({ + TEST_VALUE: '42', + }), + }), + ); }); }); diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index d318ce54b..16b0a079a 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -22,8 +22,8 @@ export default async function runAutorunExecutor( terminalAndExecutorOptions, normalizedContext, ); - const { command: cliCommand } = terminalAndExecutorOptions; const { + command: cliCommand, verbose = false, dryRun, env: executorEnv, diff --git a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts index dfe34b385..a3295de7f 100644 --- a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts @@ -132,7 +132,7 @@ describe('runAutorunExecutor', () => { expect(logger.warn).toHaveBeenCalledTimes(0); }); - it('should log env var in dryRun information if verbose is set', async () => { + it('should log CP_VERBOSE env var in dryRun information if verbose is set', async () => { const output = await runAutorunExecutor( { dryRun: true, diff --git a/packages/nx-plugin/src/executors/cli/utils.ts b/packages/nx-plugin/src/executors/cli/utils.ts index b91753402..f82c5c5e9 100644 --- a/packages/nx-plugin/src/executors/cli/utils.ts +++ b/packages/nx-plugin/src/executors/cli/utils.ts @@ -13,11 +13,12 @@ import type { export function parseAutorunExecutorOnlyOptions( options: Partial, ): AutorunCommandExecutorOnlyOptions { - const { projectPrefix, dryRun, onlyPlugins } = options; + const { projectPrefix, dryRun, onlyPlugins, env } = options; return { ...(projectPrefix && { projectPrefix }), ...(dryRun != null && { dryRun }), ...(onlyPlugins && { onlyPlugins }), + ...(env && { env }), }; } diff --git a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts index 9a75e744b..dd675c2f6 100644 --- a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts @@ -1,6 +1,8 @@ import { type MockInstance, expect, vi } from 'vitest'; +import { executorContext } from '@code-pushup/test-nx-utils'; import { osAgnosticPath } from '@code-pushup/test-utils'; import type { Command } from '../internal/types.js'; +import runAutorunExecutor from './executor'; import { parseAutorunExecutorOnlyOptions, parseAutorunExecutorOptions, @@ -59,6 +61,12 @@ describe('parseAutorunExecutorOnlyOptions', () => { parseAutorunExecutorOnlyOptions({ onlyPlugins: ['md', 'json'] }), ).toStrictEqual(expect.objectContaining({ onlyPlugins: ['md', 'json'] })); }); + + it('should log env variables options if given', async () => { + expect( + parseAutorunExecutorOnlyOptions({ env: { TEST_ENV_VAR: '42' } }), + ).toStrictEqual(expect.objectContaining({ env: { TEST_ENV_VAR: '42' } })); + }); }); describe('parseAutorunExecutorOptions', () => { @@ -84,7 +92,7 @@ describe('parseAutorunExecutorOptions', () => { projectName, workspaceRoot: 'workspaceRoot', projectConfig: { - name: 'my-app', + name: projectName, root: 'root', }, }, @@ -111,6 +119,28 @@ describe('parseAutorunExecutorOptions', () => { ); }); + it('should include the env options', () => { + const projectName = 'my-app'; + const env = { + NODE_OPTIONS: '--import tsx', + TSX_TSCONFIG_PATH: 'tsconfig.base.json', + }; + + const executorOptions = parseAutorunExecutorOptions( + { env }, + { + projectName, + workspaceRoot: 'workspaceRoot', + projectConfig: { + name: projectName, + root: 'root', + }, + }, + ); + + expect(executorOptions.env).toStrictEqual(env); + }); + it.each(['upload', 'autorun', undefined])( 'should include upload config for command %s if API key is provided', command => { diff --git a/packages/nx-plugin/src/executors/internal/config.ts b/packages/nx-plugin/src/executors/internal/config.ts index d656cecce..7c285a971 100644 --- a/packages/nx-plugin/src/executors/internal/config.ts +++ b/packages/nx-plugin/src/executors/internal/config.ts @@ -14,8 +14,9 @@ export function globalConfig( ): GlobalExecutorOptions { const { projectConfig } = context; const { root: projectRoot = '' } = projectConfig ?? {}; - const { verbose, config } = options; + const { verbose, config, command } = options; return { + command, verbose: !!verbose, config: config ?? path.join(projectRoot, 'code-pushup.config.ts'), }; diff --git a/packages/nx-plugin/src/executors/internal/config.unit.test.ts b/packages/nx-plugin/src/executors/internal/config.unit.test.ts index 298f12290..cf4077b55 100644 --- a/packages/nx-plugin/src/executors/internal/config.unit.test.ts +++ b/packages/nx-plugin/src/executors/internal/config.unit.test.ts @@ -67,6 +67,20 @@ describe('globalConfig', () => { ).toEqual(expect.objectContaining({ config: 'my.config.ts' })); }); + it('should include the command options', () => { + const { command } = globalConfig( + { command: 'collect' }, + { + workspaceRoot: '/test/root/workspace-root', + projectConfig: { + name: 'my-app', + root: 'packages/project-root', + }, + }, + ); + expect(command).toBe('collect'); + }); + it('should work with empty projectConfig', () => { expect( globalConfig( diff --git a/packages/nx-plugin/src/executors/internal/types.ts b/packages/nx-plugin/src/executors/internal/types.ts index cb206f4ee..c4da7e056 100644 --- a/packages/nx-plugin/src/executors/internal/types.ts +++ b/packages/nx-plugin/src/executors/internal/types.ts @@ -5,6 +5,7 @@ import type { ProjectConfiguration } from 'nx/src/config/workspace-json-project- */ export type GeneralExecutorOnlyOptions = { dryRun?: boolean; + env?: Record; }; /** From 983f1f8ced5349f0f284a93226bedbbd72a05c2a Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Thu, 4 Dec 2025 18:28:58 +0100 Subject: [PATCH 21/28] refactor: wip --- packages/nx-plugin/src/executors/cli/utils.unit.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts index dd675c2f6..84531ee9f 100644 --- a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts @@ -1,8 +1,6 @@ import { type MockInstance, expect, vi } from 'vitest'; -import { executorContext } from '@code-pushup/test-nx-utils'; import { osAgnosticPath } from '@code-pushup/test-utils'; import type { Command } from '../internal/types.js'; -import runAutorunExecutor from './executor'; import { parseAutorunExecutorOnlyOptions, parseAutorunExecutorOptions, From 2eb3abd9551229a4a8a7b1c739df63c520f0b493 Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Thu, 4 Dec 2025 18:39:26 +0100 Subject: [PATCH 22/28] refactor: wip --- packages/nx-plugin/src/executors/cli/utils.ts | 3 ++- packages/nx-plugin/src/executors/cli/utils.unit.test.ts | 6 ++++++ packages/nx-plugin/src/executors/internal/types.ts | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/utils.ts b/packages/nx-plugin/src/executors/cli/utils.ts index f82c5c5e9..86a195468 100644 --- a/packages/nx-plugin/src/executors/cli/utils.ts +++ b/packages/nx-plugin/src/executors/cli/utils.ts @@ -13,12 +13,13 @@ import type { export function parseAutorunExecutorOnlyOptions( options: Partial, ): AutorunCommandExecutorOnlyOptions { - const { projectPrefix, dryRun, onlyPlugins, env } = options; + const { projectPrefix, dryRun, onlyPlugins, env, bin } = options; return { ...(projectPrefix && { projectPrefix }), ...(dryRun != null && { dryRun }), ...(onlyPlugins && { onlyPlugins }), ...(env && { env }), + ...(bin && { bin }), }; } diff --git a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts index 84531ee9f..2787a2fea 100644 --- a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts @@ -65,6 +65,12 @@ describe('parseAutorunExecutorOnlyOptions', () => { parseAutorunExecutorOnlyOptions({ env: { TEST_ENV_VAR: '42' } }), ).toStrictEqual(expect.objectContaining({ env: { TEST_ENV_VAR: '42' } })); }); + + it('should process given bin', () => { + expect(parseAutorunExecutorOnlyOptions({ bin: 'index.js' })).toStrictEqual( + expect.objectContaining({ bin: 'index.js' }), + ); + }); }); describe('parseAutorunExecutorOptions', () => { diff --git a/packages/nx-plugin/src/executors/internal/types.ts b/packages/nx-plugin/src/executors/internal/types.ts index c4da7e056..8894b787e 100644 --- a/packages/nx-plugin/src/executors/internal/types.ts +++ b/packages/nx-plugin/src/executors/internal/types.ts @@ -6,6 +6,7 @@ import type { ProjectConfiguration } from 'nx/src/config/workspace-json-project- export type GeneralExecutorOnlyOptions = { dryRun?: boolean; env?: Record; + bin?: string; }; /** @@ -30,8 +31,6 @@ export type Command = | 'history'; export type GlobalExecutorOptions = { command?: Command; - bin?: string; - env?: Record; verbose?: boolean; config?: string; }; From 2787b8971bcc889f31edd58d160f2350613bcff7 Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Thu, 4 Dec 2025 18:42:30 +0100 Subject: [PATCH 23/28] refactor: wip --- .../src/executors/cli/executor.int.test.ts | 19 +++++----- .../nx-plugin/src/executors/cli/executor.ts | 10 +++--- .../src/executors/cli/executor.unit.test.ts | 20 +++++------ .../nx-plugin/src/executors/cli/schema.json | 2 +- .../nx-plugin/src/executors/cli/schema.ts | 6 ++-- .../src/executors/cli/utils.int.test.ts | 6 ++-- packages/nx-plugin/src/executors/cli/utils.ts | 18 +++++----- .../src/executors/cli/utils.unit.test.ts | 36 +++++++++---------- packages/nx-plugin/src/index.ts | 2 +- 9 files changed, 58 insertions(+), 61 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.int.test.ts b/packages/nx-plugin/src/executors/cli/executor.int.test.ts index 40cc755ca..87a22a100 100644 --- a/packages/nx-plugin/src/executors/cli/executor.int.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.int.test.ts @@ -1,14 +1,11 @@ import { afterEach, expect, vi } from 'vitest'; import { executorContext } from '@code-pushup/test-nx-utils'; import * as executeProcessModule from '../../internal/execute-process.js'; -import runAutorunExecutor from './executor.js'; +import runCliExecutor from './executor.js'; import * as utils from './utils.js'; -describe('runAutorunExecutor', () => { - const parseAutorunExecutorOptionsSpy = vi.spyOn( - utils, - 'parseAutorunExecutorOptions', - ); +describe('runCliExecutor', () => { + const parseCliExecutorOptionsSpy = vi.spyOn(utils, 'parseCliExecutorOptions'); const executeProcessSpy = vi.spyOn(executeProcessModule, 'executeProcess'); beforeEach(() => { @@ -22,22 +19,22 @@ describe('runAutorunExecutor', () => { }); afterEach(() => { - parseAutorunExecutorOptionsSpy.mockRestore(); + parseCliExecutorOptionsSpy.mockRestore(); executeProcessSpy.mockReset(); }); it('should normalize context, parse CLI options and execute command', async () => { expect(process.env).not.toHaveProperty('CP_VERBOSE', 'true'); - const output = await runAutorunExecutor( + const output = await runCliExecutor( { verbose: true }, executorContext('utils'), ); expect(output.success).toBe(true); - expect(parseAutorunExecutorOptionsSpy).toHaveBeenCalledTimes(1); + expect(parseCliExecutorOptionsSpy).toHaveBeenCalledTimes(1); //is context normalized - expect(parseAutorunExecutorOptionsSpy).toHaveBeenCalledWith( + expect(parseCliExecutorOptionsSpy).toHaveBeenCalledWith( { verbose: true }, expect.objectContaining({ projectConfig: expect.objectContaining({ name: 'utils' }), @@ -52,7 +49,7 @@ describe('runAutorunExecutor', () => { }); it('should forward env options to executeProcess', async () => { - const output = await runAutorunExecutor( + const output = await runCliExecutor( { verbose: true, env: { TEST_VALUE: '42' }, diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index 16b0a079a..77284a2dc 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -1,8 +1,8 @@ import type { ExecutorContext } from '@nx/devkit'; import { executeProcess } from '../../internal/execute-process.js'; import { normalizeContext } from '../internal/context.js'; -import type { AutorunCommandExecutorOptions } from './schema.js'; -import { parseAutorunExecutorOptions } from './utils.js'; +import type { CliCommandExecutorOptions } from './schema.js'; +import { parseCliExecutorOptions } from './utils.js'; export type ExecutorOutput = { success: boolean; @@ -11,14 +11,14 @@ export type ExecutorOutput = { }; /* eslint-disable-next-line max-lines-per-function */ -export default async function runAutorunExecutor( - terminalAndExecutorOptions: AutorunCommandExecutorOptions, +export default async function runCliExecutor( + terminalAndExecutorOptions: CliCommandExecutorOptions, context: ExecutorContext, ): Promise { const { objectToCliArgs, formatCommandStatus, logger, stringifyError } = await import('@code-pushup/utils'); const normalizedContext = normalizeContext(context); - const cliArgumentObject = parseAutorunExecutorOptions( + const cliArgumentObject = parseCliExecutorOptions( terminalAndExecutorOptions, normalizedContext, ); diff --git a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts index a3295de7f..ba3f3cb16 100644 --- a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts @@ -2,9 +2,9 @@ import { afterAll, afterEach, beforeEach, expect, vi } from 'vitest'; import { executorContext } from '@code-pushup/test-nx-utils'; import { MEMFS_VOLUME } from '@code-pushup/test-utils'; import * as executeProcessModule from '../../internal/execute-process.js'; -import runAutorunExecutor from './executor.js'; +import runCliExecutor from './executor.js'; -describe('runAutorunExecutor', () => { +describe('runCliExecutor', () => { const processEnvCP = Object.fromEntries( Object.entries(process.env).filter(([k]) => k.startsWith('CP_')), ); @@ -41,7 +41,7 @@ describe('runAutorunExecutor', () => { }); it('should call executeProcess with return result', async () => { - const output = await runAutorunExecutor({}, executorContext('utils')); + const output = await runCliExecutor({}, executorContext('utils')); expect(output.success).toBe(true); expect(output.command).toMatch('npx @code-pushup/cli'); expect(executeProcessSpy).toHaveBeenCalledWith({ @@ -52,7 +52,7 @@ describe('runAutorunExecutor', () => { }); it('should normalize context', async () => { - const output = await runAutorunExecutor( + const output = await runCliExecutor( {}, { ...executorContext('utils'), @@ -70,7 +70,7 @@ describe('runAutorunExecutor', () => { }); it('should process executorOptions', async () => { - const output = await runAutorunExecutor( + const output = await runCliExecutor( { output: 'code-pushup.config.json', persist: { filename: 'REPORT' } }, executorContext('testing-utils'), ); @@ -80,7 +80,7 @@ describe('runAutorunExecutor', () => { }); it('should create command from context and options if no api key is set', async () => { - const output = await runAutorunExecutor( + const output = await runCliExecutor( { persist: { filename: 'REPORT', format: ['md', 'json'] } }, executorContext('core'), ); @@ -92,7 +92,7 @@ describe('runAutorunExecutor', () => { it('should create command from context, options and arguments if api key is set', async () => { vi.stubEnv('CP_API_KEY', 'cp_1234567'); - const output = await runAutorunExecutor( + const output = await runCliExecutor( { persist: { filename: 'REPORT', format: ['md', 'json'] }, upload: { project: 'CLI' }, @@ -108,7 +108,7 @@ describe('runAutorunExecutor', () => { }); it('should set env var information if verbose is set', async () => { - const output = await runAutorunExecutor( + const output = await runCliExecutor( { verbose: true, }, @@ -133,7 +133,7 @@ describe('runAutorunExecutor', () => { }); it('should log CP_VERBOSE env var in dryRun information if verbose is set', async () => { - const output = await runAutorunExecutor( + const output = await runCliExecutor( { dryRun: true, verbose: true, @@ -151,7 +151,7 @@ describe('runAutorunExecutor', () => { }); it('should log command if dryRun is set', async () => { - await runAutorunExecutor({ dryRun: true }, executorContext('utils')); + await runCliExecutor({ dryRun: true }, executorContext('utils')); expect(logger.command).toHaveBeenCalledTimes(0); expect(logger.warn).toHaveBeenCalledTimes(1); diff --git a/packages/nx-plugin/src/executors/cli/schema.json b/packages/nx-plugin/src/executors/cli/schema.json index b03736e23..eca17d281 100644 --- a/packages/nx-plugin/src/executors/cli/schema.json +++ b/packages/nx-plugin/src/executors/cli/schema.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/schema", - "$id": "AutorunExecutorOptions", + "$id": "CliExecutorOptions", "title": "CodePushup CLI autorun executor", "description": "Executes the @code-pushup/cli autorun command See: https://github.com/code-pushup/cli/blob/main/packages/cli/README.md#autorun-command", "type": "object", diff --git a/packages/nx-plugin/src/executors/cli/schema.ts b/packages/nx-plugin/src/executors/cli/schema.ts index 7477a276e..6e37d48e8 100644 --- a/packages/nx-plugin/src/executors/cli/schema.ts +++ b/packages/nx-plugin/src/executors/cli/schema.ts @@ -8,15 +8,15 @@ import type { export type PrintConfigOptions = { output?: string }; export type PrintConfigCommandExecutorOptions = PrintConfigOptions; -export type AutorunCommandExecutorOnlyOptions = ProjectExecutorOnlyOptions & +export type CliCommandExecutorOnlyOptions = ProjectExecutorOnlyOptions & CollectExecutorOnlyOptions & GeneralExecutorOnlyOptions; -export type AutorunCommandExecutorOptions = Partial< +export type CliCommandExecutorOptions = Partial< { upload: Partial; persist: Partial; - } & AutorunCommandExecutorOnlyOptions & + } & CliCommandExecutorOnlyOptions & GlobalExecutorOptions > & PrintConfigOptions; diff --git a/packages/nx-plugin/src/executors/cli/utils.int.test.ts b/packages/nx-plugin/src/executors/cli/utils.int.test.ts index 180f22af1..fe00e2d4a 100644 --- a/packages/nx-plugin/src/executors/cli/utils.int.test.ts +++ b/packages/nx-plugin/src/executors/cli/utils.int.test.ts @@ -2,9 +2,9 @@ import { expect, vi } from 'vitest'; import type { UploadConfig } from '@code-pushup/models'; import { normalizedExecutorContext } from '../../../mock/utils/executor.js'; import * as config from '../internal/config.js'; -import { parseAutorunExecutorOptions } from './utils.js'; +import { parseCliExecutorOptions } from './utils.js'; -describe('parseAutorunExecutorOptions', () => { +describe('parseCliExecutorOptions', () => { const persistConfigSpy = vi.spyOn(config, 'persistConfig'); const uploadConfigSpy = vi.spyOn(config, 'uploadConfig'); const globalConfigSpy = vi.spyOn(config, 'globalConfig'); @@ -17,7 +17,7 @@ describe('parseAutorunExecutorOptions', () => { }); it('should call child config functions with options', () => { - parseAutorunExecutorOptions( + parseCliExecutorOptions( { verbose: true, persist: { filename: 'my-name' }, diff --git a/packages/nx-plugin/src/executors/cli/utils.ts b/packages/nx-plugin/src/executors/cli/utils.ts index 86a195468..7e7d131b8 100644 --- a/packages/nx-plugin/src/executors/cli/utils.ts +++ b/packages/nx-plugin/src/executors/cli/utils.ts @@ -5,14 +5,14 @@ import { } from '../internal/config.js'; import type { NormalizedExecutorContext } from '../internal/context.js'; import type { - AutorunCommandExecutorOnlyOptions, - AutorunCommandExecutorOptions, + CliCommandExecutorOnlyOptions, + CliCommandExecutorOptions, PrintConfigCommandExecutorOptions, } from './schema.js'; -export function parseAutorunExecutorOnlyOptions( - options: Partial, -): AutorunCommandExecutorOnlyOptions { +export function parseCliExecutorOnlyOptions( + options: Partial, +): CliCommandExecutorOnlyOptions { const { projectPrefix, dryRun, onlyPlugins, env, bin } = options; return { ...(projectPrefix && { projectPrefix }), @@ -32,10 +32,10 @@ export function parsePrintConfigExecutorOptions( }; } -export function parseAutorunExecutorOptions( - options: Partial, +export function parseCliExecutorOptions( + options: Partial, normalizedContext: NormalizedExecutorContext, -): AutorunCommandExecutorOptions { +): CliCommandExecutorOptions { const { projectPrefix, persist, upload, command, output } = options; const needsUploadParams = command === 'upload' || command === 'autorun' || command === undefined; @@ -46,7 +46,7 @@ export function parseAutorunExecutorOptions( const hasApiToken = uploadCfg?.apiKey != null; return { ...parsePrintConfigExecutorOptions(options), - ...parseAutorunExecutorOnlyOptions(options), + ...parseCliExecutorOnlyOptions(options), ...globalConfig(options, normalizedContext), ...(output ? { output } : {}), persist: persistConfig({ projectPrefix, ...persist }, normalizedContext), diff --git a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts index 2787a2fea..e54002892 100644 --- a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts @@ -2,8 +2,8 @@ import { type MockInstance, expect, vi } from 'vitest'; import { osAgnosticPath } from '@code-pushup/test-utils'; import type { Command } from '../internal/types.js'; import { - parseAutorunExecutorOnlyOptions, - parseAutorunExecutorOptions, + parseCliExecutorOnlyOptions, + parseCliExecutorOptions, parsePrintConfigExecutorOptions, } from './utils.js'; @@ -23,57 +23,57 @@ describe('parsePrintConfigExecutorOptions', () => { }); }); -describe('parseAutorunExecutorOnlyOptions', () => { +describe('parseCliExecutorOnlyOptions', () => { it('should provide NO default projectPrefix', () => { - expect(parseAutorunExecutorOnlyOptions({})).toStrictEqual( + expect(parseCliExecutorOnlyOptions({})).toStrictEqual( expect.not.objectContaining({ projectPrefix: expect.anything() }), ); }); it('should process given projectPrefix', () => { - expect( - parseAutorunExecutorOnlyOptions({ projectPrefix: 'cli' }), - ).toStrictEqual(expect.objectContaining({ projectPrefix: 'cli' })); + expect(parseCliExecutorOnlyOptions({ projectPrefix: 'cli' })).toStrictEqual( + expect.objectContaining({ projectPrefix: 'cli' }), + ); }); it('should provide NO default dryRun', () => { - expect(parseAutorunExecutorOnlyOptions({})).toStrictEqual( + expect(parseCliExecutorOnlyOptions({})).toStrictEqual( expect.not.objectContaining({ dryRun: expect.anything() }), ); }); it('should process given dryRun', () => { - expect(parseAutorunExecutorOnlyOptions({ dryRun: false })).toStrictEqual( + expect(parseCliExecutorOnlyOptions({ dryRun: false })).toStrictEqual( expect.objectContaining({ dryRun: false }), ); }); it('should provide default onlyPlugins', () => { - expect(parseAutorunExecutorOnlyOptions({})).toStrictEqual( + expect(parseCliExecutorOnlyOptions({})).toStrictEqual( expect.not.objectContaining({ onlyPlugins: ['json'] }), ); }); it('should process given onlyPlugins', () => { expect( - parseAutorunExecutorOnlyOptions({ onlyPlugins: ['md', 'json'] }), + parseCliExecutorOnlyOptions({ onlyPlugins: ['md', 'json'] }), ).toStrictEqual(expect.objectContaining({ onlyPlugins: ['md', 'json'] })); }); it('should log env variables options if given', async () => { expect( - parseAutorunExecutorOnlyOptions({ env: { TEST_ENV_VAR: '42' } }), + parseCliExecutorOnlyOptions({ env: { TEST_ENV_VAR: '42' } }), ).toStrictEqual(expect.objectContaining({ env: { TEST_ENV_VAR: '42' } })); }); it('should process given bin', () => { - expect(parseAutorunExecutorOnlyOptions({ bin: 'index.js' })).toStrictEqual( + expect(parseCliExecutorOnlyOptions({ bin: 'index.js' })).toStrictEqual( expect.objectContaining({ bin: 'index.js' }), ); }); }); -describe('parseAutorunExecutorOptions', () => { +describe('parseCliExecutorOptions', () => { let processEnvSpy: MockInstance<[], NodeJS.ProcessEnv>; beforeAll(() => { @@ -86,7 +86,7 @@ describe('parseAutorunExecutorOptions', () => { it('should leverage other config helper to assemble the executor config', () => { const projectName = 'my-app'; - const executorOptions = parseAutorunExecutorOptions( + const executorOptions = parseCliExecutorOptions( { persist: { filename: 'from-options', @@ -130,7 +130,7 @@ describe('parseAutorunExecutorOptions', () => { TSX_TSCONFIG_PATH: 'tsconfig.base.json', }; - const executorOptions = parseAutorunExecutorOptions( + const executorOptions = parseCliExecutorOptions( { env }, { projectName, @@ -149,7 +149,7 @@ describe('parseAutorunExecutorOptions', () => { 'should include upload config for command %s if API key is provided', command => { const projectName = 'my-app'; - const executorOptions = parseAutorunExecutorOptions( + const executorOptions = parseCliExecutorOptions( { command, upload: { @@ -178,7 +178,7 @@ describe('parseAutorunExecutorOptions', () => { 'should not include upload config for command %s', command => { const projectName = 'my-app'; - const executorOptions = parseAutorunExecutorOptions( + const executorOptions = parseCliExecutorOptions( { command, upload: { diff --git a/packages/nx-plugin/src/index.ts b/packages/nx-plugin/src/index.ts index 12e2e4825..31beb6920 100644 --- a/packages/nx-plugin/src/index.ts +++ b/packages/nx-plugin/src/index.ts @@ -10,7 +10,7 @@ const plugin = { export default plugin; -export type { AutorunCommandExecutorOptions } from './executors/cli/schema.js'; +export type { CliCommandExecutorOptions } from './executors/cli/schema.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'; From e74275bb1dea96037532773f35e6dbaffaef0e02 Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Thu, 4 Dec 2025 18:53:49 +0100 Subject: [PATCH 24/28] refactor: wip --- packages/nx-plugin/src/executors/cli/executor.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index 77284a2dc..363a64baf 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -18,10 +18,6 @@ export default async function runCliExecutor( const { objectToCliArgs, formatCommandStatus, logger, stringifyError } = await import('@code-pushup/utils'); const normalizedContext = normalizeContext(context); - const cliArgumentObject = parseCliExecutorOptions( - terminalAndExecutorOptions, - normalizedContext, - ); const { command: cliCommand, verbose = false, @@ -29,15 +25,15 @@ export default async function runCliExecutor( env: executorEnv, bin, ...restArgs - } = cliArgumentObject; + } = parseCliExecutorOptions(terminalAndExecutorOptions, normalizedContext); + logger.setVerbose(verbose); const command = bin ? `node` : 'npx'; - const positionals = [ - bin ?? '@code-pushup/cli', - ...(cliCommand ? [cliCommand] : []), + const args = [ + ...[bin ?? '@code-pushup/cli', ...(cliCommand ? [cliCommand] : [])], + ...objectToCliArgs(restArgs), ]; - const args = [...positionals, ...objectToCliArgs(restArgs)]; const commandString = formatCommandStatus([command, ...args].join(' '), { cwd: context.cwd, env: { From 0118a7e942893ce5e1d7b0140faa0893135134f7 Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Thu, 4 Dec 2025 18:55:51 +0100 Subject: [PATCH 25/28] refactor: wip --- packages/nx-plugin/src/executors/cli/executor.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.ts b/packages/nx-plugin/src/executors/cli/executor.ts index 363a64baf..9f83f5868 100644 --- a/packages/nx-plugin/src/executors/cli/executor.ts +++ b/packages/nx-plugin/src/executors/cli/executor.ts @@ -31,7 +31,8 @@ export default async function runCliExecutor( const command = bin ? `node` : 'npx'; const args = [ - ...[bin ?? '@code-pushup/cli', ...(cliCommand ? [cliCommand] : [])], + bin ?? '@code-pushup/cli', + ...(cliCommand ? [cliCommand] : []), ...objectToCliArgs(restArgs), ]; const commandString = formatCommandStatus([command, ...args].join(' '), { From 093b4e63e5451947c29702b29c5ee05153df9546 Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Thu, 4 Dec 2025 20:43:41 +0100 Subject: [PATCH 26/28] refactor: wip --- .../nx-plugin/src/executors/cli/executor.int.test.ts | 2 +- .../nx-plugin/src/executors/cli/executor.unit.test.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/executor.int.test.ts b/packages/nx-plugin/src/executors/cli/executor.int.test.ts index 87a22a100..4bde33d79 100644 --- a/packages/nx-plugin/src/executors/cli/executor.int.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.int.test.ts @@ -1,4 +1,4 @@ -import { afterEach, expect, vi } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { executorContext } from '@code-pushup/test-nx-utils'; import * as executeProcessModule from '../../internal/execute-process.js'; import runCliExecutor from './executor.js'; diff --git a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts index ba3f3cb16..120b4bbfd 100644 --- a/packages/nx-plugin/src/executors/cli/executor.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/executor.unit.test.ts @@ -1,4 +1,13 @@ -import { afterAll, afterEach, beforeEach, expect, vi } from 'vitest'; +import { + afterAll, + afterEach, + beforeAll, + beforeEach, + describe, + expect, + it, + vi, +} from 'vitest'; import { executorContext } from '@code-pushup/test-nx-utils'; import { MEMFS_VOLUME } from '@code-pushup/test-utils'; import * as executeProcessModule from '../../internal/execute-process.js'; From 4a483a69ca2c54d72479167a8e6f455173a4981b Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Thu, 4 Dec 2025 23:33:13 +0100 Subject: [PATCH 27/28] refactor: wip --- packages/nx-plugin/src/executors/cli/utils.int.test.ts | 2 +- packages/nx-plugin/src/executors/cli/utils.unit.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nx-plugin/src/executors/cli/utils.int.test.ts b/packages/nx-plugin/src/executors/cli/utils.int.test.ts index fe00e2d4a..cecff0afc 100644 --- a/packages/nx-plugin/src/executors/cli/utils.int.test.ts +++ b/packages/nx-plugin/src/executors/cli/utils.int.test.ts @@ -1,4 +1,4 @@ -import { expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; import type { UploadConfig } from '@code-pushup/models'; import { normalizedExecutorContext } from '../../../mock/utils/executor.js'; import * as config from '../internal/config.js'; diff --git a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts index e54002892..83da5cf0e 100644 --- a/packages/nx-plugin/src/executors/cli/utils.unit.test.ts +++ b/packages/nx-plugin/src/executors/cli/utils.unit.test.ts @@ -1,4 +1,4 @@ -import { type MockInstance, expect, vi } from 'vitest'; +import { type MockInstance, describe, expect, it, vi } from 'vitest'; import { osAgnosticPath } from '@code-pushup/test-utils'; import type { Command } from '../internal/types.js'; import { From e5e8df002dfb63a63fa2d4e7df13969271042541 Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Fri, 5 Dec 2025 14:48:57 +0100 Subject: [PATCH 28/28] refactor: wip --- packages/nx-plugin/src/executors/cli/schema.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/nx-plugin/src/executors/cli/schema.json b/packages/nx-plugin/src/executors/cli/schema.json index eca17d281..d2cf4a0f5 100644 --- a/packages/nx-plugin/src/executors/cli/schema.json +++ b/packages/nx-plugin/src/executors/cli/schema.json @@ -21,6 +21,13 @@ "type": "string", "description": "Path to Code PushUp CLI" }, + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Environment variables added to Code PushUp CLI process" + }, "verbose": { "type": "boolean", "description": "Print additional logs"