nx 23.2.0-beta.7 → 23.2.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/init-local.js +3 -5
- package/dist/release/changelog-renderer/index.js +4 -5
- package/dist/src/adapter/ngcli-adapter.js +60 -1
- package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +2 -2
- package/dist/src/command-line/completion/command-object.js +7 -12
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +17 -23
- package/dist/src/command-line/format/format.js +84 -101
- package/dist/src/command-line/generate/generate.js +35 -35
- package/dist/src/command-line/import/import.js +30 -40
- package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
- package/dist/src/command-line/init/command-object.js +4 -2
- package/dist/src/command-line/init/configure-plugins.js +4 -1
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
- package/dist/src/command-line/init/implementation/angular/index.js +10 -15
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
- package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -0
- package/dist/src/command-line/init/implementation/format.d.ts +18 -0
- package/dist/src/command-line/init/implementation/format.js +114 -0
- package/dist/src/command-line/init/implementation/utils.js +8 -0
- package/dist/src/command-line/init/init-v1.js +15 -18
- package/dist/src/command-line/init/init-v2.js +37 -56
- package/dist/src/command-line/migrate/agentic/definitions.js +35 -8
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +22 -3
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +13 -10
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +3 -1
- package/dist/src/command-line/migrate/agentic/handoff.js +4 -2
- package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
- package/dist/src/command-line/migrate/agentic/runner.js +24 -24
- package/dist/src/command-line/migrate/agentic/select.js +20 -30
- package/dist/src/command-line/migrate/agentic/types.d.ts +19 -3
- package/dist/src/command-line/migrate/agentic/types.js +13 -4
- package/dist/src/command-line/migrate/command-object.d.ts +3 -0
- package/dist/src/command-line/migrate/command-object.js +13 -0
- package/dist/src/command-line/migrate/execute-migration.d.ts +14 -0
- package/dist/src/command-line/migrate/execute-migration.js +30 -9
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +28 -0
- package/dist/src/command-line/migrate/migrate-analytics.js +51 -1
- package/dist/src/command-line/migrate/migrate-commits.d.ts +8 -2
- package/dist/src/command-line/migrate/migrate-commits.js +66 -19
- package/dist/src/command-line/migrate/migrate-config.d.ts +4 -2
- package/dist/src/command-line/migrate/migrate-config.js +12 -4
- package/dist/src/command-line/migrate/migrate.d.ts +13 -2
- package/dist/src/command-line/migrate/migrate.js +243 -80
- package/dist/src/command-line/migrate/multi-major.js +7 -10
- package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
- package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
- package/dist/src/command-line/migrate/run/agent-output.js +65 -0
- package/dist/src/command-line/migrate/run/index.d.ts +7 -0
- package/dist/src/command-line/migrate/run/index.js +19 -1
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
- package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
- package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
- package/dist/src/command-line/migrate/run/run-id.js +56 -0
- package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
- package/dist/src/command-line/migrate/run/run-state.js +438 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
- package/dist/src/command-line/migrate/run/state-lock.js +76 -0
- package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
- package/dist/src/command-line/migrate/run/state-machine.js +315 -0
- package/dist/src/command-line/migrate/run/util.d.ts +58 -0
- package/dist/src/command-line/migrate/run/util.js +139 -7
- package/dist/src/command-line/migrate/run/worker.d.ts +1 -0
- package/dist/src/command-line/migrate/run/worker.js +308 -45
- package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
- package/dist/src/command-line/migrate/safe-prompt.js +32 -43
- package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
- package/dist/src/command-line/migrate/step-actions.js +12 -0
- package/dist/src/command-line/migrate/text.d.ts +18 -0
- package/dist/src/command-line/migrate/text.js +26 -0
- package/dist/src/command-line/migrate/version-skew-guard.d.ts +6 -4
- package/dist/src/command-line/migrate/version-skew-guard.js +34 -14
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +16 -20
- package/dist/src/command-line/release/changelog.js +6 -17
- package/dist/src/command-line/release/plan.js +15 -28
- package/dist/src/command-line/release/release.js +6 -17
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +16 -22
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
- package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
- package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
- package/dist/src/command-line/release/version.js +2 -2
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/daemon/client/client.js +11 -2
- package/dist/src/devkit-internals.d.ts +7 -2
- package/dist/src/devkit-internals.js +22 -6
- package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
- package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
- package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
- package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
- package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
- package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
- package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
- package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
- package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
- package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
- package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +128 -2
- package/dist/src/tasks-runner/run-command.js +17 -32
- package/dist/src/tasks-runner/task-env.js +5 -2
- package/dist/src/tasks-runner/utils.js +2 -6
- package/dist/src/utils/analytics-prompt.js +4 -7
- package/dist/src/utils/chunkify.d.ts +7 -1
- package/dist/src/utils/chunkify.js +10 -3
- package/dist/src/utils/exit-codes.d.ts +9 -0
- package/dist/src/utils/exit-codes.js +19 -0
- package/dist/src/utils/fileutils.d.ts +5 -0
- package/dist/src/utils/fileutils.js +7 -2
- package/dist/src/utils/formatters/index.d.ts +13 -0
- package/dist/src/utils/formatters/index.js +74 -0
- package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
- package/dist/src/utils/formatters/oxfmt.js +764 -0
- package/dist/src/utils/formatters/prettier.d.ts +26 -0
- package/dist/src/utils/formatters/prettier.js +201 -0
- package/dist/src/utils/formatters/shared.d.ts +5 -0
- package/dist/src/utils/formatters/shared.js +8 -0
- package/dist/src/utils/git-utils.d.ts +33 -2
- package/dist/src/utils/git-utils.js +156 -8
- package/dist/src/utils/ignore.d.ts +47 -5
- package/dist/src/utils/ignore.js +93 -11
- package/dist/src/utils/long-running-target.d.ts +10 -0
- package/dist/src/utils/long-running-target.js +19 -0
- package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
- package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/nx-console-prompt.js +3 -6
- package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
- package/dist/src/utils/package-manager-config/bunfig.js +49 -0
- package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
- package/dist/src/utils/package-manager-config/npmrc.js +124 -0
- package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
- package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
- package/dist/src/utils/package-manager.d.ts +21 -2
- package/dist/src/utils/package-manager.js +244 -47
- package/dist/src/utils/params.d.ts +7 -1
- package/dist/src/utils/params.js +64 -6
- package/dist/src/utils/prompt-helpers.d.ts +53 -0
- package/dist/src/utils/prompt-helpers.js +111 -0
- package/dist/src/utils/provenance.js +6 -14
- package/dist/src/utils/registry-config/bun.d.ts +2 -0
- package/dist/src/utils/registry-config/bun.js +257 -0
- package/dist/src/utils/registry-config/index.d.ts +13 -0
- package/dist/src/utils/registry-config/index.js +102 -0
- package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
- package/dist/src/utils/registry-config/pnpm.js +1551 -0
- package/dist/src/utils/registry-config/utils.d.ts +195 -0
- package/dist/src/utils/registry-config/utils.js +496 -0
- package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-berry.js +612 -0
- package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
- package/dist/src/utils/safe-spawn.d.ts +24 -0
- package/dist/src/utils/safe-spawn.js +104 -0
- package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
- package/dist/src/utils/write-formatted-json-file.js +5 -4
- package/migrations.json +6 -0
- package/package.json +17 -13
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
- package/dist/src/utils/is-using-prettier.d.ts +0 -3
- package/dist/src/utils/is-using-prettier.js +0 -62
- package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
- package/dist/src/utils/min-release-age/npmrc.js +0 -45
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
|
-
const
|
|
5
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
6
6
|
const json_1 = require("../../generators/utils/json");
|
|
7
7
|
const nx_json_1 = require("../../generators/utils/nx-json");
|
|
8
8
|
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
|
@@ -97,5 +97,5 @@ async function update(tree) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
|
100
|
-
await (0,
|
|
100
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
101
101
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
|
-
const
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
5
|
const nx_json_1 = require("../../generators/utils/nx-json");
|
|
6
6
|
function isCustomRunnerPath(modulePath) {
|
|
7
7
|
return !['nx-cloud', '@nrwl/nx-cloud', 'nx/tasks-runners/default'].includes(modulePath);
|
|
@@ -33,6 +33,6 @@ async function update(tree) {
|
|
|
33
33
|
delete nxJson.tasksRunnerOptions;
|
|
34
34
|
}
|
|
35
35
|
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
|
36
|
-
await (0,
|
|
36
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
37
37
|
return nextSteps;
|
|
38
38
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
|
-
const
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
5
|
const nx_json_1 = require("../../generators/utils/nx-json");
|
|
6
6
|
async function update(tree) {
|
|
7
7
|
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
|
@@ -13,5 +13,5 @@ async function update(tree) {
|
|
|
13
13
|
delete nxJson.useLegacyCache;
|
|
14
14
|
}
|
|
15
15
|
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
|
16
|
-
await (0,
|
|
16
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
17
17
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
|
-
const
|
|
5
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
6
6
|
const json_1 = require("../../generators/utils/json");
|
|
7
7
|
const nx_json_1 = require("../../generators/utils/nx-json");
|
|
8
8
|
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
|
@@ -96,5 +96,5 @@ async function update(tree) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
|
99
|
-
await (0,
|
|
99
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
100
100
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
|
-
const
|
|
5
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
6
6
|
const json_1 = require("../../generators/utils/json");
|
|
7
7
|
const nx_json_1 = require("../../generators/utils/nx-json");
|
|
8
8
|
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
|
@@ -97,5 +97,5 @@ async function update(tree) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
|
100
|
-
await (0,
|
|
100
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
101
101
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = addSelfHealingToGitignore;
|
|
4
|
-
const
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
5
|
const ignore_1 = require("../../utils/ignore");
|
|
6
6
|
async function addSelfHealingToGitignore(tree) {
|
|
7
7
|
if (!tree.exists('.gitignore')) {
|
|
@@ -15,5 +15,5 @@ async function addSelfHealingToGitignore(tree) {
|
|
|
15
15
|
if (tree.exists('.prettierignore')) {
|
|
16
16
|
(0, ignore_1.addEntryToGitIgnore)(tree, '.prettierignore', '.nx/self-healing');
|
|
17
17
|
}
|
|
18
|
-
await (0,
|
|
18
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
19
19
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = addClaudeSettingsLocalToGitIgnore;
|
|
4
|
-
const
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
5
|
const ignore_1 = require("../../utils/ignore");
|
|
6
6
|
async function addClaudeSettingsLocalToGitIgnore(tree) {
|
|
7
7
|
if (!tree.exists('.gitignore')) {
|
|
@@ -12,5 +12,5 @@ async function addClaudeSettingsLocalToGitIgnore(tree) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
(0, ignore_1.addEntryToGitIgnore)(tree, '.gitignore', '.claude/settings.local.json');
|
|
15
|
-
await (0,
|
|
15
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
16
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = addClaudeWorktreesToGitIgnore;
|
|
4
|
-
const
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
5
|
const ignore_1 = require("../../utils/ignore");
|
|
6
6
|
async function addClaudeWorktreesToGitIgnore(tree) {
|
|
7
7
|
if (!tree.exists('.gitignore')) {
|
|
@@ -12,5 +12,5 @@ async function addClaudeWorktreesToGitIgnore(tree) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
(0, ignore_1.addEntryToGitIgnore)(tree, '.gitignore', '.claude/worktrees');
|
|
15
|
-
await (0,
|
|
15
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
16
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = addPolygraphToGitIgnore;
|
|
4
|
-
const
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
5
|
const ignore_1 = require("../../utils/ignore");
|
|
6
6
|
async function addPolygraphToGitIgnore(tree) {
|
|
7
7
|
if (!tree.exists('.gitignore')) {
|
|
@@ -12,5 +12,5 @@ async function addPolygraphToGitIgnore(tree) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
(0, ignore_1.addEntryToGitIgnore)(tree, '.gitignore', '.nx/polygraph');
|
|
15
|
-
await (0,
|
|
15
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
16
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = addMigrateRunsToGitIgnore;
|
|
4
|
-
const
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
5
|
const ignore_1 = require("../../utils/ignore");
|
|
6
6
|
async function addMigrateRunsToGitIgnore(tree) {
|
|
7
7
|
if (!tree.exists('.gitignore')) {
|
|
@@ -12,5 +12,5 @@ async function addMigrateRunsToGitIgnore(tree) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
(0, ignore_1.addEntryToGitIgnore)(tree, '.gitignore', '.nx/migrate-runs');
|
|
15
|
-
await (0,
|
|
15
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
16
16
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tree } from '../../generators/tree';
|
|
2
|
+
/**
|
|
3
|
+
* Target defaults resolve to a single key rather than merging, so an executor
|
|
4
|
+
* key hides the target name key entirely. Before Nx 23 a hidden `cache: true`
|
|
5
|
+
* still took effect, because cacheability was also derived from target *names*
|
|
6
|
+
* via `cacheableOperations`; Nx 23 removed that derivation and those targets
|
|
7
|
+
* silently stopped being cacheable.
|
|
8
|
+
*
|
|
9
|
+
* Write the intent into the executor key so it no longer depends on the
|
|
10
|
+
* deprecated fallback that restores the old behavior at run time.
|
|
11
|
+
*/
|
|
12
|
+
export default function update(tree: Tree): Promise<void>;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const executor_utils_1 = require("../../command-line/run/executor-utils");
|
|
5
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
6
|
+
const json_1 = require("../../generators/utils/json");
|
|
7
|
+
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
|
8
|
+
const path_1 = require("../../utils/path");
|
|
9
|
+
// TODO(v24): remove this migration alongside the runtime fallback it exists to
|
|
10
|
+
// retire (`isLegacyCachedTarget` in `target-normalization.ts`), along with its
|
|
11
|
+
// registration in `packages/nx/migrations.json`.
|
|
12
|
+
/**
|
|
13
|
+
* Target defaults resolve to a single key rather than merging, so an executor
|
|
14
|
+
* key hides the target name key entirely. Before Nx 23 a hidden `cache: true`
|
|
15
|
+
* still took effect, because cacheability was also derived from target *names*
|
|
16
|
+
* via `cacheableOperations`; Nx 23 removed that derivation and those targets
|
|
17
|
+
* silently stopped being cacheable.
|
|
18
|
+
*
|
|
19
|
+
* Write the intent into the executor key so it no longer depends on the
|
|
20
|
+
* deprecated fallback that restores the old behavior at run time.
|
|
21
|
+
*/
|
|
22
|
+
async function update(tree) {
|
|
23
|
+
const nxJson = (0, project_configuration_1.readNxJson)(tree);
|
|
24
|
+
const targetDefaults = nxJson?.targetDefaults;
|
|
25
|
+
if (!targetDefaults) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const projects = (0, project_configuration_1.getProjects)(tree);
|
|
29
|
+
const projectsMap = {};
|
|
30
|
+
// `cache` on an executor key reaches every target that resolves through it,
|
|
31
|
+
// not just the one whose target name key enables caching. Collect them all
|
|
32
|
+
// per key so the decision below can be made for the key as a whole. The
|
|
33
|
+
// collection is a list rather than a map keyed by target name: two projects
|
|
34
|
+
// routinely declare the same target name through the same executor, and only
|
|
35
|
+
// one of them may be continuous.
|
|
36
|
+
const targetsByExecutorKey = new Map();
|
|
37
|
+
const collect = (targetName, target) => {
|
|
38
|
+
// `hasOwnProperty` rather than a lookup: an executor named `__proto__` or
|
|
39
|
+
// `constructor` resolves through the prototype chain to a truthy object, so
|
|
40
|
+
// a plain lookup would collect the target and stamp `Object.prototype`.
|
|
41
|
+
if (!target?.executor ||
|
|
42
|
+
!Object.prototype.hasOwnProperty.call(targetDefaults, target.executor)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const targets = targetsByExecutorKey.get(target.executor) ?? [];
|
|
46
|
+
targets.push([targetName, target]);
|
|
47
|
+
targetsByExecutorKey.set(target.executor, targets);
|
|
48
|
+
};
|
|
49
|
+
for (const [projectName, project] of projects) {
|
|
50
|
+
projectsMap[projectName] = project;
|
|
51
|
+
for (const [targetName, target] of Object.entries(project.targets ?? {})) {
|
|
52
|
+
collect(targetName, target);
|
|
53
|
+
}
|
|
54
|
+
for (const [targetName, target] of Object.entries(packageJsonTargets(tree, project.root))) {
|
|
55
|
+
collect(targetName, target);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
let changed = false;
|
|
59
|
+
for (const [key, targets] of targetsByExecutorKey) {
|
|
60
|
+
if (!canEnableCache(targetDefaults, key, targets, tree.root, projectsMap)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
catchAllConfig(targetDefaults[key]).cache = true;
|
|
64
|
+
changed = true;
|
|
65
|
+
}
|
|
66
|
+
if (!changed) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
(0, project_configuration_1.updateNxJson)(tree, nxJson);
|
|
70
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether `cache: true` can be written onto `key` without changing behavior for
|
|
74
|
+
* any target that resolves through it.
|
|
75
|
+
*
|
|
76
|
+
* The executor key outranks every target name key, so stamping it caches all of
|
|
77
|
+
* `targets` — including any that is continuous, which makes `nx.json` fail graph
|
|
78
|
+
* construction outright. The key is only safe when every target through it
|
|
79
|
+
* independently wants caching and none of them can be continuous. Anything else
|
|
80
|
+
* is left to the runtime fallback, which decides per target after normalization
|
|
81
|
+
* and can therefore see continuity this migration cannot.
|
|
82
|
+
*/
|
|
83
|
+
function canEnableCache(targetDefaults, key, targets, workspaceRoot, projectsMap) {
|
|
84
|
+
// Targets written with `command` are rewritten to `nx:run-commands` and
|
|
85
|
+
// `package.json` scripts to `nx:run-script` before key selection, so neither
|
|
86
|
+
// names the key it resolves through. Plugins also infer continuous targets
|
|
87
|
+
// (`watch-deps`, dev servers) into projects whose config never mentions them.
|
|
88
|
+
// The target list here can never be trusted to be complete for these keys.
|
|
89
|
+
if (key === 'nx:run-commands' || key === 'nx:run-script') {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
// Already decided; never override the user's value. A filtered entry counts
|
|
93
|
+
// as decided because its value can't be evaluated without project context.
|
|
94
|
+
if (declaresAnyCache(targetDefaults[key])) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
// `continuous` is a valid field on a target default, and this key applies it
|
|
98
|
+
// to every target that resolves through it. Adding `cache` would make each of
|
|
99
|
+
// them both cacheable and continuous, which fails graph construction — so no
|
|
100
|
+
// target list can make this key safe.
|
|
101
|
+
if (declaresAnyContinuous(targetDefaults[key])) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
// Only an unfiltered entry can be amended. Appending a catch-all to an
|
|
105
|
+
// all-filtered key would make it match targets that previously fell through
|
|
106
|
+
// to the target name key, silently dropping that key's `dependsOn`/`inputs`.
|
|
107
|
+
if (!catchAllConfig(targetDefaults[key])) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
// Continuity declared by the executor's schema is resolved at graph
|
|
111
|
+
// construction for every target through this key, so one lookup covers them
|
|
112
|
+
// all. For what an executor that cannot be resolved here costs, see
|
|
113
|
+
// {@link executorDeclaresContinuous}.
|
|
114
|
+
if (executorDeclaresContinuous(key, workspaceRoot, projectsMap)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
for (const [targetName, target] of targets) {
|
|
118
|
+
if (!declaresCacheTrue(targetDefaults[targetName])) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (target.continuous || isLongRunningTargetName(targetName)) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Whether the target name key declares `cache: true` on an entry that always
|
|
129
|
+
* applies. Mirrors `declaresCacheTrue` in `target-normalization.ts`: a filtered
|
|
130
|
+
* entry declaring `cache` makes the value unknowable without project context,
|
|
131
|
+
* so nothing is claimed. Among unfiltered entries the last wins.
|
|
132
|
+
*/
|
|
133
|
+
function declaresCacheTrue(value) {
|
|
134
|
+
if (!value) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
let declared;
|
|
138
|
+
for (const entry of configEntries(value)) {
|
|
139
|
+
if (entry.cache === undefined)
|
|
140
|
+
continue;
|
|
141
|
+
if (entry.filter)
|
|
142
|
+
return false;
|
|
143
|
+
declared = entry.cache;
|
|
144
|
+
}
|
|
145
|
+
return declared === true;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Whether any entry declares `cache`, filtered or not — i.e. whether the value
|
|
149
|
+
* is already decided and must be left alone. Deliberately broader than
|
|
150
|
+
* {@link declaresCacheTrue}: a filtered `cache` blocks here rather than being
|
|
151
|
+
* read past, so the two never disagree about a filtered entry.
|
|
152
|
+
*/
|
|
153
|
+
function declaresAnyCache(value) {
|
|
154
|
+
if (!value) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
return configEntries(value).some((entry) => entry.cache !== undefined);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Whether any entry declares `continuous: true`. Filtered entries count: which
|
|
161
|
+
* projects the filter matches is unknowable here, and the only case that
|
|
162
|
+
* matters is the one where it matches.
|
|
163
|
+
*/
|
|
164
|
+
function declaresAnyContinuous(value) {
|
|
165
|
+
if (!value) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
return configEntries(value).some((entry) => entry.continuous === true);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The config blocks of a `targetDefaults` value. Entries that are not config
|
|
172
|
+
* objects are dropped rather than inspected: `nx.json` is hand-edited, and a
|
|
173
|
+
* `null` or scalar entry would otherwise throw while reading `.cache` off it.
|
|
174
|
+
*/
|
|
175
|
+
function configEntries(value) {
|
|
176
|
+
const entries = Array.isArray(value) ? value : [value];
|
|
177
|
+
return entries.filter((entry) => !!entry && typeof entry === 'object');
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The targets a project's `package.json` contributes to the graph.
|
|
181
|
+
*
|
|
182
|
+
* {@link getProjects} builds a root's configuration from its `project.json`
|
|
183
|
+
* alone whenever one exists, but the package.json plugin still creates the
|
|
184
|
+
* sibling `package.json`'s targets — it accepts any `package.json` that is
|
|
185
|
+
* either in the package manager workspaces or next to a `project.json`
|
|
186
|
+
* (`plugins/package-json/create-nodes.ts`). Those targets resolve through the
|
|
187
|
+
* same executor keys, so they belong in this decision.
|
|
188
|
+
*
|
|
189
|
+
* Targets derived from `scripts` are still not covered; they resolve through
|
|
190
|
+
* `nx:run-script`, which is never stamped for exactly that reason.
|
|
191
|
+
*/
|
|
192
|
+
function packageJsonTargets(tree, projectRoot) {
|
|
193
|
+
const packageJsonPath = (0, path_1.joinPathFragments)(projectRoot, 'package.json');
|
|
194
|
+
if (!tree.exists(packageJsonPath)) {
|
|
195
|
+
return {};
|
|
196
|
+
}
|
|
197
|
+
// A parse failure is left to throw: `readJson` names the offending file,
|
|
198
|
+
// which is the one thing a user can act on. Shapes that parse but aren't the
|
|
199
|
+
// one this reads contribute no targets rather than crashing the run.
|
|
200
|
+
const targets = (0, json_1.readJson)(tree, packageJsonPath)?.nx?.targets;
|
|
201
|
+
if (!targets || typeof targets !== 'object' || Array.isArray(targets)) {
|
|
202
|
+
return {};
|
|
203
|
+
}
|
|
204
|
+
return targets;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The unfiltered config block of a `targetDefaults` value, or undefined when the
|
|
208
|
+
* array form carries only filtered entries and when the value is not a config
|
|
209
|
+
* object at all. Never creates one — see {@link canEnableCache}.
|
|
210
|
+
*/
|
|
211
|
+
function catchAllConfig(value) {
|
|
212
|
+
// The filter check applies to both spellings: the object and single-element
|
|
213
|
+
// array forms of the same config have to reach the same verdict.
|
|
214
|
+
return configEntries(value).find((entry) => entry.filter === undefined);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Whether the executor's schema marks its targets continuous, resolved through
|
|
218
|
+
* the same `getExecutorInformation` call `normalizeTarget` makes at graph
|
|
219
|
+
* construction, so the two cannot drift on what continuous means.
|
|
220
|
+
*
|
|
221
|
+
* An executor that cannot be resolved is read as not continuous. That is the
|
|
222
|
+
* same answer `normalizeTarget` gives, but not the same trade: its lookup is
|
|
223
|
+
* repeated on every graph construction, so a failure there corrects itself,
|
|
224
|
+
* whereas this one decides a permanent edit to `nx.json`. An executor that is
|
|
225
|
+
* unresolvable while the migration runs and resolvable afterwards therefore
|
|
226
|
+
* keeps its stamped `cache` while the runtime starts marking its targets
|
|
227
|
+
* continuous — which `normalizeTargets` rejects with a `WorkspaceValidityError`,
|
|
228
|
+
* failing graph construction until `nx.json` is edited by hand.
|
|
229
|
+
*/
|
|
230
|
+
function executorDeclaresContinuous(executor, workspaceRoot, projectsMap) {
|
|
231
|
+
try {
|
|
232
|
+
const [nodeModule, name] = (0, executor_utils_1.parseExecutor)(executor);
|
|
233
|
+
const { schema } = (0, executor_utils_1.getExecutorInformation)(nodeModule, name, workspaceRoot, projectsMap);
|
|
234
|
+
return !!schema.continuous;
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Target names the pre-23 `longRunningTask` guard excluded from caching.
|
|
242
|
+
* Mirrors `isLongRunningTarget` in `target-normalization.ts`.
|
|
243
|
+
*/
|
|
244
|
+
function isLongRunningTargetName(targetName) {
|
|
245
|
+
return (targetName.endsWith(':watch') ||
|
|
246
|
+
targetName.endsWith('-watch') ||
|
|
247
|
+
targetName === 'serve' ||
|
|
248
|
+
targetName === 'dev' ||
|
|
249
|
+
targetName === 'start');
|
|
250
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#### Set cache on executor-based target defaults
|
|
2
|
+
|
|
3
|
+
Maintains compatibility with how cacheability was resolved before Nx 23.
|
|
4
|
+
|
|
5
|
+
Target defaults resolve to a single key rather than merging them. When a target matches both a target name key and an executor key, the executor key is the one that applies, and the target name key is not read at all. Earlier versions of Nx also derived cacheability from target names, so `"cache": true` on the target name key still took effect even when an executor key applied. Nx 23 reads cacheability from the resolved target only.
|
|
6
|
+
|
|
7
|
+
This migration copies `cache` onto each executor key that applies to a target whose target name key enables it, so those targets remain cacheable.
|
|
8
|
+
|
|
9
|
+
An executor key applies to every target that resolves through it, so the migration updates a key only when it can establish that caching is right for all of them. It leaves the key unchanged when the key already declares `cache`, when it declares `continuous: true`, when every entry on the key is filtered so none of them always applies, when a target through it is continuous or is a long-running target such as `serve`, `dev`, or `start`, when the executor's own schema marks its targets continuous, or when a target through it has no target name key enabling `cache`. It never updates the `nx:run-commands` or `nx:run-script` keys, because targets written with `command` and targets derived from `package.json` scripts resolve through those keys without naming them.
|
|
10
|
+
|
|
11
|
+
Where the migration makes no change, Nx still decides at run time, per target rather than per key: a target whose target name key enables `cache`, and whose resolved configuration still leaves `cache` undefined, gets it back and is reported as a deprecated fallback. Because that test is applied to the resolved target rather than to the key, it also covers the cases where a key looks decided but is not for this project — an executor key whose entries are all filtered, or whose only `cache` declaration is filtered out here. It equally covers the targets left behind because a sibling target through the same key does not opt in, and the targets reaching the `nx:run-commands` and `nx:run-script` keys. Three cases get no fallback and no warning. A continuous or long-running target, because caching it is invalid. A target whose resolved configuration already sets `cache`. And a target whose target name key was discarded as incompatible, because its entry named an executor the target does not use — before Nx 23 that target was cacheable, since cacheability was matched on target name alone and the entry's `executor` was never read. Restoring it here would mean setting `cache` with no executor key to point the user at and no migration able to retire the behavior, so it is deliberately left alone. Set `cache` on those targets directly.
|
|
12
|
+
|
|
13
|
+
Targets are read from each project's `project.json` and from the `nx.targets` block of its `package.json`. Targets inferred by a plugin, and targets derived from `package.json` scripts, are not visible to the migration — the latter is why the `nx:run-script` key is never updated. A key that looks safe here may still serve an inferred target. Set `cache` on the executor key by hand only after checking that no target reaching it is continuous; Nx rejects a target that is both cacheable and continuous. Nx names both keys in a run-time warning. That warning is emitted during project graph construction, so while the daemon is running it goes to `.nx/workspace-data/d/daemon.log` rather than the terminal; CI runs, where the daemon is disabled, print it normally.
|
|
14
|
+
|
|
15
|
+
#### Sample code changes
|
|
16
|
+
|
|
17
|
+
Given a project with a `build` target that uses the `@nx/angular:webpack-browser` executor:
|
|
18
|
+
|
|
19
|
+
##### Before
|
|
20
|
+
|
|
21
|
+
```json title="nx.json"
|
|
22
|
+
{
|
|
23
|
+
"targetDefaults": {
|
|
24
|
+
"build": {
|
|
25
|
+
"cache": true,
|
|
26
|
+
"dependsOn": ["^build"]
|
|
27
|
+
},
|
|
28
|
+
"@nx/angular:webpack-browser": {
|
|
29
|
+
"inputs": ["production", "^production"]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
##### After
|
|
36
|
+
|
|
37
|
+
```json title="nx.json"
|
|
38
|
+
{
|
|
39
|
+
"targetDefaults": {
|
|
40
|
+
"build": {
|
|
41
|
+
"cache": true,
|
|
42
|
+
"dependsOn": ["^build"]
|
|
43
|
+
},
|
|
44
|
+
"@nx/angular:webpack-browser": {
|
|
45
|
+
"inputs": ["production", "^production"],
|
|
46
|
+
"cache": true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
Binary file
|
|
Binary file
|
|
@@ -6,7 +6,7 @@ const child_process_1 = require("child_process");
|
|
|
6
6
|
const output_1 = require("../../../utils/output");
|
|
7
7
|
const json_1 = require("../../../generators/utils/json");
|
|
8
8
|
const nx_json_1 = require("../../../generators/utils/nx-json");
|
|
9
|
-
const
|
|
9
|
+
const format_changed_files_1 = require("../../../generators/internal-utils/format-changed-files");
|
|
10
10
|
const url_shorten_1 = require("../../utilities/url-shorten");
|
|
11
11
|
const get_cloud_options_1 = require("../../utilities/get-cloud-options");
|
|
12
12
|
const path_1 = require("path");
|
|
@@ -137,14 +137,14 @@ async function connectToNxCloud(tree, schema, nxJson = (0, nx_json_1.readNxJson)
|
|
|
137
137
|
}
|
|
138
138
|
if (responseFromCreateNxCloudWorkspaceV2) {
|
|
139
139
|
addNxCloudIdToNxJson(tree, responseFromCreateNxCloudWorkspaceV2?.nxCloudId, schema.directory);
|
|
140
|
-
await (0,
|
|
140
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree, {
|
|
141
141
|
silent: schema.hideFormatLogs,
|
|
142
142
|
});
|
|
143
143
|
return responseFromCreateNxCloudWorkspaceV2.nxCloudId;
|
|
144
144
|
}
|
|
145
145
|
else if (responseFromCreateNxCloudWorkspaceV1) {
|
|
146
146
|
addNxCloudAccessTokenToNxJson(tree, responseFromCreateNxCloudWorkspaceV1?.token, schema.directory);
|
|
147
|
-
await (0,
|
|
147
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree, {
|
|
148
148
|
silent: schema.hideFormatLogs,
|
|
149
149
|
});
|
|
150
150
|
return responseFromCreateNxCloudWorkspaceV1.token;
|
|
@@ -12,6 +12,16 @@ const project_graph_1 = require("../../../config/project-graph");
|
|
|
12
12
|
const file_hasher_1 = require("../../../hasher/file-hasher");
|
|
13
13
|
const project_graph_builder_1 = require("../../../project-graph/project-graph-builder");
|
|
14
14
|
const json_1 = require("../../../utils/json");
|
|
15
|
+
// Highest bun.lock version this parser has been verified against:
|
|
16
|
+
// - 1: workspace packages are no longer listed with their dependencies
|
|
17
|
+
// - 2: identical content, stricter validation in Bun's own reader
|
|
18
|
+
// - 3: values in "overrides" may be objects holding rules scoped to a parent
|
|
19
|
+
// package (`"parent": { "child": "1.0.0" }`) and keys may carry a version
|
|
20
|
+
// selector (`"parent@1"`, `"child@<2"`). This parser never reads
|
|
21
|
+
// "overrides"; the resolved packages are listed in "packages" as before.
|
|
22
|
+
// Newer versions are parsed on a best-effort basis instead of being rejected
|
|
23
|
+
// outright.
|
|
24
|
+
const MAX_KNOWN_LOCKFILE_VERSION = 3;
|
|
15
25
|
const DEPENDENCY_TYPES = [
|
|
16
26
|
'dependencies',
|
|
17
27
|
'devDependencies',
|
|
@@ -356,9 +366,12 @@ function parseLockFile(lockFileContent, lockFileHash) {
|
|
|
356
366
|
if (typeof result.lockfileVersion !== 'number') {
|
|
357
367
|
throw new Error(`Lockfile version must be a number, got ${typeof result.lockfileVersion}`);
|
|
358
368
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
throw new Error(`Unsupported lockfile version ${result.lockfileVersion}.
|
|
369
|
+
if (!Number.isInteger(result.lockfileVersion) ||
|
|
370
|
+
result.lockfileVersion < 0) {
|
|
371
|
+
throw new Error(`Unsupported lockfile version ${result.lockfileVersion}. Lockfile version must be a non-negative integer`);
|
|
372
|
+
}
|
|
373
|
+
if (result.lockfileVersion > MAX_KNOWN_LOCKFILE_VERSION) {
|
|
374
|
+
console.warn(`bun.lock has lockfileVersion ${result.lockfileVersion}, which is newer than the version ${MAX_KNOWN_LOCKFILE_VERSION} this version of Nx was tested with. Attempting to parse it anyway.`);
|
|
362
375
|
}
|
|
363
376
|
}
|
|
364
377
|
if (!result.packages || typeof result.packages !== 'object') {
|
|
@@ -616,7 +629,7 @@ function processPackageForDependencies(packageKey, packageData, lockFile, index,
|
|
|
616
629
|
const deps = packageDependencies[depType];
|
|
617
630
|
if (!deps || typeof deps !== 'object')
|
|
618
631
|
continue;
|
|
619
|
-
const depDependencies = processDependencyEntries(deps, sourceNodeName, index, ctx, workspacePackages
|
|
632
|
+
const depDependencies = processDependencyEntries(deps, packageKey, sourceNodeName, lockFile, index, ctx, workspacePackages);
|
|
620
633
|
dependencies.push(...depDependencies);
|
|
621
634
|
}
|
|
622
635
|
return dependencies;
|
|
@@ -634,12 +647,12 @@ function extractPackageDependencies(packageData) {
|
|
|
634
647
|
}
|
|
635
648
|
return undefined;
|
|
636
649
|
}
|
|
637
|
-
function processDependencyEntries(deps, sourceNodeName, index, ctx, workspacePackages
|
|
650
|
+
function processDependencyEntries(deps, sourcePackageKey, sourceNodeName, lockFile, index, ctx, workspacePackages) {
|
|
638
651
|
const dependencies = [];
|
|
639
652
|
const depsEntries = Object.entries(deps);
|
|
640
653
|
for (const [packageName, versionSpec] of depsEntries) {
|
|
641
654
|
try {
|
|
642
|
-
const dependency = processSingleDependency(packageName, versionSpec, sourceNodeName, index, ctx, workspacePackages
|
|
655
|
+
const dependency = processSingleDependency(packageName, versionSpec, sourcePackageKey, sourceNodeName, lockFile, index, ctx, workspacePackages);
|
|
643
656
|
if (dependency) {
|
|
644
657
|
dependencies.push(dependency);
|
|
645
658
|
}
|
|
@@ -650,7 +663,7 @@ function processDependencyEntries(deps, sourceNodeName, index, ctx, workspacePac
|
|
|
650
663
|
}
|
|
651
664
|
return dependencies;
|
|
652
665
|
}
|
|
653
|
-
function processSingleDependency(packageName, versionSpec, sourceNodeName, index, ctx, workspacePackages
|
|
666
|
+
function processSingleDependency(packageName, versionSpec, sourcePackageKey, sourceNodeName, lockFile, index, ctx, workspacePackages) {
|
|
654
667
|
if (typeof packageName !== 'string' || typeof versionSpec !== 'string') {
|
|
655
668
|
return null;
|
|
656
669
|
}
|
|
@@ -663,14 +676,22 @@ function processSingleDependency(packageName, versionSpec, sourceNodeName, index
|
|
|
663
676
|
}
|
|
664
677
|
let targetPackageName = packageName;
|
|
665
678
|
let targetVersion = versionSpec;
|
|
666
|
-
|
|
667
|
-
|
|
679
|
+
// A "<parent>/<name>" entry records what this parent actually resolved the
|
|
680
|
+
// dependency to. Overrides scoped to a parent (bun.lock v3) can pick a
|
|
681
|
+
// version outside the declared range, so it takes precedence over matching
|
|
682
|
+
// the range against the versions in the lockfile.
|
|
683
|
+
const nestedVersion = resolveNestedVersion(sourcePackageKey, packageName, lockFile);
|
|
684
|
+
const aliasTarget = nestedVersion ? null : resolveAliasTarget(versionSpec);
|
|
685
|
+
if (nestedVersion) {
|
|
686
|
+
targetVersion = nestedVersion;
|
|
687
|
+
}
|
|
688
|
+
else if (aliasTarget) {
|
|
668
689
|
targetPackageName = aliasTarget.packageName;
|
|
669
690
|
targetVersion = aliasTarget.version;
|
|
670
691
|
}
|
|
671
692
|
else {
|
|
672
693
|
// O(1) lookup using index instead of O(n) scan
|
|
673
|
-
const resolvedVersion = findResolvedVersion(packageName, versionSpec, index, manifests);
|
|
694
|
+
const resolvedVersion = findResolvedVersion(packageName, versionSpec, index, lockFile.manifests);
|
|
674
695
|
if (!resolvedVersion) {
|
|
675
696
|
return null;
|
|
676
697
|
}
|
|
@@ -693,6 +714,18 @@ function processSingleDependency(packageName, versionSpec, sourceNodeName, index
|
|
|
693
714
|
return null;
|
|
694
715
|
}
|
|
695
716
|
}
|
|
717
|
+
function resolveNestedVersion(sourcePackageKey, packageName, lockFile) {
|
|
718
|
+
const nestedEntry = lockFile.packages[`${sourcePackageKey}/${packageName}`];
|
|
719
|
+
if (!Array.isArray(nestedEntry) || typeof nestedEntry[0] !== 'string') {
|
|
720
|
+
return null;
|
|
721
|
+
}
|
|
722
|
+
const { name, version } = getCachedSpecInfo(nestedEntry[0]);
|
|
723
|
+
// aliases ("alias@npm:real@1.0.0") are resolved to the real package by the caller
|
|
724
|
+
if (name !== packageName || !version || version.startsWith('npm:')) {
|
|
725
|
+
return null;
|
|
726
|
+
}
|
|
727
|
+
return version;
|
|
728
|
+
}
|
|
696
729
|
function resolveTargetNodeName(targetPackageName, targetVersion, ctx) {
|
|
697
730
|
const hoistedNodeName = `npm:${targetPackageName}`;
|
|
698
731
|
const versionedNodeName = `npm:${targetPackageName}@${targetVersion}`;
|