From 5cc87bfdc26ba2a24b8833c2397a0f87a32e44c0 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Tue, 26 Sep 2023 00:09:29 -0400 Subject: [PATCH] fix(misc): properly add extra dependencies to packages (#19334) --- packages/angular/project.json | 8 ++++---- packages/cypress/project.json | 8 ++++---- packages/detox/project.json | 8 ++++---- packages/devkit/project.json | 8 ++++---- packages/esbuild/project.json | 3 +++ packages/eslint-plugin/project.json | 8 ++++---- packages/expo/project.json | 8 ++++---- packages/express/project.json | 8 ++++---- packages/jest/project.json | 8 ++++---- packages/js/project.json | 8 ++++---- packages/linter/project.json | 8 ++++---- packages/nest/project.json | 8 ++++---- packages/next/project.json | 8 ++++---- packages/node/project.json | 8 ++++---- packages/nx/project.json | 6 +++--- packages/plugin/project.json | 8 ++++---- packages/react-native/project.json | 8 ++++---- packages/react/project.json | 8 ++++---- packages/rollup/project.json | 8 ++++---- packages/storybook/project.json | 8 ++++---- packages/vite/project.json | 8 ++++---- packages/web/project.json | 8 ++++---- packages/webpack/project.json | 8 ++++---- packages/workspace/project.json | 12 +++++------- scripts/add-dependency-to-build.js | 3 ++- scripts/nx-release.ts | 10 ++++++++++ 26 files changed, 107 insertions(+), 95 deletions(-) diff --git a/packages/angular/project.json b/packages/angular/project.json index 04cbca8800260..fc517f3aed213 100644 --- a/packages/angular/project.json +++ b/packages/angular/project.json @@ -63,13 +63,13 @@ "outputs": ["{workspaceRoot}/build/packages/angular"], "dependsOn": ["build-ng", "build-base", "^build"], "options": { - "commands": [ - "node ./scripts/copy-readme.js angular", - "node ./scripts/add-dependency-to-build.js angular @nrwl/angular" - ], + "command": "node ./scripts/copy-readme.js angular", "parallel": false } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js angular @nrwl/angular" + }, "lint": {} }, "implicitDependencies": [] diff --git a/packages/cypress/project.json b/packages/cypress/project.json index 41e8f553f43ca..6ea0e21058fff 100644 --- a/packages/cypress/project.json +++ b/packages/cypress/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/cypress"], "options": { - "commands": [ - "node ./scripts/copy-readme.js cypress", - "node ./scripts/add-dependency-to-build.js cypress @nrwl/cypress" - ] + "command": "node ./scripts/copy-readme.js cypress" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js cypress @nrwl/cypress" + }, "lint": {} } } diff --git a/packages/detox/project.json b/packages/detox/project.json index b40e60519a14a..b7d7d2b431b98 100644 --- a/packages/detox/project.json +++ b/packages/detox/project.json @@ -48,11 +48,11 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/detox"], "options": { - "commands": [ - "node ./scripts/copy-readme.js detox", - "node ./scripts/add-dependency-to-build.js detox @nrwl/detox" - ] + "command": "node ./scripts/copy-readme.js detox" } + }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js detox @nrwl/detox" } } } diff --git a/packages/devkit/project.json b/packages/devkit/project.json index 53a0137b5a70a..19d43d5696420 100644 --- a/packages/devkit/project.json +++ b/packages/devkit/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/devkit"], "options": { - "commands": [ - "node ./scripts/copy-readme.js devkit", - "node ./scripts/add-dependency-to-build.js devkit @nrwl/devkit" - ] + "command": "node ./scripts/copy-readme.js devkit" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js devkit @nrwl/devkit" + }, "lint": {} } } diff --git a/packages/esbuild/project.json b/packages/esbuild/project.json index b8cd0b8877c9f..c4478a5a1a141 100644 --- a/packages/esbuild/project.json +++ b/packages/esbuild/project.json @@ -54,6 +54,9 @@ ] } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js esbuild @nrwl/esbuild" + }, "lint": {} } } diff --git a/packages/eslint-plugin/project.json b/packages/eslint-plugin/project.json index 1061e2511388c..5ae8b7cf15807 100644 --- a/packages/eslint-plugin/project.json +++ b/packages/eslint-plugin/project.json @@ -49,12 +49,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/eslint-plugin"], "options": { - "commands": [ - "node ./scripts/copy-readme.js eslint-plugin", - "node ./scripts/add-dependency-to-build.js eslint-plugin @nrwl/eslint-plugin-nx" - ] + "command": "node ./scripts/copy-readme.js eslint-plugin" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js eslint-plugin @nrwl/eslint-plugin-nx" + }, "lint": {} } } diff --git a/packages/expo/project.json b/packages/expo/project.json index 0ed86e0445c01..48cb68a77d173 100644 --- a/packages/expo/project.json +++ b/packages/expo/project.json @@ -50,11 +50,11 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/expo"], "options": { - "commands": [ - "node ./scripts/copy-readme.js expo", - "node ./scripts/add-dependency-to-build.js expo @nrwl/expo" - ] + "command": "node ./scripts/copy-readme.js expo" } + }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js expo @nrwl/expo" } }, "tags": [] diff --git a/packages/express/project.json b/packages/express/project.json index ab15f96d0fd14..5dc375e1f3731 100644 --- a/packages/express/project.json +++ b/packages/express/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/express"], "options": { - "commands": [ - "node ./scripts/copy-readme.js express", - "node ./scripts/add-dependency-to-build.js express @nrwl/express" - ] + "command": "node ./scripts/copy-readme.js express" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js express @nrwl/express" + }, "lint": {} }, "implicitDependencies": ["node"] diff --git a/packages/jest/project.json b/packages/jest/project.json index 483423244ab5c..b308c861adb05 100644 --- a/packages/jest/project.json +++ b/packages/jest/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/jest"], "options": { - "commands": [ - "node ./scripts/copy-readme.js jest", - "node ./scripts/add-dependency-to-build.js jest @nrwl/jest" - ] + "command": "node ./scripts/copy-readme.js jest" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js jest @nrwl/jest" + }, "lint": {} } } diff --git a/packages/js/project.json b/packages/js/project.json index 0b50494bc84d8..1be65cbf9d418 100644 --- a/packages/js/project.json +++ b/packages/js/project.json @@ -50,11 +50,11 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/js"], "options": { - "commands": [ - "node ./scripts/copy-readme.js js", - "node ./scripts/add-dependency-to-build.js js @nrwl/js" - ] + "command": "node ./scripts/copy-readme.js js" } + }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js js @nrwl/js" } }, "tags": [] diff --git a/packages/linter/project.json b/packages/linter/project.json index 31f6f2899de81..283dda3fbf766 100644 --- a/packages/linter/project.json +++ b/packages/linter/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/linter"], "options": { - "commands": [ - "node ./scripts/copy-readme.js linter", - "node ./scripts/add-dependency-to-build.js linter @nrwl/linter" - ] + "command": "node ./scripts/copy-readme.js linter" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js linter @nrwl/linter" + }, "lint": {} }, "implicitDependencies": ["eslint-plugin"] diff --git a/packages/nest/project.json b/packages/nest/project.json index 426311b642d44..098c84d405179 100644 --- a/packages/nest/project.json +++ b/packages/nest/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/nest"], "options": { - "commands": [ - "node ./scripts/copy-readme.js nest", - "node ./scripts/add-dependency-to-build.js nest @nrwl/nest" - ] + "command": "node ./scripts/copy-readme.js nest" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js nest @nrwl/nest" + }, "lint": {} }, "implicitDependencies": ["node", "linter"] diff --git a/packages/next/project.json b/packages/next/project.json index 855f1a893be62..7088f54340733 100644 --- a/packages/next/project.json +++ b/packages/next/project.json @@ -53,12 +53,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/next"], "options": { - "commands": [ - "node ./scripts/copy-readme.js next", - "node ./scripts/add-dependency-to-build.js next @nrwl/next" - ] + "command": "node ./scripts/copy-readme.js next" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js next @nrwl/next" + }, "lint": {} } } diff --git a/packages/node/project.json b/packages/node/project.json index 048a845a62774..6c3185fcad764 100644 --- a/packages/node/project.json +++ b/packages/node/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/node"], "options": { - "commands": [ - "node ./scripts/copy-readme.js node", - "node ./scripts/add-dependency-to-build.js node @nrwl/node" - ] + "command": "node ./scripts/copy-readme.js node" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js node @nrwl/node" + }, "lint": {} } } diff --git a/packages/nx/project.json b/packages/nx/project.json index 9b948d131368a..b6687d6f8c606 100644 --- a/packages/nx/project.json +++ b/packages/nx/project.json @@ -95,14 +95,14 @@ }, { "command": "node ./scripts/copy-readme.js nx" - }, - { - "command": "node ./scripts/add-dependency-to-build.js nx @nrwl/tao" } ], "parallel": false } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js nx @nrwl/tao" + }, "lint": {}, "test": {}, "test-native": {} diff --git a/packages/plugin/project.json b/packages/plugin/project.json index cb8587ac08dad..9e08c7cdfb686 100644 --- a/packages/plugin/project.json +++ b/packages/plugin/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/plugin"], "options": { - "commands": [ - "node ./scripts/copy-readme.js plugin", - "node ./scripts/add-dependency-to-build.js plugin @nrwl/nx-plugin" - ] + "command": "node ./scripts/copy-readme.js plugin" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js plugin @nrwl/nx-plugin" + }, "lint": {} } } diff --git a/packages/react-native/project.json b/packages/react-native/project.json index 0711cc54d2573..8cd100a58035a 100644 --- a/packages/react-native/project.json +++ b/packages/react-native/project.json @@ -44,11 +44,11 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/react-native"], "options": { - "commands": [ - "node ./scripts/copy-readme.js react-native", - "node ./scripts/add-dependency-to-build.js react-native @nrwl/react-native" - ] + "command": "node ./scripts/copy-readme.js react-native" } + }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js react-native @nrwl/react-native" } } } diff --git a/packages/react/project.json b/packages/react/project.json index 99b584c161267..d38437dd52138 100644 --- a/packages/react/project.json +++ b/packages/react/project.json @@ -58,12 +58,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/react"], "options": { - "commands": [ - "node ./scripts/copy-readme.js react", - "node ./scripts/add-dependency-to-build.js react @nrwl/react" - ] + "command": "node ./scripts/copy-readme.js react" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js react @nrwl/react" + }, "lint": {} } } diff --git a/packages/rollup/project.json b/packages/rollup/project.json index 63fa0d586270b..d82412303d1e8 100644 --- a/packages/rollup/project.json +++ b/packages/rollup/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/rollup"], "options": { - "commands": [ - "node ./scripts/copy-readme.js rollup", - "node ./scripts/add-dependency-to-build.js rollup @nrwl/rollup" - ] + "command": "node ./scripts/copy-readme.js rollup" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js rollup @nrwl/rollup" + }, "lint": {} } } diff --git a/packages/storybook/project.json b/packages/storybook/project.json index 77c9079922a94..8703c31ac8bf1 100644 --- a/packages/storybook/project.json +++ b/packages/storybook/project.json @@ -58,12 +58,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/storybook"], "options": { - "commands": [ - "node ./scripts/copy-readme.js storybook", - "node ./scripts/add-dependency-to-build.js storybook @nrwl/storybook" - ] + "command": "node ./scripts/copy-readme.js storybook" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js storybook @nrwl/storybook" + }, "lint": {} } } diff --git a/packages/vite/project.json b/packages/vite/project.json index aec9b6fd62482..c37741049043c 100644 --- a/packages/vite/project.json +++ b/packages/vite/project.json @@ -59,12 +59,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/vite"], "options": { - "commands": [ - "node ./scripts/copy-readme.js vite", - "node ./scripts/add-dependency-to-build.js vite @nrwl/vite" - ] + "command": "node ./scripts/copy-readme.js vite" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js vite @nrwl/vite" + }, "lint": { "executor": "@nx/linter:eslint", "options": { diff --git a/packages/web/project.json b/packages/web/project.json index ac8768520d736..d618bba82c0a1 100644 --- a/packages/web/project.json +++ b/packages/web/project.json @@ -53,12 +53,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/web"], "options": { - "commands": [ - "node ./scripts/copy-readme.js web", - "node ./scripts/add-dependency-to-build.js web @nrwl/web" - ] + "command": "node ./scripts/copy-readme.js web" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js web @nrwl/web" + }, "lint": {} } } diff --git a/packages/webpack/project.json b/packages/webpack/project.json index fd6cafa341b34..a1a8b50d36e94 100644 --- a/packages/webpack/project.json +++ b/packages/webpack/project.json @@ -48,12 +48,12 @@ "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/webpack"], "options": { - "commands": [ - "node ./scripts/copy-readme.js webpack", - "node ./scripts/add-dependency-to-build.js webpack @nrwl/webpack" - ] + "command": "node ./scripts/copy-readme.js webpack" } }, + "add-extra-dependencies": { + "command": "node ./scripts/add-dependency-to-build.js webpack @nrwl/webpack" + }, "lint": {} } } diff --git a/packages/workspace/project.json b/packages/workspace/project.json index 328b157372284..9355597321dcb 100644 --- a/packages/workspace/project.json +++ b/packages/workspace/project.json @@ -75,16 +75,14 @@ } }, "build": { - "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/build/packages/workspace"], + "command": "node ./scripts/copy-readme.js workspace" + }, + "add-extra-dependencies": { + "executor": "nx:run-commands", "options": { "commands": [ - { - "command": "node ./scripts/copy-readme.js workspace" - }, - { - "command": "node ./scripts/add-dependency-to-build.js workspace nx" - }, + "node ./scripts/add-dependency-to-build.js workspace nx", "node ./scripts/add-dependency-to-build.js workspace @nrwl/workspace" ], "parallel": false diff --git a/scripts/add-dependency-to-build.js b/scripts/add-dependency-to-build.js index c6091201bb658..90c6dcdf9e156 100644 --- a/scripts/add-dependency-to-build.js +++ b/scripts/add-dependency-to-build.js @@ -5,6 +5,7 @@ const [package, dependency] = process.argv.slice(2); const pkgPath = join(__dirname, '../build/packages', package, 'package.json'); const packageJson = readJsonSync(pkgPath); -packageJson.dependencies[dependency] = '*'; +const version = packageJson.version; +packageJson.dependencies[dependency] = version; writeJsonSync(pkgPath, packageJson, { spaces: 2 }); diff --git a/scripts/nx-release.ts b/scripts/nx-release.ts index 3329dc80001c0..f7b48644b20e4 100755 --- a/scripts/nx-release.ts +++ b/scripts/nx-release.ts @@ -79,6 +79,11 @@ const LARGE_BUFFER = 1024 * 1000000; runNxReleaseVersion(); + execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, { + stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', + maxBuffer: LARGE_BUFFER, + }); + let changelogCommand = `pnpm nx release changelog ${options.version} --tagVersionPrefix="" --interactive`; if (options.from) { changelogCommand += ` --from ${options.from}`; @@ -103,6 +108,11 @@ const LARGE_BUFFER = 1024 * 1000000; runNxReleaseVersion(); + execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, { + stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', + maxBuffer: LARGE_BUFFER, + }); + if (options.dryRun) { console.warn('Not Publishing because --dryRun was passed'); } else {