From fa2b07b9b1ad102ccd356197cc4087ec425c1963 Mon Sep 17 00:00:00 2001 From: Vojtech Masek Date: Mon, 21 Oct 2024 17:53:14 +0200 Subject: [PATCH 01/15] refactor: use npx to execute commands and add windows hide option to execution --- .../e2e/cli-e2e-original/setup/global-setup.ts | 8 ++++---- .../e2e/cli-e2e-original/tooling/utils/npm.ts | 5 ++++- .../tooling/utils/verdaccio-npm-env.ts | 16 +++++++++++----- .../tooling/utils/verdaccio-registry.ts | 5 +++-- .../src/executors/env-bootstrap/npm.ts | 10 ++++++---- .../env-bootstrap/verdaccio-registry.ts | 10 ++++++++-- .../src/executors/env-setup/executor.ts | 4 ++-- .../nx-verdaccio/src/internal/execute-process.ts | 7 ++++++- testing/test-nx-utils/src/lib/execute-process.ts | 2 ++ testing/test-utils/src/lib/execute-process.ts | 2 ++ tooling/bin/nx-show-project.ts | 6 ++---- .../audit/graph-project-time.audit.ts | 1 + .../audit/graph-task-time.audit.ts | 1 + 13 files changed, 52 insertions(+), 25 deletions(-) diff --git a/examples/e2e/cli-e2e-original/setup/global-setup.ts b/examples/e2e/cli-e2e-original/setup/global-setup.ts index ff352c85..e22e2072 100644 --- a/examples/e2e/cli-e2e-original/setup/global-setup.ts +++ b/examples/e2e/cli-e2e-original/setup/global-setup.ts @@ -30,9 +30,9 @@ export async function setup() { // package publish all projects await executeProcess({ - command: 'nx', + command: 'npx', args: objectToCliArgs({ - _: ['run-many'], + _: ['nx', 'run-many'], targets: 'original-npm-publish', exclude: 'tag:type:testing', skipNxCache: true, @@ -44,9 +44,9 @@ export async function setup() { // package install all projects await executeProcess({ - command: 'nx', + command: 'npx', args: objectToCliArgs({ - _: ['run-many'], + _: ['nx', 'run-many'], targets: 'original-npm-install', exclude: 'tag:type:testing', skipNxCache: true, diff --git a/examples/e2e/cli-e2e-original/tooling/utils/npm.ts b/examples/e2e/cli-e2e-original/tooling/utils/npm.ts index 064b0522..fb5ec867 100644 --- a/examples/e2e/cli-e2e-original/tooling/utils/npm.ts +++ b/examples/e2e/cli-e2e-original/tooling/utils/npm.ts @@ -19,7 +19,10 @@ export async function setupNpmWorkspace(directory: string, verbose?: boolean) { await ensureDirectoryExists(directory); process.chdir(join(cwd, directory)); try { - execFileSync('npm', ['init', '--force']).toString(); + execFileSync('npm', ['init', '--force'], { + shell: true, + windowsHide: true, + }).toString(); } catch (error) { logError(`Error creating NPM workspace: ${(error as Error).message}`); } finally { diff --git a/examples/e2e/cli-e2e-original/tooling/utils/verdaccio-npm-env.ts b/examples/e2e/cli-e2e-original/tooling/utils/verdaccio-npm-env.ts index 6e487c00..a33167a3 100644 --- a/examples/e2e/cli-e2e-original/tooling/utils/verdaccio-npm-env.ts +++ b/examples/e2e/cli-e2e-original/tooling/utils/verdaccio-npm-env.ts @@ -9,7 +9,7 @@ import { rm, writeFile } from 'node:fs/promises'; import { setupNpmWorkspace } from '../utils/npm'; import { error, info } from '../utils/logging'; import { objectToCliArgs } from '@push-based/test-utils'; -import { execSync } from 'node:child_process'; +import { execFileSync } from 'node:child_process'; function logInfo(msg: string) { info(msg, 'Verdaccio Env: '); @@ -95,7 +95,7 @@ export function configureRegistry( if (verbose) { logInfo(`Set registry:\n${setRegistry}`); } - execSync(setRegistry); + execFileSync(setRegistry, { shell: true, windowsHide: true }); /** * Protocol-Agnostic Configuration: The use of // allows NPM to configure authentication for a registry without tying it to a specific protocol (http: or https:). @@ -111,7 +111,10 @@ export function configureRegistry( if (verbose) { logInfo(`Set authToken:\n${setAuthToken}`); } - execSync(setAuthToken); + execFileSync(setAuthToken, { + shell: true, + windowsHide: true, + }); } export function unconfigureRegistry( @@ -125,7 +128,10 @@ export function unconfigureRegistry( if (verbose) { logInfo(`Delete authToken:\n${setAuthToken}`); } - execSync(setAuthToken); + execFileSync(setAuthToken, { + shell: true, + windowsHide: true, + }); const setRegistry = `npm config delete registry ${objectToCliArgs({ userconfig, @@ -133,5 +139,5 @@ export function unconfigureRegistry( if (verbose) { logInfo(`Delete registry:\n${setRegistry}`); } - execSync(setRegistry); + execFileSync(setRegistry, { shell: true, windowsHide: true }); } diff --git a/examples/e2e/cli-e2e-original/tooling/utils/verdaccio-registry.ts b/examples/e2e/cli-e2e-original/tooling/utils/verdaccio-registry.ts index 8832c49e..c14e2409 100644 --- a/examples/e2e/cli-e2e-original/tooling/utils/verdaccio-registry.ts +++ b/examples/e2e/cli-e2e-original/tooling/utils/verdaccio-registry.ts @@ -86,9 +86,9 @@ export async function startVerdaccioServer({ return new Promise((resolve, reject) => { executeProcess({ - command: 'nx', + command: 'npx', args: objectToCliArgs({ - _: [targetName, projectName ?? '', '--'], + _: ['nx', targetName, projectName ?? '', '--'], storage, port, verbose, @@ -96,6 +96,7 @@ export async function startVerdaccioServer({ clear, }), shell: true, + windowsHide: true, observer: { onStdout: (stdout: string, childProcess) => { if (verbose) { diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts index e60795e2..06725f11 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts @@ -34,6 +34,8 @@ export async function setupNpmWorkspace( await ensureDirectoryExists(environmentRoot); try { await promisify(execFile)('npm', ['init', '--force'], { + shell: true, + windowsHide: true, cwd: join(cwd, environmentRoot), }); } catch (error) { @@ -79,7 +81,7 @@ export async function configureRegistry( ); } - await promisify(exec)(setRegistry); + await promisify(exec)(setRegistry, { windowsHide: true }); /** * Protocol-Agnostic Configuration: The use of // allows NPM to configure authentication for a registry without tying it to a specific protocol (http: or https:). @@ -97,7 +99,7 @@ export async function configureRegistry( formatInfo(`Set authToken:\n${setAuthToken}`, VERDACCIO_ENV_TOKEN) ); } - await promisify(exec)(setAuthToken); + await promisify(exec)(setAuthToken, { windowsHide: true }); } export type UnconfigureRegistryOptions = Pick< @@ -133,7 +135,7 @@ export async function unconfigureRegistry( formatInfo(`Delete authToken:\n${setAuthToken}`, VERDACCIO_ENV_TOKEN) ); } - await promisify(exec)(setAuthToken); + await promisify(exec)(setAuthToken, { windowsHide: true }); const setRegistry = `npm config delete registry ${objectToCliArgs({ userconfig, @@ -143,5 +145,5 @@ export async function unconfigureRegistry( formatInfo(`Delete registry:\n${setRegistry}`, VERDACCIO_ENV_TOKEN) ); } - await promisify(exec)(setRegistry); + await promisify(exec)(setRegistry, { windowsHide: true }); } diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/verdaccio-registry.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/verdaccio-registry.ts index 61772b1c..eff2e4c4 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/verdaccio-registry.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/verdaccio-registry.ts @@ -98,9 +98,14 @@ export async function startVerdaccioServer({ const isWindows = process.platform === 'win32'; executeProcess({ - command: 'nx', + command: 'npx', args: objectToCliArgs({ - _: [TARGET_ENVIRONMENT_VERDACCIO_START, projectName ?? '', '--'], + _: [ + 'nx', + TARGET_ENVIRONMENT_VERDACCIO_START, + projectName ?? '', + '--', + ], port, ...(verbose !== undefined ? { verbose } : {}), location, @@ -111,6 +116,7 @@ export async function startVerdaccioServer({ detached: !isWindows, //stdio: ['ignore', 'ignore', 'ignore'], // Ignore I/O streams shell: true, + windowsHide: true, observer: { onStdout: (stdout: string, childProcess) => { if (verbose) { diff --git a/projects/nx-verdaccio/src/executors/env-setup/executor.ts b/projects/nx-verdaccio/src/executors/env-setup/executor.ts index 263389ab..0d558448 100644 --- a/projects/nx-verdaccio/src/executors/env-setup/executor.ts +++ b/projects/nx-verdaccio/src/executors/env-setup/executor.ts @@ -59,9 +59,9 @@ export default async function runSetupEnvironmentExecutor( try { await executeProcess({ - command: 'nx', + command: 'npx', args: objectToCliArgs({ - _: [TARGET_ENVIRONMENT_INSTALL, projectName], + _: ['nx', TARGET_ENVIRONMENT_INSTALL, projectName], environmentRoot, ...(verbose ? { verbose } : {}), }), diff --git a/projects/nx-verdaccio/src/internal/execute-process.ts b/projects/nx-verdaccio/src/internal/execute-process.ts index e358c547..d15de546 100644 --- a/projects/nx-verdaccio/src/internal/execute-process.ts +++ b/projects/nx-verdaccio/src/internal/execute-process.ts @@ -32,7 +32,11 @@ export type ProcessConfig = Omit< SpawnOptionsWithStdioTuple, 'stdio' > & { - stdio?: 'pipe' | 'inherit' | 'ignore' | (StdioPipe | 'pipe' | 'inherit' | 'ignore')[]; + stdio?: + | 'pipe' + | 'inherit' + | 'ignore' + | (StdioPipe | 'pipe' | 'inherit' | 'ignore')[]; command: string; args?: string[]; verbose?: boolean; @@ -76,6 +80,7 @@ export function executeProcess(cfg: ProcessConfig): Promise { // shell:true tells Windows to use shell command for spawning a child process const spawnedProcess = spawn(command, args ?? [], { shell: true, + windowsHide: true, ...options, }) as ChildProcessByStdio; diff --git a/testing/test-nx-utils/src/lib/execute-process.ts b/testing/test-nx-utils/src/lib/execute-process.ts index 02d974a5..9f90164d 100644 --- a/testing/test-nx-utils/src/lib/execute-process.ts +++ b/testing/test-nx-utils/src/lib/execute-process.ts @@ -63,6 +63,8 @@ export function executeProcess(cfg: ProcessConfig): Promise { // shell:true tells Windows to use shell command for spawning a child process const spawnedProcess = spawn(command, args ?? [], { shell: true, + windowsHide: true, + ...options, }) as ChildProcessByStdio; diff --git a/testing/test-utils/src/lib/execute-process.ts b/testing/test-utils/src/lib/execute-process.ts index 02d974a5..9f90164d 100644 --- a/testing/test-utils/src/lib/execute-process.ts +++ b/testing/test-utils/src/lib/execute-process.ts @@ -63,6 +63,8 @@ export function executeProcess(cfg: ProcessConfig): Promise { // shell:true tells Windows to use shell command for spawning a child process const spawnedProcess = spawn(command, args ?? [], { shell: true, + windowsHide: true, + ...options, }) as ChildProcessByStdio; diff --git a/tooling/bin/nx-show-project.ts b/tooling/bin/nx-show-project.ts index edf85066..06683851 100644 --- a/tooling/bin/nx-show-project.ts +++ b/tooling/bin/nx-show-project.ts @@ -1,4 +1,4 @@ -import { execFileSync, execSync } from 'node:child_process'; +import { execFileSync } from 'node:child_process'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; import { objectToCliArgs } from '../../../../packages/utils/src'; @@ -41,9 +41,7 @@ try { // Hide process output via "2>/dev/null". Otherwise, it will print the error message to the terminal. '2>/dev/null', ], - { - shell: true, - } + { shell: true, windowsHide: true } ).toString(); const existingPackage = viewResult diff --git a/tooling/measures/nx-performance/audit/graph-project-time.audit.ts b/tooling/measures/nx-performance/audit/graph-project-time.audit.ts index dd845914..71758856 100644 --- a/tooling/measures/nx-performance/audit/graph-project-time.audit.ts +++ b/tooling/measures/nx-performance/audit/graph-project-time.audit.ts @@ -47,6 +47,7 @@ export async function projectGraphTiming(): Promise<{ duration: number }> { const isWindows = process.platform === 'win32'; await promisify(execFile)('npx', ['nx', 'show', 'projects'], { shell: isWindows, + windowsHide: true, env: { ...process.env, NX_CACHE_PROJECT_GRAPH: 'false', diff --git a/tooling/measures/nx-performance/audit/graph-task-time.audit.ts b/tooling/measures/nx-performance/audit/graph-task-time.audit.ts index d4ba8e68..f260ef93 100644 --- a/tooling/measures/nx-performance/audit/graph-task-time.audit.ts +++ b/tooling/measures/nx-performance/audit/graph-task-time.audit.ts @@ -75,6 +75,7 @@ export async function taskGraphTiming( ], { shell: isWindows, + windowsHide: true, env: { ...process.env, NX_CACHE_PROJECT_GRAPH: 'false', From 4e8b7a081e268b73e241a99c146d3c54ef4d042f Mon Sep 17 00:00:00 2001 From: Vojtech Masek Date: Mon, 21 Oct 2024 17:58:18 +0200 Subject: [PATCH 02/15] refactor: use npm install command with explicit include of all available deps --- .../nx-verdaccio/src/executors/pkg-install/executor.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/nx-verdaccio/src/executors/pkg-install/executor.ts b/projects/nx-verdaccio/src/executors/pkg-install/executor.ts index a680cc49..4fac12ca 100644 --- a/projects/nx-verdaccio/src/executors/pkg-install/executor.ts +++ b/projects/nx-verdaccio/src/executors/pkg-install/executor.ts @@ -32,9 +32,12 @@ export default async function runNpmInstallExecutor( await executeProcess({ command: 'npm', args: objectToCliArgs({ - _: ['install', `${packageNameAndVersion}`], + _: [ + 'install', + `${packageNameAndVersion}`, + '--include=prod --include=dev --include=optional --include=peer', // install all the deps of the package + ], fund: false, // avoid polluted terminal - optional: true, // install optional deps of the package shrinkwrap: false, // avoid package-lock creation or update save: true, // save to package.json dependencies }), From 9c6e64d86b570e31937587f9c8b896de7cf3083d Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 12:57:51 +0200 Subject: [PATCH 03/15] fix: pkg-install unit tests --- projects/nx-verdaccio/src/executors/pkg-install/executor.ts | 5 ++++- .../src/executors/pkg-install/executor.unit-test.ts | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/projects/nx-verdaccio/src/executors/pkg-install/executor.ts b/projects/nx-verdaccio/src/executors/pkg-install/executor.ts index 4fac12ca..b7e7176f 100644 --- a/projects/nx-verdaccio/src/executors/pkg-install/executor.ts +++ b/projects/nx-verdaccio/src/executors/pkg-install/executor.ts @@ -35,7 +35,10 @@ export default async function runNpmInstallExecutor( _: [ 'install', `${packageNameAndVersion}`, - '--include=prod --include=dev --include=optional --include=peer', // install all the deps of the package + '--include=prod', + '--include=dev', + '--include=optional', + '--include=peer', // install all the deps of the package ], fund: false, // avoid polluted terminal shrinkwrap: false, // avoid package-lock creation or update diff --git a/projects/nx-verdaccio/src/executors/pkg-install/executor.unit-test.ts b/projects/nx-verdaccio/src/executors/pkg-install/executor.unit-test.ts index 6bd3863e..dbc047b5 100644 --- a/projects/nx-verdaccio/src/executors/pkg-install/executor.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/pkg-install/executor.unit-test.ts @@ -81,6 +81,10 @@ describe('runNpmInstallExecutor', () => { args: [ 'install', 'my-lib@1.0.0', + '--include=prod', + '--include=dev', + '--include=optional', + '--include=peer', '--no-fund', '--no-shrinkwrap', '--save', From 7485fe49a3ce71ab4cfc4f7ff2c9997eccd5fe54 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 14:45:49 +0200 Subject: [PATCH 04/15] fix: npmWorkspace tests unit tests --- .../src/executors/env-bootstrap/npm.ts | 8 +-- .../executors/env-bootstrap/npm.unit-test.ts | 51 ++++++++++--------- .../executors/env-setup/executor.unit-test.ts | 6 ++- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts index 06725f11..2e501488 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts @@ -81,7 +81,7 @@ export async function configureRegistry( ); } - await promisify(exec)(setRegistry, { windowsHide: true }); + await promisify(exec)(setRegistry, { windowsHide: true, shell: true }); /** * Protocol-Agnostic Configuration: The use of // allows NPM to configure authentication for a registry without tying it to a specific protocol (http: or https:). @@ -99,7 +99,7 @@ export async function configureRegistry( formatInfo(`Set authToken:\n${setAuthToken}`, VERDACCIO_ENV_TOKEN) ); } - await promisify(exec)(setAuthToken, { windowsHide: true }); + await promisify(exec)(setAuthToken, { windowsHide: true, shell: true }); } export type UnconfigureRegistryOptions = Pick< @@ -135,7 +135,7 @@ export async function unconfigureRegistry( formatInfo(`Delete authToken:\n${setAuthToken}`, VERDACCIO_ENV_TOKEN) ); } - await promisify(exec)(setAuthToken, { windowsHide: true }); + await promisify(exec)(setAuthToken, { windowsHide: true, shell: true }); const setRegistry = `npm config delete registry ${objectToCliArgs({ userconfig, @@ -145,5 +145,5 @@ export async function unconfigureRegistry( formatInfo(`Delete registry:\n${setRegistry}`, VERDACCIO_ENV_TOKEN) ); } - await promisify(exec)(setRegistry, { windowsHide: true }); + await promisify(exec)(setRegistry, { windowsHide: true, shell: true }); } diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts index be2459f5..775bac5b 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts @@ -3,25 +3,23 @@ import { bold, red } from 'ansis'; import { MEMFS_VOLUME } from '@push-based/test-utils'; import { configureRegistry, - type ConfigureRegistryOptions, + ConfigureRegistryOptions, setupNpmWorkspace, unconfigureRegistry, - type UnconfigureRegistryOptions, VERDACCIO_ENV_TOKEN, } from './npm'; import { exec } from 'node:child_process'; import { logger } from '@nx/devkit'; import { formatInfo } from '../../internal/logging'; -vi.mock('child_process', async () => { - const actual = await vi.importActual( - 'child_process' - ); - return { - ...actual, - exec: vi.fn().mockImplementation((cmd, cb) => cb(null, '', '')), - }; -}); +const execMock = vi.fn(); +vi.mock('util', () => ({ + promisify: vi.fn( + () => + (...args) => + execMock(...args) + ), +})); vi.mock('@nx/devkit', async () => { const actual = await vi.importActual('@nx/devkit'); @@ -34,6 +32,9 @@ vi.mock('@nx/devkit', async () => { }); describe('configureRegistry', () => { + beforeEach(() => { + execMock.mockRestore(); + }); it('should set the npm registry and authToken', async () => { const processResult: ConfigureRegistryOptions = { port: 4873, @@ -44,15 +45,15 @@ describe('configureRegistry', () => { await configureRegistry(processResult); - expect(exec).toHaveBeenCalledTimes(2); - expect(exec).toHaveBeenCalledWith( + expect(execMock).toHaveBeenCalledTimes(2); + expect(execMock).toHaveBeenCalledWith( 'npm config set registry="http://localhost:4873" --userconfig="test-config"', - expect.any(Function) + { windowsHide: true, shell: true } ); - expect(exec).toHaveBeenCalledWith( + expect(execMock).toHaveBeenCalledWith( 'npm config set //localhost:4873/:_authToken "secretVerdaccioToken" --userconfig="test-config"', - expect.any(Function) + { windowsHide: true, shell: true } ); }); @@ -66,7 +67,7 @@ describe('configureRegistry', () => { await configureRegistry(processResult, true); - expect(exec).toHaveBeenCalledTimes(2); + expect(execMock).toHaveBeenCalledTimes(2); expect(logger.info).toHaveBeenCalledWith( formatInfo( 'Set registry:\nnpm config set registry="http://localhost:4873" --userconfig="test-config"', @@ -83,6 +84,10 @@ describe('configureRegistry', () => { }); describe('unconfigureRegistry', () => { + beforeEach(() => { + execMock.mockRestore(); + }); + it('should delete the npm registry and authToken', async () => { const processResult: UnconfigureRegistryOptions = { userconfig: 'test-config', @@ -92,15 +97,15 @@ describe('unconfigureRegistry', () => { await unconfigureRegistry(processResult); - expect(exec).toHaveBeenCalledTimes(2); - expect(exec).toHaveBeenCalledWith( + expect(execMock).toHaveBeenCalledTimes(2); + expect(execMock).toHaveBeenCalledWith( 'npm config delete registry --userconfig="test-config"', - expect.any(Function) + { windowsHide: true, shell: true } ); - expect(exec).toHaveBeenCalledWith( + expect(execMock).toHaveBeenCalledWith( 'npm config delete //localhost:4873/:_authToken --userconfig="test-config"', - expect.any(Function) + { windowsHide: true, shell: true } ); }); @@ -113,7 +118,7 @@ describe('unconfigureRegistry', () => { await unconfigureRegistry(processResult, true); - expect(exec).toHaveBeenCalledTimes(2); + expect(execMock).toHaveBeenCalledTimes(2); expect(logger.info).toHaveBeenCalledWith( formatInfo( 'Delete registry:\nnpm config delete registry --userconfig="test-config"', diff --git a/projects/nx-verdaccio/src/executors/env-setup/executor.unit-test.ts b/projects/nx-verdaccio/src/executors/env-setup/executor.unit-test.ts index 943f19b3..924310e8 100644 --- a/projects/nx-verdaccio/src/executors/env-setup/executor.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/env-setup/executor.unit-test.ts @@ -86,12 +86,13 @@ describe('runSetupEnvironmentExecutor', () => { expect(executeProcessSpy).toHaveBeenCalledTimes(1); expect(executeProcessSpy).toHaveBeenCalledWith({ args: [ + 'nx', 'nxv-env-install', projectName, // @TODO check for --environmentRoot too be OS agnostic path expect.stringContaining(projectName), ], - command: 'nx', + command: 'npx', cwd: '/test', }); @@ -212,11 +213,12 @@ describe('runSetupEnvironmentExecutor', () => { expect(executeProcessSpy).toHaveBeenCalledTimes(1); expect(executeProcessSpy).toHaveBeenCalledWith({ args: [ + 'nx', 'nxv-env-install', 'my-lib-e2e', '--environmentRoot="tmp/environments/my-lib-e2e"', ], - command: 'nx', + command: 'npx', cwd: '/test', }); From 10a7c76fbce697e46057ad0cb59f046677ae06a3 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 14:52:06 +0200 Subject: [PATCH 05/15] fix: e2e --- projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts | 8 ++++---- .../src/executors/env-bootstrap/npm.unit-test.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts index 2e501488..06725f11 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.ts @@ -81,7 +81,7 @@ export async function configureRegistry( ); } - await promisify(exec)(setRegistry, { windowsHide: true, shell: true }); + await promisify(exec)(setRegistry, { windowsHide: true }); /** * Protocol-Agnostic Configuration: The use of // allows NPM to configure authentication for a registry without tying it to a specific protocol (http: or https:). @@ -99,7 +99,7 @@ export async function configureRegistry( formatInfo(`Set authToken:\n${setAuthToken}`, VERDACCIO_ENV_TOKEN) ); } - await promisify(exec)(setAuthToken, { windowsHide: true, shell: true }); + await promisify(exec)(setAuthToken, { windowsHide: true }); } export type UnconfigureRegistryOptions = Pick< @@ -135,7 +135,7 @@ export async function unconfigureRegistry( formatInfo(`Delete authToken:\n${setAuthToken}`, VERDACCIO_ENV_TOKEN) ); } - await promisify(exec)(setAuthToken, { windowsHide: true, shell: true }); + await promisify(exec)(setAuthToken, { windowsHide: true }); const setRegistry = `npm config delete registry ${objectToCliArgs({ userconfig, @@ -145,5 +145,5 @@ export async function unconfigureRegistry( formatInfo(`Delete registry:\n${setRegistry}`, VERDACCIO_ENV_TOKEN) ); } - await promisify(exec)(setRegistry, { windowsHide: true, shell: true }); + await promisify(exec)(setRegistry, { windowsHide: true }); } diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts index 775bac5b..1c1ea9d1 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts @@ -48,12 +48,12 @@ describe('configureRegistry', () => { expect(execMock).toHaveBeenCalledTimes(2); expect(execMock).toHaveBeenCalledWith( 'npm config set registry="http://localhost:4873" --userconfig="test-config"', - { windowsHide: true, shell: true } + { windowsHide: true } ); expect(execMock).toHaveBeenCalledWith( 'npm config set //localhost:4873/:_authToken "secretVerdaccioToken" --userconfig="test-config"', - { windowsHide: true, shell: true } + { windowsHide: true } ); }); @@ -100,12 +100,12 @@ describe('unconfigureRegistry', () => { expect(execMock).toHaveBeenCalledTimes(2); expect(execMock).toHaveBeenCalledWith( 'npm config delete registry --userconfig="test-config"', - { windowsHide: true, shell: true } + { windowsHide: true } ); expect(execMock).toHaveBeenCalledWith( 'npm config delete //localhost:4873/:_authToken --userconfig="test-config"', - { windowsHide: true, shell: true } + { windowsHide: true } ); }); From 378dbc243a645550d6c5ca435da4fb3ae6b1d772 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 14:58:17 +0200 Subject: [PATCH 06/15] wip --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf89efe5..7f1884e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,4 +70,4 @@ jobs: - name: Install dependencies run: npm i - name: E2E test affected projects - run: npx nx affected -t nxv-e2e --exclude="tag:type:example" + run: NX_DAEMON=false; npx nx affected -t nxv-e2e --exclude="tag:type:example" --skipNxCache From d79134f67014b0fe8b6e2f0463679c4c1972913d Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 15:00:53 +0200 Subject: [PATCH 07/15] wip 2 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f1884e7..1b0876dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,4 +70,4 @@ jobs: - name: Install dependencies run: npm i - name: E2E test affected projects - run: NX_DAEMON=false; npx nx affected -t nxv-e2e --exclude="tag:type:example" --skipNxCache + run: NX_DAEMON=false; npx nx affected -t nxv-e2e --exclude="tag:type:example" --skipNxCache --verbose From d94dd327ca30dcca17145b31e5bda0e36bc0c7a2 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 15:04:32 +0200 Subject: [PATCH 08/15] wip 3 --- package-lock.json | 176 ++++++++++++++++++++++++++++++++++++++++++---- package.json | 2 +- 2 files changed, 162 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index df13702f..966d59e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "@nx/workspace": "19.8.0", "@swc-node/register": "~1.9.1", "@swc/cli": "~0.3.12", - "@swc/core": "^1.7.22", + "@swc/core": "^1.7.39", "@swc/helpers": "~0.5.11", "@types/jest": "^29.5.12", "@types/node": "18.16.9", @@ -3843,10 +3843,11 @@ } }, "node_modules/@swc/core": { - "version": "1.7.36", + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.7.39.tgz", + "integrity": "sha512-jns6VFeOT49uoTKLWIEfiQqJAlyqldNAt80kAr8f7a5YjX0zgnG3RBiLMpksx4Ka4SlK4O6TJ/lumIM3Trp82g==", "dev": true, "hasInstallScript": true, - "license": "Apache-2.0", "dependencies": { "@swc/counter": "^0.1.3", "@swc/types": "^0.1.13" @@ -3859,16 +3860,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.7.36", - "@swc/core-darwin-x64": "1.7.36", - "@swc/core-linux-arm-gnueabihf": "1.7.36", - "@swc/core-linux-arm64-gnu": "1.7.36", - "@swc/core-linux-arm64-musl": "1.7.36", - "@swc/core-linux-x64-gnu": "1.7.36", - "@swc/core-linux-x64-musl": "1.7.36", - "@swc/core-win32-arm64-msvc": "1.7.36", - "@swc/core-win32-ia32-msvc": "1.7.36", - "@swc/core-win32-x64-msvc": "1.7.36" + "@swc/core-darwin-arm64": "1.7.39", + "@swc/core-darwin-x64": "1.7.39", + "@swc/core-linux-arm-gnueabihf": "1.7.39", + "@swc/core-linux-arm64-gnu": "1.7.39", + "@swc/core-linux-arm64-musl": "1.7.39", + "@swc/core-linux-x64-gnu": "1.7.39", + "@swc/core-linux-x64-musl": "1.7.39", + "@swc/core-win32-arm64-msvc": "1.7.39", + "@swc/core-win32-ia32-msvc": "1.7.39", + "@swc/core-win32-x64-msvc": "1.7.39" }, "peerDependencies": { "@swc/helpers": "*" @@ -3880,12 +3881,13 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.7.36", + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.7.39.tgz", + "integrity": "sha512-o2nbEL6scMBMCTvY9OnbyVXtepLuNbdblV9oNJEFia5v5eGj9WMrnRQiylH3Wp/G2NYkW7V1/ZVW+kfvIeYe9A==", "cpu": [ "arm64" ], "dev": true, - "license": "Apache-2.0 AND MIT", "optional": true, "os": [ "darwin" @@ -3894,6 +3896,150 @@ "node": ">=10" } }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.7.39.tgz", + "integrity": "sha512-qMlv3XPgtPi/Fe11VhiPDHSLiYYk2dFYl747oGsHZPq+6tIdDQjIhijXPcsUHIXYDyG7lNpODPL8cP/X1sc9MA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.7.39.tgz", + "integrity": "sha512-NP+JIkBs1ZKnpa3Lk2W1kBJMwHfNOxCUJXuTa2ckjFsuZ8OUu2gwdeLFkTHbR43dxGwH5UzSmuGocXeMowra/Q==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.7.39.tgz", + "integrity": "sha512-cPc+/HehyHyHcvAsk3ML/9wYcpWVIWax3YBaA+ScecJpSE04l/oBHPfdqKUPslqZ+Gcw0OWnIBGJT/fBZW2ayw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.7.39.tgz", + "integrity": "sha512-8RxgBC6ubFem66bk9XJ0vclu3exJ6eD7x7CwDhp5AD/tulZslTYXM7oNPjEtje3xxabXuj/bEUMNvHZhQRFdqA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.7.39.tgz", + "integrity": "sha512-3gtCPEJuXLQEolo9xsXtuPDocmXQx12vewEyFFSMSjOfakuPOBmOQMa0sVL8Wwius8C1eZVeD1fgk0omMqeC+Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.7.39.tgz", + "integrity": "sha512-mg39pW5x/eqqpZDdtjZJxrUvQNSvJF4O8wCl37fbuFUqOtXs4TxsjZ0aolt876HXxxhsQl7rS+N4KioEMSgTZw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.7.39.tgz", + "integrity": "sha512-NZwuS0mNJowH3e9bMttr7B1fB8bW5svW/yyySigv9qmV5VcQRNz1kMlCvrCLYRsa93JnARuiaBI6FazSeG8mpA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.7.39.tgz", + "integrity": "sha512-qFmvv5UExbJPXhhvCVDBnjK5Duqxr048dlVB6ZCgGzbRxuarOlawCzzLK4N172230pzlAWGLgn9CWl3+N6zfHA==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.7.39.tgz", + "integrity": "sha512-o+5IMqgOtj9+BEOp16atTfBgCogVak9svhBpwsbcJQp67bQbxGYhAPPDW/hZ2rpSSF7UdzbY9wudoX9G4trcuQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@swc/counter": { "version": "0.1.3", "dev": true, diff --git a/package.json b/package.json index 9f1103a5..14efab1f 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@nx/workspace": "19.8.0", "@swc-node/register": "~1.9.1", "@swc/cli": "~0.3.12", - "@swc/core": "^1.7.22", + "@swc/core": "^1.7.39", "@swc/helpers": "~0.5.11", "@types/jest": "^29.5.12", "@types/node": "18.16.9", From a938041a037e297d9f99d311d9198ebc9c0fca6a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 15:13:08 +0200 Subject: [PATCH 09/15] fix lint --- package-lock.json | 16 +++++++++++++++- package.json | 3 ++- projects/nx-verdaccio/.eslintrc.json | 7 ++++++- projects/nx-verdaccio/package.json | 4 +--- .../env-bootstrap/executor.unit-test.ts | 2 +- .../src/executors/env-bootstrap/npm.unit-test.ts | 3 +-- .../src/executors/env-bootstrap/schema.ts | 2 +- .../src/executors/env-setup/executor.ts | 1 - .../src/executors/env-setup/schema.ts | 2 +- .../src/executors/env-teardown/teardown-env.ts | 3 +-- .../executors/kill-process/executor.unit-test.ts | 2 -- .../src/internal/environment-root.ts | 8 ++++---- 12 files changed, 33 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 966d59e3..8fc9a85f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "license": "MIT", "dependencies": { + "@rollup/rollup-linux-x64-gnu": "*", "memfs": "^4.11.1", "simple-git": "^3.27.0", "tslib": "^2.3.0", @@ -59,7 +60,8 @@ "optionalDependencies": { "@nx/nx-darwin-arm64": "^19.6.6", "@nx/nx-darwin-x64": "^19.6.6", - "@nx/nx-linux-x64-gnu": "^19.6.6" + "@nx/nx-linux-x64-gnu": "^19.6.6", + "@rollup/rollup-linux-x64-gnu": "^4.24.0" } }, "node_modules/@ampproject/remapping": { @@ -3714,6 +3716,18 @@ "darwin" ] }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.24.0.tgz", + "integrity": "sha512-ZXFk7M72R0YYFN5q13niV0B7G8/5dcQ9JDp8keJSfr3GoZeXEoMHP/HlvqROA3OMbMdfr19IjCeNAnPUG93b6A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "dev": true, diff --git a/package.json b/package.json index 14efab1f..841f05ec 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "optionalDependencies": { "@nx/nx-darwin-arm64": "^19.6.6", "@nx/nx-darwin-x64": "^19.6.6", - "@nx/nx-linux-x64-gnu": "^19.6.6" + "@nx/nx-linux-x64-gnu": "^19.6.6", + "@rollup/rollup-linux-x64-gnu": "^4.24.0" }, "nx": { "includedScripts": [] diff --git a/projects/nx-verdaccio/.eslintrc.json b/projects/nx-verdaccio/.eslintrc.json index ab72edb1..35abf250 100644 --- a/projects/nx-verdaccio/.eslintrc.json +++ b/projects/nx-verdaccio/.eslintrc.json @@ -40,7 +40,12 @@ "error", { "buildTargets": ["build"], - "ignoredDependencies": ["verdaccio"], + "ignoredDependencies": [ + "verdaccio", + "nx", + "@code-pushup/models", + "@nx/plugin" + ], "checkMissingDependencies": true, "checkObsoleteDependencies": true, "checkVersionMismatches": true, diff --git a/projects/nx-verdaccio/package.json b/projects/nx-verdaccio/package.json index e3b9bc7e..73eff258 100644 --- a/projects/nx-verdaccio/package.json +++ b/projects/nx-verdaccio/package.json @@ -8,9 +8,7 @@ "@nx/devkit": "19.8.0", "ansis": "^3.3.2", "simple-git": "^3.27.0", - "nx": "19.8.0", - "tslib": "^2.3.0", - "verdaccio": "*" + "tslib": "^2.3.0" }, "type": "commonjs", "main": "./src/index.js", diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/executor.unit-test.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/executor.unit-test.ts index bf25290d..67a03b5b 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/executor.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/executor.unit-test.ts @@ -5,7 +5,7 @@ import * as bootstrapExecutorModule from './bootstrap-env'; import { PACKAGE_NAME } from '../../plugin/constants'; import { TARGET_ENVIRONMENT_VERDACCIO_STOP } from '../../plugin/targets/environment.targets'; import { MockAsyncIterableIterator } from '@push-based/test-utils'; -import { ExecutorContext } from '@nx/devkit'; +import { type ExecutorContext } from '@nx/devkit'; describe('runBootstrapExecutor', () => { const e2eProjectName = 'my-lib-e2e'; diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts index 1c1ea9d1..eed5dcd2 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/npm.unit-test.ts @@ -3,12 +3,11 @@ import { bold, red } from 'ansis'; import { MEMFS_VOLUME } from '@push-based/test-utils'; import { configureRegistry, - ConfigureRegistryOptions, + type ConfigureRegistryOptions, setupNpmWorkspace, unconfigureRegistry, VERDACCIO_ENV_TOKEN, } from './npm'; -import { exec } from 'node:child_process'; import { logger } from '@nx/devkit'; import { formatInfo } from '../../internal/logging'; diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/schema.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/schema.ts index e5b57a01..f3ec1c41 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/schema.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/schema.ts @@ -1,4 +1,4 @@ -import { Environment } from './npm'; +import { type Environment } from './npm'; export type BootstrapExecutorOptions = Partial< { diff --git a/projects/nx-verdaccio/src/executors/env-setup/executor.ts b/projects/nx-verdaccio/src/executors/env-setup/executor.ts index 0d558448..9b57f9cf 100644 --- a/projects/nx-verdaccio/src/executors/env-setup/executor.ts +++ b/projects/nx-verdaccio/src/executors/env-setup/executor.ts @@ -15,7 +15,6 @@ import { } from '../../plugin/targets/environment.targets'; import { runSingleExecutor } from '../../internal/run-executor'; import { rm } from 'node:fs/promises'; -import { options } from 'yargs'; import { getEnvironmentRoot } from '../../internal/environment-root'; export type ExecutorOutput = { diff --git a/projects/nx-verdaccio/src/executors/env-setup/schema.ts b/projects/nx-verdaccio/src/executors/env-setup/schema.ts index 9688789c..672a8c7a 100644 --- a/projects/nx-verdaccio/src/executors/env-setup/schema.ts +++ b/projects/nx-verdaccio/src/executors/env-setup/schema.ts @@ -1,4 +1,4 @@ -import { Environment } from '../env-bootstrap/npm'; +import { type Environment } from '../env-bootstrap/npm'; export type SetupEnvironmentExecutorOptions = Partial< Environment & { diff --git a/projects/nx-verdaccio/src/executors/env-teardown/teardown-env.ts b/projects/nx-verdaccio/src/executors/env-teardown/teardown-env.ts index 9256b149..2dfe9b0a 100644 --- a/projects/nx-verdaccio/src/executors/env-teardown/teardown-env.ts +++ b/projects/nx-verdaccio/src/executors/env-teardown/teardown-env.ts @@ -14,8 +14,7 @@ export type TeardownEnvironmentOptions = Environment & { verbose?: boolean }; export async function teardownEnvironment( context: ExecutorContext, - options: TeardownEnvironmentOptions, - git: SimpleGit = gitClient + options: TeardownEnvironmentOptions ): Promise { const environmentRoot = getEnvironmentRoot(context, options); // kill verdaccio process if running diff --git a/projects/nx-verdaccio/src/executors/kill-process/executor.unit-test.ts b/projects/nx-verdaccio/src/executors/kill-process/executor.unit-test.ts index 6536fd7c..68f04beb 100644 --- a/projects/nx-verdaccio/src/executors/kill-process/executor.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/kill-process/executor.unit-test.ts @@ -3,8 +3,6 @@ import runKillProcessExecutor from './executor'; import * as killProcessModule from './kill-process'; import { MEMFS_VOLUME } from '@push-based/test-utils'; import { logger } from '@nx/devkit'; -import { PACKAGE_NAME } from '../../plugin/constants'; -import { EXECUTOR_ENVIRONMENT_KILL_PROCESS } from './constant'; vi.mock('@nx/devkit', async () => { const actual = await vi.importActual('@nx/devkit'); diff --git a/projects/nx-verdaccio/src/internal/environment-root.ts b/projects/nx-verdaccio/src/internal/environment-root.ts index a779e66e..aedc8622 100644 --- a/projects/nx-verdaccio/src/internal/environment-root.ts +++ b/projects/nx-verdaccio/src/internal/environment-root.ts @@ -1,9 +1,9 @@ import { join } from 'node:path'; -import { ExecutorContext } from '@nx/devkit'; -import { ExpandedPluginConfiguration } from 'nx/src/config/nx-json'; -import { NxVerdaccioCreateNodeOptions } from '../plugin/schema'; +import { type ExecutorContext } from '@nx/devkit'; +import { type ExpandedPluginConfiguration } from 'nx/src/config/nx-json'; +import { type NxVerdaccioCreateNodeOptions } from '../plugin/schema'; import { DEFAULT_ENVIRONMENTS_OUTPUT_DIR } from '../plugin/constants'; -import { Environment } from '../executors/env-bootstrap/npm'; +import { type Environment } from '../executors/env-bootstrap/npm'; export function getEnvironmentDir(context: ExecutorContext) { const plugin = context.nxJsonConfiguration?.plugins?.find((pCfg) => { From 29a3805286bf6a918db906fa397db227c1ba502f Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 15:14:44 +0200 Subject: [PATCH 10/15] add lint to CI --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b0876dc..64cf84bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,29 @@ jobs: - name: Audit production dependencies run: npm audit --omit=dev --omit=optional + lint: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + name: Unit tests + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + - name: Set base and head for Nx affected commands + uses: nrwl/nx-set-shas@v4 + - name: Install dependencies + run: npm ci + - name: Unit test affected projects + run: npx nx affected -t lint --parallel=3 --verbose unit-test: strategy: fail-fast: false From 1cbe2af3535d3fbf8b25dd210600046f6d4cdc18 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 15:15:50 +0200 Subject: [PATCH 11/15] fix naming --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64cf84bb..b2b182e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,8 +45,9 @@ jobs: uses: nrwl/nx-set-shas@v4 - name: Install dependencies run: npm ci - - name: Unit test affected projects + - name: Lint affected projects run: npx nx affected -t lint --parallel=3 --verbose + unit-test: strategy: fail-fast: false From d8abc5910ac59d681553c16a2b0ca96087440261 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 15:18:25 +0200 Subject: [PATCH 12/15] fix naming --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2b182e4..321b7ad8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - name: Unit tests + name: Lint runs-on: ${{ matrix.os }} steps: - name: Checkout repository From d124c009244277e582c537165e507836637432d2 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 15:21:09 +0200 Subject: [PATCH 13/15] fix lint for examples --- .github/workflows/ci.yml | 2 +- examples/projects/core/package.json | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 321b7ad8..f18893d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest] name: Lint runs-on: ${{ matrix.os }} steps: diff --git a/examples/projects/core/package.json b/examples/projects/core/package.json index 72822950..3a3bf226 100644 --- a/examples/projects/core/package.json +++ b/examples/projects/core/package.json @@ -3,8 +3,6 @@ "version": "0.0.1", "dependencies": { "@push-based/utils": "*", - "@push-based/models": "*", - "vite": "~5.0.0", - "@nx/vite": "19.8.0" + "@push-based/models": "*" } } From bbde97de884acd5a602442d5b45ae9dfa15f519c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 15:35:32 +0200 Subject: [PATCH 14/15] add CP for main to avoid unnecessary runs --- .github/workflows/ci.yml | 6 +--- .github/workflows/merge-main.yml | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/merge-main.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f18893d8..8b24cd03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,12 +25,8 @@ jobs: run: npm audit --omit=dev --omit=optional lint: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] name: Lint - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/merge-main.yml b/.github/workflows/merge-main.yml new file mode 100644 index 00000000..c3947bb4 --- /dev/null +++ b/.github/workflows/merge-main.yml @@ -0,0 +1,49 @@ +name: Main + +on: + pull_request: + branches: + - main + push: + branches: + - main + workflow_dispatch: + inputs: + dryRun: + type: choice + description: 'Dry run' + required: true + default: 'false' + options: + - 'true' + - 'false' + +env: + NX_NON_NATIVE_HASHER: true + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + - name: Set base and head for Nx affected commands + uses: nrwl/nx-set-shas@v4 + - name: Install dependencies + run: npm ci + - name: Run Code PushUp on release commit + uses: code-pushup/github-action@v0 + with: + bin: npx nx code-pushup -- + env: + CP_SERVER: ${{ secrets.CP_SERVER }} + CP_API_KEY: ${{ secrets.CP_API_KEY }} + CP_ORGANIZATION: code-pushup + CP_PROJECT: cli From 1ec3e380190a3c9974dab9149b94a778e7db0d23 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 15:37:59 +0200 Subject: [PATCH 15/15] wip --- .github/workflows/merge-main.yml | 49 -------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 .github/workflows/merge-main.yml diff --git a/.github/workflows/merge-main.yml b/.github/workflows/merge-main.yml deleted file mode 100644 index c3947bb4..00000000 --- a/.github/workflows/merge-main.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Main - -on: - pull_request: - branches: - - main - push: - branches: - - main - workflow_dispatch: - inputs: - dryRun: - type: choice - description: 'Dry run' - required: true - default: 'false' - options: - - 'true' - - 'false' - -env: - NX_NON_NATIVE_HASHER: true - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: npm - - name: Set base and head for Nx affected commands - uses: nrwl/nx-set-shas@v4 - - name: Install dependencies - run: npm ci - - name: Run Code PushUp on release commit - uses: code-pushup/github-action@v0 - with: - bin: npx nx code-pushup -- - env: - CP_SERVER: ${{ secrets.CP_SERVER }} - CP_API_KEY: ${{ secrets.CP_API_KEY }} - CP_ORGANIZATION: code-pushup - CP_PROJECT: cli