nx 21.4.0-beta.0 → 21.4.0-beta.10
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 +2 -0
- package/bin/nx.js +6 -6
- package/bin/post-install.js +8 -22
- package/package.json +12 -11
- package/schemas/nx-schema.json +99 -1
- package/src/adapter/compat.d.ts +2 -2
- package/src/adapter/compat.d.ts.map +1 -1
- package/src/adapter/compat.js +3 -0
- package/src/command-line/graph/graph.d.ts.map +1 -1
- package/src/command-line/graph/graph.js +152 -45
- package/src/command-line/index.d.ts +23 -0
- package/src/command-line/index.d.ts.map +1 -0
- package/src/command-line/index.js +26 -0
- package/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +1 -1
- package/src/command-line/init/implementation/add-nx-to-monorepo.d.ts.map +1 -1
- package/src/command-line/init/implementation/add-nx-to-monorepo.js +2 -2
- package/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +1 -1
- package/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts.map +1 -1
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +2 -2
- package/src/command-line/init/implementation/utils.d.ts.map +1 -1
- package/src/command-line/init/implementation/utils.js +2 -7
- package/src/command-line/init/init-v2.d.ts.map +1 -1
- package/src/command-line/init/init-v2.js +41 -23
- package/src/command-line/mcp/command-object.d.ts +3 -0
- package/src/command-line/mcp/command-object.d.ts.map +1 -0
- package/src/command-line/mcp/command-object.js +28 -0
- package/src/command-line/mcp/mcp.d.ts +3 -0
- package/src/command-line/mcp/mcp.d.ts.map +1 -0
- package/src/command-line/mcp/mcp.js +23 -0
- package/src/command-line/migrate/migrate-ui-api.d.ts.map +1 -1
- package/src/command-line/migrate/migrate-ui-api.js +18 -8
- package/src/command-line/nx-cloud/connect/command-object.d.ts.map +1 -1
- package/src/command-line/nx-cloud/connect/command-object.js +2 -1
- package/src/command-line/nx-cloud/connect/connect-to-nx-cloud.d.ts +1 -0
- package/src/command-line/nx-cloud/connect/connect-to-nx-cloud.d.ts.map +1 -1
- package/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +19 -5
- package/src/command-line/nx-cloud/connect/view-logs.d.ts.map +1 -1
- package/src/command-line/nx-cloud/connect/view-logs.js +3 -5
- package/src/command-line/nx-commands.d.ts.map +1 -1
- package/src/command-line/nx-commands.js +2 -0
- package/src/command-line/release/changelog.d.ts.map +1 -1
- package/src/command-line/release/changelog.js +7 -2
- package/src/command-line/release/command-object.d.ts +7 -2
- package/src/command-line/release/command-object.d.ts.map +1 -1
- package/src/command-line/release/command-object.js +22 -4
- package/src/command-line/release/config/config.d.ts +10 -3
- package/src/command-line/release/config/config.d.ts.map +1 -1
- package/src/command-line/release/config/config.js +127 -15
- package/src/command-line/release/config/filter-release-groups.d.ts +5 -1
- package/src/command-line/release/config/filter-release-groups.d.ts.map +1 -1
- package/src/command-line/release/publish.js +13 -1
- package/src/command-line/release/release.d.ts.map +1 -1
- package/src/command-line/release/release.js +10 -2
- package/src/command-line/release/utils/resolve-nx-json-error-message.js +1 -1
- package/src/command-line/release/utils/shared.d.ts +9 -0
- package/src/command-line/release/utils/shared.d.ts.map +1 -1
- package/src/command-line/release/utils/shared.js +25 -4
- package/src/command-line/release/version/project-logger.d.ts.map +1 -1
- package/src/command-line/release/version/project-logger.js +1 -0
- package/src/command-line/release/version/release-group-processor.d.ts +6 -1
- package/src/command-line/release/version/release-group-processor.d.ts.map +1 -1
- package/src/command-line/release/version/release-group-processor.js +73 -3
- package/src/command-line/release/version/version-actions.d.ts +21 -0
- package/src/command-line/release/version/version-actions.d.ts.map +1 -1
- package/src/command-line/release/version/version-actions.js +32 -1
- package/src/command-line/release/version.d.ts.map +1 -1
- package/src/command-line/release/version.js +42 -11
- package/src/command-line/sync/sync.d.ts.map +1 -1
- package/src/command-line/sync/sync.js +8 -2
- package/src/config/nx-json.d.ts +58 -0
- package/src/config/nx-json.d.ts.map +1 -1
- package/src/config/workspace-json-project-json.d.ts +2 -1
- package/src/config/workspace-json-project-json.d.ts.map +1 -1
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/server/handle-get-sync-generator-changes.d.ts.map +1 -1
- package/src/daemon/server/handle-get-sync-generator-changes.js +1 -0
- package/src/native/index.d.ts +4 -0
- package/src/native/native-bindings.js +1 -0
- package/src/native/nx.wasi.cjs +12 -10
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -1
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts.map +1 -1
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +8 -10
- package/src/nx-cloud/utilities/onboarding.d.ts.map +1 -1
- package/src/nx-cloud/utilities/onboarding.js +1 -1
- package/src/nx-cloud/utilities/url-shorten.d.ts +1 -2
- package/src/nx-cloud/utilities/url-shorten.d.ts.map +1 -1
- package/src/nx-cloud/utilities/url-shorten.js +17 -21
- package/src/plugins/js/index.d.ts.map +1 -1
- package/src/plugins/js/index.js +10 -16
- package/src/plugins/js/lock-file/bun-parser.d.ts +15 -0
- package/src/plugins/js/lock-file/bun-parser.d.ts.map +1 -0
- package/src/plugins/js/lock-file/bun-parser.js +964 -0
- package/src/plugins/js/lock-file/lock-file.d.ts +2 -2
- package/src/plugins/js/lock-file/lock-file.d.ts.map +1 -1
- package/src/plugins/js/lock-file/lock-file.js +40 -17
- package/src/plugins/js/lock-file/npm-parser.js +2 -2
- package/src/plugins/js/lock-file/pnpm-parser.js +2 -1
- package/src/plugins/js/lock-file/project-graph-pruning.d.ts.map +1 -1
- package/src/plugins/js/lock-file/project-graph-pruning.js +3 -1
- package/src/plugins/js/package-json/create-package-json.d.ts.map +1 -1
- package/src/plugins/js/package-json/create-package-json.js +6 -4
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts.map +1 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +5 -1
- package/src/project-graph/plugins/public-api.d.ts +2 -0
- package/src/project-graph/plugins/public-api.d.ts.map +1 -1
- package/src/project-graph/utils/normalize-project-nodes.d.ts +5 -5
- package/src/project-graph/utils/normalize-project-nodes.d.ts.map +1 -1
- package/src/project-graph/utils/normalize-project-nodes.js +35 -6
- package/src/tasks-runner/is-tui-enabled.d.ts.map +1 -1
- package/src/tasks-runner/is-tui-enabled.js +2 -0
- package/src/tasks-runner/life-cycle.d.ts +2 -0
- package/src/tasks-runner/life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycle.js +7 -0
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +15 -6
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +10 -4
- package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +5 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +1 -1
- package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +1 -1
- package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +7 -12
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +21 -9
- package/src/tasks-runner/run-command.d.ts.map +1 -1
- package/src/tasks-runner/run-command.js +4 -3
- package/src/tasks-runner/task-orchestrator.d.ts.map +1 -1
- package/src/tasks-runner/task-orchestrator.js +5 -0
- package/src/tasks-runner/tasks-schedule.d.ts +1 -0
- package/src/tasks-runner/tasks-schedule.d.ts.map +1 -1
- package/src/tasks-runner/tasks-schedule.js +3 -0
- package/src/utils/ab-testing.d.ts +4 -4
- package/src/utils/ab-testing.d.ts.map +1 -1
- package/src/utils/ab-testing.js +4 -4
- package/src/utils/git-utils.d.ts +6 -5
- package/src/utils/git-utils.d.ts.map +1 -1
- package/src/utils/git-utils.js +73 -41
- package/src/utils/nx-cloud-utils.d.ts.map +1 -1
- package/src/utils/nx-cloud-utils.js +5 -2
- package/src/utils/sync-generators.d.ts +3 -1
- package/src/utils/sync-generators.d.ts.map +1 -1
- package/src/utils/sync-generators.js +7 -1
@@ -4,13 +4,13 @@ exports.generateGraph = generateGraph;
|
|
4
4
|
const crypto_1 = require("crypto");
|
5
5
|
const node_child_process_1 = require("node:child_process");
|
6
6
|
const node_fs_1 = require("node:fs");
|
7
|
-
const http = require("http");
|
7
|
+
const http = require("node:http");
|
8
8
|
const minimatch_1 = require("minimatch");
|
9
9
|
const node_url_1 = require("node:url");
|
10
|
-
const open = require(
|
11
|
-
const
|
12
|
-
const net = require("net");
|
13
|
-
const
|
10
|
+
const open = require("open");
|
11
|
+
const node_path_1 = require("node:path");
|
12
|
+
const net = require("node:net");
|
13
|
+
const node_perf_hooks_1 = require("node:perf_hooks");
|
14
14
|
const configuration_1 = require("../../config/configuration");
|
15
15
|
const fileutils_1 = require("../../utils/fileutils");
|
16
16
|
const output_1 = require("../../utils/output");
|
@@ -225,7 +225,7 @@ async function generateGraph(args, affectedProjects) {
|
|
225
225
|
process.exit(1);
|
226
226
|
}
|
227
227
|
}
|
228
|
-
let html = (0, node_fs_1.readFileSync)((0,
|
228
|
+
let html = (0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '../../core/graph/index.html'), 'utf-8');
|
229
229
|
prunedGraph = filterGraph(prunedGraph, args.focus || null, args.exclude || []);
|
230
230
|
if (args.print || args.file === 'stdout') {
|
231
231
|
console.log(JSON.stringify(await createJsonOutput(prunedGraph, rawGraph, args.projects, args.targets), null, 2));
|
@@ -234,15 +234,15 @@ async function generateGraph(args, affectedProjects) {
|
|
234
234
|
}
|
235
235
|
if (args.file) {
|
236
236
|
const workspaceFolder = workspace_root_1.workspaceRoot;
|
237
|
-
const ext = (0,
|
238
|
-
const fullFilePath = (0,
|
237
|
+
const ext = (0, node_path_1.extname)(args.file);
|
238
|
+
const fullFilePath = (0, node_path_1.isAbsolute)(args.file)
|
239
239
|
? args.file
|
240
|
-
: (0,
|
241
|
-
const fileFolderPath = (0,
|
240
|
+
: (0, node_path_1.join)(workspaceFolder, args.file);
|
241
|
+
const fileFolderPath = (0, node_path_1.dirname)(fullFilePath);
|
242
242
|
if (ext === '.html') {
|
243
|
-
const assetsFolder = (0,
|
243
|
+
const assetsFolder = (0, node_path_1.join)(fileFolderPath, 'static');
|
244
244
|
const assets = [];
|
245
|
-
(0, node_fs_1.cpSync)((0,
|
245
|
+
(0, node_fs_1.cpSync)((0, node_path_1.join)(__dirname, '../../core/graph'), assetsFolder, {
|
246
246
|
filter: (_src, dest) => {
|
247
247
|
const isntHtml = !/index\.html/.test(dest);
|
248
248
|
if (isntHtml && dest.includes('.')) {
|
@@ -261,14 +261,14 @@ async function generateGraph(args, affectedProjects) {
|
|
261
261
|
html = html.replace(/<base href="\/".*>/g, '');
|
262
262
|
html = html.replace(/type="module"/g, '');
|
263
263
|
(0, node_fs_1.writeFileSync)(fullFilePath, html);
|
264
|
-
(0, node_fs_1.writeFileSync)((0,
|
264
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(assetsFolder, 'environment.js'), environmentJs);
|
265
265
|
output_1.output.success({
|
266
266
|
title: `HTML output created in ${fileFolderPath}`,
|
267
267
|
bodyLines: [fileFolderPath, ...assets],
|
268
268
|
});
|
269
269
|
}
|
270
270
|
else if (ext === '.json') {
|
271
|
-
(0, node_fs_1.mkdirSync)((0,
|
271
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(fullFilePath), { recursive: true });
|
272
272
|
const json = await createJsonOutput(prunedGraph, rawGraph, args.projects, args.targets);
|
273
273
|
(0, fileutils_1.writeJsonFile)(fullFilePath, json);
|
274
274
|
output_1.output.success({
|
@@ -308,12 +308,12 @@ async function generateGraph(args, affectedProjects) {
|
|
308
308
|
if (target) {
|
309
309
|
url.pathname += '/' + target;
|
310
310
|
}
|
311
|
-
if (args.
|
312
|
-
url.pathname += '/all';
|
313
|
-
}
|
314
|
-
else if (args.projects) {
|
311
|
+
if (args.projects) {
|
315
312
|
url.searchParams.append('projects', args.projects.map((projectName) => projectName).join(' '));
|
316
313
|
}
|
314
|
+
else if (args.all) {
|
315
|
+
url.pathname += '/all';
|
316
|
+
}
|
317
317
|
else if (args.affected) {
|
318
318
|
url.pathname += '/affected';
|
319
319
|
}
|
@@ -377,25 +377,37 @@ async function startServer(html, environmentJs, host, port = 4211, watchForChang
|
|
377
377
|
// e.g curl --path-as-is http://localhost:9000/../fileInDanger.txt
|
378
378
|
// by limiting the path to current directory only
|
379
379
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
380
|
-
const sanitizePath = (0,
|
380
|
+
const sanitizePath = (0, node_path_1.basename)(parsedUrl.pathname);
|
381
381
|
if (sanitizePath === 'project-graph.json') {
|
382
382
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
383
383
|
res.end(JSON.stringify(currentProjectGraphClientResponse));
|
384
384
|
return;
|
385
385
|
}
|
386
386
|
if (sanitizePath === 'task-graph.json') {
|
387
|
+
const projectsParam = parsedUrl.searchParams.get('projects'); // Multiple projects
|
388
|
+
const targetName = parsedUrl.searchParams.get('target');
|
389
|
+
const configuration = parsedUrl.searchParams.get('configuration');
|
387
390
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
388
|
-
|
389
|
-
|
391
|
+
if (projectsParam && targetName) {
|
392
|
+
// Multiple projects + target (UI: selected specific projects)
|
393
|
+
const projectNames = projectsParam.split(' ').filter(Boolean);
|
394
|
+
return res.end(JSON.stringify(await createTaskGraphsForTargetAndProjects(targetName, projectNames, configuration)));
|
395
|
+
}
|
396
|
+
if (targetName) {
|
397
|
+
// Target only (UI: all projects with this target)
|
398
|
+
return res.end(JSON.stringify(await createTaskGraphsForTargetAndProjects(targetName)));
|
399
|
+
}
|
400
|
+
// Legacy - load all task graphs
|
401
|
+
return res.end(JSON.stringify(await createTaskGraphClientResponse()));
|
390
402
|
}
|
391
403
|
if (sanitizePath === 'task-inputs.json') {
|
392
|
-
|
404
|
+
node_perf_hooks_1.performance.mark('task input generation:start');
|
393
405
|
const taskId = parsedUrl.searchParams.get('taskId');
|
394
406
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
395
407
|
const inputs = await getExpandedTaskInputs(taskId);
|
396
|
-
|
408
|
+
node_perf_hooks_1.performance.mark('task input generation:end');
|
397
409
|
res.end(JSON.stringify({ [taskId]: inputs }));
|
398
|
-
|
410
|
+
node_perf_hooks_1.performance.measure('task input generation', 'task input generation:start', 'task input generation:end');
|
399
411
|
return;
|
400
412
|
}
|
401
413
|
if (sanitizePath === 'source-maps.json') {
|
@@ -427,7 +439,7 @@ async function startServer(html, environmentJs, host, port = 4211, watchForChang
|
|
427
439
|
}
|
428
440
|
return;
|
429
441
|
}
|
430
|
-
let pathname = (0,
|
442
|
+
let pathname = (0, node_path_1.join)(__dirname, '../../core/graph/', sanitizePath);
|
431
443
|
// if the file is not found or is a directory, return index.html
|
432
444
|
if (!(0, node_fs_1.existsSync)(pathname) || (0, node_fs_1.statSync)(pathname).isDirectory()) {
|
433
445
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
@@ -436,7 +448,7 @@ async function startServer(html, environmentJs, host, port = 4211, watchForChang
|
|
436
448
|
}
|
437
449
|
try {
|
438
450
|
const data = (0, node_fs_1.readFileSync)(pathname);
|
439
|
-
const ext = (0,
|
451
|
+
const ext = (0, node_path_1.parse)(pathname).ext;
|
440
452
|
res.setHeader('Content-type', mimeType[ext] || 'text/plain');
|
441
453
|
res.end(data);
|
442
454
|
}
|
@@ -530,6 +542,8 @@ function createFileWatcher() {
|
|
530
542
|
output_1.output.note({ title: 'Graph changes updated.' });
|
531
543
|
currentProjectGraphClientResponse = projectGraphClientResponse;
|
532
544
|
currentSourceMapsClientResponse = sourceMapResponse;
|
545
|
+
// Clear task graph cache when project graph changes
|
546
|
+
clearTaskGraphCache();
|
533
547
|
}
|
534
548
|
else {
|
535
549
|
output_1.output.note({ title: 'No graph changes found.' });
|
@@ -538,7 +552,7 @@ function createFileWatcher() {
|
|
538
552
|
}, 500));
|
539
553
|
}
|
540
554
|
async function createProjectGraphAndSourceMapClientResponse(affected = []) {
|
541
|
-
|
555
|
+
node_perf_hooks_1.performance.mark('project graph watch calculation:start');
|
542
556
|
let projectGraph;
|
543
557
|
let sourceMaps;
|
544
558
|
let isPartial = false;
|
@@ -573,8 +587,8 @@ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
|
|
573
587
|
}
|
574
588
|
let graph = (0, operators_1.pruneExternalNodes)(projectGraph);
|
575
589
|
let fileMap = (0, nx_deps_cache_1.readFileMapCache)()?.fileMap.projectFileMap;
|
576
|
-
|
577
|
-
|
590
|
+
node_perf_hooks_1.performance.mark('project graph watch calculation:end');
|
591
|
+
node_perf_hooks_1.performance.mark('project graph response generation:start');
|
578
592
|
const layout = (0, configuration_1.workspaceLayout)();
|
579
593
|
const projects = Object.values(graph.nodes);
|
580
594
|
const dependencies = graph.dependencies;
|
@@ -589,9 +603,9 @@ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
|
|
589
603
|
disabledTaskSyncGenerators,
|
590
604
|
}));
|
591
605
|
const hash = hasher.digest('hex');
|
592
|
-
|
593
|
-
|
594
|
-
|
606
|
+
node_perf_hooks_1.performance.mark('project graph response generation:end');
|
607
|
+
node_perf_hooks_1.performance.measure('project graph watch calculation', 'project graph watch calculation:start', 'project graph watch calculation:end');
|
608
|
+
node_perf_hooks_1.performance.measure('project graph response generation', 'project graph response generation:start', 'project graph response generation:end');
|
595
609
|
return {
|
596
610
|
projectGraphClientResponse: {
|
597
611
|
...currentProjectGraphClientResponse,
|
@@ -623,11 +637,11 @@ async function createTaskGraphClientResponse(pruneExternal = false) {
|
|
623
637
|
graph = (0, operators_1.pruneExternalNodes)(graph);
|
624
638
|
}
|
625
639
|
const nxJson = (0, configuration_1.readNxJson)();
|
626
|
-
|
640
|
+
node_perf_hooks_1.performance.mark('task graph generation:start');
|
627
641
|
const taskGraphs = getAllTaskGraphsForWorkspace(graph);
|
628
|
-
|
642
|
+
node_perf_hooks_1.performance.mark('task graph generation:end');
|
629
643
|
const planner = new native_1.HashPlanner(nxJson, (0, native_1.transferProjectGraph)((0, transform_objects_1.transformProjectGraphForRust)(graph)));
|
630
|
-
|
644
|
+
node_perf_hooks_1.performance.mark('task hash plan generation:start');
|
631
645
|
const plans = {};
|
632
646
|
for (const individualTaskGraph of Object.values(taskGraphs.taskGraphs)) {
|
633
647
|
for (const task of Object.values(individualTaskGraph.tasks)) {
|
@@ -637,16 +651,16 @@ async function createTaskGraphClientResponse(pruneExternal = false) {
|
|
637
651
|
plans[task.id] = planner.getPlans([task.id], individualTaskGraph)[task.id];
|
638
652
|
}
|
639
653
|
}
|
640
|
-
|
641
|
-
|
642
|
-
|
654
|
+
node_perf_hooks_1.performance.mark('task hash plan generation:end');
|
655
|
+
node_perf_hooks_1.performance.measure('task graph generation', 'task graph generation:start', 'task graph generation:end');
|
656
|
+
node_perf_hooks_1.performance.measure('task hash plan generation', 'task hash plan generation:start', 'task hash plan generation:end');
|
643
657
|
return {
|
644
658
|
...taskGraphs,
|
645
659
|
plans,
|
646
660
|
};
|
647
661
|
}
|
648
662
|
async function createExpandedTaskInputResponse(taskGraphClientResponse, depGraphClientResponse) {
|
649
|
-
|
663
|
+
node_perf_hooks_1.performance.mark('task input static generation:start');
|
650
664
|
const allWorkspaceFiles = await (0, all_file_data_1.allFileData)();
|
651
665
|
const response = {};
|
652
666
|
Object.entries(taskGraphClientResponse.plans).forEach(([key, inputs]) => {
|
@@ -654,8 +668,8 @@ async function createExpandedTaskInputResponse(taskGraphClientResponse, depGraph
|
|
654
668
|
const expandedInputs = expandInputs(inputs, depGraphClientResponse.projects.find((p) => p.name === project), allWorkspaceFiles, depGraphClientResponse);
|
655
669
|
response[key] = expandedInputs;
|
656
670
|
});
|
657
|
-
|
658
|
-
|
671
|
+
node_perf_hooks_1.performance.mark('task input static generation:end');
|
672
|
+
node_perf_hooks_1.performance.measure('task input static generation', 'task input static generation:start', 'task input static generation:end');
|
659
673
|
return response;
|
660
674
|
}
|
661
675
|
function getAllTaskGraphsForWorkspace(projectGraph) {
|
@@ -709,13 +723,106 @@ function createTaskId(projectId, targetId, configurationId) {
|
|
709
723
|
return `${projectId}:${targetId}`;
|
710
724
|
}
|
711
725
|
}
|
726
|
+
// Performance optimized functions for lazy loading task graphs
|
727
|
+
// In-memory cache for task graphs to avoid regeneration
|
728
|
+
const taskGraphCache = new Map();
|
729
|
+
// Clear cache when project graph changes
|
730
|
+
function clearTaskGraphCache() {
|
731
|
+
taskGraphCache.clear();
|
732
|
+
}
|
733
|
+
/**
|
734
|
+
* Creates task graphs for multiple projects with a specific target
|
735
|
+
* If no projects specified, returns graphs for all projects with the target
|
736
|
+
*/
|
737
|
+
async function createTaskGraphsForTargetAndProjects(targetName, projectNames, configuration) {
|
738
|
+
// Get project graph
|
739
|
+
let graph;
|
740
|
+
try {
|
741
|
+
graph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: false });
|
742
|
+
}
|
743
|
+
catch (e) {
|
744
|
+
if (e instanceof error_types_1.ProjectGraphError) {
|
745
|
+
graph = e.getPartialProjectGraph();
|
746
|
+
}
|
747
|
+
}
|
748
|
+
const nxJson = (0, configuration_1.readNxJson)();
|
749
|
+
// Determine which projects to process
|
750
|
+
let projectsToProcess;
|
751
|
+
if (projectNames && projectNames.length > 0) {
|
752
|
+
// Use specified projects (filter to only those that have the target)
|
753
|
+
projectsToProcess = projectNames.filter((projectName) => graph.nodes[projectName]?.data.targets?.[targetName]);
|
754
|
+
}
|
755
|
+
else {
|
756
|
+
// Get all projects with the target
|
757
|
+
projectsToProcess = Object.entries(graph.nodes)
|
758
|
+
.filter(([_, project]) => project.data.targets?.[targetName])
|
759
|
+
.map(([projectName]) => projectName);
|
760
|
+
}
|
761
|
+
node_perf_hooks_1.performance.mark(`target task graphs generation:start`);
|
762
|
+
// Create task graphs for each project
|
763
|
+
const taskGraphs = {};
|
764
|
+
const taskGraphErrors = {};
|
765
|
+
for (const projectName of projectsToProcess) {
|
766
|
+
const taskId = createTaskId(projectName, targetName, configuration);
|
767
|
+
// Check cache first
|
768
|
+
const cached = taskGraphCache.get(taskId);
|
769
|
+
if (cached) {
|
770
|
+
Object.assign(taskGraphs, cached.taskGraphs);
|
771
|
+
Object.assign(taskGraphErrors, cached.errors);
|
772
|
+
continue;
|
773
|
+
}
|
774
|
+
// Create task graph
|
775
|
+
try {
|
776
|
+
taskGraphs[taskId] = (0, create_task_graph_1.createTaskGraph)(graph, {}, [projectName], [targetName], configuration, {});
|
777
|
+
}
|
778
|
+
catch (err) {
|
779
|
+
taskGraphs[taskId] = {
|
780
|
+
tasks: {},
|
781
|
+
dependencies: {},
|
782
|
+
continuousDependencies: {},
|
783
|
+
roots: [],
|
784
|
+
};
|
785
|
+
taskGraphErrors[taskId] = err.message;
|
786
|
+
}
|
787
|
+
}
|
788
|
+
node_perf_hooks_1.performance.mark(`target task graphs generation:end`);
|
789
|
+
// Generate hash plans
|
790
|
+
const planner = new native_1.HashPlanner(nxJson, (0, native_1.transferProjectGraph)((0, transform_objects_1.transformProjectGraphForRust)(graph)));
|
791
|
+
node_perf_hooks_1.performance.mark('target task hash plan generation:start');
|
792
|
+
const plans = {};
|
793
|
+
for (const taskGraph of Object.values(taskGraphs)) {
|
794
|
+
const taskIds = Object.keys(taskGraph.tasks);
|
795
|
+
if (taskIds.length > 0) {
|
796
|
+
const taskPlans = planner.getPlans(taskIds, taskGraph);
|
797
|
+
Object.assign(plans, taskPlans);
|
798
|
+
}
|
799
|
+
}
|
800
|
+
node_perf_hooks_1.performance.mark('target task hash plan generation:end');
|
801
|
+
// Cache individual results for future requests
|
802
|
+
for (const projectName of projectsToProcess) {
|
803
|
+
const taskId = createTaskId(projectName, targetName, configuration);
|
804
|
+
if (!taskGraphCache.has(taskId)) {
|
805
|
+
taskGraphCache.set(taskId, {
|
806
|
+
taskGraphs: { [taskId]: taskGraphs[taskId] },
|
807
|
+
plans: Object.fromEntries(Object.entries(plans).filter(([key]) => key.startsWith(projectName))),
|
808
|
+
errors: taskGraphErrors[taskId]
|
809
|
+
? { [taskId]: taskGraphErrors[taskId] }
|
810
|
+
: {},
|
811
|
+
});
|
812
|
+
}
|
813
|
+
}
|
814
|
+
node_perf_hooks_1.performance.measure(`target task graphs generation for ${targetName}`, `target task graphs generation:start`, `target task graphs generation:end`);
|
815
|
+
node_perf_hooks_1.performance.measure('target task hash plan generation', 'target task hash plan generation:start', 'target task hash plan generation:end');
|
816
|
+
return { taskGraphs, plans, errors: taskGraphErrors };
|
817
|
+
}
|
712
818
|
async function getExpandedTaskInputs(taskId) {
|
713
|
-
|
714
|
-
const
|
819
|
+
// Use the optimized version that only creates the specific task graph needed
|
820
|
+
const [projectName, targetName, configuration] = taskId.split(':');
|
821
|
+
const taskGraphResponse = await createTaskGraphsForTargetAndProjects(targetName, [projectName], configuration);
|
715
822
|
const allWorkspaceFiles = await (0, all_file_data_1.allFileData)();
|
716
823
|
const inputs = taskGraphResponse.plans[taskId];
|
717
824
|
if (inputs) {
|
718
|
-
return expandInputs(inputs, currentProjectGraphClientResponse.projects.find((p) => p.name ===
|
825
|
+
return expandInputs(inputs, currentProjectGraphClientResponse.projects.find((p) => p.name === projectName), allWorkspaceFiles, currentProjectGraphClientResponse);
|
719
826
|
}
|
720
827
|
return {};
|
721
828
|
}
|
@@ -752,7 +859,7 @@ function expandInputs(inputs, project, allWorkspaceFiles, depGraphClientResponse
|
|
752
859
|
const workspaceRootsExpanded = getExpandedWorkspaceRoots(workspaceRootInputs, allWorkspaceFiles);
|
753
860
|
const otherInputsExpanded = otherInputs.map((input) => {
|
754
861
|
if (input === 'TsConfig') {
|
755
|
-
return (0,
|
862
|
+
return (0, node_path_1.relative)(workspace_root_1.workspaceRoot, (0, typescript_1.getRootTsConfigPath)());
|
756
863
|
}
|
757
864
|
if (input === 'ProjectConfiguration') {
|
758
865
|
return depGraphClientResponse.fileMap[project.name].find((file) => file.file === `${project.data.root}/project.json` ||
|
@@ -0,0 +1,23 @@
|
|
1
|
+
export * from './add/command-object';
|
2
|
+
export * from './affected/command-object';
|
3
|
+
export * from './daemon/command-object';
|
4
|
+
export * from './exec/command-object';
|
5
|
+
export * from './format/command-object';
|
6
|
+
export * from './generate/command-object';
|
7
|
+
export * from './graph/command-object';
|
8
|
+
export * from './import/command-object';
|
9
|
+
export * from './init/command-object';
|
10
|
+
export * from './list/command-object';
|
11
|
+
export * from './migrate/command-object';
|
12
|
+
export * from './new/command-object';
|
13
|
+
export * from './register/command-object';
|
14
|
+
export * from './release/command-object';
|
15
|
+
export * from './repair/command-object';
|
16
|
+
export * from './report/command-object';
|
17
|
+
export * from './reset/command-object';
|
18
|
+
export * from './run-many/command-object';
|
19
|
+
export * from './run/command-object';
|
20
|
+
export * from './show/command-object';
|
21
|
+
export * from './sync/command-object';
|
22
|
+
export * from './watch/command-object';
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/command-line/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const tslib_1 = require("tslib");
|
4
|
+
// CLI Commands Export File for Documentation
|
5
|
+
tslib_1.__exportStar(require("./add/command-object"), exports);
|
6
|
+
tslib_1.__exportStar(require("./affected/command-object"), exports);
|
7
|
+
tslib_1.__exportStar(require("./daemon/command-object"), exports);
|
8
|
+
tslib_1.__exportStar(require("./exec/command-object"), exports);
|
9
|
+
tslib_1.__exportStar(require("./format/command-object"), exports);
|
10
|
+
tslib_1.__exportStar(require("./generate/command-object"), exports);
|
11
|
+
tslib_1.__exportStar(require("./graph/command-object"), exports);
|
12
|
+
tslib_1.__exportStar(require("./import/command-object"), exports);
|
13
|
+
tslib_1.__exportStar(require("./init/command-object"), exports);
|
14
|
+
tslib_1.__exportStar(require("./list/command-object"), exports);
|
15
|
+
tslib_1.__exportStar(require("./migrate/command-object"), exports);
|
16
|
+
tslib_1.__exportStar(require("./new/command-object"), exports);
|
17
|
+
tslib_1.__exportStar(require("./register/command-object"), exports);
|
18
|
+
tslib_1.__exportStar(require("./release/command-object"), exports);
|
19
|
+
tslib_1.__exportStar(require("./repair/command-object"), exports);
|
20
|
+
tslib_1.__exportStar(require("./report/command-object"), exports);
|
21
|
+
tslib_1.__exportStar(require("./reset/command-object"), exports);
|
22
|
+
tslib_1.__exportStar(require("./run-many/command-object"), exports);
|
23
|
+
tslib_1.__exportStar(require("./run/command-object"), exports);
|
24
|
+
tslib_1.__exportStar(require("./show/command-object"), exports);
|
25
|
+
tslib_1.__exportStar(require("./sync/command-object"), exports);
|
26
|
+
tslib_1.__exportStar(require("./watch/command-object"), exports);
|
@@ -2,6 +2,6 @@ import { InitArgs } from '../init-v1';
|
|
2
2
|
type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'> & {
|
3
3
|
legacy?: boolean;
|
4
4
|
};
|
5
|
-
export declare function addNxToMonorepo(options: Options): Promise<void>;
|
5
|
+
export declare function addNxToMonorepo(options: Options, guided?: boolean): Promise<void>;
|
6
6
|
export {};
|
7
7
|
//# sourceMappingURL=add-nx-to-monorepo.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"add-nx-to-monorepo.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/init/implementation/add-nx-to-monorepo.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAYtC,KAAK,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC,GAAG;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAsB,eAAe,
|
1
|
+
{"version":3,"file":"add-nx-to-monorepo.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/init/implementation/add-nx-to-monorepo.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAYtC,KAAK,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC,GAAG;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,OAAc,iBA6FvB"}
|
@@ -9,7 +9,7 @@ const fileutils_1 = require("../../../utils/fileutils");
|
|
9
9
|
const output_1 = require("../../../utils/output");
|
10
10
|
const utils_1 = require("./utils");
|
11
11
|
const connect_to_nx_cloud_1 = require("../../nx-cloud/connect/connect-to-nx-cloud");
|
12
|
-
async function addNxToMonorepo(options) {
|
12
|
+
async function addNxToMonorepo(options, guided = true) {
|
13
13
|
const repoRoot = process.cwd();
|
14
14
|
output_1.output.log({ title: '🐳 Nx initialization' });
|
15
15
|
const packageJsonFiles = allProjectPackageJsonFiles(repoRoot);
|
@@ -18,7 +18,7 @@ async function addNxToMonorepo(options) {
|
|
18
18
|
let cacheableOperations;
|
19
19
|
let scriptOutputs = {};
|
20
20
|
let useNxCloud;
|
21
|
-
if (options.interactive && scripts.length > 0) {
|
21
|
+
if (options.interactive && scripts.length > 0 && guided) {
|
22
22
|
output_1.output.log({
|
23
23
|
title: '🧑🔧 Please answer the following questions about the scripts found in your workspace in order to generate task runner configuration',
|
24
24
|
});
|
@@ -2,6 +2,6 @@ import { InitArgs } from '../init-v1';
|
|
2
2
|
type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'> & {
|
3
3
|
legacy?: boolean;
|
4
4
|
};
|
5
|
-
export declare function addNxToNpmRepo(options: Options): Promise<void>;
|
5
|
+
export declare function addNxToNpmRepo(options: Options, guided?: boolean): Promise<void>;
|
6
6
|
export {};
|
7
7
|
//# sourceMappingURL=add-nx-to-npm-repo.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"add-nx-to-npm-repo.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/init/implementation/add-nx-to-npm-repo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAetC,KAAK,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC,GAAG;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,
|
1
|
+
{"version":3,"file":"add-nx-to-npm-repo.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/init/implementation/add-nx-to-npm-repo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAetC,KAAK,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC,GAAG;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,GAAE,OAAc,iBAgF5E"}
|
@@ -8,7 +8,7 @@ const output_1 = require("../../../utils/output");
|
|
8
8
|
const package_manager_1 = require("../../../utils/package-manager");
|
9
9
|
const utils_1 = require("./utils");
|
10
10
|
const connect_to_nx_cloud_1 = require("../../nx-cloud/connect/connect-to-nx-cloud");
|
11
|
-
async function addNxToNpmRepo(options) {
|
11
|
+
async function addNxToNpmRepo(options, guided = true) {
|
12
12
|
const repoRoot = process.cwd();
|
13
13
|
output_1.output.log({ title: '🐳 Nx initialization' });
|
14
14
|
let cacheableOperations;
|
@@ -16,7 +16,7 @@ async function addNxToNpmRepo(options) {
|
|
16
16
|
let useNxCloud;
|
17
17
|
const packageJson = (0, fileutils_1.readJsonFile)('package.json');
|
18
18
|
const scripts = Object.keys(packageJson.scripts ?? {}).filter((s) => !s.startsWith('pre') && !s.startsWith('post'));
|
19
|
-
if (options.interactive && scripts.length > 0) {
|
19
|
+
if (options.interactive && scripts.length > 0 && guided) {
|
20
20
|
output_1.output.log({
|
21
21
|
title: '🧑🔧 Please answer the following questions about the scripts found in your package.json in order to generate task runner configuration',
|
22
22
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/init/implementation/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQ9D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAEL,sBAAsB,EACvB,MAAM,gCAAgC,CAAC;
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/init/implementation/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQ9D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAEL,sBAAsB,EACvB,MAAM,gCAAgC,CAAC;AASxC,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,EAAE,EAC5B,mBAAmB,EAAE,MAAM,EAAE,EAC7B,aAAa,EAAE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,QA0C1C;AAED,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,mBAAmB,CA+GrB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,kBAAkB,CAAC,EAAE,MAAM,EAAE,QAY9B;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,QAqC3C;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,EAChB,GAAG,GAAE,sBAAmD,QAOzD;AAED,wBAAsB,SAAS,CAC7B,kBAAkB,EACd,SAAS,GACT,iBAAiB,GACjB,aAAa,GACb,kBAAkB,GAClB,cAAc,GACd,kBAAkB,GAClB,mBAAmB,iBAMxB;AAED,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAAE,GACnB,IAAI,CAiBN;AAED,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,GAAG,EAAE,sBAAsB,QAqB5B;AAED,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,MAAM,QAQjE;AAED,wBAAgB,iBAAiB,CAAC,EAChC,aAAa,EACb,WAAW,GACZ,EAAE;IACD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB,GAAG,IAAI,CAUP;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,WASlD;AAED,wBAAgB,KAAK,CAAC,WAAW,EAAE,WAAW,WAa7C"}
|
@@ -21,10 +21,8 @@ const path_2 = require("../../../utils/path");
|
|
21
21
|
const versions_1 = require("../../../utils/versions");
|
22
22
|
const fs_1 = require("fs");
|
23
23
|
const connect_to_nx_cloud_1 = require("../../../nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud");
|
24
|
-
const url_shorten_1 = require("../../../nx-cloud/utilities/url-shorten");
|
25
24
|
const connect_to_nx_cloud_2 = require("../../nx-cloud/connect/connect-to-nx-cloud");
|
26
25
|
const deduce_default_base_1 = require("./deduce-default-base");
|
27
|
-
const child_process_2 = require("../../../utils/child-process");
|
28
26
|
function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scriptOutputs) {
|
29
27
|
const nxJsonPath = (0, path_2.joinPathFragments)(repoRoot, 'nx.json');
|
30
28
|
let nxJson = {};
|
@@ -217,7 +215,7 @@ async function initCloud(installationSource) {
|
|
217
215
|
const token = await (0, connect_to_nx_cloud_2.connectWorkspaceToCloud)({
|
218
216
|
installationSource,
|
219
217
|
});
|
220
|
-
await (0, connect_to_nx_cloud_1.printSuccessMessage)(token, installationSource
|
218
|
+
await (0, connect_to_nx_cloud_1.printSuccessMessage)(token, installationSource);
|
221
219
|
}
|
222
220
|
function addVsCodeRecommendedExtensions(repoRoot, extensions) {
|
223
221
|
const vsCodeExtensionsPath = (0, path_1.join)(repoRoot, '.vscode/extensions.json');
|
@@ -263,13 +261,10 @@ function markPackageJsonAsNxProject(packageJsonPath) {
|
|
263
261
|
(0, fileutils_1.writeJsonFile)(packageJsonPath, json);
|
264
262
|
}
|
265
263
|
function printFinalMessage({ learnMoreLink, appendLines, }) {
|
266
|
-
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
267
264
|
output_1.output.success({
|
268
265
|
title: '🎉 Done!',
|
269
266
|
bodyLines: [
|
270
|
-
`-
|
271
|
-
`- Run "${(0, child_process_2.getRunNxBaseCommand)(pmc)} graph" to see the graph of projects and tasks in your workspace. https://nx.dev/core-features/explore-graph`,
|
272
|
-
learnMoreLink ? `- Learn more at ${learnMoreLink}.` : undefined,
|
267
|
+
`- Learn more about what to do next at ${learnMoreLink ?? 'https://nx.dev/getting-started/adding-to-existing'}`,
|
273
268
|
...(appendLines ?? []),
|
274
269
|
].filter(Boolean),
|
275
270
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"init-v2.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/init/init-v2.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAc,MAAM,sBAAsB,CAAC;
|
1
|
+
{"version":3,"file":"init-v2.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/init/init-v2.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAc,MAAM,sBAAsB,CAAC;AA4BvE,MAAM,WAAW,QAAQ;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAiJlE;AA2BD,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,OAAO,EACpB,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC;IACT,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oBAAoB,EAAE,OAAO,CAAC;CAC/B,CAAC,CAgID"}
|
@@ -34,7 +34,7 @@ async function initHandler(options) {
|
|
34
34
|
integrated: !!options.integrated,
|
35
35
|
});
|
36
36
|
(0, utils_1.printFinalMessage)({
|
37
|
-
learnMoreLink: 'https://nx.dev/
|
37
|
+
learnMoreLink: 'https://nx.dev/technologies/angular/migration/angular',
|
38
38
|
});
|
39
39
|
return;
|
40
40
|
}
|
@@ -45,6 +45,18 @@ async function initHandler(options) {
|
|
45
45
|
const _isTurborepo = (0, fs_1.existsSync)('turbo.json');
|
46
46
|
const _isMonorepo = _isNonJs ? false : (0, utils_1.isMonorepo)(packageJson);
|
47
47
|
const _isCRA = _isNonJs ? false : (0, utils_1.isCRA)(packageJson);
|
48
|
+
let guided = true;
|
49
|
+
if (options.interactive && !(_isTurborepo || _isCRA || _isNonJs)) {
|
50
|
+
const setupType = await (0, enquirer_1.prompt)([
|
51
|
+
{
|
52
|
+
type: 'select',
|
53
|
+
name: 'setupPreference',
|
54
|
+
message: 'Would you like a minimum or guided setup?',
|
55
|
+
choices: [{ name: 'Minimum' }, { name: 'Guided' }],
|
56
|
+
},
|
57
|
+
]).then((r) => r.setupPreference);
|
58
|
+
guided = setupType === 'Guided';
|
59
|
+
}
|
48
60
|
/**
|
49
61
|
* Turborepo users must have set up individual scripts already, and we keep the transition as minimal as possible.
|
50
62
|
* We log a message during the conversion process in addNxToTurborepo about how they can learn more about the power
|
@@ -75,7 +87,7 @@ async function initHandler(options) {
|
|
75
87
|
await (0, add_nx_to_monorepo_1.addNxToMonorepo)({
|
76
88
|
interactive: options.interactive,
|
77
89
|
nxCloud: false,
|
78
|
-
});
|
90
|
+
}, guided);
|
79
91
|
}
|
80
92
|
else if (_isNonJs) {
|
81
93
|
(0, add_nx_scripts_1.generateDotNxSetup)(version);
|
@@ -85,41 +97,47 @@ async function initHandler(options) {
|
|
85
97
|
await (0, add_nx_to_npm_repo_1.addNxToNpmRepo)({
|
86
98
|
interactive: options.interactive,
|
87
99
|
nxCloud: false,
|
88
|
-
});
|
100
|
+
}, guided);
|
89
101
|
}
|
90
|
-
const useNxCloud = options.nxCloud ??
|
91
|
-
(options.interactive ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)() : false);
|
92
102
|
const repoRoot = process.cwd();
|
93
103
|
(0, utils_1.createNxJsonFile)(repoRoot, [], [], {});
|
94
104
|
(0, utils_1.updateGitIgnore)(repoRoot);
|
95
105
|
const nxJson = (0, nx_json_1.readNxJson)(repoRoot);
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
106
|
+
if (guided) {
|
107
|
+
output_1.output.log({ title: '🧐 Checking dependencies' });
|
108
|
+
let plugins;
|
109
|
+
let updatePackageScripts;
|
110
|
+
if (_isCRA) {
|
111
|
+
plugins = ['@nx/vite'];
|
112
|
+
updatePackageScripts = true;
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
const { plugins: _plugins, updatePackageScripts: _updatePackageScripts } = await detectPlugins(nxJson, options.interactive);
|
116
|
+
plugins = _plugins;
|
117
|
+
updatePackageScripts = _updatePackageScripts;
|
118
|
+
}
|
119
|
+
output_1.output.log({ title: '📦 Installing Nx' });
|
120
|
+
(0, configure_plugins_1.installPluginPackages)(repoRoot, pmc, plugins);
|
121
|
+
await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, repoRoot, options.verbose);
|
102
122
|
}
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
123
|
+
let useNxCloud = options.nxCloud;
|
124
|
+
if (useNxCloud === undefined) {
|
125
|
+
output_1.output.log({ title: '🛠️ Setting up Self-Healing CI and Remote Caching' });
|
126
|
+
useNxCloud = options.interactive
|
127
|
+
? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
|
128
|
+
: false;
|
107
129
|
}
|
108
|
-
output_1.output.log({ title: '📦 Installing Nx' });
|
109
|
-
(0, configure_plugins_1.installPluginPackages)(repoRoot, pmc, plugins);
|
110
|
-
await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, repoRoot, options.verbose);
|
111
130
|
if (useNxCloud) {
|
112
|
-
output_1.output.log({ title: '🛠️ Setting up Nx Cloud' });
|
113
131
|
await (0, utils_1.initCloud)('nx-init');
|
114
132
|
}
|
115
133
|
(0, utils_1.printFinalMessage)({
|
134
|
+
learnMoreLink: 'https://nx.dev/getting-started/adding-to-existing',
|
116
135
|
appendLines: _isMonorepo
|
117
136
|
? [
|
118
|
-
`-
|
137
|
+
`- Read a detailed guide about adding Nx to NPM/YARN/PNPM workspaces: https://nx.dev/recipes/adopting-nx/adding-to-monorepos`,
|
138
|
+
`- Learn how Nx helps manage your TypeScript monorepo: https://nx.dev/features/maintain-ts-monorepos`,
|
119
139
|
]
|
120
|
-
: [
|
121
|
-
`- Learn how Nx works with any type of project at https://nx.dev/recipes/adopting-nx/adding-to-existing-project.`,
|
122
|
-
],
|
140
|
+
: [],
|
123
141
|
});
|
124
142
|
}
|
125
143
|
const npmPackageToPluginMap = {
|