nx 21.4.0-beta.1 → 21.4.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +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/init/implementation/utils.d.ts.map +1 -1
- package/src/command-line/init/implementation/utils.js +1 -2
- 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/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/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 +5 -3
- 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/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/project-graph/plugins/public-api.d.ts +2 -0
- package/src/project-graph/plugins/public-api.d.ts.map +1 -1
- 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/utils/ab-testing.d.ts +1 -1
- package/src/utils/ab-testing.d.ts.map +1 -1
- package/src/utils/ab-testing.js +1 -1
- 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
@@ -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` ||
|
@@ -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,7 +21,6 @@ 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
26
|
function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scriptOutputs) {
|
@@ -216,7 +215,7 @@ async function initCloud(installationSource) {
|
|
216
215
|
const token = await (0, connect_to_nx_cloud_2.connectWorkspaceToCloud)({
|
217
216
|
installationSource,
|
218
217
|
});
|
219
|
-
await (0, connect_to_nx_cloud_1.printSuccessMessage)(token, installationSource
|
218
|
+
await (0, connect_to_nx_cloud_1.printSuccessMessage)(token, installationSource);
|
220
219
|
}
|
221
220
|
function addVsCodeRecommendedExtensions(repoRoot, extensions) {
|
222
221
|
const vsCodeExtensionsPath = (0, path_1.join)(repoRoot, '.vscode/extensions.json');
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"command-object.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/mcp/command-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,aAAa,EAAE,MAAM,OAAO,CAAC;AAE5C,eAAO,MAAM,eAAe,EAAE,aAwB7B,CAAC"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.yargsMcpCommand = void 0;
|
4
|
+
exports.yargsMcpCommand = {
|
5
|
+
command: 'mcp',
|
6
|
+
describe: 'Starts the Nx MCP server.',
|
7
|
+
// @ts-expect-error - yargs types are outdated, refer to docs - https://github.com/yargs/yargs/blob/main/docs/api.md#commandmodule
|
8
|
+
builder: async (y, helpOrVersionSet) => {
|
9
|
+
if (helpOrVersionSet) {
|
10
|
+
(await Promise.resolve().then(() => require('./mcp'))).showHelp();
|
11
|
+
process.exit(0);
|
12
|
+
}
|
13
|
+
return y
|
14
|
+
.version(false)
|
15
|
+
.strict(false)
|
16
|
+
.parserConfiguration({
|
17
|
+
'unknown-options-as-args': true,
|
18
|
+
'populate--': true,
|
19
|
+
})
|
20
|
+
.usage('')
|
21
|
+
.help(false)
|
22
|
+
.showHelpOnFail(false);
|
23
|
+
},
|
24
|
+
handler: async (args) => {
|
25
|
+
await (await Promise.resolve().then(() => require('./mcp'))).mcpHandler(args);
|
26
|
+
process.exit(0);
|
27
|
+
},
|
28
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/mcp/mcp.ts"],"names":[],"mappings":"AAIA,wBAAsB,UAAU,CAAC,IAAI,EAAE,GAAG,iBAazC;AAED,wBAAsB,QAAQ,kBAa7B"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.mcpHandler = mcpHandler;
|
4
|
+
exports.showHelp = showHelp;
|
5
|
+
const child_process_1 = require("child_process");
|
6
|
+
const package_manager_1 = require("../../utils/package-manager");
|
7
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
8
|
+
async function mcpHandler(args) {
|
9
|
+
const packageManagerCommands = (0, package_manager_1.getPackageManagerCommand)();
|
10
|
+
const passthroughArgs = args['_'][0] === 'mcp' ? args['_'].slice(1) : args['_'];
|
11
|
+
(0, child_process_1.spawnSync)(packageManagerCommands.dlx, ['-y', 'nx-mcp@latest', ...passthroughArgs], {
|
12
|
+
stdio: 'inherit',
|
13
|
+
cwd: workspace_root_1.workspaceRoot,
|
14
|
+
});
|
15
|
+
}
|
16
|
+
async function showHelp() {
|
17
|
+
const packageManagerCommands = (0, package_manager_1.getPackageManagerCommand)();
|
18
|
+
const helpOutput = (0, child_process_1.spawnSync)(packageManagerCommands.dlx, ['-y', 'nx-mcp@latest', '--help'], {
|
19
|
+
cwd: workspace_root_1.workspaceRoot,
|
20
|
+
encoding: 'utf-8',
|
21
|
+
});
|
22
|
+
console.log(helpOutput.stdout?.toString().replaceAll('nx-mcp', 'nx mcp'));
|
23
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"migrate-ui-api.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/migrate/migrate-ui-api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAUxD,MAAM,MAAM,sBAAsB,GAAG;IACnC,mBAAmB,CAAC,EAAE,MAAM,CAC1B,MAAM,EACN,mBAAmB,GAAG,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,CAC5E,CAAC;IACF,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,CAAC;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,kBAAkB,EAAE,MAAM,QA6B3B;AAED,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,MAAM,QAkCtB;AAED,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,sBAAsB,EACjC,aAAa,EAAE;IACb,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,
|
1
|
+
{"version":3,"file":"migrate-ui-api.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/migrate/migrate-ui-api.ts"],"names":[],"mappings":"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"}
|
@@ -130,10 +130,15 @@ async function runSingleMigration(workspacePath, migration, configuration) {
|
|
130
130
|
type: change.type,
|
131
131
|
})), gitRefAfter, nextSteps));
|
132
132
|
if (gitRefBefore !== gitRefAfter) {
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
133
|
+
try {
|
134
|
+
(0, child_process_1.execSync)('git add migrations.json', {
|
135
|
+
cwd: workspacePath,
|
136
|
+
encoding: 'utf-8',
|
137
|
+
});
|
138
|
+
}
|
139
|
+
catch (e) {
|
140
|
+
// do nothing, this will fail if it's gitignored
|
141
|
+
}
|
137
142
|
(0, child_process_1.execSync)('git commit --amend --no-verify --no-edit', {
|
138
143
|
cwd: workspacePath,
|
139
144
|
encoding: 'utf-8',
|
@@ -163,10 +168,15 @@ async function runSingleMigration(workspacePath, migration, configuration) {
|
|
163
168
|
currentMigrationId = null;
|
164
169
|
migrationCancelled = false;
|
165
170
|
modifyMigrationsJsonMetadata(workspacePath, removeRunningMigration(migration.id));
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
171
|
+
try {
|
172
|
+
(0, child_process_1.execSync)('git add migrations.json', {
|
173
|
+
cwd: workspacePath,
|
174
|
+
encoding: 'utf-8',
|
175
|
+
});
|
176
|
+
}
|
177
|
+
catch (e) {
|
178
|
+
// do nothing, this will fail if it's gitignored
|
179
|
+
}
|
170
180
|
}
|
171
181
|
}
|
172
182
|
async function getImplementationPath(workspacePath, migration) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"command-object.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/nx-cloud/connect/command-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,aAAa,EAAE,MAAM,OAAO,CAAC;AAK5C,eAAO,MAAM,mBAAmB,EAAE,
|
1
|
+
{"version":3,"file":"command-object.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/nx-cloud/connect/command-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,aAAa,EAAE,MAAM,OAAO,CAAC;AAK5C,eAAO,MAAM,mBAAmB,EAAE,aAoBjC,CAAC;AAUF,eAAO,MAAM,oBAAoB,EAAE,aAMlC,CAAC"}
|
@@ -10,7 +10,8 @@ exports.yargsConnectCommand = {
|
|
10
10
|
describe: `Connect workspace to Nx Cloud.`,
|
11
11
|
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)(withConnectOptions(yargs), 'connect-to-nx-cloud'),
|
12
12
|
handler: async (args) => {
|
13
|
-
|
13
|
+
const checkRemote = process.env.NX_SKIP_CHECK_REMOTE !== 'true';
|
14
|
+
await (await Promise.resolve().then(() => require('./connect-to-nx-cloud'))).connectToNxCloudCommand({ ...args, checkRemote });
|
14
15
|
await (await Promise.resolve().then(() => require('../../../utils/ab-testing'))).recordStat({
|
15
16
|
command: 'connect',
|
16
17
|
nxVersion: versions_1.nxVersion,
|
@@ -7,6 +7,7 @@ export declare function connectToNxCloudIfExplicitlyAsked(opts: NxArgs): Promise
|
|
7
7
|
export declare function connectWorkspaceToCloud(options: ConnectToNxCloudOptions, directory?: string): Promise<string>;
|
8
8
|
export declare function connectToNxCloudCommand(options: {
|
9
9
|
generateToken?: boolean;
|
10
|
+
checkRemote?: boolean;
|
10
11
|
}, command?: string): Promise<boolean>;
|
11
12
|
export declare function connectExistingRepoToNxCloudPrompt(command?: string, key?: MessageKey): Promise<boolean>;
|
12
13
|
export declare function connectToNxCloudWithPrompt(command: string): Promise<void>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connect-to-nx-cloud.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/nx-cloud/connect/connect-to-nx-cloud.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,uBAAuB,EACxB,MAAM,sEAAsE,CAAC;AAI9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EACL,UAAU,EAIX,MAAM,2BAA2B,CAAC;
|
1
|
+
{"version":3,"file":"connect-to-nx-cloud.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/nx-cloud/connect/connect-to-nx-cloud.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,uBAAuB,EACxB,MAAM,sEAAsE,CAAC;AAI9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EACL,UAAU,EAIX,MAAM,2BAA2B,CAAC;AAQnC,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,mBAAmB,WAiBlE;AAED,wBAAsB,iCAAiC,CACrD,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,uBAAuB,EAChC,SAAS,SAAgB,mBAO1B;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,EAC3D,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CA8ElB;AAMD,wBAAsB,kCAAkC,CACtD,OAAO,SAAS,EAChB,GAAG,GAAE,UAA2B,GAC/B,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,MAAM,iBAY/D"}
|
@@ -16,6 +16,7 @@ const child_process_1 = require("../../../utils/child-process");
|
|
16
16
|
const ab_testing_1 = require("../../../utils/ab-testing");
|
17
17
|
const versions_1 = require("../../../utils/versions");
|
18
18
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
19
|
+
const git_utils_1 = require("../../../utils/git-utils");
|
19
20
|
const chalk = require("chalk");
|
20
21
|
const ora = require('ora');
|
21
22
|
const open = require('open');
|
@@ -25,8 +26,9 @@ function onlyDefaultRunnerIsUsed(nxJson) {
|
|
25
26
|
// No tasks runner options OR no default runner defined:
|
26
27
|
// - If access token defined, uses cloud runner
|
27
28
|
// - If no access token defined, uses default
|
28
|
-
return (!(nxJson.nxCloudAccessToken ??
|
29
|
-
|
29
|
+
return (!(nxJson.nxCloudAccessToken ??
|
30
|
+
process.env.NX_CLOUD_AUTH_TOKEN ??
|
31
|
+
process.env.NX_CLOUD_ACCESS_TOKEN) && !nxJson.nxCloudId);
|
30
32
|
}
|
31
33
|
return defaultRunner === 'nx/tasks-runners/default';
|
32
34
|
}
|
@@ -59,14 +61,26 @@ async function connectToNxCloudCommand(options, command) {
|
|
59
61
|
const installationSource = process.env.NX_CONSOLE
|
60
62
|
? 'nx-console'
|
61
63
|
: 'nx-connect';
|
64
|
+
const hasRemote = !!(0, git_utils_1.getVcsRemoteInfo)();
|
65
|
+
if (!hasRemote && options.checkRemote) {
|
66
|
+
output_1.output.error({
|
67
|
+
title: 'Missing VCS provider',
|
68
|
+
bodyLines: [
|
69
|
+
'Push this repository to a VCS provider (e.g., GitHub) and try again.',
|
70
|
+
'Go to https://github.com/new to create a repository on GitHub.',
|
71
|
+
],
|
72
|
+
});
|
73
|
+
return false;
|
74
|
+
}
|
62
75
|
if ((0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) {
|
63
|
-
const token = process.env.
|
76
|
+
const token = process.env.NX_CLOUD_AUTH_TOKEN ||
|
77
|
+
process.env.NX_CLOUD_ACCESS_TOKEN ||
|
64
78
|
nxJson.nxCloudAccessToken ||
|
65
79
|
nxJson.nxCloudId;
|
66
80
|
if (!token) {
|
67
81
|
throw new Error(`Unable to authenticate. If you are connecting to Nx Cloud locally, set Nx Cloud ID in nx.json. If you are connecting in a CI context, either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`);
|
68
82
|
}
|
69
|
-
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)(installationSource, token, options?.generateToken
|
83
|
+
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)(installationSource, token, undefined, options?.generateToken === true);
|
70
84
|
output_1.output.log({
|
71
85
|
title: '✔ This workspace already has Nx Cloud set up',
|
72
86
|
bodyLines: [
|
@@ -81,7 +95,7 @@ async function connectToNxCloudCommand(options, command) {
|
|
81
95
|
generateToken: options?.generateToken,
|
82
96
|
installationSource: command ?? installationSource,
|
83
97
|
});
|
84
|
-
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)('nx-connect', token, options?.generateToken
|
98
|
+
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)('nx-connect', token, undefined, options?.generateToken === true);
|
85
99
|
try {
|
86
100
|
const cloudConnectSpinner = ora(`Opening Nx Cloud ${connectCloudUrl} in your browser to connect your workspace.`).start();
|
87
101
|
await sleep(2000);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"view-logs.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/nx-cloud/connect/view-logs.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"view-logs.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/command-line/nx-cloud/connect/view-logs.ts"],"names":[],"mappings":"AAWA,wBAAsB,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAiDhD"}
|
@@ -7,8 +7,6 @@ const nx_cloud_utils_1 = require("../../../utils/nx-cloud-utils");
|
|
7
7
|
const output_1 = require("../../../utils/output");
|
8
8
|
const nx_json_1 = require("../../../config/nx-json");
|
9
9
|
const connect_to_nx_cloud_1 = require("./connect-to-nx-cloud");
|
10
|
-
const connect_to_nx_cloud_2 = require("../../../nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud");
|
11
|
-
const url_shorten_1 = require("../../../nx-cloud/utilities/url-shorten");
|
12
10
|
async function viewLogs() {
|
13
11
|
const cloudUsed = (0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)());
|
14
12
|
if (cloudUsed) {
|
@@ -28,10 +26,10 @@ async function viewLogs() {
|
|
28
26
|
output_1.output.log({
|
29
27
|
title: 'Connecting to Nx Cloud',
|
30
28
|
});
|
31
|
-
|
29
|
+
await (0, connect_to_nx_cloud_1.connectWorkspaceToCloud)({
|
32
30
|
installationSource: 'view-logs',
|
31
|
+
generateToken: true,
|
33
32
|
});
|
34
|
-
await (0, connect_to_nx_cloud_2.printSuccessMessage)(token, 'view-logs', await (0, url_shorten_1.repoUsesGithub)());
|
35
33
|
}
|
36
34
|
catch (e) {
|
37
35
|
output_1.output.log({
|
@@ -48,7 +46,7 @@ async function viewLogs() {
|
|
48
46
|
if (!cloudUsed) {
|
49
47
|
output_1.output.note({
|
50
48
|
title: 'Your workspace is now connected to Nx Cloud',
|
51
|
-
bodyLines: [`Learn more about Nx Cloud at https://nx.
|
49
|
+
bodyLines: [`Learn more about Nx Cloud at https://nx.dev/nx-cloud`],
|
52
50
|
});
|
53
51
|
}
|
54
52
|
return 0;
|