nx 21.0.0-beta.3 → 21.0.0-beta.5
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/package.json +11 -11
- package/src/command-line/migrate/migrate-ui-api.d.ts +56 -0
- package/src/command-line/migrate/migrate-ui-api.js +188 -0
- package/src/command-line/migrate/migrate.d.ts +17 -0
- package/src/command-line/migrate/migrate.js +106 -63
- package/src/config/misc-interfaces.d.ts +10 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/native/index.d.ts +2 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/tasks-runner/default-tasks-runner.js +1 -1
- package/src/tasks-runner/init-tasks-runner.js +2 -1
- package/src/tasks-runner/is-tui-enabled.d.ts +1 -1
- package/src/tasks-runner/is-tui-enabled.js +12 -6
- package/src/tasks-runner/life-cycle.d.ts +2 -2
- package/src/tasks-runner/life-cycle.js +2 -2
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +2 -1
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +13 -6
- package/src/tasks-runner/run-command.d.ts +2 -1
- package/src/tasks-runner/run-command.js +14 -6
- package/src/tasks-runner/running-tasks/running-task.d.ts +2 -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-orchestrator.d.ts +6 -3
- package/src/tasks-runner/task-orchestrator.js +51 -23
- 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/utils/git-utils.d.ts +1 -1
- package/src/utils/git-utils.js +8 -3
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "21.0.0-beta.
|
3
|
+
"version": "21.0.0-beta.5",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -83,16 +83,16 @@
|
|
83
83
|
}
|
84
84
|
},
|
85
85
|
"optionalDependencies": {
|
86
|
-
"@nx/nx-darwin-arm64": "21.0.0-beta.
|
87
|
-
"@nx/nx-darwin-x64": "21.0.0-beta.
|
88
|
-
"@nx/nx-freebsd-x64": "21.0.0-beta.
|
89
|
-
"@nx/nx-linux-arm-gnueabihf": "21.0.0-beta.
|
90
|
-
"@nx/nx-linux-arm64-gnu": "21.0.0-beta.
|
91
|
-
"@nx/nx-linux-arm64-musl": "21.0.0-beta.
|
92
|
-
"@nx/nx-linux-x64-gnu": "21.0.0-beta.
|
93
|
-
"@nx/nx-linux-x64-musl": "21.0.0-beta.
|
94
|
-
"@nx/nx-win32-arm64-msvc": "21.0.0-beta.
|
95
|
-
"@nx/nx-win32-x64-msvc": "21.0.0-beta.
|
86
|
+
"@nx/nx-darwin-arm64": "21.0.0-beta.5",
|
87
|
+
"@nx/nx-darwin-x64": "21.0.0-beta.5",
|
88
|
+
"@nx/nx-freebsd-x64": "21.0.0-beta.5",
|
89
|
+
"@nx/nx-linux-arm-gnueabihf": "21.0.0-beta.5",
|
90
|
+
"@nx/nx-linux-arm64-gnu": "21.0.0-beta.5",
|
91
|
+
"@nx/nx-linux-arm64-musl": "21.0.0-beta.5",
|
92
|
+
"@nx/nx-linux-x64-gnu": "21.0.0-beta.5",
|
93
|
+
"@nx/nx-linux-x64-musl": "21.0.0-beta.5",
|
94
|
+
"@nx/nx-win32-arm64-msvc": "21.0.0-beta.5",
|
95
|
+
"@nx/nx-win32-x64-msvc": "21.0.0-beta.5"
|
96
96
|
},
|
97
97
|
"nx-migrations": {
|
98
98
|
"migrations": "./migrations.json",
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import type { MigrationDetailsWithId } from '../../config/misc-interfaces';
|
2
|
+
import type { FileChange } from '../../generators/tree';
|
3
|
+
export type MigrationsJsonMetadata = {
|
4
|
+
completedMigrations?: Record<string, SuccessfulMigration | FailedMigration | SkippedMigration>;
|
5
|
+
runningMigrations?: string[];
|
6
|
+
initialGitRef?: {
|
7
|
+
ref: string;
|
8
|
+
subject: string;
|
9
|
+
};
|
10
|
+
confirmedPackageUpdates?: boolean;
|
11
|
+
targetVersion?: string;
|
12
|
+
};
|
13
|
+
export type SuccessfulMigration = {
|
14
|
+
type: 'successful';
|
15
|
+
name: string;
|
16
|
+
changedFiles: Omit<FileChange, 'content'>[];
|
17
|
+
ref: string;
|
18
|
+
};
|
19
|
+
export type FailedMigration = {
|
20
|
+
type: 'failed';
|
21
|
+
name: string;
|
22
|
+
error: string;
|
23
|
+
};
|
24
|
+
export type SkippedMigration = {
|
25
|
+
type: 'skipped';
|
26
|
+
};
|
27
|
+
export declare function recordInitialMigrationMetadata(workspacePath: string, versionToMigrateTo: string): void;
|
28
|
+
export declare function finishMigrationProcess(workspacePath: string, squashCommits: boolean, commitMessage: string): void;
|
29
|
+
export declare function runSingleMigration(workspacePath: string, migration: MigrationDetailsWithId, configuration: {
|
30
|
+
createCommits: boolean;
|
31
|
+
commitPrefix?: string;
|
32
|
+
}): Promise<void>;
|
33
|
+
export declare function getImplementationPath(workspacePath: string, migration: MigrationDetailsWithId): Promise<string>;
|
34
|
+
export declare function modifyMigrationsJsonMetadata(workspacePath: string, modify: (migrationsJsonMetadata: MigrationsJsonMetadata) => MigrationsJsonMetadata): void;
|
35
|
+
export declare function addSuccessfulMigration(id: string, fileChanges: Omit<FileChange, 'content'>[], ref: string): (migrationsJsonMetadata: MigrationsJsonMetadata) => MigrationsJsonMetadata;
|
36
|
+
export declare function addFailedMigration(id: string, error: string): (migrationsJsonMetadata: MigrationsJsonMetadata) => {
|
37
|
+
completedMigrations?: Record<string, SuccessfulMigration | FailedMigration | SkippedMigration>;
|
38
|
+
runningMigrations?: string[];
|
39
|
+
initialGitRef?: {
|
40
|
+
ref: string;
|
41
|
+
subject: string;
|
42
|
+
};
|
43
|
+
confirmedPackageUpdates?: boolean;
|
44
|
+
targetVersion?: string;
|
45
|
+
};
|
46
|
+
export declare function addSkippedMigration(id: string): (migrationsJsonMetadata: MigrationsJsonMetadata) => {
|
47
|
+
completedMigrations?: Record<string, SuccessfulMigration | FailedMigration | SkippedMigration>;
|
48
|
+
runningMigrations?: string[];
|
49
|
+
initialGitRef?: {
|
50
|
+
ref: string;
|
51
|
+
subject: string;
|
52
|
+
};
|
53
|
+
confirmedPackageUpdates?: boolean;
|
54
|
+
targetVersion?: string;
|
55
|
+
};
|
56
|
+
export declare function readMigrationsJsonMetadata(workspacePath: string): MigrationsJsonMetadata;
|
@@ -0,0 +1,188 @@
|
|
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.addFailedMigration = addFailedMigration;
|
10
|
+
exports.addSkippedMigration = addSkippedMigration;
|
11
|
+
exports.readMigrationsJsonMetadata = readMigrationsJsonMetadata;
|
12
|
+
const child_process_1 = require("child_process");
|
13
|
+
const fs_1 = require("fs");
|
14
|
+
const path_1 = require("path");
|
15
|
+
const migrate_1 = require("./migrate");
|
16
|
+
function recordInitialMigrationMetadata(workspacePath, versionToMigrateTo) {
|
17
|
+
const migrationsJsonPath = (0, path_1.join)(workspacePath, 'migrations.json');
|
18
|
+
const parsedMigrationsJson = JSON.parse((0, fs_1.readFileSync)(migrationsJsonPath, 'utf-8'));
|
19
|
+
const gitRef = (0, child_process_1.execSync)('git rev-parse HEAD', {
|
20
|
+
cwd: workspacePath,
|
21
|
+
encoding: 'utf-8',
|
22
|
+
}).trim();
|
23
|
+
const gitSubject = (0, child_process_1.execSync)('git log -1 --pretty=%s', {
|
24
|
+
cwd: workspacePath,
|
25
|
+
encoding: 'utf-8',
|
26
|
+
}).trim();
|
27
|
+
parsedMigrationsJson['nx-console'] = {
|
28
|
+
initialGitRef: {
|
29
|
+
ref: gitRef,
|
30
|
+
subject: gitSubject,
|
31
|
+
},
|
32
|
+
targetVersion: versionToMigrateTo,
|
33
|
+
};
|
34
|
+
(0, fs_1.writeFileSync)(migrationsJsonPath, JSON.stringify(parsedMigrationsJson, null, 2));
|
35
|
+
}
|
36
|
+
function finishMigrationProcess(workspacePath, squashCommits, commitMessage) {
|
37
|
+
const migrationsJsonPath = (0, path_1.join)(workspacePath, 'migrations.json');
|
38
|
+
const parsedMigrationsJson = JSON.parse((0, fs_1.readFileSync)(migrationsJsonPath, 'utf-8'));
|
39
|
+
const initialGitRef = parsedMigrationsJson['nx-console'].initialGitRef;
|
40
|
+
if ((0, fs_1.existsSync)(migrationsJsonPath)) {
|
41
|
+
(0, fs_1.rmSync)(migrationsJsonPath);
|
42
|
+
}
|
43
|
+
(0, child_process_1.execSync)('git add .', {
|
44
|
+
cwd: workspacePath,
|
45
|
+
encoding: 'utf-8',
|
46
|
+
});
|
47
|
+
(0, child_process_1.execSync)(`git commit -m "${commitMessage}" --no-verify`, {
|
48
|
+
cwd: workspacePath,
|
49
|
+
encoding: 'utf-8',
|
50
|
+
});
|
51
|
+
if (squashCommits && initialGitRef) {
|
52
|
+
(0, child_process_1.execSync)(`git reset --soft ${initialGitRef.ref}`, {
|
53
|
+
cwd: workspacePath,
|
54
|
+
encoding: 'utf-8',
|
55
|
+
});
|
56
|
+
(0, child_process_1.execSync)(`git commit -m "${commitMessage}" --no-verify`, {
|
57
|
+
cwd: workspacePath,
|
58
|
+
encoding: 'utf-8',
|
59
|
+
});
|
60
|
+
}
|
61
|
+
}
|
62
|
+
async function runSingleMigration(workspacePath, migration, configuration) {
|
63
|
+
try {
|
64
|
+
modifyMigrationsJsonMetadata(workspacePath, addRunningMigration(migration.id));
|
65
|
+
const gitRefBefore = (0, child_process_1.execSync)('git rev-parse HEAD', {
|
66
|
+
cwd: workspacePath,
|
67
|
+
encoding: 'utf-8',
|
68
|
+
}).trim();
|
69
|
+
// For Migrate UI, this current module is loaded either from:
|
70
|
+
// 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.
|
71
|
+
// 2. Bundled into Console, so the version is fixed to what we build Console with.
|
72
|
+
const updatedMigrateModule = await Promise.resolve().then(() => require('./migrate.js'));
|
73
|
+
const fileChanges = await updatedMigrateModule.runNxOrAngularMigration(workspacePath, migration, false, configuration.createCommits, configuration.commitPrefix || 'chore: [nx migration] ', undefined, true);
|
74
|
+
const gitRefAfter = (0, child_process_1.execSync)('git rev-parse HEAD', {
|
75
|
+
cwd: workspacePath,
|
76
|
+
encoding: 'utf-8',
|
77
|
+
}).trim();
|
78
|
+
modifyMigrationsJsonMetadata(workspacePath, addSuccessfulMigration(migration.id, fileChanges.map((change) => ({
|
79
|
+
path: change.path,
|
80
|
+
type: change.type,
|
81
|
+
})), gitRefAfter));
|
82
|
+
if (gitRefBefore !== gitRefAfter) {
|
83
|
+
(0, child_process_1.execSync)('git add migrations.json', {
|
84
|
+
cwd: workspacePath,
|
85
|
+
encoding: 'utf-8',
|
86
|
+
});
|
87
|
+
(0, child_process_1.execSync)('git commit --amend --no-verify --no-edit', {
|
88
|
+
cwd: workspacePath,
|
89
|
+
encoding: 'utf-8',
|
90
|
+
});
|
91
|
+
}
|
92
|
+
}
|
93
|
+
catch (e) {
|
94
|
+
modifyMigrationsJsonMetadata(workspacePath, addFailedMigration(migration.id, e.message));
|
95
|
+
}
|
96
|
+
finally {
|
97
|
+
modifyMigrationsJsonMetadata(workspacePath, removeRunningMigration(migration.id));
|
98
|
+
(0, child_process_1.execSync)('git add migrations.json', {
|
99
|
+
cwd: workspacePath,
|
100
|
+
encoding: 'utf-8',
|
101
|
+
});
|
102
|
+
}
|
103
|
+
}
|
104
|
+
async function getImplementationPath(workspacePath, migration) {
|
105
|
+
const { collection, collectionPath } = (0, migrate_1.readMigrationCollection)(migration.package, workspacePath);
|
106
|
+
const { path } = (0, migrate_1.getImplementationPath)(collection, collectionPath, migration.name);
|
107
|
+
return path;
|
108
|
+
}
|
109
|
+
function modifyMigrationsJsonMetadata(workspacePath, modify) {
|
110
|
+
const migrationsJsonPath = (0, path_1.join)(workspacePath, 'migrations.json');
|
111
|
+
const migrationsJson = JSON.parse((0, fs_1.readFileSync)(migrationsJsonPath, 'utf-8'));
|
112
|
+
migrationsJson['nx-console'] = modify(migrationsJson['nx-console']);
|
113
|
+
(0, fs_1.writeFileSync)(migrationsJsonPath, JSON.stringify(migrationsJson, null, 2));
|
114
|
+
}
|
115
|
+
function addSuccessfulMigration(id, fileChanges, ref) {
|
116
|
+
return (migrationsJsonMetadata) => {
|
117
|
+
const copied = { ...migrationsJsonMetadata };
|
118
|
+
if (!copied.completedMigrations) {
|
119
|
+
copied.completedMigrations = {};
|
120
|
+
}
|
121
|
+
copied.completedMigrations = {
|
122
|
+
...copied.completedMigrations,
|
123
|
+
[id]: {
|
124
|
+
type: 'successful',
|
125
|
+
name: id,
|
126
|
+
changedFiles: fileChanges,
|
127
|
+
ref,
|
128
|
+
},
|
129
|
+
};
|
130
|
+
return copied;
|
131
|
+
};
|
132
|
+
}
|
133
|
+
function addFailedMigration(id, error) {
|
134
|
+
return (migrationsJsonMetadata) => {
|
135
|
+
const copied = { ...migrationsJsonMetadata };
|
136
|
+
if (!copied.completedMigrations) {
|
137
|
+
copied.completedMigrations = {};
|
138
|
+
}
|
139
|
+
copied.completedMigrations = {
|
140
|
+
...copied.completedMigrations,
|
141
|
+
[id]: {
|
142
|
+
type: 'failed',
|
143
|
+
name: id,
|
144
|
+
error,
|
145
|
+
},
|
146
|
+
};
|
147
|
+
return copied;
|
148
|
+
};
|
149
|
+
}
|
150
|
+
function addSkippedMigration(id) {
|
151
|
+
return (migrationsJsonMetadata) => {
|
152
|
+
const copied = { ...migrationsJsonMetadata };
|
153
|
+
if (!copied.completedMigrations) {
|
154
|
+
copied.completedMigrations = {};
|
155
|
+
}
|
156
|
+
copied.completedMigrations = {
|
157
|
+
...copied.completedMigrations,
|
158
|
+
[id]: {
|
159
|
+
type: 'skipped',
|
160
|
+
},
|
161
|
+
};
|
162
|
+
return copied;
|
163
|
+
};
|
164
|
+
}
|
165
|
+
function addRunningMigration(id) {
|
166
|
+
return (migrationsJsonMetadata) => {
|
167
|
+
migrationsJsonMetadata.runningMigrations = [
|
168
|
+
...(migrationsJsonMetadata.runningMigrations ?? []),
|
169
|
+
id,
|
170
|
+
];
|
171
|
+
return migrationsJsonMetadata;
|
172
|
+
};
|
173
|
+
}
|
174
|
+
function removeRunningMigration(id) {
|
175
|
+
return (migrationsJsonMetadata) => {
|
176
|
+
migrationsJsonMetadata.runningMigrations =
|
177
|
+
migrationsJsonMetadata.runningMigrations?.filter((n) => n !== id);
|
178
|
+
if (migrationsJsonMetadata.runningMigrations?.length === 0) {
|
179
|
+
delete migrationsJsonMetadata.runningMigrations;
|
180
|
+
}
|
181
|
+
return migrationsJsonMetadata;
|
182
|
+
};
|
183
|
+
}
|
184
|
+
function readMigrationsJsonMetadata(workspacePath) {
|
185
|
+
const migrationsJsonPath = (0, path_1.join)(workspacePath, 'migrations.json');
|
186
|
+
const migrationsJson = JSON.parse((0, fs_1.readFileSync)(migrationsJsonPath, 'utf-8'));
|
187
|
+
return migrationsJson['nx-console'];
|
188
|
+
}
|
@@ -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;
|
@@ -108,8 +109,24 @@ export declare function executeMigrations(root: string, migrations: {
|
|
108
109
|
version: string;
|
109
110
|
cli?: "nx" | "angular";
|
110
111
|
}[]>;
|
112
|
+
export declare function runNxOrAngularMigration(root: string, migration: {
|
113
|
+
package: string;
|
114
|
+
name: string;
|
115
|
+
description?: string;
|
116
|
+
version: string;
|
117
|
+
cli?: 'nx' | 'angular';
|
118
|
+
}, isVerbose: boolean, shouldCreateCommits: boolean, commitPrefix: string, installDepsIfChanged?: () => void, handleInstallDeps?: boolean): Promise<FileChange[]>;
|
111
119
|
export declare function migrate(root: string, args: {
|
112
120
|
[k: string]: any;
|
113
121
|
}, rawArgs: string[]): Promise<number>;
|
114
122
|
export declare function runMigration(): void;
|
123
|
+
export declare function readMigrationCollection(packageName: string, root: string): {
|
124
|
+
collection: MigrationsJson;
|
125
|
+
collectionPath: string;
|
126
|
+
};
|
127
|
+
export declare function getImplementationPath(collection: MigrationsJson, collectionPath: string, name: string): {
|
128
|
+
path: string;
|
129
|
+
fnSymbol: string;
|
130
|
+
};
|
131
|
+
export declare function nxCliPath(nxWorkspaceRoot?: string): string;
|
115
132
|
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");
|
@@ -809,9 +813,12 @@ async function generateMigrationsJsonAndUpdatePackageJson(root, opts) {
|
|
809
813
|
// The above code is to remind folks when updating to a new major and not currently using Nx cloud.
|
810
814
|
// If for some reason it fails, it shouldn't affect the overall migration process
|
811
815
|
}
|
812
|
-
|
813
|
-
|
814
|
-
|
816
|
+
const bodyLines = process.env['NX_CONSOLE']
|
817
|
+
? [
|
818
|
+
'- Inspect the package.json changes in the built-in diff editor [Click to open]',
|
819
|
+
'- Confirm the changes to install the new dependencies and continue the migration',
|
820
|
+
]
|
821
|
+
: [
|
815
822
|
`- Make sure package.json changes make sense and then run '${pmc.install}',`,
|
816
823
|
...(migrations.length > 0
|
817
824
|
? [`- Run '${pmc.exec} nx migrate --run-migrations'`]
|
@@ -830,7 +837,10 @@ async function generateMigrationsJsonAndUpdatePackageJson(root, opts) {
|
|
830
837
|
`- You may run '${pmc.run('nx', 'connect-to-nx-cloud')}' to get faster builds, GitHub integration, and more. Check out https://nx.app`,
|
831
838
|
]
|
832
839
|
: []),
|
833
|
-
]
|
840
|
+
];
|
841
|
+
output_1.output.log({
|
842
|
+
title: 'Next steps:',
|
843
|
+
bodyLines,
|
834
844
|
});
|
835
845
|
}
|
836
846
|
catch (e) {
|
@@ -881,26 +891,31 @@ function showConnectToCloudMessage() {
|
|
881
891
|
return false;
|
882
892
|
}
|
883
893
|
}
|
884
|
-
function runInstall() {
|
885
|
-
|
894
|
+
function runInstall(nxWorkspaceRoot) {
|
895
|
+
let packageManager;
|
896
|
+
let pmCommands;
|
897
|
+
if (nxWorkspaceRoot) {
|
898
|
+
packageManager = (0, package_manager_1.detectPackageManager)(nxWorkspaceRoot);
|
899
|
+
pmCommands = (0, package_manager_1.getPackageManagerCommand)(packageManager, nxWorkspaceRoot);
|
900
|
+
}
|
901
|
+
else {
|
902
|
+
pmCommands = (0, package_manager_1.getPackageManagerCommand)();
|
903
|
+
}
|
886
904
|
// TODO: remove this
|
887
|
-
if ((0, package_manager_1.detectPackageManager)() === 'npm') {
|
905
|
+
if (packageManager ?? (0, package_manager_1.detectPackageManager)() === 'npm') {
|
888
906
|
process.env.npm_config_legacy_peer_deps ??= 'true';
|
889
907
|
}
|
890
908
|
output_1.output.log({
|
891
909
|
title: `Running '${pmCommands.install}' to make sure necessary packages are installed`,
|
892
910
|
});
|
893
|
-
(0, child_process_1.execSync)(pmCommands.install, {
|
911
|
+
(0, child_process_1.execSync)(pmCommands.install, {
|
912
|
+
stdio: [0, 1, 2],
|
913
|
+
windowsHide: false,
|
914
|
+
cwd: nxWorkspaceRoot ?? process.cwd(),
|
915
|
+
});
|
894
916
|
}
|
895
917
|
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
|
-
};
|
918
|
+
const changedDepInstaller = new ChangedDepInstaller(root);
|
904
919
|
const migrationsWithNoChanges = [];
|
905
920
|
const sortedMigrations = migrations.sort((a, b) => {
|
906
921
|
// special case for the split configuration migration to run first
|
@@ -920,49 +935,9 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
920
935
|
for (const m of sortedMigrations) {
|
921
936
|
logger_1.logger.info(`Running migration ${m.package}: ${m.name}`);
|
922
937
|
try {
|
923
|
-
const
|
924
|
-
if (
|
925
|
-
|
926
|
-
logger_1.logger.info(`Ran ${m.name} from ${m.package}`);
|
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
|
-
}
|
938
|
+
const changes = await runNxOrAngularMigration(root, m, isVerbose, shouldCreateCommits, commitPrefix, () => changedDepInstaller.installDepsIfChanged());
|
939
|
+
if (changes.length === 0) {
|
940
|
+
migrationsWithNoChanges.push(m);
|
966
941
|
}
|
967
942
|
logger_1.logger.info(`---------------------------------------------------------`);
|
968
943
|
}
|
@@ -974,10 +949,78 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
|
|
974
949
|
}
|
975
950
|
}
|
976
951
|
if (!shouldCreateCommits) {
|
977
|
-
installDepsIfChanged();
|
952
|
+
changedDepInstaller.installDepsIfChanged();
|
978
953
|
}
|
979
954
|
return migrationsWithNoChanges;
|
980
955
|
}
|
956
|
+
class ChangedDepInstaller {
|
957
|
+
constructor(root) {
|
958
|
+
this.root = root;
|
959
|
+
this.initialDeps = getStringifiedPackageJsonDeps(root);
|
960
|
+
}
|
961
|
+
installDepsIfChanged() {
|
962
|
+
const currentDeps = getStringifiedPackageJsonDeps(this.root);
|
963
|
+
if (this.initialDeps !== currentDeps) {
|
964
|
+
runInstall(this.root);
|
965
|
+
}
|
966
|
+
this.initialDeps = currentDeps;
|
967
|
+
}
|
968
|
+
}
|
969
|
+
async function runNxOrAngularMigration(root, migration, isVerbose, shouldCreateCommits, commitPrefix, installDepsIfChanged, handleInstallDeps = false) {
|
970
|
+
if (!installDepsIfChanged) {
|
971
|
+
const changedDepInstaller = new ChangedDepInstaller(root);
|
972
|
+
installDepsIfChanged = () => changedDepInstaller.installDepsIfChanged();
|
973
|
+
}
|
974
|
+
const { collection, collectionPath } = readMigrationCollection(migration.package, root);
|
975
|
+
let changes = [];
|
976
|
+
if (!isAngularMigration(collection, collectionPath, migration.name)) {
|
977
|
+
changes = await runNxMigration(root, collectionPath, collection, migration.name);
|
978
|
+
logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
|
979
|
+
logger_1.logger.info(` ${migration.description}\n`);
|
980
|
+
if (changes.length < 1) {
|
981
|
+
logger_1.logger.info(`No changes were made\n`);
|
982
|
+
return [];
|
983
|
+
}
|
984
|
+
logger_1.logger.info('Changes:');
|
985
|
+
(0, tree_1.printChanges)(changes, ' ');
|
986
|
+
logger_1.logger.info('');
|
987
|
+
}
|
988
|
+
else {
|
989
|
+
const ngCliAdapter = await getNgCompatLayer();
|
990
|
+
const { madeChanges, loggingQueue } = await ngCliAdapter.runMigration(root, migration.package, migration.name, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(await (0, project_graph_1.createProjectGraphAsync)())
|
991
|
+
.projects, isVerbose);
|
992
|
+
logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
|
993
|
+
logger_1.logger.info(` ${migration.description}\n`);
|
994
|
+
if (!madeChanges) {
|
995
|
+
logger_1.logger.info(`No changes were made\n`);
|
996
|
+
return [];
|
997
|
+
}
|
998
|
+
logger_1.logger.info('Changes:');
|
999
|
+
loggingQueue.forEach((log) => logger_1.logger.info(' ' + log));
|
1000
|
+
logger_1.logger.info('');
|
1001
|
+
}
|
1002
|
+
if (shouldCreateCommits) {
|
1003
|
+
installDepsIfChanged();
|
1004
|
+
const commitMessage = `${commitPrefix}${migration.name}`;
|
1005
|
+
try {
|
1006
|
+
const committedSha = (0, git_utils_1.commitChanges)(commitMessage, root);
|
1007
|
+
if (committedSha) {
|
1008
|
+
logger_1.logger.info(chalk.dim(`- Commit created for changes: ${committedSha}`));
|
1009
|
+
}
|
1010
|
+
else {
|
1011
|
+
logger_1.logger.info(chalk.red(`- A commit could not be created/retrieved for an unknown reason`));
|
1012
|
+
}
|
1013
|
+
}
|
1014
|
+
catch (e) {
|
1015
|
+
logger_1.logger.info(chalk.red(`- ${e.message}`));
|
1016
|
+
}
|
1017
|
+
// if we are running this function alone, we need to install deps internally
|
1018
|
+
}
|
1019
|
+
else if (handleInstallDeps) {
|
1020
|
+
installDepsIfChanged();
|
1021
|
+
}
|
1022
|
+
return changes;
|
1023
|
+
}
|
981
1024
|
async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits = false, commitPrefix) {
|
982
1025
|
if (!process.env.NX_MIGRATE_SKIP_INSTALL) {
|
983
1026
|
runInstall();
|
@@ -1111,7 +1154,7 @@ function getImplementationPath(collection, collectionPath, name) {
|
|
1111
1154
|
}
|
1112
1155
|
return { path: implPath, fnSymbol };
|
1113
1156
|
}
|
1114
|
-
function nxCliPath() {
|
1157
|
+
function nxCliPath(nxWorkspaceRoot) {
|
1115
1158
|
const version = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
|
1116
1159
|
try {
|
1117
1160
|
const packageManager = (0, package_manager_1.detectPackageManager)();
|
@@ -1124,7 +1167,7 @@ function nxCliPath() {
|
|
1124
1167
|
},
|
1125
1168
|
license: 'MIT',
|
1126
1169
|
});
|
1127
|
-
(0, package_manager_1.copyPackageManagerConfigurationFiles)(workspace_root_1.workspaceRoot, tmpDir);
|
1170
|
+
(0, package_manager_1.copyPackageManagerConfigurationFiles)(nxWorkspaceRoot ?? workspace_root_1.workspaceRoot, tmpDir);
|
1128
1171
|
if (pmc.preInstall) {
|
1129
1172
|
// ensure package.json and repo in tmp folder is set to a proper package manager state
|
1130
1173
|
(0, child_process_1.execSync)(pmc.preInstall, {
|
@@ -1148,7 +1191,7 @@ function nxCliPath() {
|
|
1148
1191
|
});
|
1149
1192
|
// Set NODE_PATH so that these modules can be used for module resolution
|
1150
1193
|
addToNodePath((0, path_1.join)(tmpDir, 'node_modules'));
|
1151
|
-
addToNodePath((0, path_1.join)(workspace_root_1.workspaceRoot, 'node_modules'));
|
1194
|
+
addToNodePath((0, path_1.join)(nxWorkspaceRoot ?? workspace_root_1.workspaceRoot, 'node_modules'));
|
1152
1195
|
return (0, path_1.join)(tmpDir, `node_modules`, '.bin', 'nx');
|
1153
1196
|
}
|
1154
1197
|
catch (e) {
|
@@ -58,6 +58,16 @@ export interface MigrationsJsonEntry {
|
|
58
58
|
factory?: string;
|
59
59
|
requires?: Record<string, string>;
|
60
60
|
}
|
61
|
+
export type MigrationDetailsWithId = GeneratedMigrationDetails & {
|
62
|
+
id: string;
|
63
|
+
};
|
64
|
+
export interface GeneratedMigrationDetails {
|
65
|
+
name: string;
|
66
|
+
version: string;
|
67
|
+
package: string;
|
68
|
+
description: string;
|
69
|
+
implementation: string;
|
70
|
+
}
|
61
71
|
export interface MigrationsJson {
|
62
72
|
name?: string;
|
63
73
|
version?: string;
|