From 00248aa85d0110cec9faeed7b6a25acc01d36ba1 Mon Sep 17 00:00:00 2001 From: Tine Kondo Date: Fri, 3 Nov 2023 00:56:38 +0100 Subject: [PATCH] =?UTF-8?q?fix(plugins):=20change=20locally=20published=20?= =?UTF-8?q?packages=20version=20from=20`1.0.0`=20->=20`0.0.0-e2e=E2=80=A6?= =?UTF-8?q?=20(#20023)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/add-local-registry-scripts.spec.ts | 33 +++++++++++++++++++ .../src/utils/add-local-registry-scripts.ts | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 packages/js/src/utils/add-local-registry-scripts.spec.ts diff --git a/packages/js/src/utils/add-local-registry-scripts.spec.ts b/packages/js/src/utils/add-local-registry-scripts.spec.ts new file mode 100644 index 0000000000000..65ea0a45248c2 --- /dev/null +++ b/packages/js/src/utils/add-local-registry-scripts.spec.ts @@ -0,0 +1,33 @@ +import { addLocalRegistryScripts } from './add-local-registry-scripts'; +import { Tree, writeJson } from '@nx/devkit'; +import { createTree } from '@nx/devkit/testing'; + +describe('addLocalRegistryScripts', () => { + let tree: Tree; + const startLocalRegistryPath = 'tools/scripts/start-local-registry.ts'; + const stopLocalRegistryPath = 'tools/scripts/stop-local-registry.ts'; + + beforeEach(() => { + tree = createTree(); + writeJson(tree, 'project.json', { + name: 'mylib', + }); + }); + + it('should add "start-local-registry.ts" and "stop-local-registry.ts" in workspace\'s "tools/scripts" folder', () => { + expect(addLocalRegistryScripts(tree)).toEqual({ + startLocalRegistryPath, + stopLocalRegistryPath, + }); + + expect(tree.exists(startLocalRegistryPath)).toBe(true); + expect(tree.exists(stopLocalRegistryPath)).toBe(true); + }); + + it('should set published version to "0.0.0-e2e"', () => { + addLocalRegistryScripts(tree); + + const startLocalRegistry = tree.read(startLocalRegistryPath, 'utf-8'); + expect(/'0\.0\.0-e2e'/.test(startLocalRegistry)).toBe(true); + }); +}); diff --git a/packages/js/src/utils/add-local-registry-scripts.ts b/packages/js/src/utils/add-local-registry-scripts.ts index 0ef34f266b35f..947e11caadb52 100644 --- a/packages/js/src/utils/add-local-registry-scripts.ts +++ b/packages/js/src/utils/add-local-registry-scripts.ts @@ -22,7 +22,7 @@ export default async () => { const nx = require.resolve('nx'); execFileSync( nx, - ['run-many', '--targets', 'publish', '--ver', '1.0.0', '--tag', 'e2e'], + ['run-many', '--targets', 'publish', '--ver', '0.0.0-e2e', '--tag', 'e2e'], { env: process.env, stdio: 'inherit' } ); };