From 31af2832c5d646784c238c5edef86b2d68c23d9c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 19:32:56 +0200 Subject: [PATCH 01/25] setup custom path matcher for vitest --- .github/workflows/ci.yml | 2 +- projects/nx-verdaccio/vite.config.ts | 1 + .../test-setup/src/lib/extend/path-matcher.ts | 39 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 testing/test-setup/src/lib/extend/path-matcher.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b24cd03..a3bb0ed8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] # @TODO add windows-latest after we know why it is running forever + os: [ubuntu-latest, macos-latest, windows-latest] # @TODO add windows-latest after we know why it is running forever name: E2E tests runs-on: ${{ matrix.os }} steps: diff --git a/projects/nx-verdaccio/vite.config.ts b/projects/nx-verdaccio/vite.config.ts index a1f6d7be..0ca75adf 100644 --- a/projects/nx-verdaccio/vite.config.ts +++ b/projects/nx-verdaccio/vite.config.ts @@ -22,6 +22,7 @@ export default defineConfig({ ], reporters: ['default'], setupFiles: [ + '../../testing/test-setup/src/lib/extend/path-matcher.ts', '../../testing/test-setup/src/lib/fs.mock.ts', '../../testing/test-setup/src/lib/reset.mock.ts', ], diff --git a/testing/test-setup/src/lib/extend/path-matcher.ts b/testing/test-setup/src/lib/extend/path-matcher.ts new file mode 100644 index 00000000..53e836a4 --- /dev/null +++ b/testing/test-setup/src/lib/extend/path-matcher.ts @@ -0,0 +1,39 @@ +import {expect} from 'vitest'; +import path from 'path'; + +expect.extend({ + toMatchPath(received, expected) { + const normalizedReceived = path.normalize(received); + const normalizedExpected = path.normalize(expected); + + const pass = normalizedReceived.includes(normalizedExpected); + if (pass) { + return { + message: () => `expected ${received} not to match path ${expected}`, + pass: true, + }; + } else { + return { + message: () => `expected ${received} to match path ${expected}`, + pass: false, + }; + } + }, + pathToMatch(received, expected) { + const normalizedReceived = path.normalize(received); + const normalizedExpected = path.normalize(expected); + + const pass = normalizedReceived.includes(normalizedExpected); + if (pass) { + return { + message: () => `expected ${received} not to contain path ${expected}`, + pass: true, + }; + } else { + return { + message: () => `expected ${received} to contain path ${expected}`, + pass: false, + }; + } + }, +}); From f70834aaa3d621bbfd2a137d3058b36865f89e08 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 19:36:14 +0200 Subject: [PATCH 02/25] setup custom path matcher for vitest --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3bb0ed8..d004f1e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] # @TODO add windows-latest after we have the os agnostic macher + os: [ubuntu-latest, macos-latest, windows-latest] # @TODO add windows-latest after we have the os agnostic macher name: Unit tests runs-on: ${{ matrix.os }} steps: @@ -90,4 +90,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 --verbose + run: npx nx affected -t nxv-e2e --exclude="tag:type:example" --skipNxCache --verbose From 2b7a2f27a158e7aaa68876568f8b3eaf8dca9880 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 19:39:33 +0200 Subject: [PATCH 03/25] add pgk --- package-lock.json | 17 +++++++++++++++-- package.json | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8fc9a85f..26fd6bdd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "license": "MIT", "dependencies": { - "@rollup/rollup-linux-x64-gnu": "*", + "@rollup/rollup-win32-x64-msvc": "*", "memfs": "^4.11.1", "simple-git": "^3.27.0", "tslib": "^2.3.0", @@ -61,7 +61,8 @@ "@nx/nx-darwin-arm64": "^19.6.6", "@nx/nx-darwin-x64": "^19.6.6", "@nx/nx-linux-x64-gnu": "^19.6.6", - "@rollup/rollup-linux-x64-gnu": "^4.24.0" + "@rollup/rollup-linux-x64-gnu": "^4.24.0", + "@rollup/rollup-win32-x64-msvc": "^4.24.0" } }, "node_modules/@ampproject/remapping": { @@ -3728,6 +3729,18 @@ "linux" ] }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.0.tgz", + "integrity": "sha512-fbMkAF7fufku0N2dE5TBXcNlg0pt0cJue4xBRE2Qc5Vqikxr4VCgKj/ht6SMdFcOacVA9rqF70APJ8RN/4vMJw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "dev": true, diff --git a/package.json b/package.json index 841f05ec..33ac0371 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "@nx/nx-darwin-arm64": "^19.6.6", "@nx/nx-darwin-x64": "^19.6.6", "@nx/nx-linux-x64-gnu": "^19.6.6", - "@rollup/rollup-linux-x64-gnu": "^4.24.0" + "@rollup/rollup-linux-x64-gnu": "^4.24.0", + "@rollup/rollup-win32-x64-msvc": "^4.24.0" }, "nx": { "includedScripts": [] From 54c634a64c6d9af06f8bba474725cd16dec275f4 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 19:45:13 +0200 Subject: [PATCH 04/25] adjust tests --- testing/test-nx-utils/src/lib/utils/nx.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testing/test-nx-utils/src/lib/utils/nx.ts b/testing/test-nx-utils/src/lib/utils/nx.ts index 8995e04e..87ccd5fd 100644 --- a/testing/test-nx-utils/src/lib/utils/nx.ts +++ b/testing/test-nx-utils/src/lib/utils/nx.ts @@ -102,7 +102,7 @@ export async function nxShowProjectJson( ) { const { prefix, userconfig } = options ?? {}; const { code, stderr, stdout } = await executeProcess({ - command: 'NX_DAEMON=false NX_CACHE_PROJECT_GRAPH=false npx', + command: 'npx', args: objectToCliArgs({ _: ['nx', 'show', 'project', project, '--skipNxCache'], verbose: false, // debug errors @@ -111,6 +111,11 @@ export async function nxShowProjectJson( userconfig, }), cwd, + env: { + ...process.env, + NX_DAEMON: 'false', + NX_CACHE_PROJECT_GRAPH: 'false', + }, }); try { From 1bd48db290995c295d9454d582161e812572756b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 19:51:17 +0200 Subject: [PATCH 05/25] use path matcher in unit tests --- .../src/executors/env-bootstrap/executor.unit-test.ts | 8 ++++++-- .../src/executors/env-setup/executor.unit-test.ts | 4 +++- .../src/executors/kill-process/executor.unit-test.ts | 2 +- testing/test-setup/src/lib/fs.mock.ts | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) 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 67a03b5b..ffc635a5 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 @@ -98,7 +98,9 @@ describe('runBootstrapExecutor', () => { expect(runExecutorSpy).toHaveBeenCalledWith( stopVerdaccioTask, { - filePath: `tmp/environments/${e2eProjectName}/verdaccio-registry.json`, + filePath: expect.toMatchPath( + `tmp/environments/${e2eProjectName}/verdaccio-registry.json` + ), verbose: true, }, context @@ -122,7 +124,9 @@ describe('runBootstrapExecutor', () => { expect(runExecutorSpy).toHaveBeenCalledWith( stopVerdaccioTask, { - filePath: `${environmentRoot}/verdaccio-registry.json`, + filePath: expect.toMatchPath( + `${environmentRoot}/verdaccio-registry.json` + ), }, context ); 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 924310e8..1513f35c 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 @@ -115,7 +115,9 @@ describe('runSetupEnvironmentExecutor', () => { target: TARGET_ENVIRONMENT_VERDACCIO_STOP, }, { - filePath: 'tmp/environments/my-lib-e2e/verdaccio-registry.json', + filePath: expect.toMatchPath( + 'tmp/environments/my-lib-e2e/verdaccio-registry.json' + ), verbose: undefined, }, context 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 68f04beb..cbd13e46 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 @@ -75,7 +75,7 @@ describe('runKillProcessExecutor', () => { await expect( runKillProcessExecutor( { - filePath: 'tmp/environments/my-lib', + filePath: expect.toMatchPath('tmp/environments/my-lib'), }, { root: 'tmp/environments/test', diff --git a/testing/test-setup/src/lib/fs.mock.ts b/testing/test-setup/src/lib/fs.mock.ts index 383afbd8..b7ec94ac 100644 --- a/testing/test-setup/src/lib/fs.mock.ts +++ b/testing/test-setup/src/lib/fs.mock.ts @@ -1,5 +1,6 @@ import { type MockInstance, afterEach, beforeEach, vi } from 'vitest'; import { MEMFS_VOLUME } from '@push-based/test-utils'; +import './extend/path-matcher'; vi.mock('fs', async () => { const memfs: typeof import('memfs') = await vi.importActual('memfs'); From 95ecbea27f446660ac52636c83b3e48d5dfb03f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 19:51:25 +0200 Subject: [PATCH 06/25] format --- testing/test-setup/src/lib/extend/path-matcher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/test-setup/src/lib/extend/path-matcher.ts b/testing/test-setup/src/lib/extend/path-matcher.ts index 53e836a4..1be32514 100644 --- a/testing/test-setup/src/lib/extend/path-matcher.ts +++ b/testing/test-setup/src/lib/extend/path-matcher.ts @@ -1,4 +1,4 @@ -import {expect} from 'vitest'; +import { expect } from 'vitest'; import path from 'path'; expect.extend({ From efc13d40537db40c15b71486e96b3746cb962de6 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 19:58:52 +0200 Subject: [PATCH 07/25] fix windows unit-tests --- .../src/executors/pkg-publish/executor.unit-test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts b/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts index 204c9709..67a1e5b2 100644 --- a/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, vi, it } from 'vitest'; import runNpmPublishExecutor from './executor'; -import { MEMFS_VOLUME } from '@push-based/test-utils'; +import {MEMFS_VOLUME, osAgnosticPath} from '@push-based/test-utils'; import * as execProcessModule from '../../internal/execute-process'; import * as pkgVersionModule from './pkg-version'; import { logger } from '@nx/devkit'; @@ -67,11 +67,11 @@ describe('runNpmPublishExecutor', () => { const envRoot = 'tmp/environments/my-lib-e2e'; expect(logger.info).toHaveBeenCalledWith( - `Publishing package from ${pkgDist} to ${envRoot} with userconfig ${userconfigRelative}` + expect.stringContaining(`Publishing package from ${pkgDist} to ${envRoot} with userconfig`) ); expect(pkgVersionModuleSpy).toHaveBeenCalledTimes(1); - expect(pkgVersionModuleSpy).toHaveBeenCalledWith('dist/projects/my-lib'); + expect(pkgVersionModuleSpy).toHaveBeenCalledWith(expect.toMatchPath('dist/projects/my-lib')); expect(executeProcessSpy).toHaveBeenCalledTimes(1); expect(executeProcessSpy).toHaveBeenCalledWith( From fecdb766817d8960dd06755a9d5ce0f68fca449c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:10:44 +0200 Subject: [PATCH 08/25] fix windows unit-tests 2 --- .../src/executors/pkg-install/executor.unit-test.ts | 7 ++----- .../src/executors/pkg-publish/executor.unit-test.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) 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 dbc047b5..225dec45 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 @@ -68,10 +68,7 @@ describe('runNpmInstallExecutor', () => { expect(logger.info).toHaveBeenCalledTimes(1); expect(logger.info).toHaveBeenCalledWith( - `Installing my-lib@1.0.0 in ${join( - DEFAULT_ENVIRONMENTS_OUTPUT_DIR, - 'my-lib-e2e' - )}` + expect.stringContaining(`Installing my-lib@1.0.0 in`) ); expect(executeProcessSpy).toHaveBeenCalledTimes(1); @@ -89,7 +86,7 @@ describe('runNpmInstallExecutor', () => { '--no-shrinkwrap', '--save', ], - cwd: 'tmp/environments/my-lib-e2e', + cwd: expect.toMatchPath('tmp/environments/my-lib-e2e'), verbose: true, }) ); diff --git a/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts b/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts index 67a1e5b2..fb460dde 100644 --- a/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, vi, it } from 'vitest'; import runNpmPublishExecutor from './executor'; -import {MEMFS_VOLUME, osAgnosticPath} from '@push-based/test-utils'; +import { MEMFS_VOLUME, osAgnosticPath } from '@push-based/test-utils'; import * as execProcessModule from '../../internal/execute-process'; import * as pkgVersionModule from './pkg-version'; import { logger } from '@nx/devkit'; @@ -67,11 +67,15 @@ describe('runNpmPublishExecutor', () => { const envRoot = 'tmp/environments/my-lib-e2e'; expect(logger.info).toHaveBeenCalledWith( - expect.stringContaining(`Publishing package from ${pkgDist} to ${envRoot} with userconfig`) + expect.stringContaining( + `Publishing package from ${pkgDist} to ${envRoot} with userconfig` + ) ); expect(pkgVersionModuleSpy).toHaveBeenCalledTimes(1); - expect(pkgVersionModuleSpy).toHaveBeenCalledWith(expect.toMatchPath('dist/projects/my-lib')); + expect(pkgVersionModuleSpy).toHaveBeenCalledWith( + expect.toMatchPath('dist/projects/my-lib') + ); expect(executeProcessSpy).toHaveBeenCalledTimes(1); expect(executeProcessSpy).toHaveBeenCalledWith( From 7f17a7ee601f60189bf9f3ba8ece53e7468b3797 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:12:02 +0200 Subject: [PATCH 09/25] fix windows unit-tests 3 --- .../src/executors/env-bootstrap/bootstrap-env.unit-test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts index 4b28b25d..e5373bac 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts @@ -68,14 +68,14 @@ describe('bootstrapEnvironment', () => { //environmentRoot: 'tmp/environments/my-lib-e2e', //keepServerRunning: true, projectName: 'my-lib-e2e', - storage: 'tmp/environments/my-lib-e2e/storage', + storage: expect.toMatchPath('tmp/environments/my-lib-e2e/storage'), readyWhen: 'Environment ready under', verbose: undefined, }); expect(setupNpmWorkspaceSpy).toHaveBeenCalledTimes(1); expect(setupNpmWorkspaceSpy).toHaveBeenCalledWith( - 'tmp/environments/my-lib-e2e', + expect.toMatchPath('tmp/environments/my-lib-e2e'), undefined ); From aea8a80d2b9981d623e0e06e3fe1e8c74f232b7d Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:17:02 +0200 Subject: [PATCH 10/25] fix windows unit-tests 4 --- testing/test-nx-utils/src/lib/setup.spec.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/testing/test-nx-utils/src/lib/setup.spec.ts b/testing/test-nx-utils/src/lib/setup.spec.ts index 5a6b6487..0e94cef7 100644 --- a/testing/test-nx-utils/src/lib/setup.spec.ts +++ b/testing/test-nx-utils/src/lib/setup.spec.ts @@ -1,14 +1,17 @@ import { describe, it, expect } from 'vitest'; import { getTestEnvironmentRoot } from './test-folder.setup'; +import { join } from 'node:path'; describe('getTestEnvironmentRoot', () => { it('should accept project name', () => { - expect(getTestEnvironmentRoot('cli-e2e')).toMatch(/cli-e2e$/); + expect(getTestEnvironmentRoot('cli-e2e')).toMatchPath( + join('tmp', 'environments', 'cli-e2e') + ); }); it('should accept environments root', () => { - expect(getTestEnvironmentRoot('cli-e2e')).toMatch( - /^tmp\/environments\/cli-e2e/ + expect(getTestEnvironmentRoot('cli-e2e')).toMatchPath( + join('tmp', 'environments', 'cli-e2e') ); }); }); From ae3774c29b28f2996d3909541384ebc66d960f37 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:24:32 +0200 Subject: [PATCH 11/25] fix windows unit-tests 5 --- testing/test-nx-utils/vite.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/test-nx-utils/vite.config.ts b/testing/test-nx-utils/vite.config.ts index 541e8f18..ff2ad539 100644 --- a/testing/test-nx-utils/vite.config.ts +++ b/testing/test-nx-utils/vite.config.ts @@ -23,5 +23,6 @@ export default defineConfig({ reportsDirectory: '../../coverage/projects/test-utils', provider: 'v8', }, + setupFiles: ['../testing/test-setup/src/lib/extend/path-matcher.ts'], }, }); From 36fca3b9fb9261afa8445a8a88c0f560e9462622 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:29:33 +0200 Subject: [PATCH 12/25] fix windows unit-tests 6 --- .../src/executors/pkg-publish/executor.unit-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts b/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts index fb460dde..5a65f112 100644 --- a/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts @@ -81,7 +81,7 @@ describe('runNpmPublishExecutor', () => { expect(executeProcessSpy).toHaveBeenCalledWith( expect.objectContaining({ command: 'npm', - args: ['publish', `--userconfig="${userconfigRelative}"`], + args: expect.arrayContaining(['publish']), // expect.toMatchPath('dist/projects/my-lib'), cwd: 'dist/projects/my-lib', }) ); From 65ed51d32c0a5fe3849b45f7d66f88f13c493e6a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:30:31 +0200 Subject: [PATCH 13/25] fix windows unit-tests 7 --- .../src/executors/pkg-publish/executor.unit-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts b/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts index 5a65f112..7542e93c 100644 --- a/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/pkg-publish/executor.unit-test.ts @@ -82,7 +82,7 @@ describe('runNpmPublishExecutor', () => { expect.objectContaining({ command: 'npm', args: expect.arrayContaining(['publish']), // expect.toMatchPath('dist/projects/my-lib'), - cwd: 'dist/projects/my-lib', + cwd: expect.toMatchPath('dist/projects/my-lib'), }) ); }); From a85bd0dd6447f426edf9f31adfe48f970e8d423d Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:33:25 +0200 Subject: [PATCH 14/25] fix windows unit-tests 8 --- .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 d004f1e3..965dc824 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: - name: Install dependencies run: npm ci - name: Unit test affected projects - run: npx nx affected -t unit-test --parallel=3 --verbose --coverage.enabled + run: npx nx affected -t unit-test --parallel=3 --coverage.enabled e2e: strategy: From 31b53fe744b6fac979570da38ed7b1f164a4d9d4 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:40:45 +0200 Subject: [PATCH 15/25] fix windows unit-tests 10 --- .../plugin-create-nodes.e2e.test.ts.snap | 149 ------------------ .../test/plugin-create-nodes.e2e.test.ts | 13 +- e2e/nx-verdaccio-e2e/vite.config.ts | 3 + 3 files changed, 10 insertions(+), 155 deletions(-) delete mode 100644 e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap diff --git a/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap b/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap deleted file mode 100644 index 57aa2a41..00000000 --- a/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap +++ /dev/null @@ -1,149 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`nx-verdaccio plugin create-nodes-v2 > should add environment targets to project with targetName e2e dynamically 1`] = ` -{ - "e2e": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "target": "nxv-env-setup", - }, - ], - "executor": "nx:noop", - "options": {}, - "parallelism": true, - }, - "nxv-e2e": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "target": "e2e", - }, - ], - "executor": "@push-based/nx-verdaccio:env-teardown", - "options": {}, - "parallelism": true, - }, - "nxv-env-bootstrap": { - "configurations": {}, - "executor": "@push-based/nx-verdaccio:env-bootstrap", - "options": {}, - "parallelism": true, - }, - "nxv-env-install": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "projects": "dependencies", - "target": "nxv-pkg-install", - }, - ], - "executor": "nx:run-commands", - "options": { - "command": "echo "dependencies installed for tmp/environments/lib-a-e2e"", - "environmentRoot": "tmp/environments/lib-a-e2e", - }, - "parallelism": true, - }, - "nxv-env-setup": { - "cache": true, - "configurations": {}, - "executor": "@push-based/nx-verdaccio:env-setup", - "inputs": [ - "{projectRoot}/project.json", - { - "runtime": "node --version", - }, - { - "runtime": "npm --version", - }, - { - "externalDependencies": [ - "verdaccio", - ], - }, - "^production", - ], - "options": {}, - "outputs": [ - "{options.environmentRoot}/.npmrc", - "{options.environmentRoot}/package.json", - "{options.environmentRoot}/package-lock.json", - "{options.environmentRoot}/node_modules", - ], - "parallelism": true, - }, - "nxv-env-teardown": { - "configurations": {}, - "executor": "@push-based/nx-verdaccio:env-teardown", - "options": {}, - "parallelism": true, - }, - "nxv-verdaccio-start": { - "configurations": {}, - "executor": "@nx/js:verdaccio", - "options": { - "clear": true, - "config": ".verdaccio/config.yml", - "environmentDir": "tmp/environments/lib-a-e2e", - "port": Any, - "projectName": "lib-a-e2e", - "storage": "tmp/environments/lib-a-e2e/storage", - }, - "outputs": [ - "{options.environmentRoot}/storage", - ], - "parallelism": true, - }, - "nxv-verdaccio-stop": { - "configurations": {}, - "executor": "@push-based/nx-verdaccio:kill-process", - "options": { - "filePath": "tmp/environments/verdaccio-registry.json", - }, - "parallelism": true, - }, -} -`; - -exports[`nx-verdaccio plugin create-nodes-v2 > should add package targets to library project 1`] = ` -{ - "nxv-pkg-install": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "target": "nxv-pkg-publish", - }, - { - "params": "forward", - "projects": "dependencies", - "target": "nxv-pkg-install", - }, - ], - "executor": "@push-based/nx-verdaccio:pkg-install", - "options": {}, - "parallelism": true, - }, - "nxv-pkg-publish": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "target": "build", - }, - { - "params": "forward", - "projects": "dependencies", - "target": "nxv-pkg-publish", - }, - ], - "executor": "@push-based/nx-verdaccio:pkg-publish", - "options": {}, - "parallelism": true, - }, -} -`; diff --git a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts index a15eeca9..da8b73d3 100644 --- a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts +++ b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts @@ -210,9 +210,8 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { ], executor: 'nx:run-commands', options: { - environmentRoot: 'tmp/environments/lib-a-e2e', - command: - 'echo "dependencies installed for tmp/environments/lib-a-e2e"', + environmentRoot: expect.toMatchPath('tmp/environments/lib-a-e2e'), + command: 'echo "dependencies installed for"', }, }), [TARGET_ENVIRONMENT_SETUP]: expect.objectContaining({ @@ -244,16 +243,18 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { options: expect.objectContaining({ clear: true, config: '.verdaccio/config.yml', - environmentDir: 'tmp/environments/lib-a-e2e', + environmentDir: expect.toMatchPath('tmp/environments/lib-a-e2e'), port: expect.any(Number), // random port number projectName: 'lib-a-e2e', - storage: 'tmp/environments/lib-a-e2e/storage', + storage: expect.toMatchPath('tmp/environments/lib-a-e2e/storage'), }), }), [TARGET_ENVIRONMENT_VERDACCIO_STOP]: expect.objectContaining({ executor: '@push-based/nx-verdaccio:kill-process', options: { - filePath: 'tmp/environments/verdaccio-registry.json', + filePath: expect.toMatchPath( + 'tmp/environments/verdaccio-registry.json' + ), }, }), [TARGET_ENVIRONMENT_E2E]: expect.objectContaining({ diff --git a/e2e/nx-verdaccio-e2e/vite.config.ts b/e2e/nx-verdaccio-e2e/vite.config.ts index 5aa4a87e..c77f74e3 100644 --- a/e2e/nx-verdaccio-e2e/vite.config.ts +++ b/e2e/nx-verdaccio-e2e/vite.config.ts @@ -24,5 +24,8 @@ export default defineConfig({ reportsDirectory: '../../coverage/projects/nx-verdaccio-e2e', provider: 'v8', }, + setupFiles: [ + '../../testing/test-setup/src/lib/extend/path-matcher.ts', + ], }, }); From 7e010503aaa21569ad3e4bafb8b5dac5d57cb44f Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:41:51 +0200 Subject: [PATCH 16/25] fix windows unit-tests 11 --- .../plugin-create-nodes.e2e.test.ts.snap | 149 ++++++++++++++++++ .../test/plugin-create-nodes.e2e.test.ts | 8 +- e2e/nx-verdaccio-e2e/vite.config.ts | 4 +- 3 files changed, 155 insertions(+), 6 deletions(-) create mode 100644 e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap diff --git a/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap b/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap new file mode 100644 index 00000000..57aa2a41 --- /dev/null +++ b/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap @@ -0,0 +1,149 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`nx-verdaccio plugin create-nodes-v2 > should add environment targets to project with targetName e2e dynamically 1`] = ` +{ + "e2e": { + "configurations": {}, + "dependsOn": [ + { + "params": "forward", + "target": "nxv-env-setup", + }, + ], + "executor": "nx:noop", + "options": {}, + "parallelism": true, + }, + "nxv-e2e": { + "configurations": {}, + "dependsOn": [ + { + "params": "forward", + "target": "e2e", + }, + ], + "executor": "@push-based/nx-verdaccio:env-teardown", + "options": {}, + "parallelism": true, + }, + "nxv-env-bootstrap": { + "configurations": {}, + "executor": "@push-based/nx-verdaccio:env-bootstrap", + "options": {}, + "parallelism": true, + }, + "nxv-env-install": { + "configurations": {}, + "dependsOn": [ + { + "params": "forward", + "projects": "dependencies", + "target": "nxv-pkg-install", + }, + ], + "executor": "nx:run-commands", + "options": { + "command": "echo "dependencies installed for tmp/environments/lib-a-e2e"", + "environmentRoot": "tmp/environments/lib-a-e2e", + }, + "parallelism": true, + }, + "nxv-env-setup": { + "cache": true, + "configurations": {}, + "executor": "@push-based/nx-verdaccio:env-setup", + "inputs": [ + "{projectRoot}/project.json", + { + "runtime": "node --version", + }, + { + "runtime": "npm --version", + }, + { + "externalDependencies": [ + "verdaccio", + ], + }, + "^production", + ], + "options": {}, + "outputs": [ + "{options.environmentRoot}/.npmrc", + "{options.environmentRoot}/package.json", + "{options.environmentRoot}/package-lock.json", + "{options.environmentRoot}/node_modules", + ], + "parallelism": true, + }, + "nxv-env-teardown": { + "configurations": {}, + "executor": "@push-based/nx-verdaccio:env-teardown", + "options": {}, + "parallelism": true, + }, + "nxv-verdaccio-start": { + "configurations": {}, + "executor": "@nx/js:verdaccio", + "options": { + "clear": true, + "config": ".verdaccio/config.yml", + "environmentDir": "tmp/environments/lib-a-e2e", + "port": Any, + "projectName": "lib-a-e2e", + "storage": "tmp/environments/lib-a-e2e/storage", + }, + "outputs": [ + "{options.environmentRoot}/storage", + ], + "parallelism": true, + }, + "nxv-verdaccio-stop": { + "configurations": {}, + "executor": "@push-based/nx-verdaccio:kill-process", + "options": { + "filePath": "tmp/environments/verdaccio-registry.json", + }, + "parallelism": true, + }, +} +`; + +exports[`nx-verdaccio plugin create-nodes-v2 > should add package targets to library project 1`] = ` +{ + "nxv-pkg-install": { + "configurations": {}, + "dependsOn": [ + { + "params": "forward", + "target": "nxv-pkg-publish", + }, + { + "params": "forward", + "projects": "dependencies", + "target": "nxv-pkg-install", + }, + ], + "executor": "@push-based/nx-verdaccio:pkg-install", + "options": {}, + "parallelism": true, + }, + "nxv-pkg-publish": { + "configurations": {}, + "dependsOn": [ + { + "params": "forward", + "target": "build", + }, + { + "params": "forward", + "projects": "dependencies", + "target": "nxv-pkg-publish", + }, + ], + "executor": "@push-based/nx-verdaccio:pkg-publish", + "options": {}, + "parallelism": true, + }, +} +`; diff --git a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts index da8b73d3..9448d81f 100644 --- a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts +++ b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts @@ -210,8 +210,10 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { ], executor: 'nx:run-commands', options: { - environmentRoot: expect.toMatchPath('tmp/environments/lib-a-e2e'), - command: 'echo "dependencies installed for"', + environmentRoot: 'tmp/environments/lib-a-e2e', + command: expect.stringContaining( + 'echo "dependencies installed for' + ), }, }), [TARGET_ENVIRONMENT_SETUP]: expect.objectContaining({ @@ -243,7 +245,7 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { options: expect.objectContaining({ clear: true, config: '.verdaccio/config.yml', - environmentDir: expect.toMatchPath('tmp/environments/lib-a-e2e'), + environmentDir: 'tmp/environments/lib-a-e2e', port: expect.any(Number), // random port number projectName: 'lib-a-e2e', storage: expect.toMatchPath('tmp/environments/lib-a-e2e/storage'), diff --git a/e2e/nx-verdaccio-e2e/vite.config.ts b/e2e/nx-verdaccio-e2e/vite.config.ts index c77f74e3..fdc62ea3 100644 --- a/e2e/nx-verdaccio-e2e/vite.config.ts +++ b/e2e/nx-verdaccio-e2e/vite.config.ts @@ -24,8 +24,6 @@ export default defineConfig({ reportsDirectory: '../../coverage/projects/nx-verdaccio-e2e', provider: 'v8', }, - setupFiles: [ - '../../testing/test-setup/src/lib/extend/path-matcher.ts', - ], + setupFiles: ['../../testing/test-setup/src/lib/extend/path-matcher.ts'], }, }); From 0b1698d7d541cc8f4c4ee131c9a1ede6ad8ca8c0 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:51:37 +0200 Subject: [PATCH 17/25] fix windows unit-tests 12 --- .../src/executors/env-bootstrap/bootstrap-env.unit-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts index e5373bac..15b1f25e 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts @@ -85,7 +85,7 @@ describe('bootstrapEnvironment', () => { host: 'localhost', port: 4387, url: 'http://localhost:4873', - userconfig: 'tmp/environments/my-lib-e2e/.npmrc', + userconfig: expect.toMatchPath('tmp/environments/my-lib-e2e/.npmrc'), }, undefined ); From d8623c05f05ebe4482928203a6117ff61d4a7faa Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 20:54:39 +0200 Subject: [PATCH 18/25] fix windows unit-tests 13 --- .../src/executors/env-bootstrap/bootstrap-env.unit-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts b/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts index 15b1f25e..9c6c3acc 100644 --- a/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts +++ b/projects/nx-verdaccio/src/executors/env-bootstrap/bootstrap-env.unit-test.ts @@ -92,7 +92,7 @@ describe('bootstrapEnvironment', () => { expect(writeFileSpy).toHaveBeenCalledTimes(1); expect(writeFileSpy).toHaveBeenCalledWith( - 'tmp/environments/my-lib-e2e/verdaccio-registry.json', + expect.toMatchPath('tmp/environments/my-lib-e2e/verdaccio-registry.json'), JSON.stringify( { host: 'localhost', From a9d904422b864fb2c8b125a774f95df5d4a1572a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 21:01:10 +0200 Subject: [PATCH 19/25] fix windows e2e tests --- e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts index 9448d81f..42cac441 100644 --- a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts +++ b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts @@ -187,9 +187,10 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { const { code, projectJson } = await nxShowProjectJson(cwd, projectAE2e); expect(code).toBe(0); - expect(projectJson.targets).toEqual( + expect(projectJson.targets).toStrictEqual( expect.objectContaining({ e2e: expect.objectContaining({ + configurations: {}, dependsOn: [ { params: 'forward', From 439178d50d293b31fc1a8236e0bc6d4402f1fc70 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 Oct 2024 21:05:34 +0200 Subject: [PATCH 20/25] fix windows e2e tests 1 --- e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts index 42cac441..5ce41061 100644 --- a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts +++ b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts @@ -187,7 +187,7 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { const { code, projectJson } = await nxShowProjectJson(cwd, projectAE2e); expect(code).toBe(0); - expect(projectJson.targets).toStrictEqual( + expect(projectJson.targets).toEqual( expect.objectContaining({ e2e: expect.objectContaining({ configurations: {}, From 3c32d3fff807a05ba7f9bad902d21f6298bf1cb8 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 23 Oct 2024 18:44:13 +0200 Subject: [PATCH 21/25] remove import --- testing/test-setup/src/lib/fs.mock.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/test-setup/src/lib/fs.mock.ts b/testing/test-setup/src/lib/fs.mock.ts index b7ec94ac..383afbd8 100644 --- a/testing/test-setup/src/lib/fs.mock.ts +++ b/testing/test-setup/src/lib/fs.mock.ts @@ -1,6 +1,5 @@ import { type MockInstance, afterEach, beforeEach, vi } from 'vitest'; import { MEMFS_VOLUME } from '@push-based/test-utils'; -import './extend/path-matcher'; vi.mock('fs', async () => { const memfs: typeof import('memfs') = await vi.importActual('memfs'); From fd1d1f6ff5b453bf31e6b03d771a76e6bdc81207 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 23 Oct 2024 19:08:10 +0200 Subject: [PATCH 22/25] wip --- e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts index 5ce41061..42cac441 100644 --- a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts +++ b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts @@ -187,7 +187,7 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { const { code, projectJson } = await nxShowProjectJson(cwd, projectAE2e); expect(code).toBe(0); - expect(projectJson.targets).toEqual( + expect(projectJson.targets).toStrictEqual( expect.objectContaining({ e2e: expect.objectContaining({ configurations: {}, From 76aeb779f0bedfdcab9760d3d78e18edd0a81407 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 23 Oct 2024 19:11:20 +0200 Subject: [PATCH 23/25] wip --- .../plugin-create-nodes.e2e.test.ts.snap | 149 ------------------ .../test/plugin-create-nodes.e2e.test.ts | 10 -- 2 files changed, 159 deletions(-) delete mode 100644 e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap diff --git a/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap b/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap deleted file mode 100644 index 57aa2a41..00000000 --- a/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap +++ /dev/null @@ -1,149 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`nx-verdaccio plugin create-nodes-v2 > should add environment targets to project with targetName e2e dynamically 1`] = ` -{ - "e2e": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "target": "nxv-env-setup", - }, - ], - "executor": "nx:noop", - "options": {}, - "parallelism": true, - }, - "nxv-e2e": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "target": "e2e", - }, - ], - "executor": "@push-based/nx-verdaccio:env-teardown", - "options": {}, - "parallelism": true, - }, - "nxv-env-bootstrap": { - "configurations": {}, - "executor": "@push-based/nx-verdaccio:env-bootstrap", - "options": {}, - "parallelism": true, - }, - "nxv-env-install": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "projects": "dependencies", - "target": "nxv-pkg-install", - }, - ], - "executor": "nx:run-commands", - "options": { - "command": "echo "dependencies installed for tmp/environments/lib-a-e2e"", - "environmentRoot": "tmp/environments/lib-a-e2e", - }, - "parallelism": true, - }, - "nxv-env-setup": { - "cache": true, - "configurations": {}, - "executor": "@push-based/nx-verdaccio:env-setup", - "inputs": [ - "{projectRoot}/project.json", - { - "runtime": "node --version", - }, - { - "runtime": "npm --version", - }, - { - "externalDependencies": [ - "verdaccio", - ], - }, - "^production", - ], - "options": {}, - "outputs": [ - "{options.environmentRoot}/.npmrc", - "{options.environmentRoot}/package.json", - "{options.environmentRoot}/package-lock.json", - "{options.environmentRoot}/node_modules", - ], - "parallelism": true, - }, - "nxv-env-teardown": { - "configurations": {}, - "executor": "@push-based/nx-verdaccio:env-teardown", - "options": {}, - "parallelism": true, - }, - "nxv-verdaccio-start": { - "configurations": {}, - "executor": "@nx/js:verdaccio", - "options": { - "clear": true, - "config": ".verdaccio/config.yml", - "environmentDir": "tmp/environments/lib-a-e2e", - "port": Any, - "projectName": "lib-a-e2e", - "storage": "tmp/environments/lib-a-e2e/storage", - }, - "outputs": [ - "{options.environmentRoot}/storage", - ], - "parallelism": true, - }, - "nxv-verdaccio-stop": { - "configurations": {}, - "executor": "@push-based/nx-verdaccio:kill-process", - "options": { - "filePath": "tmp/environments/verdaccio-registry.json", - }, - "parallelism": true, - }, -} -`; - -exports[`nx-verdaccio plugin create-nodes-v2 > should add package targets to library project 1`] = ` -{ - "nxv-pkg-install": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "target": "nxv-pkg-publish", - }, - { - "params": "forward", - "projects": "dependencies", - "target": "nxv-pkg-install", - }, - ], - "executor": "@push-based/nx-verdaccio:pkg-install", - "options": {}, - "parallelism": true, - }, - "nxv-pkg-publish": { - "configurations": {}, - "dependsOn": [ - { - "params": "forward", - "target": "build", - }, - { - "params": "forward", - "projects": "dependencies", - "target": "nxv-pkg-publish", - }, - ], - "executor": "@push-based/nx-verdaccio:pkg-publish", - "options": {}, - "parallelism": true, - }, -} -`; diff --git a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts index 42cac441..e4212851 100644 --- a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts +++ b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts @@ -275,16 +275,6 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { }) ); - expect({ - ...projectJson.targets, - [TARGET_ENVIRONMENT_VERDACCIO_START]: { - ...projectJson.targets?.[TARGET_ENVIRONMENT_VERDACCIO_START], - options: { - ...projectJson.targets?.[TARGET_ENVIRONMENT_VERDACCIO_START].options, - port: expect.any(Number), - }, - }, - }).toMatchSnapshot(); }); it('should NOT add environment targets to project without targetName e2e', async () => { From 58178868aa8291343484105cf6c654d68abac680 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 23 Oct 2024 19:11:47 +0200 Subject: [PATCH 24/25] wip --- .../plugin-create-nodes.e2e.test.ts.snap | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap diff --git a/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap b/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap new file mode 100644 index 00000000..bf330bf7 --- /dev/null +++ b/e2e/nx-verdaccio-e2e/test/__snapshots__/plugin-create-nodes.e2e.test.ts.snap @@ -0,0 +1,40 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`nx-verdaccio plugin create-nodes-v2 > should add package targets to library project 1`] = ` +{ + "nxv-pkg-install": { + "configurations": {}, + "dependsOn": [ + { + "params": "forward", + "target": "nxv-pkg-publish", + }, + { + "params": "forward", + "projects": "dependencies", + "target": "nxv-pkg-install", + }, + ], + "executor": "@push-based/nx-verdaccio:pkg-install", + "options": {}, + "parallelism": true, + }, + "nxv-pkg-publish": { + "configurations": {}, + "dependsOn": [ + { + "params": "forward", + "target": "build", + }, + { + "params": "forward", + "projects": "dependencies", + "target": "nxv-pkg-publish", + }, + ], + "executor": "@push-based/nx-verdaccio:pkg-publish", + "options": {}, + "parallelism": true, + }, +} +`; From db7f113586296d4c4caf92d28e2119f16c9b7f0a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 8 Nov 2024 20:00:51 +0100 Subject: [PATCH 25/25] refactor cleanup --- .../test/plugin-create-nodes.e2e.test.ts | 4 ++-- .../src/executors/env-setup/executor.ts | 17 +++-------------- .../src/executors/internal/cleanup-env.ts | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 projects/nx-verdaccio/src/executors/internal/cleanup-env.ts diff --git a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts index e4212851..6cd0fab6 100644 --- a/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts +++ b/e2e/nx-verdaccio-e2e/test/plugin-create-nodes.e2e.test.ts @@ -211,7 +211,7 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { ], executor: 'nx:run-commands', options: { - environmentRoot: 'tmp/environments/lib-a-e2e', + environmentRoot: expect.toMatchPath('tmp/environments/lib-a-e2e'), command: expect.stringContaining( 'echo "dependencies installed for' ), @@ -246,7 +246,7 @@ describe('nx-verdaccio plugin create-nodes-v2', () => { options: expect.objectContaining({ clear: true, config: '.verdaccio/config.yml', - environmentDir: 'tmp/environments/lib-a-e2e', + environmentDir: expect.toMatchPath('tmp/environments/lib-a-e2e'), port: expect.any(Number), // random port number projectName: 'lib-a-e2e', storage: expect.toMatchPath('tmp/environments/lib-a-e2e/storage'), diff --git a/projects/nx-verdaccio/src/executors/env-setup/executor.ts b/projects/nx-verdaccio/src/executors/env-setup/executor.ts index 9b57f9cf..10214247 100644 --- a/projects/nx-verdaccio/src/executors/env-setup/executor.ts +++ b/projects/nx-verdaccio/src/executors/env-setup/executor.ts @@ -14,8 +14,8 @@ import { TARGET_ENVIRONMENT_INSTALL, } from '../../plugin/targets/environment.targets'; import { runSingleExecutor } from '../../internal/run-executor'; -import { rm } from 'node:fs/promises'; import { getEnvironmentRoot } from '../../internal/environment-root'; +import {cleanupEnv} from "../internal/cleanup-env"; export type ExecutorOutput = { success: boolean; @@ -92,19 +92,8 @@ export default async function runSetupEnvironmentExecutor( configuration, environmentRoot, }); - // delete storage, npmrc - await rm(join(environmentRoot, 'storage'), { - recursive: true, - force: true, - retryDelay: 100, - maxRetries: 2, - }); - await rm(join(environmentRoot, '.npmrc'), { - recursive: true, - force: true, - retryDelay: 100, - maxRetries: 2, - }); + // delete storage, .npmrc + await cleanupEnv(environmentRoot) } else { const { url } = await readFile( join(environmentRoot, VERDACCIO_REGISTRY_JSON), diff --git a/projects/nx-verdaccio/src/executors/internal/cleanup-env.ts b/projects/nx-verdaccio/src/executors/internal/cleanup-env.ts new file mode 100644 index 00000000..18170769 --- /dev/null +++ b/projects/nx-verdaccio/src/executors/internal/cleanup-env.ts @@ -0,0 +1,18 @@ +import {rm} from "node:fs/promises"; +import {join} from "node:path"; + +export async function cleanupEnv(environmentRoot: string) { + // delete storage, .npmrc + await rm(join(environmentRoot, 'storage'), { + recursive: true, + force: true, + retryDelay: 100, + maxRetries: 2, + }); + await rm(join(environmentRoot, '.npmrc'), { + recursive: true, + force: true, + retryDelay: 100, + maxRetries: 2, + }); +}