nx 21.2.0-beta.1 → 21.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/README.md +1 -1
- package/package.json +11 -11
- package/src/command-line/affected/command-object.js +1 -1
- package/src/command-line/graph/graph.d.ts +1 -0
- package/src/command-line/graph/graph.js +56 -11
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +23 -4
- package/src/command-line/migrate/migrate.js +10 -4
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +2 -1
- package/src/executors/run-commands/run-commands.impl.js +5 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/utilities/url-shorten.d.ts +1 -1
- package/src/nx-cloud/utilities/url-shorten.js +27 -26
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +6 -3
- package/src/tasks-runner/run-command.js +11 -0
- package/src/tasks-runner/running-tasks/noop-child-process.d.ts +2 -1
- package/src/tasks-runner/running-tasks/noop-child-process.js +4 -1
package/README.md
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
# Nx: Smart Repos · Fast Builds
|
24
24
|
|
25
|
-
|
25
|
+
An AI-first build platform that connects everything from your editor to CI. Helping you deliver fast, without breaking things.
|
26
26
|
|
27
27
|
## Getting Started
|
28
28
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "21.2.0-beta.
|
3
|
+
"version": "21.2.0-beta.2",
|
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.2.0-beta.
|
87
|
-
"@nx/nx-darwin-x64": "21.2.0-beta.
|
88
|
-
"@nx/nx-freebsd-x64": "21.2.0-beta.
|
89
|
-
"@nx/nx-linux-arm-gnueabihf": "21.2.0-beta.
|
90
|
-
"@nx/nx-linux-arm64-gnu": "21.2.0-beta.
|
91
|
-
"@nx/nx-linux-arm64-musl": "21.2.0-beta.
|
92
|
-
"@nx/nx-linux-x64-gnu": "21.2.0-beta.
|
93
|
-
"@nx/nx-linux-x64-musl": "21.2.0-beta.
|
94
|
-
"@nx/nx-win32-arm64-msvc": "21.2.0-beta.
|
95
|
-
"@nx/nx-win32-x64-msvc": "21.2.0-beta.
|
86
|
+
"@nx/nx-darwin-arm64": "21.2.0-beta.2",
|
87
|
+
"@nx/nx-darwin-x64": "21.2.0-beta.2",
|
88
|
+
"@nx/nx-freebsd-x64": "21.2.0-beta.2",
|
89
|
+
"@nx/nx-linux-arm-gnueabihf": "21.2.0-beta.2",
|
90
|
+
"@nx/nx-linux-arm64-gnu": "21.2.0-beta.2",
|
91
|
+
"@nx/nx-linux-arm64-musl": "21.2.0-beta.2",
|
92
|
+
"@nx/nx-linux-x64-gnu": "21.2.0-beta.2",
|
93
|
+
"@nx/nx-linux-x64-musl": "21.2.0-beta.2",
|
94
|
+
"@nx/nx-win32-arm64-msvc": "21.2.0-beta.2",
|
95
|
+
"@nx/nx-win32-x64-msvc": "21.2.0-beta.2"
|
96
96
|
},
|
97
97
|
"nx-migrations": {
|
98
98
|
"migrations": "./migrations.json",
|
@@ -6,7 +6,7 @@ const documentation_1 = require("../yargs-utils/documentation");
|
|
6
6
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
7
7
|
exports.yargsAffectedCommand = {
|
8
8
|
command: 'affected',
|
9
|
-
describe: 'Run target for affected projects. See https://nx.dev/ci/features/affected for more details.',
|
9
|
+
describe: 'Run target for affected projects. Affected projects are projects that have been changed and projects that depend on the changed projects. See https://nx.dev/ci/features/affected for more details.',
|
10
10
|
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withTuiOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withTargetAndConfigurationOption)((0, shared_options_1.withBatch)(yargs))))))
|
11
11
|
.option('all', {
|
12
12
|
type: 'boolean',
|
@@ -9,6 +9,7 @@ const minimatch_1 = require("minimatch");
|
|
9
9
|
const node_url_1 = require("node:url");
|
10
10
|
const open = require("open");
|
11
11
|
const path_1 = require("path");
|
12
|
+
const net = require("net");
|
12
13
|
const perf_hooks_1 = require("perf_hooks");
|
13
14
|
const configuration_1 = require("../../config/configuration");
|
14
15
|
const fileutils_1 = require("../../utils/fileutils");
|
@@ -207,7 +208,7 @@ async function generateGraph(args, affectedProjects) {
|
|
207
208
|
}
|
208
209
|
}
|
209
210
|
if (args.affected) {
|
210
|
-
affectedProjects = (await (0, affected_1.getAffectedGraphNodes)((0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', { printWarnings: args.file !== 'stdout' }, (0, configuration_1.readNxJson)()).nxArgs, rawGraph)).map((n) => n.name);
|
211
|
+
affectedProjects = (await (0, affected_1.getAffectedGraphNodes)((0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', { printWarnings: !args.print && args.file !== 'stdout' }, (0, configuration_1.readNxJson)()).nxArgs, rawGraph)).map((n) => n.name);
|
211
212
|
}
|
212
213
|
if (args.exclude) {
|
213
214
|
const invalidExcludes = [];
|
@@ -226,13 +227,12 @@ async function generateGraph(args, affectedProjects) {
|
|
226
227
|
}
|
227
228
|
let html = (0, node_fs_1.readFileSync)((0, path_1.join)(__dirname, '../../core/graph/index.html'), 'utf-8');
|
228
229
|
prunedGraph = filterGraph(prunedGraph, args.focus || null, args.exclude || []);
|
230
|
+
if (args.print || args.file === 'stdout') {
|
231
|
+
console.log(JSON.stringify(await createJsonOutput(prunedGraph, rawGraph, args.projects, args.targets), null, 2));
|
232
|
+
await output_1.output.drain();
|
233
|
+
process.exit(0);
|
234
|
+
}
|
229
235
|
if (args.file) {
|
230
|
-
// stdout is a magical constant that doesn't actually write a file
|
231
|
-
if (args.file === 'stdout') {
|
232
|
-
console.log(JSON.stringify(await createJsonOutput(prunedGraph, rawGraph, args.projects, args.targets), null, 2));
|
233
|
-
await output_1.output.drain();
|
234
|
-
process.exit(0);
|
235
|
-
}
|
236
236
|
const workspaceFolder = workspace_root_1.workspaceRoot;
|
237
237
|
const ext = (0, path_1.extname)(args.file);
|
238
238
|
const fullFilePath = (0, path_1.isAbsolute)(args.file)
|
@@ -287,7 +287,20 @@ async function generateGraph(args, affectedProjects) {
|
|
287
287
|
}
|
288
288
|
else {
|
289
289
|
const environmentJs = buildEnvironmentJs(args.exclude || [], args.watch, !!args.file && args.file.endsWith('html') ? 'build' : 'serve');
|
290
|
-
|
290
|
+
let app;
|
291
|
+
let url;
|
292
|
+
try {
|
293
|
+
const result = await startServer(html, environmentJs, args.host || '127.0.0.1', args.port || 4211, args.watch, affectedProjects, args.focus, args.groupByFolder, args.exclude);
|
294
|
+
app = result.app;
|
295
|
+
url = result.url;
|
296
|
+
}
|
297
|
+
catch (err) {
|
298
|
+
output_1.output.error({
|
299
|
+
title: 'Failed to start graph server',
|
300
|
+
bodyLines: [err.message],
|
301
|
+
});
|
302
|
+
process.exit(1);
|
303
|
+
}
|
291
304
|
url.pathname = args.view;
|
292
305
|
if (args.focus) {
|
293
306
|
url.pathname += '/' + encodeURIComponent(args.focus);
|
@@ -318,6 +331,28 @@ async function generateGraph(args, affectedProjects) {
|
|
318
331
|
});
|
319
332
|
}
|
320
333
|
}
|
334
|
+
function findAvailablePort(startPort, host = '127.0.0.1') {
|
335
|
+
return new Promise((resolve, reject) => {
|
336
|
+
const server = net.createServer();
|
337
|
+
server.listen(startPort, host, () => {
|
338
|
+
const port = server.address().port;
|
339
|
+
server.close(() => {
|
340
|
+
resolve(port);
|
341
|
+
});
|
342
|
+
});
|
343
|
+
server.on('error', (err) => {
|
344
|
+
if (err.code === 'EADDRINUSE') {
|
345
|
+
// Port is in use, try the next one
|
346
|
+
findAvailablePort(startPort + 1, host)
|
347
|
+
.then(resolve)
|
348
|
+
.catch(reject);
|
349
|
+
}
|
350
|
+
else {
|
351
|
+
reject(err);
|
352
|
+
}
|
353
|
+
});
|
354
|
+
});
|
355
|
+
}
|
321
356
|
async function startServer(html, environmentJs, host, port = 4211, watchForChanges = true, affected = [], focus = null, groupByFolder = false, exclude = []) {
|
322
357
|
let unregisterFileWatcher;
|
323
358
|
if (watchForChanges && !client_1.daemonClient.enabled()) {
|
@@ -418,9 +453,19 @@ async function startServer(html, environmentJs, host, port = 4211, watchForChang
|
|
418
453
|
};
|
419
454
|
process.on('SIGINT', () => handleTermination(128 + 2));
|
420
455
|
process.on('SIGTERM', () => handleTermination(128 + 15));
|
421
|
-
|
422
|
-
|
423
|
-
|
456
|
+
// Find an available port starting from the requested port
|
457
|
+
const availablePort = await findAvailablePort(port, host);
|
458
|
+
return new Promise((res, rej) => {
|
459
|
+
app.on('error', (err) => {
|
460
|
+
rej(err);
|
461
|
+
});
|
462
|
+
app.listen(availablePort, host, () => {
|
463
|
+
if (availablePort !== port) {
|
464
|
+
output_1.output.note({
|
465
|
+
title: `Port ${port} was already in use, using port ${availablePort} instead`,
|
466
|
+
});
|
467
|
+
}
|
468
|
+
res({ app, url: new node_url_1.URL(`http://${host}:${availablePort}`) });
|
424
469
|
});
|
425
470
|
});
|
426
471
|
}
|
@@ -5,28 +5,47 @@ const child_process_1 = require("child_process");
|
|
5
5
|
const path_1 = require("path");
|
6
6
|
const semver_1 = require("semver");
|
7
7
|
const fileutils_1 = require("../../../../utils/fileutils");
|
8
|
+
const installation_directory_1 = require("../../../../utils/installation-directory");
|
8
9
|
const object_sort_1 = require("../../../../utils/object-sort");
|
9
10
|
const output_1 = require("../../../../utils/output");
|
10
11
|
const package_json_1 = require("../../../../utils/package-json");
|
11
12
|
const package_manager_1 = require("../../../../utils/package-manager");
|
12
|
-
const utils_1 = require("../utils");
|
13
13
|
const connect_to_nx_cloud_1 = require("../../../connect/connect-to-nx-cloud");
|
14
|
+
const utils_1 = require("../utils");
|
14
15
|
// map of Angular major versions to Nx versions to use for legacy `nx init` migrations,
|
15
16
|
// key is major Angular version and value is Nx version to use
|
16
17
|
const nxAngularLegacyVersionMap = {
|
17
18
|
14: '~17.0.0',
|
18
19
|
15: '~19.0.0',
|
19
20
|
16: '~20.1.0',
|
21
|
+
17: '~21.1.0',
|
20
22
|
};
|
21
23
|
// min major angular version supported in latest Nx
|
22
|
-
const minMajorAngularVersionSupported =
|
24
|
+
const minMajorAngularVersionSupported = Math.max(...Object.keys(nxAngularLegacyVersionMap).map(Number)) + 1;
|
23
25
|
// version when the Nx CLI changed from @nrwl/tao & @nrwl/cli to nx
|
24
26
|
const versionWithConsolidatedPackages = '13.9.0';
|
25
27
|
// version when packages were rescoped from @nrwl/* to @nx/*
|
26
28
|
const versionWithRescopeToNx = '16.0.0-beta.2';
|
27
29
|
async function getLegacyMigrationFunctionIfApplicable(repoRoot, options) {
|
28
|
-
|
29
|
-
|
30
|
+
let majorAngularVersion;
|
31
|
+
try {
|
32
|
+
const angularVersion = (0, package_json_1.readModulePackageJson)('@angular/core', [
|
33
|
+
repoRoot,
|
34
|
+
...(0, installation_directory_1.getNxRequirePaths)(),
|
35
|
+
]).packageJson.version;
|
36
|
+
majorAngularVersion = (0, semver_1.major)(angularVersion);
|
37
|
+
}
|
38
|
+
catch {
|
39
|
+
output_1.output.error({
|
40
|
+
title: 'Could not determine the existing Angular version',
|
41
|
+
bodyLines: [
|
42
|
+
'Please ensure "@angular/core" is installed in the workspace and you are running this command from the root of the workspace.',
|
43
|
+
],
|
44
|
+
});
|
45
|
+
// errors are caught in the initHandler and not logged to the user, so we
|
46
|
+
// log it first and then throw to ensure it is logged to the user
|
47
|
+
throw new Error('Could not determine the existing Angular version');
|
48
|
+
}
|
30
49
|
if (majorAngularVersion >= minMajorAngularVersionSupported) {
|
31
50
|
// non-legacy
|
32
51
|
return null;
|
@@ -1175,6 +1175,7 @@ function getImplementationPath(collection, collectionPath, name) {
|
|
1175
1175
|
}
|
1176
1176
|
function nxCliPath(nxWorkspaceRoot) {
|
1177
1177
|
const version = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
|
1178
|
+
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
1178
1179
|
try {
|
1179
1180
|
const packageManager = (0, package_manager_1.detectPackageManager)();
|
1180
1181
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
@@ -1187,25 +1188,30 @@ function nxCliPath(nxWorkspaceRoot) {
|
|
1187
1188
|
license: 'MIT',
|
1188
1189
|
});
|
1189
1190
|
(0, package_manager_1.copyPackageManagerConfigurationFiles)(nxWorkspaceRoot ?? workspace_root_1.workspaceRoot, tmpDir);
|
1191
|
+
// Let's print the output of the install process to the console when verbose
|
1192
|
+
// is enabled, so it's easier to debug issues with the installation process
|
1193
|
+
const stdio = isVerbose
|
1194
|
+
? ['ignore', 'inherit', 'inherit']
|
1195
|
+
: 'ignore';
|
1190
1196
|
if (pmc.preInstall) {
|
1191
1197
|
// ensure package.json and repo in tmp folder is set to a proper package manager state
|
1192
1198
|
(0, child_process_1.execSync)(pmc.preInstall, {
|
1193
1199
|
cwd: tmpDir,
|
1194
|
-
stdio
|
1200
|
+
stdio,
|
1195
1201
|
windowsHide: false,
|
1196
1202
|
});
|
1197
1203
|
// if it's berry ensure we set the node_linker to node-modules
|
1198
1204
|
if (packageManager === 'yarn' && pmc.ciInstall.includes('immutable')) {
|
1199
1205
|
(0, child_process_1.execSync)('yarn config set nodeLinker node-modules', {
|
1200
1206
|
cwd: tmpDir,
|
1201
|
-
stdio
|
1207
|
+
stdio,
|
1202
1208
|
windowsHide: false,
|
1203
1209
|
});
|
1204
1210
|
}
|
1205
1211
|
}
|
1206
1212
|
(0, child_process_1.execSync)(pmc.install, {
|
1207
1213
|
cwd: tmpDir,
|
1208
|
-
stdio
|
1214
|
+
stdio,
|
1209
1215
|
windowsHide: false,
|
1210
1216
|
});
|
1211
1217
|
// Set NODE_PATH so that these modules can be used for module resolution
|
@@ -1215,7 +1221,7 @@ function nxCliPath(nxWorkspaceRoot) {
|
|
1215
1221
|
}
|
1216
1222
|
catch (e) {
|
1217
1223
|
console.error(`Failed to install the ${version} version of the migration script. Using the current version.`);
|
1218
|
-
if (
|
1224
|
+
if (isVerbose) {
|
1219
1225
|
console.error(e);
|
1220
1226
|
}
|
1221
1227
|
return null;
|