nx 21.0.0-beta.1 → 21.0.0-beta.11
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/.eslintrc.json +5 -1
- package/migrations.json +15 -35
- package/package.json +12 -12
- package/release/index.d.ts +1 -1
- package/release/index.js +2 -1
- package/schemas/nx-schema.json +187 -35
- package/schemas/project-schema.json +5 -0
- package/src/adapter/angular-json.js +11 -0
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +3 -0
- package/src/command-line/add/add.js +6 -16
- package/src/command-line/affected/command-object.js +6 -6
- package/src/command-line/examples.js +0 -4
- package/src/command-line/exec/command-object.js +1 -1
- package/src/command-line/generate/generator-utils.js +8 -3
- package/src/command-line/import/import.js +1 -1
- package/src/command-line/init/command-object.js +18 -6
- package/src/command-line/init/configure-plugins.d.ts +6 -7
- package/src/command-line/init/configure-plugins.js +52 -38
- package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
- package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
- package/src/command-line/init/implementation/check-compatible-with-plugins.js +7 -1
- package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
- package/src/command-line/init/implementation/deduce-default-base.js +53 -0
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +6 -4
- package/src/command-line/init/implementation/react/index.d.ts +1 -1
- package/src/command-line/init/implementation/react/index.js +32 -185
- package/src/command-line/init/implementation/react/write-vite-config.js +19 -3
- package/src/command-line/init/implementation/utils.d.ts +6 -2
- package/src/command-line/init/implementation/utils.js +110 -45
- package/src/command-line/init/init-v1.js +1 -1
- package/src/command-line/init/init-v2.d.ts +1 -0
- package/src/command-line/init/init-v2.js +70 -39
- package/src/command-line/migrate/migrate-ui-api.d.ts +58 -0
- package/src/command-line/migrate/migrate-ui-api.js +227 -0
- package/src/command-line/migrate/migrate.d.ts +23 -4
- package/src/command-line/migrate/migrate.js +138 -86
- package/src/command-line/nx-commands.js +19 -5
- package/src/command-line/register/command-object.d.ts +6 -0
- package/src/command-line/{activate-powerpack → register}/command-object.js +9 -9
- package/src/command-line/register/register.d.ts +2 -0
- package/src/command-line/register/register.js +9 -0
- package/src/command-line/release/changelog.js +18 -15
- package/src/command-line/release/command-object.d.ts +8 -0
- package/src/command-line/release/command-object.js +9 -0
- package/src/command-line/release/config/config.d.ts +8 -7
- package/src/command-line/release/config/config.js +139 -45
- package/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
- package/src/command-line/release/config/use-legacy-versioning.js +9 -0
- package/src/command-line/release/index.d.ts +4 -0
- package/src/command-line/release/index.js +6 -1
- package/src/command-line/release/plan-check.js +6 -3
- package/src/command-line/release/plan.js +7 -3
- package/src/command-line/release/publish.js +7 -3
- package/src/command-line/release/release.js +8 -3
- package/src/command-line/release/utils/batch-projects-by-generator-config.js +6 -3
- package/src/command-line/release/utils/git.d.ts +3 -2
- package/src/command-line/release/utils/git.js +65 -9
- package/src/command-line/release/utils/github.js +3 -1
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
- package/src/command-line/release/utils/resolve-semver-specifier.js +2 -1
- package/src/command-line/release/utils/semver.d.ts +8 -0
- package/src/command-line/release/utils/semver.js +8 -0
- package/src/command-line/release/utils/shared-legacy.d.ts +25 -0
- package/src/command-line/release/utils/shared-legacy.js +2 -0
- package/src/command-line/release/utils/shared.d.ts +11 -17
- package/src/command-line/release/version/derive-specifier-from-conventional-commits.d.ts +7 -0
- package/src/command-line/release/version/derive-specifier-from-conventional-commits.js +47 -0
- package/src/command-line/release/version/deriver-specifier-from-version-plans.d.ts +8 -0
- package/src/command-line/release/version/deriver-specifier-from-version-plans.js +59 -0
- package/src/command-line/release/version/project-logger.d.ts +8 -0
- package/src/command-line/release/version/project-logger.js +45 -0
- package/src/command-line/release/version/release-group-processor.d.ts +252 -0
- package/src/command-line/release/version/release-group-processor.js +1057 -0
- package/src/command-line/release/version/resolve-current-version.d.ts +32 -0
- package/src/command-line/release/version/resolve-current-version.js +241 -0
- package/src/command-line/release/version/test-utils.d.ts +93 -0
- package/src/command-line/release/version/test-utils.js +415 -0
- package/src/command-line/release/version/topological-sort.d.ts +9 -0
- package/src/command-line/release/version/topological-sort.js +41 -0
- package/src/command-line/release/version/version-actions.d.ts +171 -0
- package/src/command-line/release/version/version-actions.js +195 -0
- package/src/command-line/release/version-legacy.d.ts +46 -0
- package/src/command-line/release/version-legacy.js +453 -0
- package/src/command-line/release/version.d.ts +0 -40
- package/src/command-line/release/version.js +84 -262
- package/src/command-line/repair/repair.js +8 -3
- package/src/command-line/report/report.d.ts +7 -3
- package/src/command-line/report/report.js +52 -18
- package/src/command-line/run/command-object.js +2 -2
- package/src/command-line/run/executor-utils.d.ts +6 -1
- package/src/command-line/run/executor-utils.js +10 -1
- package/src/command-line/run/run.js +2 -2
- package/src/command-line/run-many/command-object.js +2 -2
- package/src/command-line/yargs-utils/shared-options.d.ts +4 -0
- package/src/command-line/yargs-utils/shared-options.js +20 -0
- package/src/config/misc-interfaces.d.ts +20 -2
- package/src/config/nx-json.d.ts +158 -18
- package/src/config/project-graph.d.ts +4 -2
- package/src/config/project-graph.js +8 -0
- package/src/config/workspace-json-project-json.d.ts +2 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.css +2 -2
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.d.ts +2 -0
- package/src/daemon/client/client.js +15 -0
- package/src/daemon/message-types/glob.d.ts +7 -0
- package/src/daemon/message-types/glob.js +9 -1
- package/src/daemon/message-types/hash-glob.d.ts +6 -0
- package/src/daemon/message-types/hash-glob.js +9 -1
- package/src/daemon/server/handle-glob.d.ts +1 -0
- package/src/daemon/server/handle-glob.js +8 -0
- package/src/daemon/server/handle-hash-glob.d.ts +1 -0
- package/src/daemon/server/handle-hash-glob.js +8 -0
- package/src/daemon/server/logger.js +2 -1
- package/src/daemon/server/server.js +7 -0
- package/src/devkit-exports.d.ts +1 -1
- package/src/devkit-internals.d.ts +3 -2
- package/src/devkit-internals.js +5 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +2 -5
- package/src/executors/run-commands/run-commands.impl.js +14 -42
- package/src/executors/run-commands/running-tasks.d.ts +9 -4
- package/src/executors/run-commands/running-tasks.js +103 -30
- package/src/executors/run-script/run-script.impl.js +4 -3
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +8 -0
- package/src/generators/testing-utils/create-tree.js +5 -1
- package/src/migrations/update-21-0-0/release-version-config-changes.d.ts +2 -0
- package/src/migrations/update-21-0-0/release-version-config-changes.js +111 -0
- package/src/migrations/update-21-0-0/remove-custom-tasks-runner.d.ts +2 -0
- package/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +38 -0
- package/src/migrations/{update-18-0-0/disable-crystal-for-existing-workspaces.js → update-21-0-0/remove-legacy-cache.js} +10 -4
- package/src/native/index.d.ts +98 -19
- package/src/native/index.js +16 -2
- package/src/native/native-bindings.js +7 -0
- package/src/native/nx.wasi-browser.js +20 -19
- package/src/native/nx.wasi.cjs +20 -19
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +3 -3
- package/src/plugins/js/index.d.ts +2 -1
- package/src/plugins/js/index.js +8 -1
- package/src/plugins/js/lock-file/lock-file.js +28 -13
- package/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
- package/src/plugins/js/lock-file/utils/package-json.js +8 -6
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
- package/src/plugins/js/lock-file/yarn-parser.js +85 -39
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +10 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +59 -6
- package/src/plugins/js/utils/packages.js +22 -3
- package/src/plugins/js/utils/register.js +1 -0
- package/src/plugins/js/utils/typescript.js +3 -3
- package/src/plugins/package-json/create-nodes.d.ts +1 -1
- package/src/plugins/package-json/create-nodes.js +4 -2
- package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
- package/src/project-graph/error-types.js +32 -2
- package/src/project-graph/file-utils.d.ts +1 -10
- package/src/project-graph/file-utils.js +2 -77
- package/src/project-graph/plugins/get-plugins.js +2 -1
- package/src/project-graph/plugins/in-process-loader.js +1 -1
- package/src/project-graph/plugins/isolation/plugin-worker.js +12 -6
- package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
- package/src/project-graph/plugins/loaded-nx-plugin.js +1 -5
- package/src/project-graph/plugins/public-api.d.ts +1 -1
- package/src/project-graph/plugins/utils.d.ts +2 -2
- package/src/project-graph/plugins/utils.js +2 -2
- package/src/project-graph/project-graph.js +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +3 -3
- package/src/project-graph/utils/project-configuration-utils.js +54 -21
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
- package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
- package/src/tasks-runner/batch/batch-messages.d.ts +2 -0
- package/src/tasks-runner/batch/run-batch.js +4 -5
- package/src/tasks-runner/cache.d.ts +21 -8
- package/src/tasks-runner/cache.js +106 -38
- package/src/tasks-runner/create-task-graph.d.ts +0 -1
- package/src/tasks-runner/create-task-graph.js +11 -11
- package/src/tasks-runner/default-tasks-runner.js +5 -14
- package/src/tasks-runner/forked-process-task-runner.d.ts +8 -3
- package/src/tasks-runner/forked-process-task-runner.js +59 -46
- package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
- package/src/tasks-runner/init-tasks-runner.js +62 -2
- package/src/tasks-runner/is-tui-enabled.d.ts +2 -0
- package/src/tasks-runner/is-tui-enabled.js +64 -0
- package/src/tasks-runner/life-cycle.d.ts +14 -3
- package/src/tasks-runner/life-cycle.js +37 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +2 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +15 -7
- package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +5 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +35 -5
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +18 -0
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +230 -0
- package/src/tasks-runner/pseudo-terminal.d.ts +11 -7
- package/src/tasks-runner/pseudo-terminal.js +47 -35
- package/src/tasks-runner/run-command.d.ts +4 -1
- package/src/tasks-runner/run-command.js +219 -63
- package/src/tasks-runner/running-tasks/node-child-process.js +4 -11
- package/src/tasks-runner/running-tasks/running-task.d.ts +3 -0
- package/src/tasks-runner/running-tasks/shared-running-task.d.ts +14 -0
- package/src/tasks-runner/running-tasks/shared-running-task.js +30 -0
- package/src/tasks-runner/task-env.d.ts +1 -4
- package/src/tasks-runner/task-env.js +2 -0
- package/src/tasks-runner/task-graph-utils.d.ts +3 -0
- package/src/tasks-runner/task-graph-utils.js +31 -2
- package/src/tasks-runner/task-orchestrator.d.ts +26 -10
- package/src/tasks-runner/task-orchestrator.js +221 -57
- package/src/tasks-runner/tasks-runner.d.ts +1 -0
- package/src/tasks-runner/tasks-schedule.d.ts +1 -0
- package/src/tasks-runner/tasks-schedule.js +9 -0
- package/src/tasks-runner/utils.d.ts +2 -2
- package/src/tasks-runner/utils.js +18 -12
- package/src/utils/child-process.d.ts +4 -0
- package/src/utils/child-process.js +23 -30
- package/src/utils/command-line-utils.d.ts +1 -1
- package/src/utils/find-matching-projects.js +2 -2
- package/src/utils/git-utils.d.ts +1 -1
- package/src/utils/git-utils.js +8 -3
- package/src/utils/handle-errors.js +15 -0
- package/src/utils/is-ci.js +4 -1
- package/src/utils/is-using-prettier.d.ts +3 -0
- package/src/utils/is-using-prettier.js +62 -0
- package/src/utils/nx-key.d.ts +7 -0
- package/src/utils/nx-key.js +52 -0
- package/src/utils/package-json.d.ts +1 -1
- package/src/utils/package-json.js +16 -2
- package/src/utils/package-manager.js +2 -2
- package/src/utils/path.js +1 -1
- package/src/utils/require-nx-key.d.ts +1 -0
- package/src/utils/require-nx-key.js +22 -0
- package/src/utils/workspace-context.d.ts +2 -0
- package/src/utils/workspace-context.js +16 -0
- package/src/command-line/activate-powerpack/activate-powerpack.d.ts +0 -2
- package/src/command-line/activate-powerpack/activate-powerpack.js +0 -34
- package/src/command-line/activate-powerpack/command-object.d.ts +0 -6
- package/src/command-line/init/implementation/react/write-craco-config.d.ts +0 -1
- package/src/command-line/init/implementation/react/write-craco-config.js +0 -61
- package/src/migrations/update-17-0-0/move-cache-directory.d.ts +0 -2
- package/src/migrations/update-17-0-0/move-cache-directory.js +0 -35
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +0 -72
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +0 -2
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +0 -122
- package/src/migrations/update-17-2-0/move-default-base.d.ts +0 -5
- package/src/migrations/update-17-2-0/move-default-base.js +0 -21
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
- package/src/migrations/update-17-3-0/nx-release-path.js +0 -47
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +0 -2
- package/src/utils/powerpack.d.ts +0 -5
- package/src/utils/powerpack.js +0 -33
- /package/src/migrations/{update-17-0-0/rm-default-collection-npm-scope.d.ts → update-21-0-0/remove-legacy-cache.d.ts} +0 -0
@@ -0,0 +1,227 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.recordInitialMigrationMetadata = recordInitialMigrationMetadata;
|
4
|
+
exports.finishMigrationProcess = finishMigrationProcess;
|
5
|
+
exports.runSingleMigration = runSingleMigration;
|
6
|
+
exports.getImplementationPath = getImplementationPath;
|
7
|
+
exports.modifyMigrationsJsonMetadata = modifyMigrationsJsonMetadata;
|
8
|
+
exports.addSuccessfulMigration = addSuccessfulMigration;
|
9
|
+
exports.updateRefForSuccessfulMigration = updateRefForSuccessfulMigration;
|
10
|
+
exports.addFailedMigration = addFailedMigration;
|
11
|
+
exports.addSkippedMigration = addSkippedMigration;
|
12
|
+
exports.readMigrationsJsonMetadata = readMigrationsJsonMetadata;
|
13
|
+
exports.undoMigration = undoMigration;
|
14
|
+
const child_process_1 = require("child_process");
|
15
|
+
const fs_1 = require("fs");
|
16
|
+
const path_1 = require("path");
|
17
|
+
const migrate_1 = require("./migrate");
|
18
|
+
function recordInitialMigrationMetadata(workspacePath, versionToMigrateTo) {
|
19
|
+
const migrationsJsonPath = (0, path_1.join)(workspacePath, 'migrations.json');
|
20
|
+
const parsedMigrationsJson = JSON.parse((0, fs_1.readFileSync)(migrationsJsonPath, 'utf-8'));
|
21
|
+
const gitRef = (0, child_process_1.execSync)('git rev-parse HEAD', {
|
22
|
+
cwd: workspacePath,
|
23
|
+
encoding: 'utf-8',
|
24
|
+
}).trim();
|
25
|
+
const gitSubject = (0, child_process_1.execSync)('git log -1 --pretty=%s', {
|
26
|
+
cwd: workspacePath,
|
27
|
+
encoding: 'utf-8',
|
28
|
+
}).trim();
|
29
|
+
parsedMigrationsJson['nx-console'] = {
|
30
|
+
initialGitRef: {
|
31
|
+
ref: gitRef,
|
32
|
+
subject: gitSubject,
|
33
|
+
},
|
34
|
+
targetVersion: versionToMigrateTo,
|
35
|
+
};
|
36
|
+
(0, fs_1.writeFileSync)(migrationsJsonPath, JSON.stringify(parsedMigrationsJson, null, 2));
|
37
|
+
}
|
38
|
+
function finishMigrationProcess(workspacePath, squashCommits, commitMessage) {
|
39
|
+
const migrationsJsonPath = (0, path_1.join)(workspacePath, 'migrations.json');
|
40
|
+
const parsedMigrationsJson = JSON.parse((0, fs_1.readFileSync)(migrationsJsonPath, 'utf-8'));
|
41
|
+
const initialGitRef = parsedMigrationsJson['nx-console'].initialGitRef;
|
42
|
+
if ((0, fs_1.existsSync)(migrationsJsonPath)) {
|
43
|
+
(0, fs_1.rmSync)(migrationsJsonPath);
|
44
|
+
}
|
45
|
+
(0, child_process_1.execSync)('git add .', {
|
46
|
+
cwd: workspacePath,
|
47
|
+
encoding: 'utf-8',
|
48
|
+
});
|
49
|
+
(0, child_process_1.execSync)(`git commit -m "${commitMessage}" --no-verify`, {
|
50
|
+
cwd: workspacePath,
|
51
|
+
encoding: 'utf-8',
|
52
|
+
});
|
53
|
+
if (squashCommits && initialGitRef) {
|
54
|
+
(0, child_process_1.execSync)(`git reset --soft ${initialGitRef.ref}`, {
|
55
|
+
cwd: workspacePath,
|
56
|
+
encoding: 'utf-8',
|
57
|
+
});
|
58
|
+
(0, child_process_1.execSync)(`git commit -m "${commitMessage}" --no-verify`, {
|
59
|
+
cwd: workspacePath,
|
60
|
+
encoding: 'utf-8',
|
61
|
+
});
|
62
|
+
}
|
63
|
+
}
|
64
|
+
async function runSingleMigration(workspacePath, migration, configuration) {
|
65
|
+
try {
|
66
|
+
modifyMigrationsJsonMetadata(workspacePath, addRunningMigration(migration.id));
|
67
|
+
const gitRefBefore = (0, child_process_1.execSync)('git rev-parse HEAD', {
|
68
|
+
cwd: workspacePath,
|
69
|
+
encoding: 'utf-8',
|
70
|
+
}).trim();
|
71
|
+
// For Migrate UI, this current module is loaded either from:
|
72
|
+
// 1. The CLI path to the migrated modules. The version of Nx is of the user's choosing. This may or may not have the new migrate API, so Console will check that `runSingleMigration` exists before using it.
|
73
|
+
// 2. Bundled into Console, so the version is fixed to what we build Console with.
|
74
|
+
const updatedMigrateModule = await Promise.resolve().then(() => require('./migrate.js'));
|
75
|
+
const { changes: fileChanges } = await updatedMigrateModule.runNxOrAngularMigration(workspacePath, migration, false, configuration.createCommits, configuration.commitPrefix || 'chore: [nx migration] ', undefined, true);
|
76
|
+
const gitRefAfter = (0, child_process_1.execSync)('git rev-parse HEAD', {
|
77
|
+
cwd: workspacePath,
|
78
|
+
encoding: 'utf-8',
|
79
|
+
}).trim();
|
80
|
+
modifyMigrationsJsonMetadata(workspacePath, addSuccessfulMigration(migration.id, fileChanges.map((change) => ({
|
81
|
+
path: change.path,
|
82
|
+
type: change.type,
|
83
|
+
})), gitRefAfter));
|
84
|
+
if (gitRefBefore !== gitRefAfter) {
|
85
|
+
(0, child_process_1.execSync)('git add migrations.json', {
|
86
|
+
cwd: workspacePath,
|
87
|
+
encoding: 'utf-8',
|
88
|
+
});
|
89
|
+
(0, child_process_1.execSync)('git commit --amend --no-verify --no-edit', {
|
90
|
+
cwd: workspacePath,
|
91
|
+
encoding: 'utf-8',
|
92
|
+
});
|
93
|
+
// The revision changes after the amend, so we need to update it
|
94
|
+
const amendedGitRef = (0, child_process_1.execSync)('git rev-parse HEAD', {
|
95
|
+
cwd: workspacePath,
|
96
|
+
encoding: 'utf-8',
|
97
|
+
}).trim();
|
98
|
+
modifyMigrationsJsonMetadata(workspacePath, updateRefForSuccessfulMigration(migration.id, amendedGitRef));
|
99
|
+
}
|
100
|
+
}
|
101
|
+
catch (e) {
|
102
|
+
modifyMigrationsJsonMetadata(workspacePath, addFailedMigration(migration.id, e.message));
|
103
|
+
}
|
104
|
+
finally {
|
105
|
+
modifyMigrationsJsonMetadata(workspacePath, removeRunningMigration(migration.id));
|
106
|
+
(0, child_process_1.execSync)('git add migrations.json', {
|
107
|
+
cwd: workspacePath,
|
108
|
+
encoding: 'utf-8',
|
109
|
+
});
|
110
|
+
}
|
111
|
+
}
|
112
|
+
async function getImplementationPath(workspacePath, migration) {
|
113
|
+
const { collection, collectionPath } = (0, migrate_1.readMigrationCollection)(migration.package, workspacePath);
|
114
|
+
const { path } = (0, migrate_1.getImplementationPath)(collection, collectionPath, migration.name);
|
115
|
+
return path;
|
116
|
+
}
|
117
|
+
function modifyMigrationsJsonMetadata(workspacePath, modify) {
|
118
|
+
const migrationsJsonPath = (0, path_1.join)(workspacePath, 'migrations.json');
|
119
|
+
const migrationsJson = JSON.parse((0, fs_1.readFileSync)(migrationsJsonPath, 'utf-8'));
|
120
|
+
migrationsJson['nx-console'] = modify(migrationsJson['nx-console']);
|
121
|
+
(0, fs_1.writeFileSync)(migrationsJsonPath, JSON.stringify(migrationsJson, null, 2));
|
122
|
+
}
|
123
|
+
function addSuccessfulMigration(id, fileChanges, ref) {
|
124
|
+
return (migrationsJsonMetadata) => {
|
125
|
+
const copied = { ...migrationsJsonMetadata };
|
126
|
+
if (!copied.completedMigrations) {
|
127
|
+
copied.completedMigrations = {};
|
128
|
+
}
|
129
|
+
copied.completedMigrations = {
|
130
|
+
...copied.completedMigrations,
|
131
|
+
[id]: {
|
132
|
+
type: 'successful',
|
133
|
+
name: id,
|
134
|
+
changedFiles: fileChanges,
|
135
|
+
ref,
|
136
|
+
},
|
137
|
+
};
|
138
|
+
return copied;
|
139
|
+
};
|
140
|
+
}
|
141
|
+
function updateRefForSuccessfulMigration(id, ref) {
|
142
|
+
return (migrationsJsonMetadata) => {
|
143
|
+
const copied = { ...migrationsJsonMetadata };
|
144
|
+
if (!copied.completedMigrations) {
|
145
|
+
copied.completedMigrations = {};
|
146
|
+
}
|
147
|
+
const existing = copied.completedMigrations[id];
|
148
|
+
if (existing && existing.type === 'successful') {
|
149
|
+
existing.ref = ref;
|
150
|
+
}
|
151
|
+
else {
|
152
|
+
throw new Error(`Attempted to update ref for unsuccessful migration`);
|
153
|
+
}
|
154
|
+
return copied;
|
155
|
+
};
|
156
|
+
}
|
157
|
+
function addFailedMigration(id, error) {
|
158
|
+
return (migrationsJsonMetadata) => {
|
159
|
+
const copied = { ...migrationsJsonMetadata };
|
160
|
+
if (!copied.completedMigrations) {
|
161
|
+
copied.completedMigrations = {};
|
162
|
+
}
|
163
|
+
copied.completedMigrations = {
|
164
|
+
...copied.completedMigrations,
|
165
|
+
[id]: {
|
166
|
+
type: 'failed',
|
167
|
+
name: id,
|
168
|
+
error,
|
169
|
+
},
|
170
|
+
};
|
171
|
+
return copied;
|
172
|
+
};
|
173
|
+
}
|
174
|
+
function addSkippedMigration(id) {
|
175
|
+
return (migrationsJsonMetadata) => {
|
176
|
+
const copied = { ...migrationsJsonMetadata };
|
177
|
+
if (!copied.completedMigrations) {
|
178
|
+
copied.completedMigrations = {};
|
179
|
+
}
|
180
|
+
copied.completedMigrations = {
|
181
|
+
...copied.completedMigrations,
|
182
|
+
[id]: {
|
183
|
+
type: 'skipped',
|
184
|
+
},
|
185
|
+
};
|
186
|
+
return copied;
|
187
|
+
};
|
188
|
+
}
|
189
|
+
function addRunningMigration(id) {
|
190
|
+
return (migrationsJsonMetadata) => {
|
191
|
+
migrationsJsonMetadata.runningMigrations = [
|
192
|
+
...(migrationsJsonMetadata.runningMigrations ?? []),
|
193
|
+
id,
|
194
|
+
];
|
195
|
+
return migrationsJsonMetadata;
|
196
|
+
};
|
197
|
+
}
|
198
|
+
function removeRunningMigration(id) {
|
199
|
+
return (migrationsJsonMetadata) => {
|
200
|
+
migrationsJsonMetadata.runningMigrations =
|
201
|
+
migrationsJsonMetadata.runningMigrations?.filter((n) => n !== id);
|
202
|
+
if (migrationsJsonMetadata.runningMigrations?.length === 0) {
|
203
|
+
delete migrationsJsonMetadata.runningMigrations;
|
204
|
+
}
|
205
|
+
return migrationsJsonMetadata;
|
206
|
+
};
|
207
|
+
}
|
208
|
+
function readMigrationsJsonMetadata(workspacePath) {
|
209
|
+
const migrationsJsonPath = (0, path_1.join)(workspacePath, 'migrations.json');
|
210
|
+
const migrationsJson = JSON.parse((0, fs_1.readFileSync)(migrationsJsonPath, 'utf-8'));
|
211
|
+
return migrationsJson['nx-console'];
|
212
|
+
}
|
213
|
+
function undoMigration(workspacePath, id) {
|
214
|
+
return (migrationsJsonMetadata) => {
|
215
|
+
const existing = migrationsJsonMetadata.completedMigrations[id];
|
216
|
+
if (existing.type !== 'successful')
|
217
|
+
throw new Error(`undoMigration called on unsuccessful migration: ${id}`);
|
218
|
+
(0, child_process_1.execSync)(`git reset --hard ${existing.ref}^`, {
|
219
|
+
cwd: workspacePath,
|
220
|
+
encoding: 'utf-8',
|
221
|
+
});
|
222
|
+
migrationsJsonMetadata.completedMigrations[id] = {
|
223
|
+
type: 'skipped',
|
224
|
+
};
|
225
|
+
return migrationsJsonMetadata;
|
226
|
+
};
|
227
|
+
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { MigrationsJson, PackageJsonUpdateForPackage as PackageUpdate } from '../../config/misc-interfaces';
|
2
2
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
3
|
+
import { FileChange } from '../../generators/tree';
|
3
4
|
import { ArrayPackageGroup, PackageJson } from '../../utils/package-json';
|
4
5
|
export interface ResolvedMigrationConfiguration extends MigrationsJson {
|
5
6
|
packageGroup?: ArrayPackageGroup;
|
@@ -40,7 +41,6 @@ export declare class Migrator {
|
|
40
41
|
name: string;
|
41
42
|
version: string;
|
42
43
|
description?: string;
|
43
|
-
cli?: string;
|
44
44
|
implementation?: string;
|
45
45
|
factory?: string;
|
46
46
|
requires?: Record<string, string>;
|
@@ -100,16 +100,35 @@ export declare function executeMigrations(root: string, migrations: {
|
|
100
100
|
name: string;
|
101
101
|
description?: string;
|
102
102
|
version: string;
|
103
|
-
cli?: 'nx' | 'angular';
|
104
103
|
}[], isVerbose: boolean, shouldCreateCommits: boolean, commitPrefix: string): Promise<{
|
104
|
+
migrationsWithNoChanges: {
|
105
|
+
package: string;
|
106
|
+
name: string;
|
107
|
+
description?: string;
|
108
|
+
version: string;
|
109
|
+
}[];
|
110
|
+
nextSteps: string[];
|
111
|
+
}>;
|
112
|
+
export declare function runNxOrAngularMigration(root: string, migration: {
|
105
113
|
package: string;
|
106
114
|
name: string;
|
107
115
|
description?: string;
|
108
116
|
version: string;
|
109
|
-
|
110
|
-
|
117
|
+
}, isVerbose: boolean, shouldCreateCommits: boolean, commitPrefix: string, installDepsIfChanged?: () => void, handleInstallDeps?: boolean): Promise<{
|
118
|
+
changes: FileChange[];
|
119
|
+
nextSteps: string[];
|
120
|
+
}>;
|
111
121
|
export declare function migrate(root: string, args: {
|
112
122
|
[k: string]: any;
|
113
123
|
}, rawArgs: string[]): Promise<number>;
|
114
124
|
export declare function runMigration(): void;
|
125
|
+
export declare function readMigrationCollection(packageName: string, root: string): {
|
126
|
+
collection: MigrationsJson;
|
127
|
+
collectionPath: string;
|
128
|
+
};
|
129
|
+
export declare function getImplementationPath(collection: MigrationsJson, collectionPath: string, name: string): {
|
130
|
+
path: string;
|
131
|
+
fnSymbol: string;
|
132
|
+
};
|
133
|
+
export declare function nxCliPath(nxWorkspaceRoot?: string): string;
|
115
134
|
export {};
|
@@ -4,8 +4,12 @@ exports.Migrator = void 0;
|
|
4
4
|
exports.normalizeVersion = normalizeVersion;
|
5
5
|
exports.parseMigrationsOptions = parseMigrationsOptions;
|
6
6
|
exports.executeMigrations = executeMigrations;
|
7
|
+
exports.runNxOrAngularMigration = runNxOrAngularMigration;
|
7
8
|
exports.migrate = migrate;
|
8
9
|
exports.runMigration = runMigration;
|
10
|
+
exports.readMigrationCollection = readMigrationCollection;
|
11
|
+
exports.getImplementationPath = getImplementationPath;
|
12
|
+
exports.nxCliPath = nxCliPath;
|
9
13
|
const chalk = require("chalk");
|
10
14
|
const child_process_1 = require("child_process");
|
11
15
|
const enquirer_1 = require("enquirer");
|
@@ -643,7 +647,11 @@ async function getPackageMigrationsUsingInstall(packageName, packageVersion) {
|
|
643
647
|
result = { ...migrations, packageGroup, version: packageJson.version };
|
644
648
|
}
|
645
649
|
catch (e) {
|
646
|
-
|
650
|
+
output_1.output.warn({
|
651
|
+
title: `Failed to fetch migrations for ${packageName}@${packageVersion}`,
|
652
|
+
bodyLines: [e.message],
|
653
|
+
});
|
654
|
+
return {};
|
647
655
|
}
|
648
656
|
finally {
|
649
657
|
await cleanup();
|
@@ -809,9 +817,12 @@ async function generateMigrationsJsonAndUpdatePackageJson(root, opts) {
|
|
809
817
|
// The above code is to remind folks when updating to a new major and not currently using Nx cloud.
|
810
818
|
// If for some reason it fails, it shouldn't affect the overall migration process
|
811
819
|
}
|
812
|
-
|
813
|
-
|
814
|
-
|
820
|
+
const bodyLines = process.env['NX_CONSOLE']
|
821
|
+
? [
|
822
|
+
'- Inspect the package.json changes in the built-in diff editor [Click to open]',
|
823
|
+
'- Confirm the changes to install the new dependencies and continue the migration',
|
824
|
+
]
|
825
|
+
: [
|
815
826
|
`- Make sure package.json changes make sense and then run '${pmc.install}',`,
|
816
827
|
...(migrations.length > 0
|
817
828
|
? [`- Run '${pmc.exec} nx migrate --run-migrations'`]
|
@@ -830,7 +841,10 @@ async function generateMigrationsJsonAndUpdatePackageJson(root, opts) {
|
|
830
841
|
`- You may run '${pmc.run('nx', 'connect-to-nx-cloud')}' to get faster builds, GitHub integration, and more. Check out https://nx.app`,
|
831
842
|
]
|
832
843
|
: []),
|
833
|
-
]
|
844
|
+
];
|
845
|
+
output_1.output.log({
|
846
|
+
title: 'Next steps:',
|
847
|
+
bodyLines,
|
834
848
|
});
|
835
849
|
}
|
836
850
|
catch (e) {
|
@@ -860,7 +874,6 @@ function addSplitConfigurationMigrationIfAvailable(from, packageJson) {
|
|
860
874
|
{
|
861
875
|
version: '15.7.0-beta.0',
|
862
876
|
description: 'Split global configuration files into individual project.json files. This migration has been added automatically to the beginning of your migration set to retroactively make them work with the new version of Nx.',
|
863
|
-
cli: 'nx',
|
864
877
|
implementation: './src/migrations/update-15-7-0/split-configuration-into-project-json-files',
|
865
878
|
package: '@nrwl/workspace',
|
866
879
|
name: '15-7-0-split-configuration-into-project-json-files',
|
@@ -881,26 +894,31 @@ function showConnectToCloudMessage() {
|
|
881
894
|
return false;
|
882
895
|
}
|
883
896
|
}
|
884
|
-
function runInstall() {
|
885
|
-
|
897
|
+
function runInstall(nxWorkspaceRoot) {
|
898
|
+
let packageManager;
|
899
|
+
let pmCommands;
|
900
|
+
if (nxWorkspaceRoot) {
|
901
|
+
packageManager = (0, package_manager_1.detectPackageManager)(nxWorkspaceRoot);
|
902
|
+
pmCommands = (0, package_manager_1.getPackageManagerCommand)(packageManager, nxWorkspaceRoot);
|
903
|
+
}
|
904
|
+
else {
|
905
|
+
pmCommands = (0, package_manager_1.getPackageManagerCommand)();
|
906
|
+
}
|
886
907
|
// TODO: remove this
|
887
|
-
if ((0, package_manager_1.detectPackageManager)() === 'npm') {
|
908
|
+
if (packageManager ?? (0, package_manager_1.detectPackageManager)() === 'npm') {
|
888
909
|
process.env.npm_config_legacy_peer_deps ??= 'true';
|
889
910
|
}
|
890
911
|
output_1.output.log({
|
891
912
|
title: `Running '${pmCommands.install}' to make sure necessary packages are installed`,
|
892
913
|
});
|
893
|
-
(0, child_process_1.execSync)(pmCommands.install, {
|
914
|
+
(0, child_process_1.execSync)(pmCommands.install, {
|
915
|
+
stdio: [0, 1, 2],
|
916
|
+
windowsHide: false,
|
917
|
+
cwd: nxWorkspaceRoot ?? process.cwd(),
|
918
|
+
});
|
894
919
|
}
|
895
920
|
async function executeMigrations(root, migrations, isVerbose, shouldCreateCommits, commitPrefix) {
|
896
|
-
|
897
|
-
const installDepsIfChanged = () => {
|
898
|
-
const currentDeps = getStringifiedPackageJsonDeps(root);
|
899
|
-
if (initialDeps !== currentDeps) {
|
900
|
-
runInstall();
|
901
|
-
}
|
902
|
-
initialDeps = currentDeps;
|
903
|
-
};
|
921
|
+
const changedDepInstaller = new ChangedDepInstaller(root);
|
904
922
|
const migrationsWithNoChanges = [];
|
905
923
|
const sortedMigrations = migrations.sort((a, b) => {
|
906
924
|
// special case for the split configuration migration to run first
|
@@ -917,52 +935,14 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
917
935
|
logger_1.logger.info(`Running the following migrations:`);
|
918
936
|
sortedMigrations.forEach((m) => logger_1.logger.info(`- ${m.package}: ${m.name} (${m.description})`));
|
919
937
|
logger_1.logger.info(`---------------------------------------------------------\n`);
|
938
|
+
const allNextSteps = [];
|
920
939
|
for (const m of sortedMigrations) {
|
921
940
|
logger_1.logger.info(`Running migration ${m.package}: ${m.name}`);
|
922
941
|
try {
|
923
|
-
const {
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
logger_1.logger.info(` ${m.description}\n`);
|
928
|
-
if (changes.length < 1) {
|
929
|
-
logger_1.logger.info(`No changes were made\n`);
|
930
|
-
migrationsWithNoChanges.push(m);
|
931
|
-
continue;
|
932
|
-
}
|
933
|
-
logger_1.logger.info('Changes:');
|
934
|
-
(0, tree_1.printChanges)(changes, ' ');
|
935
|
-
logger_1.logger.info('');
|
936
|
-
}
|
937
|
-
else {
|
938
|
-
const ngCliAdapter = await getNgCompatLayer();
|
939
|
-
const { madeChanges, loggingQueue } = await ngCliAdapter.runMigration(root, m.package, m.name, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(await (0, project_graph_1.createProjectGraphAsync)()).projects, isVerbose);
|
940
|
-
logger_1.logger.info(`Ran ${m.name} from ${m.package}`);
|
941
|
-
logger_1.logger.info(` ${m.description}\n`);
|
942
|
-
if (!madeChanges) {
|
943
|
-
logger_1.logger.info(`No changes were made\n`);
|
944
|
-
migrationsWithNoChanges.push(m);
|
945
|
-
continue;
|
946
|
-
}
|
947
|
-
logger_1.logger.info('Changes:');
|
948
|
-
loggingQueue.forEach((log) => logger_1.logger.info(' ' + log));
|
949
|
-
logger_1.logger.info('');
|
950
|
-
}
|
951
|
-
if (shouldCreateCommits) {
|
952
|
-
installDepsIfChanged();
|
953
|
-
const commitMessage = `${commitPrefix}${m.name}`;
|
954
|
-
try {
|
955
|
-
const committedSha = (0, git_utils_1.commitChanges)(commitMessage);
|
956
|
-
if (committedSha) {
|
957
|
-
logger_1.logger.info(chalk.dim(`- Commit created for changes: ${committedSha}`));
|
958
|
-
}
|
959
|
-
else {
|
960
|
-
logger_1.logger.info(chalk.red(`- A commit could not be created/retrieved for an unknown reason`));
|
961
|
-
}
|
962
|
-
}
|
963
|
-
catch (e) {
|
964
|
-
logger_1.logger.info(chalk.red(`- ${e.message}`));
|
965
|
-
}
|
942
|
+
const { changes, nextSteps } = await runNxOrAngularMigration(root, m, isVerbose, shouldCreateCommits, commitPrefix, () => changedDepInstaller.installDepsIfChanged());
|
943
|
+
allNextSteps.push(...nextSteps);
|
944
|
+
if (changes.length === 0) {
|
945
|
+
migrationsWithNoChanges.push(m);
|
966
946
|
}
|
967
947
|
logger_1.logger.info(`---------------------------------------------------------`);
|
968
948
|
}
|
@@ -974,9 +954,78 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
974
954
|
}
|
975
955
|
}
|
976
956
|
if (!shouldCreateCommits) {
|
957
|
+
changedDepInstaller.installDepsIfChanged();
|
958
|
+
}
|
959
|
+
return { migrationsWithNoChanges, nextSteps: allNextSteps };
|
960
|
+
}
|
961
|
+
class ChangedDepInstaller {
|
962
|
+
constructor(root) {
|
963
|
+
this.root = root;
|
964
|
+
this.initialDeps = getStringifiedPackageJsonDeps(root);
|
965
|
+
}
|
966
|
+
installDepsIfChanged() {
|
967
|
+
const currentDeps = getStringifiedPackageJsonDeps(this.root);
|
968
|
+
if (this.initialDeps !== currentDeps) {
|
969
|
+
runInstall(this.root);
|
970
|
+
}
|
971
|
+
this.initialDeps = currentDeps;
|
972
|
+
}
|
973
|
+
}
|
974
|
+
async function runNxOrAngularMigration(root, migration, isVerbose, shouldCreateCommits, commitPrefix, installDepsIfChanged, handleInstallDeps = false) {
|
975
|
+
if (!installDepsIfChanged) {
|
976
|
+
const changedDepInstaller = new ChangedDepInstaller(root);
|
977
|
+
installDepsIfChanged = () => changedDepInstaller.installDepsIfChanged();
|
978
|
+
}
|
979
|
+
const { collection, collectionPath } = readMigrationCollection(migration.package, root);
|
980
|
+
let changes = [];
|
981
|
+
let nextSteps = [];
|
982
|
+
if (!isAngularMigration(collection, migration.name)) {
|
983
|
+
({ nextSteps, changes } = await runNxMigration(root, collectionPath, collection, migration.name));
|
984
|
+
logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
|
985
|
+
logger_1.logger.info(` ${migration.description}\n`);
|
986
|
+
if (changes.length < 1) {
|
987
|
+
logger_1.logger.info(`No changes were made\n`);
|
988
|
+
return { changes, nextSteps };
|
989
|
+
}
|
990
|
+
logger_1.logger.info('Changes:');
|
991
|
+
(0, tree_1.printChanges)(changes, ' ');
|
992
|
+
logger_1.logger.info('');
|
993
|
+
}
|
994
|
+
else {
|
995
|
+
const ngCliAdapter = await getNgCompatLayer();
|
996
|
+
const { madeChanges, loggingQueue } = await ngCliAdapter.runMigration(root, migration.package, migration.name, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(await (0, project_graph_1.createProjectGraphAsync)())
|
997
|
+
.projects, isVerbose);
|
998
|
+
logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
|
999
|
+
logger_1.logger.info(` ${migration.description}\n`);
|
1000
|
+
if (!madeChanges) {
|
1001
|
+
logger_1.logger.info(`No changes were made\n`);
|
1002
|
+
return { changes, nextSteps };
|
1003
|
+
}
|
1004
|
+
logger_1.logger.info('Changes:');
|
1005
|
+
loggingQueue.forEach((log) => logger_1.logger.info(' ' + log));
|
1006
|
+
logger_1.logger.info('');
|
1007
|
+
}
|
1008
|
+
if (shouldCreateCommits) {
|
1009
|
+
installDepsIfChanged();
|
1010
|
+
const commitMessage = `${commitPrefix}${migration.name}`;
|
1011
|
+
try {
|
1012
|
+
const committedSha = (0, git_utils_1.commitChanges)(commitMessage, root);
|
1013
|
+
if (committedSha) {
|
1014
|
+
logger_1.logger.info(chalk.dim(`- Commit created for changes: ${committedSha}`));
|
1015
|
+
}
|
1016
|
+
else {
|
1017
|
+
logger_1.logger.info(chalk.red(`- A commit could not be created/retrieved for an unknown reason`));
|
1018
|
+
}
|
1019
|
+
}
|
1020
|
+
catch (e) {
|
1021
|
+
logger_1.logger.info(chalk.red(`- ${e.message}`));
|
1022
|
+
}
|
1023
|
+
// if we are running this function alone, we need to install deps internally
|
1024
|
+
}
|
1025
|
+
else if (handleInstallDeps) {
|
977
1026
|
installDepsIfChanged();
|
978
1027
|
}
|
979
|
-
return
|
1028
|
+
return { changes, nextSteps };
|
980
1029
|
}
|
981
1030
|
async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits = false, commitPrefix) {
|
982
1031
|
if (!process.env.NX_MIGRATE_SKIP_INSTALL) {
|
@@ -1010,7 +1059,7 @@ async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits =
|
|
1010
1059
|
(shouldCreateCommits ? ', with each applied in a dedicated commit' : ''),
|
1011
1060
|
});
|
1012
1061
|
const migrations = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, opts.runMigrations)).migrations;
|
1013
|
-
const migrationsWithNoChanges = await executeMigrations(root, migrations, isVerbose, shouldCreateCommits, commitPrefix);
|
1062
|
+
const { migrationsWithNoChanges, nextSteps } = await executeMigrations(root, migrations, isVerbose, shouldCreateCommits, commitPrefix);
|
1014
1063
|
if (migrationsWithNoChanges.length < migrations.length) {
|
1015
1064
|
output_1.output.success({
|
1016
1065
|
title: `Successfully finished running migrations from '${opts.runMigrations}'. This workspace is up to date!`,
|
@@ -1021,6 +1070,12 @@ async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits =
|
|
1021
1070
|
title: `No changes were made from running '${opts.runMigrations}'. This workspace is up to date!`,
|
1022
1071
|
});
|
1023
1072
|
}
|
1073
|
+
if (nextSteps.length > 0) {
|
1074
|
+
output_1.output.log({
|
1075
|
+
title: `Some migrations have additional information, see below.`,
|
1076
|
+
bodyLines: nextSteps.map((line) => `- ${line}`),
|
1077
|
+
});
|
1078
|
+
}
|
1024
1079
|
}
|
1025
1080
|
function getStringifiedPackageJsonDeps(root) {
|
1026
1081
|
try {
|
@@ -1037,11 +1092,18 @@ async function runNxMigration(root, collectionPath, collection, name) {
|
|
1037
1092
|
const { path: implPath, fnSymbol } = getImplementationPath(collection, collectionPath, name);
|
1038
1093
|
const fn = require(implPath)[fnSymbol];
|
1039
1094
|
const host = new tree_1.FsTree(root, process.env.NX_VERBOSE_LOGGING === 'true', `migration ${collection.name}:${name}`);
|
1040
|
-
await fn(host, {});
|
1095
|
+
let nextSteps = await fn(host, {});
|
1096
|
+
// This accounts for migrations that mistakenly return a generator callback
|
1097
|
+
// from a migration. We've never executed these, so its not a breaking change that
|
1098
|
+
// we don't call them now... but currently shipping a migration with one wouldn't break
|
1099
|
+
// the migrate flow, so we are being cautious.
|
1100
|
+
if (!isStringArray(nextSteps)) {
|
1101
|
+
nextSteps = [];
|
1102
|
+
}
|
1041
1103
|
host.lock();
|
1042
1104
|
const changes = host.listChanges();
|
1043
1105
|
(0, tree_1.flushChanges)(root, changes);
|
1044
|
-
return changes;
|
1106
|
+
return { changes, nextSteps };
|
1045
1107
|
}
|
1046
1108
|
async function migrate(root, args, rawArgs) {
|
1047
1109
|
await client_1.daemonClient.stop();
|
@@ -1111,7 +1173,7 @@ function getImplementationPath(collection, collectionPath, name) {
|
|
1111
1173
|
}
|
1112
1174
|
return { path: implPath, fnSymbol };
|
1113
1175
|
}
|
1114
|
-
function nxCliPath() {
|
1176
|
+
function nxCliPath(nxWorkspaceRoot) {
|
1115
1177
|
const version = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
|
1116
1178
|
try {
|
1117
1179
|
const packageManager = (0, package_manager_1.detectPackageManager)();
|
@@ -1124,7 +1186,7 @@ function nxCliPath() {
|
|
1124
1186
|
},
|
1125
1187
|
license: 'MIT',
|
1126
1188
|
});
|
1127
|
-
(0, package_manager_1.copyPackageManagerConfigurationFiles)(workspace_root_1.workspaceRoot, tmpDir);
|
1189
|
+
(0, package_manager_1.copyPackageManagerConfigurationFiles)(nxWorkspaceRoot ?? workspace_root_1.workspaceRoot, tmpDir);
|
1128
1190
|
if (pmc.preInstall) {
|
1129
1191
|
// ensure package.json and repo in tmp folder is set to a proper package manager state
|
1130
1192
|
(0, child_process_1.execSync)(pmc.preInstall, {
|
@@ -1148,7 +1210,7 @@ function nxCliPath() {
|
|
1148
1210
|
});
|
1149
1211
|
// Set NODE_PATH so that these modules can be used for module resolution
|
1150
1212
|
addToNodePath((0, path_1.join)(tmpDir, 'node_modules'));
|
1151
|
-
addToNodePath((0, path_1.join)(workspace_root_1.workspaceRoot, 'node_modules'));
|
1213
|
+
addToNodePath((0, path_1.join)(nxWorkspaceRoot ?? workspace_root_1.workspaceRoot, 'node_modules'));
|
1152
1214
|
return (0, path_1.join)(tmpDir, `node_modules`, '.bin', 'nx');
|
1153
1215
|
}
|
1154
1216
|
catch (e) {
|
@@ -1171,24 +1233,8 @@ function addToNodePath(dir) {
|
|
1171
1233
|
// Update the env variable.
|
1172
1234
|
process.env.NODE_PATH = paths.join(delimiter);
|
1173
1235
|
}
|
1174
|
-
|
1175
|
-
|
1176
|
-
const entry = collection.generators?.[name] || collection.schematics?.[name];
|
1177
|
-
const shouldBeNx = !!collection.generators?.[name];
|
1178
|
-
const shouldBeNg = !!collection.schematics?.[name];
|
1179
|
-
if (entry.cli && entry.cli !== 'nx' && collection.generators?.[name]) {
|
1180
|
-
output_1.output.warn({
|
1181
|
-
title: `The migration '${collection.name}:${name}' appears to be an Angular CLI migration, but is located in the 'generators' section of migrations.json.`,
|
1182
|
-
bodyLines: [
|
1183
|
-
'In Nx 21, migrations inside `generators` will be treated as Nx Devkit migrations and therefore may not run correctly if they are using Angular Devkit.',
|
1184
|
-
'If the migration should be run with Angular Devkit, please place the migration inside `schematics` instead.',
|
1185
|
-
"Please open an issue on the plugin's repository if you believe this is an error.",
|
1186
|
-
],
|
1187
|
-
});
|
1188
|
-
}
|
1189
|
-
// Currently, if the cli property exists we listen to it. If its nx, its not an ng cli migration.
|
1190
|
-
// If the property is not set, we will fall back to our intuition.
|
1191
|
-
return entry.cli ? entry.cli !== 'nx' : !shouldBeNx && shouldBeNg;
|
1236
|
+
function isAngularMigration(collection, name) {
|
1237
|
+
return !collection.generators?.[name] && collection.schematics?.[name];
|
1192
1238
|
}
|
1193
1239
|
const getNgCompatLayer = (() => {
|
1194
1240
|
let _ngCliAdapter;
|
@@ -1200,3 +1246,9 @@ const getNgCompatLayer = (() => {
|
|
1200
1246
|
return _ngCliAdapter;
|
1201
1247
|
};
|
1202
1248
|
})();
|
1249
|
+
function isStringArray(value) {
|
1250
|
+
if (!Array.isArray(value)) {
|
1251
|
+
return false;
|
1252
|
+
}
|
1253
|
+
return value.every((v) => typeof v === 'string');
|
1254
|
+
}
|