nx 23.2.0-beta.0 → 23.2.0-beta.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 +1 -1
- package/dist/src/analytics/analytics.d.ts +6 -0
- package/dist/src/analytics/analytics.js +7 -1
- package/dist/src/analytics/index.d.ts +1 -1
- package/dist/src/analytics/index.js +2 -1
- 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/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/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 +1 -45
- package/dist/src/command-line/migrate/migrate.js +17 -375
- package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
- package/dist/src/command-line/release/utils/release-graph.d.ts +2 -2
- package/dist/src/command-line/release/utils/shared.d.ts +2 -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/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 +1 -1
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
- package/dist/src/daemon/server/server.js +7 -4
- package/dist/src/devkit-internals.d.ts +1 -0
- package/dist/src/devkit-internals.js +5 -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/native/index.d.ts +25 -2
- package/dist/src/native/native-bindings.js +2 -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/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -0
- package/dist/src/project-graph/build-project-graph.js +7 -1
- package/dist/src/project-graph/file-utils.js +6 -1
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
- package/dist/src/project-graph/project-graph.js +3 -0
- package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
- package/dist/src/tasks-runner/life-cycle.js +2 -2
- package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +9 -4
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +5 -4
- package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +16 -8
- package/dist/src/tasks-runner/life-cycles/performance-report.js +55 -27
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
- package/dist/src/tasks-runner/pseudo-terminal.js +2 -2
- package/dist/src/tasks-runner/task-orchestrator.d.ts +4 -1
- package/dist/src/tasks-runner/task-orchestrator.js +23 -6
- package/dist/src/utils/acknowledge-build-scripts.js +7 -5
- package/dist/src/utils/command-line-utils.js +30 -20
- package/dist/src/utils/git-revision.d.ts +12 -0
- package/dist/src/utils/git-revision.js +25 -0
- package/dist/src/utils/package-manager.js +6 -2
- package/package.json +11 -11
|
@@ -1,25 +1,20 @@
|
|
|
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.confirmCommitsOnDefaultBranch = confirmCommitsOnDefaultBranch;
|
|
15
14
|
exports.resolveShouldRunValidation = resolveShouldRunValidation;
|
|
16
15
|
exports.executeMigrations = executeMigrations;
|
|
17
|
-
exports.runNxOrAngularMigration = runNxOrAngularMigration;
|
|
18
|
-
exports.parseMigrationReturn = parseMigrationReturn;
|
|
19
16
|
exports.migrate = migrate;
|
|
20
17
|
exports.runMigration = runMigration;
|
|
21
|
-
exports.readMigrationCollection = readMigrationCollection;
|
|
22
|
-
exports.getImplementationPath = getImplementationPath;
|
|
23
18
|
exports.resolveMigrationForRun = resolveMigrationForRun;
|
|
24
19
|
exports.resolveDocumentationFileToWorkspacePath = resolveDocumentationFileToWorkspacePath;
|
|
25
20
|
exports.nxCliPath = nxCliPath;
|
|
@@ -27,14 +22,12 @@ const tslib_1 = require("tslib");
|
|
|
27
22
|
const pc = tslib_1.__importStar(require("picocolors"));
|
|
28
23
|
const child_process_1 = require("child_process");
|
|
29
24
|
const safe_prompt_1 = require("./safe-prompt");
|
|
30
|
-
const handle_import_1 = require("../../utils/handle-import");
|
|
31
25
|
const path_1 = require("path");
|
|
32
26
|
const module_1 = require("module");
|
|
33
27
|
const path_2 = require("../../utils/path");
|
|
34
28
|
const semver_1 = require("semver");
|
|
35
29
|
const node_url_1 = require("node:url");
|
|
36
30
|
const util_1 = require("util");
|
|
37
|
-
const tree_1 = require("../../generators/tree");
|
|
38
31
|
const fileutils_1 = require("../../utils/fileutils");
|
|
39
32
|
const tar_1 = require("../../utils/tar");
|
|
40
33
|
const write_formatted_json_file_1 = require("../../utils/write-formatted-json-file");
|
|
@@ -57,7 +50,6 @@ const configuration_1 = require("../../config/configuration");
|
|
|
57
50
|
const child_process_2 = require("../../utils/child-process");
|
|
58
51
|
const client_1 = require("../../daemon/client/client");
|
|
59
52
|
const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
|
|
60
|
-
const project_graph_1 = require("../../project-graph/project-graph");
|
|
61
53
|
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
|
62
54
|
const provenance_1 = require("../../utils/provenance");
|
|
63
55
|
const catalog_1 = require("../../utils/catalog");
|
|
@@ -76,6 +68,8 @@ const update_filters_1 = require("./update-filters");
|
|
|
76
68
|
Object.defineProperty(exports, "filterDowngradedUpdates", { enumerable: true, get: function () { return update_filters_1.filterDowngradedUpdates; } });
|
|
77
69
|
const version_utils_1 = require("./version-utils");
|
|
78
70
|
Object.defineProperty(exports, "normalizeVersion", { enumerable: true, get: function () { return version_utils_1.normalizeVersion; } });
|
|
71
|
+
const execute_migration_1 = require("./execute-migration");
|
|
72
|
+
tslib_1.__exportStar(require("./execute-migration"), exports);
|
|
79
73
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
80
74
|
function formatCommandFailure(command, error) {
|
|
81
75
|
const normalizeCommandOutput = (output) => {
|
|
@@ -1191,7 +1185,7 @@ async function getPackageMigrationsUsingInstallImpl(packageName, packageVersion,
|
|
|
1191
1185
|
// as-is by the outer catch instead of being mislabeled as install failures.
|
|
1192
1186
|
throw new Error(formatCommandFailure(addCommand, e));
|
|
1193
1187
|
}
|
|
1194
|
-
const { migrations: migrationsFilePath, packageGroup, supportsOptionalMigrations, packageJson, } = readPackageMigrationConfig(packageName, dir);
|
|
1188
|
+
const { migrations: migrationsFilePath, packageGroup, supportsOptionalMigrations, packageJson, } = (0, execute_migration_1.readPackageMigrationConfig)(packageName, dir);
|
|
1195
1189
|
let migrations = undefined;
|
|
1196
1190
|
let resolvedPromptFiles;
|
|
1197
1191
|
if (migrationsFilePath) {
|
|
@@ -1218,32 +1212,6 @@ async function getPackageMigrationsUsingInstallImpl(packageName, packageVersion,
|
|
|
1218
1212
|
}
|
|
1219
1213
|
return result;
|
|
1220
1214
|
}
|
|
1221
|
-
function readPackageMigrationConfig(packageName, dir) {
|
|
1222
|
-
const { path: packageJsonPath, packageJson: json } = (0, package_json_1.readModulePackageJson)(packageName, (0, installation_directory_1.getNxRequirePaths)(dir));
|
|
1223
|
-
const config = (0, package_json_1.readNxMigrateConfig)(json);
|
|
1224
|
-
if (!config) {
|
|
1225
|
-
return { packageJson: json, migrations: null, packageGroup: [] };
|
|
1226
|
-
}
|
|
1227
|
-
try {
|
|
1228
|
-
const migrationFile = require.resolve(config.migrations, {
|
|
1229
|
-
paths: [(0, path_1.dirname)(packageJsonPath)],
|
|
1230
|
-
});
|
|
1231
|
-
return {
|
|
1232
|
-
packageJson: json,
|
|
1233
|
-
migrations: migrationFile,
|
|
1234
|
-
packageGroup: config.packageGroup,
|
|
1235
|
-
supportsOptionalMigrations: config.supportsOptionalMigrations,
|
|
1236
|
-
};
|
|
1237
|
-
}
|
|
1238
|
-
catch {
|
|
1239
|
-
return {
|
|
1240
|
-
packageJson: json,
|
|
1241
|
-
migrations: null,
|
|
1242
|
-
packageGroup: config.packageGroup,
|
|
1243
|
-
supportsOptionalMigrations: config.supportsOptionalMigrations,
|
|
1244
|
-
};
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
1215
|
async function createMigrationsFile(root, migrations) {
|
|
1248
1216
|
await (0, write_formatted_json_file_1.writeFormattedJsonFile)((0, path_1.join)(root, 'migrations.json'), { migrations });
|
|
1249
1217
|
}
|
|
@@ -1610,118 +1578,6 @@ function showConnectToCloudMessage() {
|
|
|
1610
1578
|
return false;
|
|
1611
1579
|
}
|
|
1612
1580
|
}
|
|
1613
|
-
function runInstall(nxWorkspaceRoot, phase = 'pre-migration') {
|
|
1614
|
-
const cwd = nxWorkspaceRoot ?? process.cwd();
|
|
1615
|
-
const packageManager = (0, package_manager_1.detectPackageManager)(cwd);
|
|
1616
|
-
const pmCommands = (0, package_manager_1.getPackageManagerCommand)(packageManager, cwd);
|
|
1617
|
-
const installCommand = `${pmCommands.install} ${pmCommands.ignoreScriptsFlag ?? ''}`;
|
|
1618
|
-
output_1.output.log({
|
|
1619
|
-
title: `Running '${installCommand}' to make sure necessary packages are installed`,
|
|
1620
|
-
});
|
|
1621
|
-
return new Promise((resolve, reject) => {
|
|
1622
|
-
// For npm, pipe stderr so we can detect peer dependency errors while still
|
|
1623
|
-
// mirroring it live to the user's terminal. Other package managers inherit
|
|
1624
|
-
// stderr directly since we don't need to inspect their output.
|
|
1625
|
-
const shouldCaptureStderr = packageManager === 'npm';
|
|
1626
|
-
const child = (0, child_process_1.spawn)(installCommand, {
|
|
1627
|
-
shell: true,
|
|
1628
|
-
stdio: ['inherit', 'inherit', shouldCaptureStderr ? 'pipe' : 'inherit'],
|
|
1629
|
-
windowsHide: true,
|
|
1630
|
-
cwd,
|
|
1631
|
-
});
|
|
1632
|
-
const stderrChunks = [];
|
|
1633
|
-
child.stderr?.on('data', (chunk) => {
|
|
1634
|
-
process.stderr.write(chunk);
|
|
1635
|
-
stderrChunks.push(chunk);
|
|
1636
|
-
});
|
|
1637
|
-
child.on('error', reject);
|
|
1638
|
-
child.on('close', (code) => {
|
|
1639
|
-
if (code === 0) {
|
|
1640
|
-
resolve();
|
|
1641
|
-
return;
|
|
1642
|
-
}
|
|
1643
|
-
if (shouldCaptureStderr) {
|
|
1644
|
-
const stderr = Buffer.concat(stderrChunks).toString().trim();
|
|
1645
|
-
if (isNpmPeerDepsError(stderr)) {
|
|
1646
|
-
// Log the remediation guidance here so every caller of `runInstall`
|
|
1647
|
-
// (CLI migrate, `nx repair`, single-migration runner, etc.) surfaces
|
|
1648
|
-
// it consistently. Top-level callers catch `NpmPeerDepsInstallError`
|
|
1649
|
-
// and return a non-zero exit code without re-logging.
|
|
1650
|
-
logNpmPeerDepsError(phase);
|
|
1651
|
-
reject(new NpmPeerDepsInstallError());
|
|
1652
|
-
return;
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
reject(new Error(`Command failed: ${installCommand}`));
|
|
1656
|
-
});
|
|
1657
|
-
});
|
|
1658
|
-
}
|
|
1659
|
-
class NpmPeerDepsInstallError extends Error {
|
|
1660
|
-
constructor() {
|
|
1661
|
-
super('npm install failed due to peer dependency conflicts.');
|
|
1662
|
-
this.name = 'NpmPeerDepsInstallError';
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
/**
|
|
1666
|
-
* Detects npm peer-dependency resolution failures. Keyed on the `ERESOLVE`
|
|
1667
|
-
* error code, which npm consistently emits for this class of failure across
|
|
1668
|
-
* v7+ (`npm ERR! code ERESOLVE` / `npm error code ERESOLVE`). Falls back to a
|
|
1669
|
-
* small set of stable phrases in case the code line is missing from the
|
|
1670
|
-
* captured output.
|
|
1671
|
-
*/
|
|
1672
|
-
function isNpmPeerDepsError(stderr) {
|
|
1673
|
-
if (/\bERESOLVE\b/.test(stderr)) {
|
|
1674
|
-
return true;
|
|
1675
|
-
}
|
|
1676
|
-
const lowerStderr = stderr.toLowerCase();
|
|
1677
|
-
return (lowerStderr.includes('unable to resolve dependency tree') ||
|
|
1678
|
-
lowerStderr.includes('could not resolve dependency') ||
|
|
1679
|
-
lowerStderr.includes('conflicting peer dependency'));
|
|
1680
|
-
}
|
|
1681
|
-
function logNpmPeerDepsError(phase) {
|
|
1682
|
-
const peerDepsResolutionSteps = [
|
|
1683
|
-
'Recommended approaches (in order of preference):',
|
|
1684
|
-
'',
|
|
1685
|
-
'1. Use "overrides" in package.json to force compatible versions across the dependency tree.',
|
|
1686
|
-
' See https://docs.npmjs.com/cli/configuring-npm/package-json#overrides',
|
|
1687
|
-
'2. Persist legacy peer deps resolution in the project ".npmrc":',
|
|
1688
|
-
' npm config set legacy-peer-deps=true --location=project',
|
|
1689
|
-
' (bypasses peer dependency resolution; use with caution)',
|
|
1690
|
-
'3. As a last resort, force the installation by running "npm install --force".',
|
|
1691
|
-
' (does not persist and may produce broken installs)',
|
|
1692
|
-
];
|
|
1693
|
-
const manualInstallHint = [
|
|
1694
|
-
'If you installed the dependencies manually, pass "--skip-install" to avoid re-installing them:',
|
|
1695
|
-
' nx migrate --run-migrations --skip-install',
|
|
1696
|
-
];
|
|
1697
|
-
if (phase === 'pre-migration') {
|
|
1698
|
-
output_1.output.error({
|
|
1699
|
-
title: 'You need to resolve the peer dependency conflicts before the migration can continue',
|
|
1700
|
-
bodyLines: [
|
|
1701
|
-
...peerDepsResolutionSteps,
|
|
1702
|
-
'',
|
|
1703
|
-
'Once the conflicts are resolved, re-run the migrations:',
|
|
1704
|
-
' nx migrate --run-migrations',
|
|
1705
|
-
'',
|
|
1706
|
-
...manualInstallHint,
|
|
1707
|
-
],
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
else {
|
|
1711
|
-
output_1.output.error({
|
|
1712
|
-
title: 'Some migrations have been applied, but installing the updated dependencies failed',
|
|
1713
|
-
bodyLines: [
|
|
1714
|
-
...peerDepsResolutionSteps,
|
|
1715
|
-
'',
|
|
1716
|
-
'Once the conflicts are resolved, run "npm install" to install the updated dependencies.',
|
|
1717
|
-
'If the migration was interrupted before completing, re-run the remaining migrations:',
|
|
1718
|
-
' nx migrate --run-migrations',
|
|
1719
|
-
'',
|
|
1720
|
-
...manualInstallHint,
|
|
1721
|
-
],
|
|
1722
|
-
});
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
1581
|
function resolveAgenticRunId(migrations) {
|
|
1726
1582
|
return (0, semver_1.rsort)(migrations.map((m) => (0, version_utils_1.normalizeVersion)(m.version)))[0];
|
|
1727
1583
|
}
|
|
@@ -1823,7 +1679,7 @@ function resolveShouldRunValidation(args) {
|
|
|
1823
1679
|
return args.validate !== false && args.agenticKind === 'enabled';
|
|
1824
1680
|
}
|
|
1825
1681
|
async function executeMigrations(root, migrations, isVerbose, shouldCreateCommits, commitPrefix, shouldSkipInstall = false, agentic, agenticHasDiffContext = false, shouldRunValidation = false) {
|
|
1826
|
-
const changedDepInstaller = new ChangedDepInstaller(root, shouldSkipInstall);
|
|
1682
|
+
const changedDepInstaller = new execute_migration_1.ChangedDepInstaller(root, shouldSkipInstall);
|
|
1827
1683
|
const migrationsWithNoChanges = [];
|
|
1828
1684
|
const sortedMigrations = migrations.sort((a, b) => {
|
|
1829
1685
|
// Under `--agentic`, hoist the v23 migration that ignores
|
|
@@ -1983,7 +1839,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
1983
1839
|
}
|
|
1984
1840
|
}
|
|
1985
1841
|
else if ((0, migration_shape_1.isHybridMigration)(m)) {
|
|
1986
|
-
const { changes, nextSteps, agentContext, logs, madeChanges } = await runNxOrAngularMigration(root, m, isVerbose,
|
|
1842
|
+
const { changes, nextSteps, agentContext, logs, madeChanges } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
|
|
1987
1843
|
/* captureGeneratorOutput: */ !!agenticRun, resolvedCollection);
|
|
1988
1844
|
migrationEmittedNextSteps.push(...nextSteps);
|
|
1989
1845
|
if (agenticRun) {
|
|
@@ -2047,7 +1903,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
2047
1903
|
// Defer commit until validation succeeds; failed validation leaves
|
|
2048
1904
|
// changes uncommitted in the working tree for the user to review.
|
|
2049
1905
|
const validationRun = agenticRun && shouldRunValidation ? agenticRun : undefined;
|
|
2050
|
-
const { changes, nextSteps, agentContext, logs, madeChanges } = await runNxOrAngularMigration(root, m, isVerbose,
|
|
1906
|
+
const { changes, nextSteps, agentContext, logs, madeChanges } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
|
|
2051
1907
|
/* captureGeneratorOutput: */ !!validationRun, resolvedCollection);
|
|
2052
1908
|
migrationEmittedNextSteps.push(...nextSteps);
|
|
2053
1909
|
const canRunValidation = !!validationRun && changes.length > 0;
|
|
@@ -2124,7 +1980,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
2124
1980
|
// `nx repair` reuses executeMigrations; only record for migrate runs.
|
|
2125
1981
|
if ((0, migrate_analytics_1.hasMigrateRunStarted)()) {
|
|
2126
1982
|
(0, migrate_analytics_1.reportMigrateRunError)({
|
|
2127
|
-
code: e instanceof NpmPeerDepsInstallError
|
|
1983
|
+
code: e instanceof execute_migration_1.NpmPeerDepsInstallError
|
|
2128
1984
|
? 'npm_install'
|
|
2129
1985
|
: inAgenticStep
|
|
2130
1986
|
? 'agentic'
|
|
@@ -2135,7 +1991,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
2135
1991
|
error: e,
|
|
2136
1992
|
});
|
|
2137
1993
|
}
|
|
2138
|
-
if (!(e instanceof NpmPeerDepsInstallError)) {
|
|
1994
|
+
if (!(e instanceof execute_migration_1.NpmPeerDepsInstallError)) {
|
|
2139
1995
|
// `withGeneratorOutputCapture` attaches the generator's `console.*`
|
|
2140
1996
|
// output as `capturedLogs` (best-effort; may be absent). Surface it
|
|
2141
1997
|
// so the user sees what the generator printed before it crashed.
|
|
@@ -2189,30 +2045,6 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
|
2189
2045
|
retainedAtSuccess: (0, migrate_output_1.retainedMigrations)(outcomes).map((p) => `${p.package}: ${p.name}`),
|
|
2190
2046
|
};
|
|
2191
2047
|
}
|
|
2192
|
-
class ChangedDepInstaller {
|
|
2193
|
-
constructor(root, shouldSkipInstall = false) {
|
|
2194
|
-
this.root = root;
|
|
2195
|
-
this.shouldSkipInstall = shouldSkipInstall;
|
|
2196
|
-
this._skippedInstall = false;
|
|
2197
|
-
this.initialDeps = getStringifiedPackageJsonDeps(root);
|
|
2198
|
-
}
|
|
2199
|
-
get skippedInstall() {
|
|
2200
|
-
return this._skippedInstall;
|
|
2201
|
-
}
|
|
2202
|
-
async installDepsIfChanged() {
|
|
2203
|
-
const currentDeps = getStringifiedPackageJsonDeps(this.root);
|
|
2204
|
-
if (this.initialDeps !== currentDeps) {
|
|
2205
|
-
if (this.shouldSkipInstall) {
|
|
2206
|
-
this._skippedInstall = true;
|
|
2207
|
-
}
|
|
2208
|
-
else {
|
|
2209
|
-
await runInstall(this.root, 'post-migration');
|
|
2210
|
-
}
|
|
2211
|
-
}
|
|
2212
|
-
this.initialDeps = currentDeps;
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
exports.ChangedDepInstaller = ChangedDepInstaller;
|
|
2216
2048
|
function logSkippedPostMigrationInstall(root) {
|
|
2217
2049
|
const packageManager = (0, package_manager_1.detectPackageManager)(root);
|
|
2218
2050
|
const installCommand = (0, package_manager_1.getPackageManagerCommand)(packageManager, root).install;
|
|
@@ -2221,58 +2053,9 @@ function logSkippedPostMigrationInstall(root) {
|
|
|
2221
2053
|
bodyLines: [`Run "${installCommand}" to install the updated dependencies.`],
|
|
2222
2054
|
});
|
|
2223
2055
|
}
|
|
2224
|
-
async function runNxOrAngularMigration(root, migration, isVerbose, captureGeneratorOutput = false, resolvedCollection) {
|
|
2225
|
-
const { collection, collectionPath } = resolvedCollection ?? readMigrationCollection(migration.package, root);
|
|
2226
|
-
let changes = [];
|
|
2227
|
-
let nextSteps = [];
|
|
2228
|
-
let agentContext = [];
|
|
2229
|
-
let logs = '';
|
|
2230
|
-
// Angular's `ngResult.changes` is synthesized from the schematic's
|
|
2231
|
-
// DryRunEvent stream so Nx and Angular paths can share commit/validation
|
|
2232
|
-
// gating via `changes.length > 0`.
|
|
2233
|
-
let madeChanges = false;
|
|
2234
|
-
logger_1.logger.info(pc.dim('→ Running generator…'));
|
|
2235
|
-
if (!isAngularMigration(collection, migration.name)) {
|
|
2236
|
-
({ nextSteps, changes, agentContext, logs } = await runNxMigration(root, collectionPath, collection, migration.name, migration.version, captureGeneratorOutput));
|
|
2237
|
-
madeChanges = changes.length > 0;
|
|
2238
|
-
logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
|
|
2239
|
-
if (migration.description) {
|
|
2240
|
-
logger_1.logger.info(` ${migration.description}`);
|
|
2241
|
-
}
|
|
2242
|
-
logger_1.logger.info('');
|
|
2243
|
-
if (!madeChanges) {
|
|
2244
|
-
logger_1.logger.info(`No changes were made\n`);
|
|
2245
|
-
return { changes, nextSteps, agentContext, logs, madeChanges };
|
|
2246
|
-
}
|
|
2247
|
-
logger_1.logger.info('Changes:');
|
|
2248
|
-
(0, tree_1.printChanges)(changes, ' ');
|
|
2249
|
-
logger_1.logger.info('');
|
|
2250
|
-
}
|
|
2251
|
-
else {
|
|
2252
|
-
const ngCliAdapter = await getNgCompatLayer();
|
|
2253
|
-
const migrationProjectGraph = await (0, project_graph_1.createProjectGraphAsync)();
|
|
2254
|
-
const ngResult = await ngCliAdapter.runMigration(root, migration.package, migration.name, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(migrationProjectGraph).projects, isVerbose, migrationProjectGraph);
|
|
2255
|
-
changes = ngResult.changes;
|
|
2256
|
-
madeChanges = ngResult.madeChanges;
|
|
2257
|
-
logs = ngResult.loggingQueue.join('\n');
|
|
2258
|
-
logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
|
|
2259
|
-
if (migration.description) {
|
|
2260
|
-
logger_1.logger.info(` ${migration.description}`);
|
|
2261
|
-
}
|
|
2262
|
-
logger_1.logger.info('');
|
|
2263
|
-
if (!madeChanges) {
|
|
2264
|
-
logger_1.logger.info(`No changes were made\n`);
|
|
2265
|
-
return { changes, nextSteps, agentContext, logs, madeChanges };
|
|
2266
|
-
}
|
|
2267
|
-
logger_1.logger.info('Changes:');
|
|
2268
|
-
ngResult.loggingQueue.forEach((log) => logger_1.logger.info(' ' + log));
|
|
2269
|
-
logger_1.logger.info('');
|
|
2270
|
-
}
|
|
2271
|
-
return { changes, nextSteps, agentContext, logs, madeChanges };
|
|
2272
|
-
}
|
|
2273
2056
|
async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits, commitPrefix, shouldSkipInstall = false) {
|
|
2274
2057
|
if (!shouldSkipInstall && !process.env.NX_MIGRATE_SKIP_INSTALL) {
|
|
2275
|
-
await runInstall();
|
|
2058
|
+
await (0, execute_migration_1.runInstall)();
|
|
2276
2059
|
}
|
|
2277
2060
|
if (!__dirname.startsWith(workspace_root_1.workspaceRoot)) {
|
|
2278
2061
|
// we are running from a temp installation with nx latest, switch to running
|
|
@@ -2464,59 +2247,6 @@ async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits, c
|
|
|
2464
2247
|
appliedCount,
|
|
2465
2248
|
});
|
|
2466
2249
|
}
|
|
2467
|
-
function getStringifiedPackageJsonDeps(root) {
|
|
2468
|
-
try {
|
|
2469
|
-
const { dependencies, devDependencies } = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
|
|
2470
|
-
return JSON.stringify([dependencies, devDependencies]);
|
|
2471
|
-
}
|
|
2472
|
-
catch {
|
|
2473
|
-
// We don't really care if the .nx/installation property changes,
|
|
2474
|
-
// whenever nxw is invoked it will handle the dep updates.
|
|
2475
|
-
return '';
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
async function runNxMigration(root, collectionPath, collection, name, migrationVersion, captureGeneratorOutput) {
|
|
2479
|
-
const { path: implPath, fnSymbol } = getImplementationPath(collection, collectionPath, name, migrationVersion);
|
|
2480
|
-
const fn = require(implPath)[fnSymbol];
|
|
2481
|
-
const host = new tree_1.FsTree(root, process.env.NX_VERBOSE_LOGGING === 'true', `migration ${collection.name}:${name}`);
|
|
2482
|
-
let result;
|
|
2483
|
-
let logs = '';
|
|
2484
|
-
if (captureGeneratorOutput) {
|
|
2485
|
-
const { withGeneratorOutputCapture } = require('./agentic/capture-generator-output');
|
|
2486
|
-
({ result, logs } = await withGeneratorOutputCapture(() => fn(host, {})));
|
|
2487
|
-
}
|
|
2488
|
-
else {
|
|
2489
|
-
result = await fn(host, {});
|
|
2490
|
-
}
|
|
2491
|
-
const { nextSteps, agentContext } = parseMigrationReturn(result);
|
|
2492
|
-
host.lock();
|
|
2493
|
-
const changes = host.listChanges();
|
|
2494
|
-
(0, tree_1.flushChanges)(root, changes);
|
|
2495
|
-
return { changes, nextSteps, agentContext, logs };
|
|
2496
|
-
}
|
|
2497
|
-
function parseMigrationReturn(value) {
|
|
2498
|
-
if (Array.isArray(value)) {
|
|
2499
|
-
return { nextSteps: filterStrings(value), agentContext: [] };
|
|
2500
|
-
}
|
|
2501
|
-
if (value && typeof value === 'object') {
|
|
2502
|
-
const obj = value;
|
|
2503
|
-
return {
|
|
2504
|
-
nextSteps: filterStrings(obj.nextSteps),
|
|
2505
|
-
agentContext: filterStrings(obj.agentContext),
|
|
2506
|
-
};
|
|
2507
|
-
}
|
|
2508
|
-
// Catches `void`, mistakenly-returned generator callbacks, malformed values.
|
|
2509
|
-
return { nextSteps: [], agentContext: [] };
|
|
2510
|
-
}
|
|
2511
|
-
// Bucket-level tolerance: a single non-string entry shouldn't discard the
|
|
2512
|
-
// whole `nextSteps` / `agentContext` array. Migration authors occasionally
|
|
2513
|
-
// push `null` / `undefined` / a number into the array; we drop the bad entries
|
|
2514
|
-
// and keep the rest so end-of-run guidance isn't silently lost.
|
|
2515
|
-
function filterStrings(value) {
|
|
2516
|
-
if (!Array.isArray(value))
|
|
2517
|
-
return [];
|
|
2518
|
-
return value.filter((v) => typeof v === 'string');
|
|
2519
|
-
}
|
|
2520
2250
|
async function migrate(root, args, rawArgs) {
|
|
2521
2251
|
await client_1.daemonClient.stop();
|
|
2522
2252
|
return (0, handle_errors_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
|
@@ -2550,7 +2280,7 @@ async function migrate(root, args, rawArgs) {
|
|
|
2550
2280
|
// The remediation guidance is already logged by `runInstall`; swallow
|
|
2551
2281
|
// the error here so `handleErrors` doesn't print a noisy stack after
|
|
2552
2282
|
// the friendly output.
|
|
2553
|
-
if (e instanceof NpmPeerDepsInstallError) {
|
|
2283
|
+
if (e instanceof execute_migration_1.NpmPeerDepsInstallError) {
|
|
2554
2284
|
(0, migrate_analytics_1.reportMigrateRunError)({ code: 'npm_install', error: e });
|
|
2555
2285
|
return 1;
|
|
2556
2286
|
}
|
|
@@ -2577,6 +2307,10 @@ async function runMigration() {
|
|
|
2577
2307
|
process.env.npm_config_registry.match(/^https:\/\/registry\.(npmjs\.org|yarnpkg\.com)/)) {
|
|
2578
2308
|
delete process.env.npm_config_registry;
|
|
2579
2309
|
}
|
|
2310
|
+
// Intentionally not runNxSync: `p` is an nx CLI freshly installed into a
|
|
2311
|
+
// temp dir by nxCliPath() (latest, or NX_MIGRATE_CLI_VERSION), so
|
|
2312
|
+
// migrations run with an up-to-date migrate implementation instead of
|
|
2313
|
+
// the workspace's current nx.
|
|
2580
2314
|
return runOrReturnExitCode(() => (0, child_process_1.execSync)(`${p} _migrate ${process.argv.slice(3).join(' ')}`, {
|
|
2581
2315
|
stdio: ['inherit', 'inherit', 'inherit'],
|
|
2582
2316
|
windowsHide: true,
|
|
@@ -2585,39 +2319,6 @@ async function runMigration() {
|
|
|
2585
2319
|
return runLocalMigrate();
|
|
2586
2320
|
});
|
|
2587
2321
|
}
|
|
2588
|
-
function readMigrationCollection(packageName, root) {
|
|
2589
|
-
const collectionPath = readPackageMigrationConfig(packageName, root).migrations;
|
|
2590
|
-
const collection = (0, fileutils_1.readJsonFile)(collectionPath);
|
|
2591
|
-
collection.name ??= packageName;
|
|
2592
|
-
return {
|
|
2593
|
-
collection,
|
|
2594
|
-
collectionPath,
|
|
2595
|
-
};
|
|
2596
|
-
}
|
|
2597
|
-
function getImplementationPath(collection, collectionPath, name, migrationVersion) {
|
|
2598
|
-
const g = collection.generators?.[name] || collection.schematics?.[name];
|
|
2599
|
-
if (!g) {
|
|
2600
|
-
throw new MigrationImplementationMissingError(`Unable to determine implementation path for "${collectionPath}:${name}"`, collectionPath, migrationVersion);
|
|
2601
|
-
}
|
|
2602
|
-
const implRelativePathAndMaybeSymbol = g.implementation || g.factory;
|
|
2603
|
-
const [implRelativePath, fnSymbol = 'default'] = implRelativePathAndMaybeSymbol.split('#');
|
|
2604
|
-
let implPath;
|
|
2605
|
-
try {
|
|
2606
|
-
implPath = require.resolve(implRelativePath, {
|
|
2607
|
-
paths: [(0, path_1.dirname)(collectionPath)],
|
|
2608
|
-
});
|
|
2609
|
-
}
|
|
2610
|
-
catch (e) {
|
|
2611
|
-
try {
|
|
2612
|
-
// workaround for a bug in node 12
|
|
2613
|
-
implPath = require.resolve(`${(0, path_1.dirname)(collectionPath)}/${implRelativePath}`);
|
|
2614
|
-
}
|
|
2615
|
-
catch {
|
|
2616
|
-
throw new MigrationImplementationMissingError(`Could not resolve implementation for migration "${name}" from "${collectionPath}"`, collectionPath, migrationVersion ?? g.version);
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
return { path: implPath, fnSymbol };
|
|
2620
|
-
}
|
|
2621
2322
|
/**
|
|
2622
2323
|
* Resolves a migration's collection once and derives everything the run loop
|
|
2623
2324
|
* needs from that single read: the implementation context (`collection` +
|
|
@@ -2636,11 +2337,11 @@ function getImplementationPath(collection, collectionPath, name, migrationVersio
|
|
|
2636
2337
|
function resolveMigrationForRun(root, migration, resolveDocumentation) {
|
|
2637
2338
|
let resolvedCollection;
|
|
2638
2339
|
if (!(0, migration_shape_1.isPromptOnlyMigration)(migration)) {
|
|
2639
|
-
resolvedCollection = readMigrationCollection(migration.package, root);
|
|
2340
|
+
resolvedCollection = (0, execute_migration_1.readMigrationCollection)(migration.package, root);
|
|
2640
2341
|
}
|
|
2641
2342
|
else if (resolveDocumentation && migration.documentation) {
|
|
2642
2343
|
try {
|
|
2643
|
-
resolvedCollection = readMigrationCollection(migration.package, root);
|
|
2344
|
+
resolvedCollection = (0, execute_migration_1.readMigrationCollection)(migration.package, root);
|
|
2644
2345
|
}
|
|
2645
2346
|
catch {
|
|
2646
2347
|
// Non-fatal: documentation is supplementary; the warning below fires.
|
|
@@ -2675,52 +2376,6 @@ function resolveDocumentationFileToWorkspacePath(root, migrationsDir, documentat
|
|
|
2675
2376
|
const relativePath = (0, path_1.relative)(root, documentationFile);
|
|
2676
2377
|
return relativePath.startsWith('..') ? documentationFile : relativePath;
|
|
2677
2378
|
}
|
|
2678
|
-
class MigrationImplementationMissingError extends Error {
|
|
2679
|
-
constructor(baseMessage, collectionPath, migrationVersion) {
|
|
2680
|
-
super(buildMigrationMissingMessage(baseMessage, collectionPath, migrationVersion));
|
|
2681
|
-
this.name = 'MigrationImplementationMissingError';
|
|
2682
|
-
}
|
|
2683
|
-
}
|
|
2684
|
-
function buildMigrationMissingMessage(baseMessage, collectionPath, migrationVersion) {
|
|
2685
|
-
if (!migrationVersion) {
|
|
2686
|
-
return baseMessage;
|
|
2687
|
-
}
|
|
2688
|
-
try {
|
|
2689
|
-
const packageJsonPath = (0, path_1.join)((0, path_1.dirname)(collectionPath), 'package.json');
|
|
2690
|
-
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
2691
|
-
return baseMessage;
|
|
2692
|
-
}
|
|
2693
|
-
const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
2694
|
-
const installedVersion = packageJson.version;
|
|
2695
|
-
if (installedVersion &&
|
|
2696
|
-
(0, semver_1.lt)((0, version_utils_1.normalizeVersion)(installedVersion), (0, version_utils_1.normalizeVersion)(migrationVersion))) {
|
|
2697
|
-
const packageManager = (0, package_manager_1.detectPackageManager)();
|
|
2698
|
-
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
2699
|
-
const overrideFieldName = getOverrideFieldName(packageManager);
|
|
2700
|
-
return (`${baseMessage}\n\n` +
|
|
2701
|
-
`The installed version of "${packageJson.name}" is ${installedVersion}, ` +
|
|
2702
|
-
`but this migration requires version ${migrationVersion}. ` +
|
|
2703
|
-
`This likely means the package version is being held back by an ${overrideFieldName} ` +
|
|
2704
|
-
`in your package.json. ` +
|
|
2705
|
-
`Remove the ${overrideFieldName} and run "${pmc.install}" to install the correct version.`);
|
|
2706
|
-
}
|
|
2707
|
-
}
|
|
2708
|
-
catch {
|
|
2709
|
-
// Fall through to return the base message if we can't read package info
|
|
2710
|
-
}
|
|
2711
|
-
return baseMessage;
|
|
2712
|
-
}
|
|
2713
|
-
function getOverrideFieldName(packageManager) {
|
|
2714
|
-
switch (packageManager) {
|
|
2715
|
-
case 'pnpm':
|
|
2716
|
-
return '"pnpm.overrides"';
|
|
2717
|
-
case 'yarn':
|
|
2718
|
-
return '"resolutions"';
|
|
2719
|
-
case 'npm':
|
|
2720
|
-
case 'bun':
|
|
2721
|
-
return '"overrides"';
|
|
2722
|
-
}
|
|
2723
|
-
}
|
|
2724
2379
|
async function nxCliPath(nxWorkspaceRoot) {
|
|
2725
2380
|
const version = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
|
|
2726
2381
|
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
|
@@ -2790,16 +2445,3 @@ function addToNodePath(dir) {
|
|
|
2790
2445
|
// Update the env variable.
|
|
2791
2446
|
process.env.NODE_PATH = paths.join(delimiter);
|
|
2792
2447
|
}
|
|
2793
|
-
function isAngularMigration(collection, name) {
|
|
2794
|
-
return !collection.generators?.[name] && collection.schematics?.[name];
|
|
2795
|
-
}
|
|
2796
|
-
const getNgCompatLayer = (() => {
|
|
2797
|
-
let _ngCliAdapter;
|
|
2798
|
-
return async function getNgCompatLayer() {
|
|
2799
|
-
if (!_ngCliAdapter) {
|
|
2800
|
-
_ngCliAdapter = await (0, handle_import_1.handleImport)('../../adapter/ngcli-adapter.js', __dirname);
|
|
2801
|
-
require('../../adapter/compat');
|
|
2802
|
-
}
|
|
2803
|
-
return _ngCliAdapter;
|
|
2804
|
-
};
|
|
2805
|
-
})();
|
|
@@ -39,6 +39,8 @@ async function viewLogs() {
|
|
|
39
39
|
return 1;
|
|
40
40
|
}
|
|
41
41
|
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
|
42
|
+
// Intentionally not runNxSync: this invokes the separate `nx-cloud` binary,
|
|
43
|
+
// not the nx CLI that runNxSync resolves.
|
|
42
44
|
(0, child_process_1.execSync)(`${pmc.exec} nx-cloud upload-and-show-run-details`, {
|
|
43
45
|
stdio: [0, 1, 2],
|
|
44
46
|
windowsHide: true,
|
|
@@ -86,8 +86,8 @@ export declare class ReleaseGraph {
|
|
|
86
86
|
source: string;
|
|
87
87
|
target: string;
|
|
88
88
|
type: string;
|
|
89
|
-
dependencyCollection: string;
|
|
90
|
-
rawVersionSpec: string;
|
|
89
|
+
dependencyCollection: string | null;
|
|
90
|
+
rawVersionSpec: string | null;
|
|
91
91
|
}[]>;
|
|
92
92
|
readonly releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>;
|
|
93
93
|
private originalFilteredProjects;
|
|
@@ -24,8 +24,8 @@ export interface VersionDataEntry {
|
|
|
24
24
|
source: string;
|
|
25
25
|
target: string;
|
|
26
26
|
type: string;
|
|
27
|
-
dependencyCollection: string;
|
|
28
|
-
rawVersionSpec: string;
|
|
27
|
+
dependencyCollection: string | null;
|
|
28
|
+
rawVersionSpec: string | null;
|
|
29
29
|
}[];
|
|
30
30
|
}
|
|
31
31
|
export declare function isPrerelease(version: string): boolean;
|