nx 21.0.0-beta.0 → 21.0.0-beta.1
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
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "21.0.0-beta.
|
3
|
+
"version": "21.0.0-beta.1",
|
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.1",
|
87
|
+
"@nx/nx-darwin-x64": "21.0.0-beta.1",
|
88
|
+
"@nx/nx-freebsd-x64": "21.0.0-beta.1",
|
89
|
+
"@nx/nx-linux-arm-gnueabihf": "21.0.0-beta.1",
|
90
|
+
"@nx/nx-linux-arm64-gnu": "21.0.0-beta.1",
|
91
|
+
"@nx/nx-linux-arm64-musl": "21.0.0-beta.1",
|
92
|
+
"@nx/nx-linux-x64-gnu": "21.0.0-beta.1",
|
93
|
+
"@nx/nx-linux-x64-musl": "21.0.0-beta.1",
|
94
|
+
"@nx/nx-win32-arm64-msvc": "21.0.0-beta.1",
|
95
|
+
"@nx/nx-win32-x64-msvc": "21.0.0-beta.1"
|
96
96
|
},
|
97
97
|
"nx-migrations": {
|
98
98
|
"migrations": "./migrations.json",
|
@@ -118,10 +118,10 @@ class Migrator {
|
|
118
118
|
const packagesToCheck = await this.populatePackageJsonUpdatesAndGetPackagesToCheck(targetPackage, target);
|
119
119
|
for (const packageToCheck of packagesToCheck) {
|
120
120
|
const filteredUpdates = {};
|
121
|
-
for (const packageUpdate of packageToCheck.updates) {
|
121
|
+
for (const [packageUpdateKey, packageUpdate] of Object.entries(packageToCheck.updates)) {
|
122
122
|
if (this.areRequirementsMet(packageUpdate.requires) &&
|
123
123
|
(!this.interactive ||
|
124
|
-
(await this.runPackageJsonUpdatesConfirmationPrompt(packageUpdate)))) {
|
124
|
+
(await this.runPackageJsonUpdatesConfirmationPrompt(packageUpdate, packageUpdateKey, packageToCheck.package)))) {
|
125
125
|
Object.entries(packageUpdate.packages).forEach(([name, update]) => {
|
126
126
|
filteredUpdates[name] = update;
|
127
127
|
this.packageUpdates[name] = update;
|
@@ -166,15 +166,15 @@ class Migrator {
|
|
166
166
|
addToPackageJson: target.addToPackageJson || false,
|
167
167
|
});
|
168
168
|
const { packageJsonUpdates, packageGroupOrder } = this.getPackageJsonUpdatesFromMigrationConfig(targetPackage, targetVersion, migrationConfig);
|
169
|
-
if (!packageJsonUpdates.length) {
|
169
|
+
if (!Object.keys(packageJsonUpdates).length) {
|
170
170
|
return [];
|
171
171
|
}
|
172
|
-
const shouldCheckUpdates = packageJsonUpdates.some((packageJsonUpdate) => (this.interactive && packageJsonUpdate['x-prompt']) ||
|
172
|
+
const shouldCheckUpdates = Object.values(packageJsonUpdates).some((packageJsonUpdate) => (this.interactive && packageJsonUpdate['x-prompt']) ||
|
173
173
|
Object.keys(packageJsonUpdate.requires ?? {}).length);
|
174
174
|
if (shouldCheckUpdates) {
|
175
175
|
return [{ package: targetPackage, updates: packageJsonUpdates }];
|
176
176
|
}
|
177
|
-
const packageUpdatesToApply = packageJsonUpdates.reduce((m, c) => ({ ...m, ...c.packages }), {});
|
177
|
+
const packageUpdatesToApply = Object.values(packageJsonUpdates).reduce((m, c) => ({ ...m, ...c.packages }), {});
|
178
178
|
return (await Promise.all(Object.entries(packageUpdatesToApply).map(([packageName, packageUpdate]) => this.populatePackageJsonUpdatesAndGetPackagesToCheck(packageName, packageUpdate))))
|
179
179
|
.filter((pkgs) => pkgs.length)
|
180
180
|
.flat()
|
@@ -185,7 +185,7 @@ class Migrator {
|
|
185
185
|
const packageGroupOrder = this.getPackageJsonUpdatesFromPackageGroup(packageName, targetVersion, migrationConfig);
|
186
186
|
if (!migrationConfig.packageJsonUpdates ||
|
187
187
|
!this.getPkgVersion(packageName)) {
|
188
|
-
return { packageJsonUpdates:
|
188
|
+
return { packageJsonUpdates: {}, packageGroupOrder };
|
189
189
|
}
|
190
190
|
const packageJsonUpdates = this.filterPackageJsonUpdates(migrationConfig.packageJsonUpdates, packageName, targetVersion);
|
191
191
|
return { packageJsonUpdates, packageGroupOrder };
|
@@ -228,8 +228,8 @@ class Migrator {
|
|
228
228
|
return packageGroupOrder;
|
229
229
|
}
|
230
230
|
filterPackageJsonUpdates(packageJsonUpdates, packageName, targetVersion) {
|
231
|
-
const filteredPackageJsonUpdates =
|
232
|
-
for (const packageJsonUpdate of Object.
|
231
|
+
const filteredPackageJsonUpdates = {};
|
232
|
+
for (const [packageJsonUpdateKey, packageJsonUpdate] of Object.entries(packageJsonUpdates)) {
|
233
233
|
if (!packageJsonUpdate.packages ||
|
234
234
|
this.lt(packageJsonUpdate.version, this.getPkgVersion(packageName)) ||
|
235
235
|
this.gt(packageJsonUpdate.version, targetVersion)) {
|
@@ -254,7 +254,7 @@ class Migrator {
|
|
254
254
|
}
|
255
255
|
if (Object.keys(filtered).length) {
|
256
256
|
packageJsonUpdate.packages = filtered;
|
257
|
-
filteredPackageJsonUpdates
|
257
|
+
filteredPackageJsonUpdates[packageJsonUpdateKey] = packageJsonUpdate;
|
258
258
|
}
|
259
259
|
}
|
260
260
|
return filteredPackageJsonUpdates;
|
@@ -313,7 +313,7 @@ class Migrator {
|
|
313
313
|
includePrerelease: true,
|
314
314
|
}));
|
315
315
|
}
|
316
|
-
async runPackageJsonUpdatesConfirmationPrompt(packageUpdate) {
|
316
|
+
async runPackageJsonUpdatesConfirmationPrompt(packageUpdate, packageUpdateKey, packageName) {
|
317
317
|
if (!packageUpdate['x-prompt']) {
|
318
318
|
return Promise.resolve(true);
|
319
319
|
}
|
@@ -322,14 +322,17 @@ class Migrator {
|
|
322
322
|
// a same prompt was already answered, skip
|
323
323
|
return Promise.resolve(false);
|
324
324
|
}
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
325
|
+
const promptConfig = {
|
326
|
+
name: 'shouldApply',
|
327
|
+
type: 'confirm',
|
328
|
+
message: packageUpdate['x-prompt'],
|
329
|
+
initial: true,
|
330
|
+
};
|
331
|
+
if (packageName.startsWith('@nx/')) {
|
332
|
+
// @ts-expect-error -- enquirer types aren't correct, footer does exist
|
333
|
+
promptConfig.footer = () => chalk.dim(` View migration details at https://nx.dev/nx-api/${packageName.replace('@nx/', '')}#${packageUpdateKey.replace(/[-\.]/g, '')}packageupdates`);
|
334
|
+
}
|
335
|
+
return await (0, enquirer_1.prompt)([promptConfig]).then(({ shouldApply }) => {
|
333
336
|
this.promptAnswers[promptKey] = shouldApply;
|
334
337
|
if (!shouldApply &&
|
335
338
|
(!this.minVersionWithSkippedUpdates ||
|
Binary file
|
@@ -150,10 +150,15 @@ function writeCache(cache, projectGraph, sourceMaps, errors) {
|
|
150
150
|
computedAt: Date.now(),
|
151
151
|
});
|
152
152
|
(0, node_fs_1.renameSync)(tmpProjectGraphPath, exports.nxProjectGraph);
|
153
|
-
(0, fileutils_1.writeJsonFile)(tmpFileMapPath, cache);
|
154
|
-
(0, node_fs_1.renameSync)(tmpFileMapPath, exports.nxFileMap);
|
155
153
|
(0, fileutils_1.writeJsonFile)(tmpSourceMapPath, sourceMaps);
|
156
154
|
(0, node_fs_1.renameSync)(tmpSourceMapPath, exports.nxSourceMaps);
|
155
|
+
// only write the file map if there are no errors
|
156
|
+
// if there were errors, the errors make the filemap invalid
|
157
|
+
// TODO: We should be able to keep the valid part of the filemap if the errors being thrown told us which parts of the filemap were invalid
|
158
|
+
if (errors.length === 0) {
|
159
|
+
(0, fileutils_1.writeJsonFile)(tmpFileMapPath, cache);
|
160
|
+
(0, node_fs_1.renameSync)(tmpFileMapPath, exports.nxFileMap);
|
161
|
+
}
|
157
162
|
done = true;
|
158
163
|
}
|
159
164
|
catch (err) {
|
@@ -57,22 +57,18 @@ class LoadedNxPlugin {
|
|
57
57
|
if (plugin.preTasksExecution) {
|
58
58
|
this.preTasksExecution = async (context) => {
|
59
59
|
const updates = {};
|
60
|
-
let
|
60
|
+
let originalEnv = process.env;
|
61
61
|
if ((0, enabled_1.isIsolationEnabled)() || (0, client_1.isDaemonEnabled)()) {
|
62
|
-
|
62
|
+
process.env = new Proxy(originalEnv, {
|
63
63
|
set: (target, key, value) => {
|
64
64
|
target[key] = value;
|
65
65
|
updates[key] = value;
|
66
66
|
return true;
|
67
67
|
},
|
68
68
|
});
|
69
|
-
process.env = proxy;
|
70
|
-
revokeFn = revoke;
|
71
69
|
}
|
72
70
|
await plugin.preTasksExecution(this.options, context);
|
73
|
-
|
74
|
-
revokeFn();
|
75
|
-
}
|
71
|
+
process.env = originalEnv;
|
76
72
|
return updates;
|
77
73
|
};
|
78
74
|
}
|
@@ -149,7 +149,7 @@ function handleProjectGraphError(opts, e) {
|
|
149
149
|
bodyLines: bodyLines,
|
150
150
|
});
|
151
151
|
}
|
152
|
-
else {
|
152
|
+
else if (typeof e.message === 'string') {
|
153
153
|
const lines = e.message.split('\n');
|
154
154
|
output_1.output.error({
|
155
155
|
title: lines[0],
|
@@ -159,6 +159,9 @@ function handleProjectGraphError(opts, e) {
|
|
159
159
|
console.error(e);
|
160
160
|
}
|
161
161
|
}
|
162
|
+
else {
|
163
|
+
console.error(e);
|
164
|
+
}
|
162
165
|
process.exit(1);
|
163
166
|
}
|
164
167
|
else {
|