nx 23.1.0 → 23.1.2
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/nx.js +2 -1
- package/dist/release/changelog-renderer/index.js +4 -5
- package/dist/release/index.d.ts +1 -1
- package/dist/src/ai/configure-ai-agents-disclaimer.d.ts +5 -0
- package/dist/src/ai/configure-ai-agents-disclaimer.js +31 -0
- package/dist/src/analytics/analytics.d.ts +6 -0
- package/dist/src/analytics/analytics.js +16 -8
- package/dist/src/analytics/index.d.ts +1 -1
- package/dist/src/analytics/index.js +2 -1
- package/dist/src/command-line/add/add.js +13 -1
- package/dist/src/command-line/affected/affected.js +1 -0
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +2 -2
- package/dist/src/command-line/graph/graph.d.ts +1 -0
- package/dist/src/command-line/graph/graph.js +15 -6
- package/dist/src/command-line/import/import.js +2 -3
- package/dist/src/command-line/init/ai-agent-prompts.d.ts +1 -1
- package/dist/src/command-line/init/ai-agent-prompts.js +7 -6
- package/dist/src/command-line/init/command-object.js +10 -2
- package/dist/src/command-line/init/configure-plugins.js +3 -2
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +4 -2
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +4 -3
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +4 -3
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +4 -3
- package/dist/src/command-line/init/implementation/angular/index.js +4 -2
- package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +2 -5
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +3 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +4 -1
- package/dist/src/command-line/init/implementation/utils.d.ts +3 -3
- package/dist/src/command-line/init/implementation/utils.js +22 -3
- package/dist/src/command-line/init/init-v2.js +4 -5
- package/dist/src/command-line/migrate/execute-migration.d.ts +72 -0
- package/dist/src/command-line/migrate/execute-migration.js +389 -0
- package/dist/src/command-line/migrate/migrate-ui-api.js +17 -12
- package/dist/src/command-line/migrate/migrate.d.ts +5 -45
- package/dist/src/command-line/migrate/migrate.js +122 -402
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +1 -1
- package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
- package/dist/src/command-line/release/changelog.js +5 -0
- package/dist/src/command-line/release/index.d.ts +1 -1
- package/dist/src/command-line/release/utils/git.js +7 -3
- package/dist/src/command-line/release/utils/release-graph.d.ts +19 -2
- package/dist/src/command-line/release/utils/release-graph.js +71 -19
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +7 -1
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +1 -1
- package/dist/src/command-line/release/utils/shared.d.ts +2 -2
- package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
- package/dist/src/command-line/release/version/release-group-processor.js +80 -6
- package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
- package/dist/src/command-line/release/version/version-actions.js +9 -1
- package/dist/src/command-line/release/version.js +9 -5
- package/dist/src/command-line/reset/reset.js +6 -1
- package/dist/src/command-line/run/run-one.js +1 -0
- package/dist/src/command-line/run-many/run-many.js +1 -0
- package/dist/src/command-line/show/show-target/info.js +11 -2
- package/dist/src/command-line/show/show-target/inputs.js +50 -153
- package/dist/src/command-line/show/show-target/outputs.js +48 -173
- package/dist/src/command-line/show/show-target/utils.d.ts +28 -0
- package/dist/src/command-line/show/show-target/utils.js +83 -3
- package/dist/src/command-line/watch/watch.js +13 -0
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
- package/dist/src/commands-runner/create-command-graph.js +5 -0
- package/dist/src/config/nx-json.d.ts +5 -3
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +52 -3
- package/dist/src/daemon/client/client.js +177 -55
- package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
- package/dist/src/daemon/client/daemon-environment.js +110 -2
- package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
- package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
- package/dist/src/daemon/message-types/daemon-message.js +25 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
- package/dist/src/daemon/server/latest-nx.js +5 -2
- package/dist/src/daemon/server/server.js +31 -4
- package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
- package/dist/src/daemon/server/shutdown-utils.js +11 -4
- package/dist/src/daemon/socket-utils.d.ts +1 -0
- package/dist/src/daemon/socket-utils.js +24 -3
- package/dist/src/daemon/tmp-dir.d.ts +43 -3
- package/dist/src/daemon/tmp-dir.js +437 -15
- package/dist/src/devkit-internals.d.ts +96 -3
- package/dist/src/devkit-internals.js +200 -4
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +5 -0
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +9 -2
- package/dist/src/generators/tree.d.ts +4 -2
- package/dist/src/generators/utils/nx-json.js +13 -3
- package/dist/src/hasher/check-task-files.d.ts +86 -0
- package/dist/src/hasher/check-task-files.js +378 -0
- 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/index.d.ts +31 -2
- package/dist/src/native/index.js +71 -28
- package/dist/src/native/native-bindings.js +3 -0
- package/dist/src/native/native-file-cache-location.d.ts +17 -1
- package/dist/src/native/native-file-cache-location.js +86 -12
- 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/utilities/get-cloud-options.js +5 -2
- package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
- package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
- package/dist/src/plugins/js/lock-file/npm-parser.js +71 -27
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +110 -17
- package/dist/src/plugins/js/lock-file/project-graph-pruning.js +15 -9
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -0
- package/dist/src/plugins/js/lock-file/yarn-parser.js +32 -5
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +14 -4
- package/dist/src/plugins/js/utils/register.d.ts +18 -0
- package/dist/src/plugins/js/utils/register.js +81 -0
- package/dist/src/plugins/js/utils/typescript.d.ts +9 -0
- package/dist/src/plugins/js/utils/typescript.js +15 -0
- package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
- package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
- package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
- package/dist/src/project-graph/build-project-graph.js +7 -1
- package/dist/src/project-graph/error-types.d.ts +12 -1
- package/dist/src/project-graph/error-types.js +68 -3
- package/dist/src/project-graph/file-utils.js +6 -1
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +22 -1
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
- package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
- package/dist/src/project-graph/plugins/transpiler.js +4 -0
- package/dist/src/project-graph/project-graph.js +23 -0
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +10 -12
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +93 -63
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +5 -8
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +16 -15
- package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +12 -5
- package/dist/src/project-graph/utils/project-configuration/source-maps.js +21 -7
- package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-defaults.js +26 -27
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +50 -8
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +149 -6
- package/dist/src/project-graph/utils/project-configuration/utils.d.ts +15 -0
- package/dist/src/project-graph/utils/project-configuration/utils.js +42 -6
- package/dist/src/project-graph/utils/project-configuration-utils.d.ts +15 -12
- package/dist/src/project-graph/utils/project-configuration-utils.js +79 -101
- package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +11 -4
- package/dist/src/tasks-runner/life-cycles/performance-analysis.js +15 -6
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +5 -4
- package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +18 -8
- package/dist/src/tasks-runner/life-cycles/performance-report.js +66 -29
- package/dist/src/tasks-runner/run-command.js +4 -2
- package/dist/src/tasks-runner/task-env.d.ts +9 -0
- package/dist/src/tasks-runner/task-env.js +31 -4
- package/dist/src/tasks-runner/task-orchestrator.d.ts +4 -1
- package/dist/src/tasks-runner/task-orchestrator.js +23 -10
- package/dist/src/tasks-runner/utils.js +2 -6
- package/dist/src/utils/acknowledge-build-scripts.d.ts +13 -0
- package/dist/src/utils/acknowledge-build-scripts.js +102 -0
- package/dist/src/utils/analytics-prompt.d.ts +0 -6
- package/dist/src/utils/analytics-prompt.js +0 -51
- package/dist/src/utils/assert-workspace-validity.js +7 -2
- package/dist/src/utils/catalog/manager-utils.d.ts +1 -2
- package/dist/src/utils/catalog/manager-utils.js +22 -5
- package/dist/src/utils/catalog/pnpm-manager.d.ts +1 -0
- package/dist/src/utils/catalog/pnpm-manager.js +3 -15
- package/dist/src/utils/catalog/yarn-manager.d.ts +1 -0
- package/dist/src/utils/catalog/yarn-manager.js +3 -15
- package/dist/src/utils/command-line-utils.js +30 -20
- package/dist/src/utils/fileutils.d.ts +5 -0
- package/dist/src/utils/fileutils.js +7 -2
- package/dist/src/utils/git-revision.d.ts +12 -0
- package/dist/src/utils/git-revision.js +25 -0
- package/dist/src/utils/git-utils.d.ts +16 -3
- package/dist/src/utils/git-utils.js +146 -52
- package/dist/src/utils/git-worktrees.d.ts +30 -0
- package/dist/src/utils/git-worktrees.js +212 -0
- package/dist/src/utils/ignore.d.ts +128 -1
- package/dist/src/utils/ignore.js +182 -12
- 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/behavior/pnpm.js +9 -7
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
- package/dist/src/utils/nx-tmp-dir.js +40 -0
- package/dist/src/utils/owned-private-dir.d.ts +132 -0
- package/dist/src/utils/owned-private-dir.js +323 -0
- package/dist/src/utils/package-json.js +11 -7
- 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 +23 -2
- package/dist/src/utils/package-manager.js +264 -43
- package/dist/src/utils/provenance.js +18 -16
- 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/shell-quoting.d.ts +15 -0
- package/dist/src/utils/shell-quoting.js +35 -0
- package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
- package/dist/src/utils/wait-for-socket-connection.js +14 -8
- package/dist/src/utils/workspace-id.d.ts +20 -0
- package/dist/src/utils/workspace-id.js +54 -0
- package/migrations.json +13 -1
- package/package.json +22 -17
- package/dist/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
- package/dist/src/migrations/update-17-3-0/nx-release-path.js +0 -47
- package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
- package/dist/src/utils/min-release-age/npmrc.js +0 -45
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isHybridMigration = exports.isPromptOnlyMigration = exports.filterDowngradedUpdates = exports.Migrator = exports.normalizeVersion = void 0;
|
|
4
4
|
exports.formatCommandFailure = formatCommandFailure;
|
|
5
5
|
exports.resolveCanonicalNxPackage = resolveCanonicalNxPackage;
|
|
6
6
|
exports.resolveInclude = resolveInclude;
|
|
7
7
|
exports.parseMigrationsOptions = parseMigrationsOptions;
|
|
8
8
|
exports.createFetcher = createFetcher;
|
|
9
9
|
exports.generateMigrationsJsonAndUpdatePackageJson = generateMigrationsJsonAndUpdatePackageJson;
|
|
10
|
-
exports.isNpmPeerDepsError = isNpmPeerDepsError;
|
|
11
10
|
exports.resolveAgenticRunId = resolveAgenticRunId;
|
|
12
11
|
exports.formatSkippedPromptsNextStep = formatSkippedPromptsNextStep;
|
|
13
12
|
exports.resolveCreateCommits = resolveCreateCommits;
|
|
14
13
|
exports.resolveShouldRunValidation = resolveShouldRunValidation;
|
|
15
14
|
exports.executeMigrations = executeMigrations;
|
|
16
|
-
exports.runNxOrAngularMigration = runNxOrAngularMigration;
|
|
17
|
-
exports.parseMigrationReturn = parseMigrationReturn;
|
|
18
15
|
exports.migrate = migrate;
|
|
19
16
|
exports.runMigration = runMigration;
|
|
20
|
-
exports.readMigrationCollection = readMigrationCollection;
|
|
21
|
-
exports.getImplementationPath = getImplementationPath;
|
|
22
17
|
exports.resolveMigrationForRun = resolveMigrationForRun;
|
|
23
18
|
exports.resolveDocumentationFileToWorkspacePath = resolveDocumentationFileToWorkspacePath;
|
|
24
19
|
exports.nxCliPath = nxCliPath;
|
|
@@ -26,14 +21,12 @@ const tslib_1 = require("tslib");
|
|
|
26
21
|
const pc = tslib_1.__importStar(require("picocolors"));
|
|
27
22
|
const child_process_1 = require("child_process");
|
|
28
23
|
const safe_prompt_1 = require("./safe-prompt");
|
|
29
|
-
const handle_import_1 = require("../../utils/handle-import");
|
|
30
24
|
const path_1 = require("path");
|
|
31
25
|
const module_1 = require("module");
|
|
32
26
|
const path_2 = require("../../utils/path");
|
|
33
27
|
const semver_1 = require("semver");
|
|
34
28
|
const node_url_1 = require("node:url");
|
|
35
29
|
const util_1 = require("util");
|
|
36
|
-
const tree_1 = require("../../generators/tree");
|
|
37
30
|
const fileutils_1 = require("../../utils/fileutils");
|
|
38
31
|
const tar_1 = require("../../utils/tar");
|
|
39
32
|
const write_formatted_json_file_1 = require("../../utils/write-formatted-json-file");
|
|
@@ -55,7 +48,6 @@ const configuration_1 = require("../../config/configuration");
|
|
|
55
48
|
const child_process_2 = require("../../utils/child-process");
|
|
56
49
|
const client_1 = require("../../daemon/client/client");
|
|
57
50
|
const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
|
|
58
|
-
const project_graph_1 = require("../../project-graph/project-graph");
|
|
59
51
|
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
|
60
52
|
const provenance_1 = require("../../utils/provenance");
|
|
61
53
|
const catalog_1 = require("../../utils/catalog");
|
|
@@ -74,6 +66,8 @@ const update_filters_1 = require("./update-filters");
|
|
|
74
66
|
Object.defineProperty(exports, "filterDowngradedUpdates", { enumerable: true, get: function () { return update_filters_1.filterDowngradedUpdates; } });
|
|
75
67
|
const version_utils_1 = require("./version-utils");
|
|
76
68
|
Object.defineProperty(exports, "normalizeVersion", { enumerable: true, get: function () { return version_utils_1.normalizeVersion; } });
|
|
69
|
+
const execute_migration_1 = require("./execute-migration");
|
|
70
|
+
tslib_1.__exportStar(require("./execute-migration"), exports);
|
|
77
71
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
78
72
|
function formatCommandFailure(command, error) {
|
|
79
73
|
const normalizeCommandOutput = (output) => {
|
|
@@ -116,6 +110,8 @@ class Migrator {
|
|
|
116
110
|
this.packageUpdates = {};
|
|
117
111
|
this.collectedVersions = {};
|
|
118
112
|
this.promptAnswers = {};
|
|
113
|
+
this.pendingPackageJsonUpdates = new Map();
|
|
114
|
+
this.appliedPackageJsonUpdates = new Set();
|
|
119
115
|
if ((opts.include === 'required' || opts.include === 'optional') &&
|
|
120
116
|
!opts.requiredPackages) {
|
|
121
117
|
throw new Error(`Error: 'requiredPackages' is required when 'include' is '${opts.include}'.`);
|
|
@@ -143,6 +139,7 @@ class Migrator {
|
|
|
143
139
|
version: targetVersion,
|
|
144
140
|
addToPackageJson: false,
|
|
145
141
|
});
|
|
142
|
+
await this.applyPendingPackageJsonUpdates();
|
|
146
143
|
this.applyIncludeFilter();
|
|
147
144
|
const { migrations, promptContents } = await this.createMigrateJson();
|
|
148
145
|
return {
|
|
@@ -188,29 +185,66 @@ class Migrator {
|
|
|
188
185
|
for (const packageToCheck of packagesToCheck) {
|
|
189
186
|
const filteredUpdates = {};
|
|
190
187
|
for (const [packageUpdateKey, packageUpdate] of Object.entries(packageToCheck.updates)) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
188
|
+
Object.assign(filteredUpdates, await this.applyPackageJsonUpdate(packageToCheck.package, packageUpdateKey, packageUpdate));
|
|
189
|
+
}
|
|
190
|
+
await Promise.all(Object.entries(filteredUpdates).map(([name, update]) => this.buildPackageJsonUpdates(name, update)));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async applyPackageJsonUpdate(sourcePackage, packageUpdateKey, packageUpdate) {
|
|
194
|
+
const appliedKey = JSON.stringify([sourcePackage, packageUpdateKey]);
|
|
195
|
+
if (this.appliedPackageJsonUpdates.has(appliedKey)) {
|
|
196
|
+
this.pendingPackageJsonUpdates.delete(appliedKey);
|
|
197
|
+
return {};
|
|
198
|
+
}
|
|
199
|
+
if (!this.areRequirementsMet(packageUpdate.requires) ||
|
|
200
|
+
this.areIncompatiblePackagesPresent(packageUpdate.incompatibleWith)) {
|
|
201
|
+
this.pendingPackageJsonUpdates.set(appliedKey, {
|
|
202
|
+
package: sourcePackage,
|
|
203
|
+
key: packageUpdateKey,
|
|
204
|
+
update: packageUpdate,
|
|
205
|
+
});
|
|
206
|
+
return {};
|
|
207
|
+
}
|
|
208
|
+
this.pendingPackageJsonUpdates.delete(appliedKey);
|
|
209
|
+
if (this.interactive &&
|
|
210
|
+
!(await this.runPackageJsonUpdatesConfirmationPrompt(packageUpdate, packageUpdateKey, sourcePackage))) {
|
|
211
|
+
return {};
|
|
212
|
+
}
|
|
213
|
+
this.appliedPackageJsonUpdates.add(appliedKey);
|
|
214
|
+
const updateEntries = Object.entries(packageUpdate.packages);
|
|
215
|
+
// Validate all up front so invalid metadata fails fast, before any
|
|
216
|
+
// resolution does I/O.
|
|
217
|
+
for (const [name, update] of updateEntries) {
|
|
218
|
+
this.validatePackageUpdateVersion(sourcePackage, name, update);
|
|
219
|
+
}
|
|
220
|
+
const filteredUpdates = {};
|
|
221
|
+
// Resolve serially: resolution can prompt (pnpm strict cooldown) and append
|
|
222
|
+
// to minimumReleaseAgeExclude, so a serial loop avoids overlapping prompts
|
|
223
|
+
// and keeps packageUpdates ordering stable.
|
|
224
|
+
for (const [name, update] of updateEntries) {
|
|
225
|
+
const resolvedUpdate = {
|
|
226
|
+
...update,
|
|
227
|
+
version: await this.resolveVersionForCascade(name, update.version),
|
|
228
|
+
};
|
|
229
|
+
this.addPackageUpdate(name, resolvedUpdate);
|
|
230
|
+
filteredUpdates[name] = this.packageUpdates[name];
|
|
231
|
+
}
|
|
232
|
+
return filteredUpdates;
|
|
233
|
+
}
|
|
234
|
+
async applyPendingPackageJsonUpdates() {
|
|
235
|
+
while (this.pendingPackageJsonUpdates.size) {
|
|
236
|
+
let applied = false;
|
|
237
|
+
const filteredUpdates = {};
|
|
238
|
+
for (const pending of [...this.pendingPackageJsonUpdates.values()]) {
|
|
239
|
+
const updates = await this.applyPackageJsonUpdate(pending.package, pending.key, pending.update);
|
|
240
|
+
if (Object.keys(updates).length) {
|
|
241
|
+
applied = true;
|
|
242
|
+
Object.assign(filteredUpdates, updates);
|
|
212
243
|
}
|
|
213
244
|
}
|
|
245
|
+
if (!applied) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
214
248
|
await Promise.all(Object.entries(filteredUpdates).map(([name, update]) => this.buildPackageJsonUpdates(name, update)));
|
|
215
249
|
}
|
|
216
250
|
}
|
|
@@ -414,7 +448,7 @@ class Migrator {
|
|
|
414
448
|
}
|
|
415
449
|
addPackageUpdate(name, packageUpdate) {
|
|
416
450
|
if (!this.packageUpdates[name] ||
|
|
417
|
-
this.
|
|
451
|
+
!this.lt(packageUpdate.version, this.packageUpdates[name].version)) {
|
|
418
452
|
this.packageUpdates[name] = packageUpdate;
|
|
419
453
|
}
|
|
420
454
|
}
|
|
@@ -1051,6 +1085,15 @@ function createFetcher(pmc) {
|
|
|
1051
1085
|
migrationsCache[packageName + '-' + packageVersion] = migrations;
|
|
1052
1086
|
}
|
|
1053
1087
|
migrations = fetchMigrations(packageName, packageVersion, setCache).then((result) => {
|
|
1088
|
+
// An exact requested version must come back verbatim; a mismatch means
|
|
1089
|
+
// a config surface (registry proxy, override, cooldown gate) silently
|
|
1090
|
+
// substituted another version, which would corrupt the whole plan.
|
|
1091
|
+
if ((0, semver_1.valid)(packageVersion) &&
|
|
1092
|
+
result.version &&
|
|
1093
|
+
result.version !== packageVersion) {
|
|
1094
|
+
throw new Error(`Fetching ${packageName}@${packageVersion} resolved to version ${result.version}. ` +
|
|
1095
|
+
`Check for registry, override, or minimum-release-age configuration that hides the requested version.`);
|
|
1096
|
+
}
|
|
1054
1097
|
if (result.schematics) {
|
|
1055
1098
|
result.generators = { ...result.schematics, ...result.generators };
|
|
1056
1099
|
delete result.schematics;
|
|
@@ -1090,8 +1133,30 @@ async function getPackageMigrationsUsingRegistry(packageName, packageVersion) {
|
|
|
1090
1133
|
// try to obtain the migrations from the registry directly
|
|
1091
1134
|
return await downloadPackageMigrationsFromRegistry(packageName, packageVersion, migrationsConfig);
|
|
1092
1135
|
}
|
|
1136
|
+
// Matched exactly: a hostname that merely contains one of these is a different
|
|
1137
|
+
// registry. registry.yarnpkg.com is npmjs' CNAME, so it serves the same
|
|
1138
|
+
// metadata; the two loopback literals are the spellings of a local registry
|
|
1139
|
+
// that the substring below cannot reach, since neither contains "localhost".
|
|
1140
|
+
const FULL_METADATA_REGISTRIES = [
|
|
1141
|
+
'registry.npmjs.org',
|
|
1142
|
+
'registry.yarnpkg.com',
|
|
1143
|
+
'127.0.0.1',
|
|
1144
|
+
'[::1]',
|
|
1145
|
+
];
|
|
1146
|
+
// Matched as substrings, since neither names a single host: a local registry
|
|
1147
|
+
// can sit on a subdomain of localhost, and an Artifactory instance is
|
|
1148
|
+
// identified only by that word appearing somewhere in its hostname.
|
|
1149
|
+
const FULL_METADATA_REGISTRY_MARKERS = [
|
|
1150
|
+
'localhost',
|
|
1151
|
+
'artifactory',
|
|
1152
|
+
];
|
|
1093
1153
|
async function getPackageMigrationsConfigFromRegistry(packageName, packageVersion) {
|
|
1094
|
-
const result = await (0, package_manager_1.packageRegistryView)(packageName, packageVersion,
|
|
1154
|
+
const result = await (0, package_manager_1.packageRegistryView)(packageName, packageVersion, [
|
|
1155
|
+
'nx-migrations',
|
|
1156
|
+
'ng-update',
|
|
1157
|
+
'dist',
|
|
1158
|
+
'--json',
|
|
1159
|
+
]);
|
|
1095
1160
|
if (!result) {
|
|
1096
1161
|
return null;
|
|
1097
1162
|
}
|
|
@@ -1099,9 +1164,10 @@ async function getPackageMigrationsConfigFromRegistry(packageName, packageVersio
|
|
|
1099
1164
|
if (!json['nx-migrations'] && !json['ng-update']) {
|
|
1100
1165
|
const registry = new node_url_1.URL('dist' in json ? json.dist.tarball : json.tarball)
|
|
1101
1166
|
.hostname;
|
|
1102
|
-
//
|
|
1103
|
-
//
|
|
1104
|
-
if (!
|
|
1167
|
+
// Other registries may not support full metadata via npm view; throw to
|
|
1168
|
+
// trigger the install fallback.
|
|
1169
|
+
if (!FULL_METADATA_REGISTRIES.includes(registry) &&
|
|
1170
|
+
!FULL_METADATA_REGISTRY_MARKERS.some((v) => registry.includes(v))) {
|
|
1105
1171
|
throw new Error(`Getting migration config from registry is not supported from ${registry}`);
|
|
1106
1172
|
}
|
|
1107
1173
|
}
|
|
@@ -1111,7 +1177,13 @@ async function downloadPackageMigrationsFromRegistry(packageName, packageVersion
|
|
|
1111
1177
|
const { dir, cleanup } = (0, package_manager_1.createTempNpmDirectory)();
|
|
1112
1178
|
let result;
|
|
1113
1179
|
try {
|
|
1114
|
-
const { tarballPath } = await (0, package_manager_1.packageRegistryPack)(dir, packageName, packageVersion
|
|
1180
|
+
const { tarballPath } = await (0, package_manager_1.packageRegistryPack)(dir, packageName, packageVersion,
|
|
1181
|
+
// packageVersion is exact and already resolved through the workspace
|
|
1182
|
+
// package manager's min-release-age policy by the fetcher. In an npm
|
|
1183
|
+
// workspace the pack gate IS that policy, so leave it enforcing; for
|
|
1184
|
+
// other package managers npm's gate is foreign config with no
|
|
1185
|
+
// exclusions and would wrongly re-judge the vetted version.
|
|
1186
|
+
{ bypassMinReleaseAge: (0, package_manager_1.detectPackageManager)() !== 'npm' });
|
|
1115
1187
|
const fullTarballPath = (0, path_1.join)(dir, tarballPath);
|
|
1116
1188
|
let migrations;
|
|
1117
1189
|
try {
|
|
@@ -1189,7 +1261,7 @@ async function getPackageMigrationsUsingInstallImpl(packageName, packageVersion,
|
|
|
1189
1261
|
// as-is by the outer catch instead of being mislabeled as install failures.
|
|
1190
1262
|
throw new Error(formatCommandFailure(addCommand, e));
|
|
1191
1263
|
}
|
|
1192
|
-
const { migrations: migrationsFilePath, packageGroup, supportsOptionalMigrations, packageJson, } = readPackageMigrationConfig(packageName, dir);
|
|
1264
|
+
const { migrations: migrationsFilePath, packageGroup, supportsOptionalMigrations, packageJson, } = (0, execute_migration_1.readPackageMigrationConfig)(packageName, dir);
|
|
1193
1265
|
let migrations = undefined;
|
|
1194
1266
|
let resolvedPromptFiles;
|
|
1195
1267
|
if (migrationsFilePath) {
|
|
@@ -1216,32 +1288,6 @@ async function getPackageMigrationsUsingInstallImpl(packageName, packageVersion,
|
|
|
1216
1288
|
}
|
|
1217
1289
|
return result;
|
|
1218
1290
|
}
|
|
1219
|
-
function readPackageMigrationConfig(packageName, dir) {
|
|
1220
|
-
const { path: packageJsonPath, packageJson: json } = (0, package_json_1.readModulePackageJson)(packageName, (0, installation_directory_1.getNxRequirePaths)(dir));
|
|
1221
|
-
const config = (0, package_json_1.readNxMigrateConfig)(json);
|
|
1222
|
-
if (!config) {
|
|
1223
|
-
return { packageJson: json, migrations: null, packageGroup: [] };
|
|
1224
|
-
}
|
|
1225
|
-
try {
|
|
1226
|
-
const migrationFile = require.resolve(config.migrations, {
|
|
1227
|
-
paths: [(0, path_1.dirname)(packageJsonPath)],
|
|
1228
|
-
});
|
|
1229
|
-
return {
|
|
1230
|
-
packageJson: json,
|
|
1231
|
-
migrations: migrationFile,
|
|
1232
|
-
packageGroup: config.packageGroup,
|
|
1233
|
-
supportsOptionalMigrations: config.supportsOptionalMigrations,
|
|
1234
|
-
};
|
|
1235
|
-
}
|
|
1236
|
-
catch {
|
|
1237
|
-
return {
|
|
1238
|
-
packageJson: json,
|
|
1239
|
-
migrations: null,
|
|
1240
|
-
packageGroup: config.packageGroup,
|
|
1241
|
-
supportsOptionalMigrations: config.supportsOptionalMigrations,
|
|
1242
|
-
};
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
1291
|
async function createMigrationsFile(root, migrations) {
|
|
1246
1292
|
await (0, write_formatted_json_file_1.writeFormattedJsonFile)((0, path_1.join)(root, 'migrations.json'), { migrations });
|
|
1247
1293
|
}
|
|
@@ -1608,118 +1654,6 @@ function showConnectToCloudMessage() {
|
|
|
1608
1654
|
return false;
|
|
1609
1655
|
}
|
|
1610
1656
|
}
|
|
1611
|
-
function runInstall(nxWorkspaceRoot, phase = 'pre-migration') {
|
|
1612
|
-
const cwd = nxWorkspaceRoot ?? process.cwd();
|
|
1613
|
-
const packageManager = (0, package_manager_1.detectPackageManager)(cwd);
|
|
1614
|
-
const pmCommands = (0, package_manager_1.getPackageManagerCommand)(packageManager, cwd);
|
|
1615
|
-
const installCommand = `${pmCommands.install} ${pmCommands.ignoreScriptsFlag ?? ''}`;
|
|
1616
|
-
output_1.output.log({
|
|
1617
|
-
title: `Running '${installCommand}' to make sure necessary packages are installed`,
|
|
1618
|
-
});
|
|
1619
|
-
return new Promise((resolve, reject) => {
|
|
1620
|
-
// For npm, pipe stderr so we can detect peer dependency errors while still
|
|
1621
|
-
// mirroring it live to the user's terminal. Other package managers inherit
|
|
1622
|
-
// stderr directly since we don't need to inspect their output.
|
|
1623
|
-
const shouldCaptureStderr = packageManager === 'npm';
|
|
1624
|
-
const child = (0, child_process_1.spawn)(installCommand, {
|
|
1625
|
-
shell: true,
|
|
1626
|
-
stdio: ['inherit', 'inherit', shouldCaptureStderr ? 'pipe' : 'inherit'],
|
|
1627
|
-
windowsHide: true,
|
|
1628
|
-
cwd,
|
|
1629
|
-
});
|
|
1630
|
-
const stderrChunks = [];
|
|
1631
|
-
child.stderr?.on('data', (chunk) => {
|
|
1632
|
-
process.stderr.write(chunk);
|
|
1633
|
-
stderrChunks.push(chunk);
|
|
1634
|
-
});
|
|
1635
|
-
child.on('error', reject);
|
|
1636
|
-
child.on('close', (code) => {
|
|
1637
|
-
if (code === 0) {
|
|
1638
|
-
resolve();
|
|
1639
|
-
return;
|
|
1640
|
-
}
|
|
1641
|
-
if (shouldCaptureStderr) {
|
|
1642
|
-
const stderr = Buffer.concat(stderrChunks).toString().trim();
|
|
1643
|
-
if (isNpmPeerDepsError(stderr)) {
|
|
1644
|
-
// Log the remediation guidance here so every caller of `runInstall`
|
|
1645
|
-
// (CLI migrate, `nx repair`, single-migration runner, etc.) surfaces
|
|
1646
|
-
// it consistently. Top-level callers catch `NpmPeerDepsInstallError`
|
|
1647
|
-
// and return a non-zero exit code without re-logging.
|
|
1648
|
-
logNpmPeerDepsError(phase);
|
|
1649
|
-
reject(new NpmPeerDepsInstallError());
|
|
1650
|
-
return;
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
reject(new Error(`Command failed: ${installCommand}`));
|
|
1654
|
-
});
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
class NpmPeerDepsInstallError extends Error {
|
|
1658
|
-
constructor() {
|
|
1659
|
-
super('npm install failed due to peer dependency conflicts.');
|
|
1660
|
-
this.name = 'NpmPeerDepsInstallError';
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
/**
|
|
1664
|
-
* Detects npm peer-dependency resolution failures. Keyed on the `ERESOLVE`
|
|
1665
|
-
* error code, which npm consistently emits for this class of failure across
|
|
1666
|
-
* v7+ (`npm ERR! code ERESOLVE` / `npm error code ERESOLVE`). Falls back to a
|
|
1667
|
-
* small set of stable phrases in case the code line is missing from the
|
|
1668
|
-
* captured output.
|
|
1669
|
-
*/
|
|
1670
|
-
function isNpmPeerDepsError(stderr) {
|
|
1671
|
-
if (/\bERESOLVE\b/.test(stderr)) {
|
|
1672
|
-
return true;
|
|
1673
|
-
}
|
|
1674
|
-
const lowerStderr = stderr.toLowerCase();
|
|
1675
|
-
return (lowerStderr.includes('unable to resolve dependency tree') ||
|
|
1676
|
-
lowerStderr.includes('could not resolve dependency') ||
|
|
1677
|
-
lowerStderr.includes('conflicting peer dependency'));
|
|
1678
|
-
}
|
|
1679
|
-
function logNpmPeerDepsError(phase) {
|
|
1680
|
-
const peerDepsResolutionSteps = [
|
|
1681
|
-
'Recommended approaches (in order of preference):',
|
|
1682
|
-
'',
|
|
1683
|
-
'1. Use "overrides" in package.json to force compatible versions across the dependency tree.',
|
|
1684
|
-
' See https://docs.npmjs.com/cli/configuring-npm/package-json#overrides',
|
|
1685
|
-
'2. Persist legacy peer deps resolution in the project ".npmrc":',
|
|
1686
|
-
' npm config set legacy-peer-deps=true --location=project',
|
|
1687
|
-
' (bypasses peer dependency resolution; use with caution)',
|
|
1688
|
-
'3. As a last resort, force the installation by running "npm install --force".',
|
|
1689
|
-
' (does not persist and may produce broken installs)',
|
|
1690
|
-
];
|
|
1691
|
-
const manualInstallHint = [
|
|
1692
|
-
'If you installed the dependencies manually, pass "--skip-install" to avoid re-installing them:',
|
|
1693
|
-
' nx migrate --run-migrations --skip-install',
|
|
1694
|
-
];
|
|
1695
|
-
if (phase === 'pre-migration') {
|
|
1696
|
-
output_1.output.error({
|
|
1697
|
-
title: 'You need to resolve the peer dependency conflicts before the migration can continue',
|
|
1698
|
-
bodyLines: [
|
|
1699
|
-
...peerDepsResolutionSteps,
|
|
1700
|
-
'',
|
|
1701
|
-
'Once the conflicts are resolved, re-run the migrations:',
|
|
1702
|
-
' nx migrate --run-migrations',
|
|
1703
|
-
'',
|
|
1704
|
-
...manualInstallHint,
|
|
1705
|
-
],
|
|
1706
|
-
});
|
|
1707
|
-
}
|
|
1708
|
-
else {
|
|
1709
|
-
output_1.output.error({
|
|
1710
|
-
title: 'Some migrations have been applied, but installing the updated dependencies failed',
|
|
1711
|
-
bodyLines: [
|
|
1712
|
-
...peerDepsResolutionSteps,
|
|
1713
|
-
'',
|
|
1714
|
-
'Once the conflicts are resolved, run "npm install" to install the updated dependencies.',
|
|
1715
|
-
'If the migration was interrupted before completing, re-run the remaining migrations:',
|
|
1716
|
-
' nx migrate --run-migrations',
|
|
1717
|
-
'',
|
|
1718
|
-
...manualInstallHint,
|
|
1719
|
-
],
|
|
1720
|
-
});
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
1657
|
function resolveAgenticRunId(migrations) {
|
|
1724
1658
|
return (0, semver_1.rsort)(migrations.map((m) => (0, version_utils_1.normalizeVersion)(m.version)))[0];
|
|
1725
1659
|
}
|
|
@@ -1797,7 +1731,7 @@ function resolveShouldRunValidation(args) {
|
|
|
1797
1731
|
return args.validate !== false && args.agenticKind === 'enabled';
|
|
1798
1732
|
}
|
|
1799
1733
|
async function executeMigrations(root, migrations, isVerbose, shouldCreateCommits, commitPrefix, shouldSkipInstall = false, agentic, agenticHasDiffContext = false, shouldRunValidation = false) {
|
|
1800
|
-
const changedDepInstaller = new ChangedDepInstaller(root, shouldSkipInstall);
|
|
1734
|
+
const changedDepInstaller = new execute_migration_1.ChangedDepInstaller(root, shouldSkipInstall);
|
|
1801
1735
|
const migrationsWithNoChanges = [];
|
|
1802
1736
|
const sortedMigrations = migrations.sort((a, b) => {
|
|
1803
1737
|
// Under `--agentic`, hoist the v23 migration that ignores
|
|
@@ -1957,7 +1891,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
1957
1891
|
}
|
|
1958
1892
|
}
|
|
1959
1893
|
else if ((0, migration_shape_1.isHybridMigration)(m)) {
|
|
1960
|
-
const { changes, nextSteps, agentContext, logs, madeChanges } = await runNxOrAngularMigration(root, m, isVerbose,
|
|
1894
|
+
const { changes, nextSteps, agentContext, logs, madeChanges } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
|
|
1961
1895
|
/* captureGeneratorOutput: */ !!agenticRun, resolvedCollection);
|
|
1962
1896
|
migrationEmittedNextSteps.push(...nextSteps);
|
|
1963
1897
|
if (agenticRun) {
|
|
@@ -2021,7 +1955,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
2021
1955
|
// Defer commit until validation succeeds; failed validation leaves
|
|
2022
1956
|
// changes uncommitted in the working tree for the user to review.
|
|
2023
1957
|
const validationRun = agenticRun && shouldRunValidation ? agenticRun : undefined;
|
|
2024
|
-
const { changes, nextSteps, agentContext, logs, madeChanges } = await runNxOrAngularMigration(root, m, isVerbose,
|
|
1958
|
+
const { changes, nextSteps, agentContext, logs, madeChanges } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
|
|
2025
1959
|
/* captureGeneratorOutput: */ !!validationRun, resolvedCollection);
|
|
2026
1960
|
migrationEmittedNextSteps.push(...nextSteps);
|
|
2027
1961
|
const canRunValidation = !!validationRun && changes.length > 0;
|
|
@@ -2098,7 +2032,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
2098
2032
|
// `nx repair` reuses executeMigrations; only record for migrate runs.
|
|
2099
2033
|
if ((0, migrate_analytics_1.hasMigrateRunStarted)()) {
|
|
2100
2034
|
(0, migrate_analytics_1.reportMigrateRunError)({
|
|
2101
|
-
code: e instanceof NpmPeerDepsInstallError
|
|
2035
|
+
code: e instanceof execute_migration_1.NpmPeerDepsInstallError
|
|
2102
2036
|
? 'npm_install'
|
|
2103
2037
|
: inAgenticStep
|
|
2104
2038
|
? 'agentic'
|
|
@@ -2109,7 +2043,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
2109
2043
|
error: e,
|
|
2110
2044
|
});
|
|
2111
2045
|
}
|
|
2112
|
-
if (!(e instanceof NpmPeerDepsInstallError)) {
|
|
2046
|
+
if (!(e instanceof execute_migration_1.NpmPeerDepsInstallError)) {
|
|
2113
2047
|
// `withGeneratorOutputCapture` attaches the generator's `console.*`
|
|
2114
2048
|
// output as `capturedLogs` (best-effort; may be absent). Surface it
|
|
2115
2049
|
// so the user sees what the generator printed before it crashed.
|
|
@@ -2163,30 +2097,6 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
2163
2097
|
retainedAtSuccess: (0, migrate_output_1.retainedMigrations)(outcomes).map((p) => `${p.package}: ${p.name}`),
|
|
2164
2098
|
};
|
|
2165
2099
|
}
|
|
2166
|
-
class ChangedDepInstaller {
|
|
2167
|
-
constructor(root, shouldSkipInstall = false) {
|
|
2168
|
-
this.root = root;
|
|
2169
|
-
this.shouldSkipInstall = shouldSkipInstall;
|
|
2170
|
-
this._skippedInstall = false;
|
|
2171
|
-
this.initialDeps = getStringifiedPackageJsonDeps(root);
|
|
2172
|
-
}
|
|
2173
|
-
get skippedInstall() {
|
|
2174
|
-
return this._skippedInstall;
|
|
2175
|
-
}
|
|
2176
|
-
async installDepsIfChanged() {
|
|
2177
|
-
const currentDeps = getStringifiedPackageJsonDeps(this.root);
|
|
2178
|
-
if (this.initialDeps !== currentDeps) {
|
|
2179
|
-
if (this.shouldSkipInstall) {
|
|
2180
|
-
this._skippedInstall = true;
|
|
2181
|
-
}
|
|
2182
|
-
else {
|
|
2183
|
-
await runInstall(this.root, 'post-migration');
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
this.initialDeps = currentDeps;
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
exports.ChangedDepInstaller = ChangedDepInstaller;
|
|
2190
2100
|
function logSkippedPostMigrationInstall(root) {
|
|
2191
2101
|
const packageManager = (0, package_manager_1.detectPackageManager)(root);
|
|
2192
2102
|
const installCommand = (0, package_manager_1.getPackageManagerCommand)(packageManager, root).install;
|
|
@@ -2195,58 +2105,9 @@ function logSkippedPostMigrationInstall(root) {
|
|
|
2195
2105
|
bodyLines: [`Run "${installCommand}" to install the updated dependencies.`],
|
|
2196
2106
|
});
|
|
2197
2107
|
}
|
|
2198
|
-
async function runNxOrAngularMigration(root, migration, isVerbose, captureGeneratorOutput = false, resolvedCollection) {
|
|
2199
|
-
const { collection, collectionPath } = resolvedCollection ?? readMigrationCollection(migration.package, root);
|
|
2200
|
-
let changes = [];
|
|
2201
|
-
let nextSteps = [];
|
|
2202
|
-
let agentContext = [];
|
|
2203
|
-
let logs = '';
|
|
2204
|
-
// Angular's `ngResult.changes` is synthesized from the schematic's
|
|
2205
|
-
// DryRunEvent stream so Nx and Angular paths can share commit/validation
|
|
2206
|
-
// gating via `changes.length > 0`.
|
|
2207
|
-
let madeChanges = false;
|
|
2208
|
-
logger_1.logger.info(pc.dim('→ Running generator…'));
|
|
2209
|
-
if (!isAngularMigration(collection, migration.name)) {
|
|
2210
|
-
({ nextSteps, changes, agentContext, logs } = await runNxMigration(root, collectionPath, collection, migration.name, migration.version, captureGeneratorOutput));
|
|
2211
|
-
madeChanges = changes.length > 0;
|
|
2212
|
-
logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
|
|
2213
|
-
if (migration.description) {
|
|
2214
|
-
logger_1.logger.info(` ${migration.description}`);
|
|
2215
|
-
}
|
|
2216
|
-
logger_1.logger.info('');
|
|
2217
|
-
if (!madeChanges) {
|
|
2218
|
-
logger_1.logger.info(`No changes were made\n`);
|
|
2219
|
-
return { changes, nextSteps, agentContext, logs, madeChanges };
|
|
2220
|
-
}
|
|
2221
|
-
logger_1.logger.info('Changes:');
|
|
2222
|
-
(0, tree_1.printChanges)(changes, ' ');
|
|
2223
|
-
logger_1.logger.info('');
|
|
2224
|
-
}
|
|
2225
|
-
else {
|
|
2226
|
-
const ngCliAdapter = await getNgCompatLayer();
|
|
2227
|
-
const migrationProjectGraph = await (0, project_graph_1.createProjectGraphAsync)();
|
|
2228
|
-
const ngResult = await ngCliAdapter.runMigration(root, migration.package, migration.name, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(migrationProjectGraph).projects, isVerbose, migrationProjectGraph);
|
|
2229
|
-
changes = ngResult.changes;
|
|
2230
|
-
madeChanges = ngResult.madeChanges;
|
|
2231
|
-
logs = ngResult.loggingQueue.join('\n');
|
|
2232
|
-
logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
|
|
2233
|
-
if (migration.description) {
|
|
2234
|
-
logger_1.logger.info(` ${migration.description}`);
|
|
2235
|
-
}
|
|
2236
|
-
logger_1.logger.info('');
|
|
2237
|
-
if (!madeChanges) {
|
|
2238
|
-
logger_1.logger.info(`No changes were made\n`);
|
|
2239
|
-
return { changes, nextSteps, agentContext, logs, madeChanges };
|
|
2240
|
-
}
|
|
2241
|
-
logger_1.logger.info('Changes:');
|
|
2242
|
-
ngResult.loggingQueue.forEach((log) => logger_1.logger.info(' ' + log));
|
|
2243
|
-
logger_1.logger.info('');
|
|
2244
|
-
}
|
|
2245
|
-
return { changes, nextSteps, agentContext, logs, madeChanges };
|
|
2246
|
-
}
|
|
2247
2108
|
async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits, commitPrefix, shouldSkipInstall = false) {
|
|
2248
2109
|
if (!shouldSkipInstall && !process.env.NX_MIGRATE_SKIP_INSTALL) {
|
|
2249
|
-
await runInstall();
|
|
2110
|
+
await (0, execute_migration_1.runInstall)();
|
|
2250
2111
|
}
|
|
2251
2112
|
if (!__dirname.startsWith(workspace_root_1.workspaceRoot)) {
|
|
2252
2113
|
// we are running from a temp installation with nx latest, switch to running
|
|
@@ -2419,59 +2280,6 @@ async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits, c
|
|
|
2419
2280
|
appliedCount,
|
|
2420
2281
|
});
|
|
2421
2282
|
}
|
|
2422
|
-
function getStringifiedPackageJsonDeps(root) {
|
|
2423
|
-
try {
|
|
2424
|
-
const { dependencies, devDependencies } = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
|
|
2425
|
-
return JSON.stringify([dependencies, devDependencies]);
|
|
2426
|
-
}
|
|
2427
|
-
catch {
|
|
2428
|
-
// We don't really care if the .nx/installation property changes,
|
|
2429
|
-
// whenever nxw is invoked it will handle the dep updates.
|
|
2430
|
-
return '';
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
|
-
async function runNxMigration(root, collectionPath, collection, name, migrationVersion, captureGeneratorOutput) {
|
|
2434
|
-
const { path: implPath, fnSymbol } = getImplementationPath(collection, collectionPath, name, migrationVersion);
|
|
2435
|
-
const fn = require(implPath)[fnSymbol];
|
|
2436
|
-
const host = new tree_1.FsTree(root, process.env.NX_VERBOSE_LOGGING === 'true', `migration ${collection.name}:${name}`);
|
|
2437
|
-
let result;
|
|
2438
|
-
let logs = '';
|
|
2439
|
-
if (captureGeneratorOutput) {
|
|
2440
|
-
const { withGeneratorOutputCapture } = require('./agentic/capture-generator-output');
|
|
2441
|
-
({ result, logs } = await withGeneratorOutputCapture(() => fn(host, {})));
|
|
2442
|
-
}
|
|
2443
|
-
else {
|
|
2444
|
-
result = await fn(host, {});
|
|
2445
|
-
}
|
|
2446
|
-
const { nextSteps, agentContext } = parseMigrationReturn(result);
|
|
2447
|
-
host.lock();
|
|
2448
|
-
const changes = host.listChanges();
|
|
2449
|
-
(0, tree_1.flushChanges)(root, changes);
|
|
2450
|
-
return { changes, nextSteps, agentContext, logs };
|
|
2451
|
-
}
|
|
2452
|
-
function parseMigrationReturn(value) {
|
|
2453
|
-
if (Array.isArray(value)) {
|
|
2454
|
-
return { nextSteps: filterStrings(value), agentContext: [] };
|
|
2455
|
-
}
|
|
2456
|
-
if (value && typeof value === 'object') {
|
|
2457
|
-
const obj = value;
|
|
2458
|
-
return {
|
|
2459
|
-
nextSteps: filterStrings(obj.nextSteps),
|
|
2460
|
-
agentContext: filterStrings(obj.agentContext),
|
|
2461
|
-
};
|
|
2462
|
-
}
|
|
2463
|
-
// Catches `void`, mistakenly-returned generator callbacks, malformed values.
|
|
2464
|
-
return { nextSteps: [], agentContext: [] };
|
|
2465
|
-
}
|
|
2466
|
-
// Bucket-level tolerance: a single non-string entry shouldn't discard the
|
|
2467
|
-
// whole `nextSteps` / `agentContext` array. Migration authors occasionally
|
|
2468
|
-
// push `null` / `undefined` / a number into the array; we drop the bad entries
|
|
2469
|
-
// and keep the rest so end-of-run guidance isn't silently lost.
|
|
2470
|
-
function filterStrings(value) {
|
|
2471
|
-
if (!Array.isArray(value))
|
|
2472
|
-
return [];
|
|
2473
|
-
return value.filter((v) => typeof v === 'string');
|
|
2474
|
-
}
|
|
2475
2283
|
async function migrate(root, args, rawArgs) {
|
|
2476
2284
|
await client_1.daemonClient.stop();
|
|
2477
2285
|
return (0, handle_errors_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
|
@@ -2505,7 +2313,7 @@ async function migrate(root, args, rawArgs) {
|
|
|
2505
2313
|
// The remediation guidance is already logged by `runInstall`; swallow
|
|
2506
2314
|
// the error here so `handleErrors` doesn't print a noisy stack after
|
|
2507
2315
|
// the friendly output.
|
|
2508
|
-
if (e instanceof NpmPeerDepsInstallError) {
|
|
2316
|
+
if (e instanceof execute_migration_1.NpmPeerDepsInstallError) {
|
|
2509
2317
|
(0, migrate_analytics_1.reportMigrateRunError)({ code: 'npm_install', error: e });
|
|
2510
2318
|
return 1;
|
|
2511
2319
|
}
|
|
@@ -2532,6 +2340,10 @@ async function runMigration() {
|
|
|
2532
2340
|
process.env.npm_config_registry.match(/^https:\/\/registry\.(npmjs\.org|yarnpkg\.com)/)) {
|
|
2533
2341
|
delete process.env.npm_config_registry;
|
|
2534
2342
|
}
|
|
2343
|
+
// Intentionally not runNxSync: `p` is an nx CLI freshly installed into a
|
|
2344
|
+
// temp dir by nxCliPath() (latest, or NX_MIGRATE_CLI_VERSION), so
|
|
2345
|
+
// migrations run with an up-to-date migrate implementation instead of
|
|
2346
|
+
// the workspace's current nx.
|
|
2535
2347
|
return runOrReturnExitCode(() => (0, child_process_1.execSync)(`${p} _migrate ${process.argv.slice(3).join(' ')}`, {
|
|
2536
2348
|
stdio: ['inherit', 'inherit', 'inherit'],
|
|
2537
2349
|
windowsHide: true,
|
|
@@ -2540,39 +2352,6 @@ async function runMigration() {
|
|
|
2540
2352
|
return runLocalMigrate();
|
|
2541
2353
|
});
|
|
2542
2354
|
}
|
|
2543
|
-
function readMigrationCollection(packageName, root) {
|
|
2544
|
-
const collectionPath = readPackageMigrationConfig(packageName, root).migrations;
|
|
2545
|
-
const collection = (0, fileutils_1.readJsonFile)(collectionPath);
|
|
2546
|
-
collection.name ??= packageName;
|
|
2547
|
-
return {
|
|
2548
|
-
collection,
|
|
2549
|
-
collectionPath,
|
|
2550
|
-
};
|
|
2551
|
-
}
|
|
2552
|
-
function getImplementationPath(collection, collectionPath, name, migrationVersion) {
|
|
2553
|
-
const g = collection.generators?.[name] || collection.schematics?.[name];
|
|
2554
|
-
if (!g) {
|
|
2555
|
-
throw new MigrationImplementationMissingError(`Unable to determine implementation path for "${collectionPath}:${name}"`, collectionPath, migrationVersion);
|
|
2556
|
-
}
|
|
2557
|
-
const implRelativePathAndMaybeSymbol = g.implementation || g.factory;
|
|
2558
|
-
const [implRelativePath, fnSymbol = 'default'] = implRelativePathAndMaybeSymbol.split('#');
|
|
2559
|
-
let implPath;
|
|
2560
|
-
try {
|
|
2561
|
-
implPath = require.resolve(implRelativePath, {
|
|
2562
|
-
paths: [(0, path_1.dirname)(collectionPath)],
|
|
2563
|
-
});
|
|
2564
|
-
}
|
|
2565
|
-
catch (e) {
|
|
2566
|
-
try {
|
|
2567
|
-
// workaround for a bug in node 12
|
|
2568
|
-
implPath = require.resolve(`${(0, path_1.dirname)(collectionPath)}/${implRelativePath}`);
|
|
2569
|
-
}
|
|
2570
|
-
catch {
|
|
2571
|
-
throw new MigrationImplementationMissingError(`Could not resolve implementation for migration "${name}" from "${collectionPath}"`, collectionPath, migrationVersion ?? g.version);
|
|
2572
|
-
}
|
|
2573
|
-
}
|
|
2574
|
-
return { path: implPath, fnSymbol };
|
|
2575
|
-
}
|
|
2576
2355
|
/**
|
|
2577
2356
|
* Resolves a migration's collection once and derives everything the run loop
|
|
2578
2357
|
* needs from that single read: the implementation context (`collection` +
|
|
@@ -2591,11 +2370,11 @@ function getImplementationPath(collection, collectionPath, name, migrationVersio
|
|
|
2591
2370
|
function resolveMigrationForRun(root, migration, resolveDocumentation) {
|
|
2592
2371
|
let resolvedCollection;
|
|
2593
2372
|
if (!(0, migration_shape_1.isPromptOnlyMigration)(migration)) {
|
|
2594
|
-
resolvedCollection = readMigrationCollection(migration.package, root);
|
|
2373
|
+
resolvedCollection = (0, execute_migration_1.readMigrationCollection)(migration.package, root);
|
|
2595
2374
|
}
|
|
2596
2375
|
else if (resolveDocumentation && migration.documentation) {
|
|
2597
2376
|
try {
|
|
2598
|
-
resolvedCollection = readMigrationCollection(migration.package, root);
|
|
2377
|
+
resolvedCollection = (0, execute_migration_1.readMigrationCollection)(migration.package, root);
|
|
2599
2378
|
}
|
|
2600
2379
|
catch {
|
|
2601
2380
|
// Non-fatal: documentation is supplementary; the warning below fires.
|
|
@@ -2630,52 +2409,6 @@ function resolveDocumentationFileToWorkspacePath(root, migrationsDir, documentat
|
|
|
2630
2409
|
const relativePath = (0, path_1.relative)(root, documentationFile);
|
|
2631
2410
|
return relativePath.startsWith('..') ? documentationFile : relativePath;
|
|
2632
2411
|
}
|
|
2633
|
-
class MigrationImplementationMissingError extends Error {
|
|
2634
|
-
constructor(baseMessage, collectionPath, migrationVersion) {
|
|
2635
|
-
super(buildMigrationMissingMessage(baseMessage, collectionPath, migrationVersion));
|
|
2636
|
-
this.name = 'MigrationImplementationMissingError';
|
|
2637
|
-
}
|
|
2638
|
-
}
|
|
2639
|
-
function buildMigrationMissingMessage(baseMessage, collectionPath, migrationVersion) {
|
|
2640
|
-
if (!migrationVersion) {
|
|
2641
|
-
return baseMessage;
|
|
2642
|
-
}
|
|
2643
|
-
try {
|
|
2644
|
-
const packageJsonPath = (0, path_1.join)((0, path_1.dirname)(collectionPath), 'package.json');
|
|
2645
|
-
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
2646
|
-
return baseMessage;
|
|
2647
|
-
}
|
|
2648
|
-
const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
2649
|
-
const installedVersion = packageJson.version;
|
|
2650
|
-
if (installedVersion &&
|
|
2651
|
-
(0, semver_1.lt)((0, version_utils_1.normalizeVersion)(installedVersion), (0, version_utils_1.normalizeVersion)(migrationVersion))) {
|
|
2652
|
-
const packageManager = (0, package_manager_1.detectPackageManager)();
|
|
2653
|
-
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
2654
|
-
const overrideFieldName = getOverrideFieldName(packageManager);
|
|
2655
|
-
return (`${baseMessage}\n\n` +
|
|
2656
|
-
`The installed version of "${packageJson.name}" is ${installedVersion}, ` +
|
|
2657
|
-
`but this migration requires version ${migrationVersion}. ` +
|
|
2658
|
-
`This likely means the package version is being held back by an ${overrideFieldName} ` +
|
|
2659
|
-
`in your package.json. ` +
|
|
2660
|
-
`Remove the ${overrideFieldName} and run "${pmc.install}" to install the correct version.`);
|
|
2661
|
-
}
|
|
2662
|
-
}
|
|
2663
|
-
catch {
|
|
2664
|
-
// Fall through to return the base message if we can't read package info
|
|
2665
|
-
}
|
|
2666
|
-
return baseMessage;
|
|
2667
|
-
}
|
|
2668
|
-
function getOverrideFieldName(packageManager) {
|
|
2669
|
-
switch (packageManager) {
|
|
2670
|
-
case 'pnpm':
|
|
2671
|
-
return '"pnpm.overrides"';
|
|
2672
|
-
case 'yarn':
|
|
2673
|
-
return '"resolutions"';
|
|
2674
|
-
case 'npm':
|
|
2675
|
-
case 'bun':
|
|
2676
|
-
return '"overrides"';
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
2679
2412
|
async function nxCliPath(nxWorkspaceRoot) {
|
|
2680
2413
|
const version = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
|
|
2681
2414
|
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
|
@@ -2745,16 +2478,3 @@ function addToNodePath(dir) {
|
|
|
2745
2478
|
// Update the env variable.
|
|
2746
2479
|
process.env.NODE_PATH = paths.join(delimiter);
|
|
2747
2480
|
}
|
|
2748
|
-
function isAngularMigration(collection, name) {
|
|
2749
|
-
return !collection.generators?.[name] && collection.schematics?.[name];
|
|
2750
|
-
}
|
|
2751
|
-
const getNgCompatLayer = (() => {
|
|
2752
|
-
let _ngCliAdapter;
|
|
2753
|
-
return async function getNgCompatLayer() {
|
|
2754
|
-
if (!_ngCliAdapter) {
|
|
2755
|
-
_ngCliAdapter = await (0, handle_import_1.handleImport)('../../adapter/ngcli-adapter.js', __dirname);
|
|
2756
|
-
require('../../adapter/compat');
|
|
2757
|
-
}
|
|
2758
|
-
return _ngCliAdapter;
|
|
2759
|
-
};
|
|
2760
|
-
})();
|