nx 19.4.0-canary.20240626-3a2e8d4 → 19.4.0-rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/package.json +14 -14
  2. package/src/command-line/connect/connect-to-nx-cloud.d.ts +1 -1
  3. package/src/command-line/connect/connect-to-nx-cloud.js +16 -25
  4. package/src/command-line/graph/graph.d.ts +1 -0
  5. package/src/command-line/graph/graph.js +46 -2
  6. package/src/command-line/run/command-object.js +2 -1
  7. package/src/config/workspace-json-project-json.d.ts +8 -0
  8. package/src/core/graph/main.js +1 -1
  9. package/src/core/graph/styles.css +1 -1
  10. package/src/daemon/socket-utils.d.ts +1 -0
  11. package/src/daemon/socket-utils.js +6 -1
  12. package/src/executors/run-commands/run-commands.impl.d.ts +1 -1
  13. package/src/executors/run-commands/run-commands.impl.js +26 -15
  14. package/src/executors/run-commands/schema.json +14 -0
  15. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -0
  16. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +68 -33
  17. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +5 -0
  18. package/src/nx-cloud/utilities/url-shorten.d.ts +2 -1
  19. package/src/nx-cloud/utilities/url-shorten.js +42 -14
  20. package/src/plugins/js/index.js +2 -0
  21. package/src/plugins/js/package-json/create-package-json.js +2 -2
  22. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +9 -2
  23. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +40 -0
  24. package/src/project-graph/plugins/internal-api.js +1 -1
  25. package/src/project-graph/plugins/isolation/index.d.ts +1 -1
  26. package/src/project-graph/plugins/isolation/index.js +3 -15
  27. package/src/project-graph/plugins/isolation/messaging.d.ts +6 -3
  28. package/src/project-graph/plugins/isolation/messaging.js +9 -3
  29. package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
  30. package/src/project-graph/plugins/isolation/plugin-pool.js +126 -50
  31. package/src/project-graph/plugins/isolation/plugin-worker.js +128 -107
  32. package/src/tasks-runner/task-env.d.ts +13 -0
  33. package/src/tasks-runner/task-env.js +41 -26
  34. package/src/utils/git-utils.d.ts +1 -1
  35. package/src/utils/git-utils.js +13 -2
  36. package/src/utils/is-ci.js +1 -0
  37. package/src/utils/nx-cloud-utils.d.ts +1 -1
  38. package/src/utils/nx-cloud-utils.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "19.4.0-canary.20240626-3a2e8d4",
3
+ "version": "19.4.0-rc.0",
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": {
@@ -45,8 +45,8 @@
45
45
  "cli-cursor": "3.1.0",
46
46
  "cli-spinners": "2.6.1",
47
47
  "cliui": "^8.0.1",
48
- "dotenv": "~16.3.1",
49
- "dotenv-expand": "~10.0.0",
48
+ "dotenv": "~16.4.5",
49
+ "dotenv-expand": "~11.0.6",
50
50
  "enquirer": "~2.3.6",
51
51
  "figures": "3.2.0",
52
52
  "flat": "^5.0.2",
@@ -70,7 +70,7 @@
70
70
  "yargs-parser": "21.1.1",
71
71
  "node-machine-id": "1.1.12",
72
72
  "ora": "5.3.0",
73
- "@nrwl/tao": "19.4.0-canary.20240626-3a2e8d4"
73
+ "@nrwl/tao": "19.4.0-rc.0"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@swc-node/register": "^1.8.0",
@@ -85,16 +85,16 @@
85
85
  }
86
86
  },
87
87
  "optionalDependencies": {
88
- "@nx/nx-darwin-x64": "19.4.0-canary.20240626-3a2e8d4",
89
- "@nx/nx-darwin-arm64": "19.4.0-canary.20240626-3a2e8d4",
90
- "@nx/nx-linux-x64-gnu": "19.4.0-canary.20240626-3a2e8d4",
91
- "@nx/nx-linux-x64-musl": "19.4.0-canary.20240626-3a2e8d4",
92
- "@nx/nx-win32-x64-msvc": "19.4.0-canary.20240626-3a2e8d4",
93
- "@nx/nx-linux-arm64-gnu": "19.4.0-canary.20240626-3a2e8d4",
94
- "@nx/nx-linux-arm64-musl": "19.4.0-canary.20240626-3a2e8d4",
95
- "@nx/nx-linux-arm-gnueabihf": "19.4.0-canary.20240626-3a2e8d4",
96
- "@nx/nx-win32-arm64-msvc": "19.4.0-canary.20240626-3a2e8d4",
97
- "@nx/nx-freebsd-x64": "19.4.0-canary.20240626-3a2e8d4"
88
+ "@nx/nx-darwin-x64": "19.4.0-rc.0",
89
+ "@nx/nx-darwin-arm64": "19.4.0-rc.0",
90
+ "@nx/nx-linux-x64-gnu": "19.4.0-rc.0",
91
+ "@nx/nx-linux-x64-musl": "19.4.0-rc.0",
92
+ "@nx/nx-win32-x64-msvc": "19.4.0-rc.0",
93
+ "@nx/nx-linux-arm64-gnu": "19.4.0-rc.0",
94
+ "@nx/nx-linux-arm64-musl": "19.4.0-rc.0",
95
+ "@nx/nx-linux-arm-gnueabihf": "19.4.0-rc.0",
96
+ "@nx/nx-win32-arm64-msvc": "19.4.0-rc.0",
97
+ "@nx/nx-freebsd-x64": "19.4.0-rc.0"
98
98
  },
99
99
  "nx-migrations": {
100
100
  "migrations": "./migrations.json",
@@ -3,6 +3,6 @@ import { NxArgs } from '../../utils/command-line-utils';
3
3
  import { MessageKey } from '../../utils/ab-testing';
4
4
  export declare function onlyDefaultRunnerIsUsed(nxJson: NxJsonConfiguration): boolean;
5
5
  export declare function connectToNxCloudIfExplicitlyAsked(opts: NxArgs): Promise<void>;
6
- export declare function connectToNxCloudCommand(): Promise<boolean>;
6
+ export declare function connectToNxCloudCommand(command?: string): Promise<boolean>;
7
7
  export declare function connectToNxCloudWithPrompt(command: string): Promise<void>;
8
8
  export declare function connectExistingRepoToNxCloudPrompt(key?: MessageKey): Promise<boolean>;
@@ -41,38 +41,29 @@ async function connectToNxCloudIfExplicitlyAsked(opts) {
41
41
  }
42
42
  }
43
43
  exports.connectToNxCloudIfExplicitlyAsked = connectToNxCloudIfExplicitlyAsked;
44
- async function connectToNxCloudCommand() {
44
+ async function connectToNxCloudCommand(command) {
45
45
  const nxJson = (0, configuration_1.readNxJson)();
46
46
  if ((0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) {
47
- if (process.env.NX_NEW_CLOUD_ONBOARDING !== 'true') {
48
- output_1.output.log({
49
- title: '✔ This workspace already has Nx Cloud set up',
50
- bodyLines: [
51
- 'If you have not done so already, connect your workspace to your Nx Cloud account:',
52
- `- Login at ${(0, nx_cloud_utils_1.getNxCloudUrl)(nxJson)} to connect your repository`,
53
- ],
54
- });
47
+ const token = process.env.NX_CLOUD_ACCESS_TOKEN || nxJson.nxCloudAccessToken;
48
+ if (!token) {
49
+ throw new Error(`Unable to authenticate. Either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`);
55
50
  }
56
- else {
57
- const token = process.env.NX_CLOUD_ACCESS_TOKEN || nxJson.nxCloudAccessToken;
58
- if (!token) {
59
- throw new Error(`Unable to authenticate. Either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`);
60
- }
61
- const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)('nx-connect', token);
62
- output_1.output.log({
63
- title: '✔ This workspace already has Nx Cloud set up',
64
- bodyLines: [
65
- 'If you have not done so already, connect your workspace to your Nx Cloud account:',
66
- `- Connect with Nx Cloud at:
51
+ const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)('nx-connect', token);
52
+ output_1.output.log({
53
+ title: '✔ This workspace already has Nx Cloud set up',
54
+ bodyLines: [
55
+ 'If you have not done so already, connect your workspace to your Nx Cloud account:',
56
+ `- Connect with Nx Cloud at:
67
57
 
68
58
  ${connectCloudUrl}`,
69
- ],
70
- });
71
- }
59
+ ],
60
+ });
72
61
  return false;
73
62
  }
74
63
  const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, false, 'connect-to-nx-cloud');
75
- const callback = await (0, connect_to_nx_cloud_1.connectToNxCloud)(tree, {});
64
+ const callback = await (0, connect_to_nx_cloud_1.connectToNxCloud)(tree, {
65
+ installationSource: command ?? 'nx-connect',
66
+ });
76
67
  tree.lock();
77
68
  (0, tree_1.flushChanges)(workspace_root_1.workspaceRoot, tree.listChanges());
78
69
  await callback();
@@ -81,7 +72,7 @@ async function connectToNxCloudCommand() {
81
72
  exports.connectToNxCloudCommand = connectToNxCloudCommand;
82
73
  async function connectToNxCloudWithPrompt(command) {
83
74
  const setNxCloud = await nxCloudPrompt('setupNxCloud');
84
- const useCloud = setNxCloud === 'yes' ? await connectToNxCloudCommand() : false;
75
+ const useCloud = setNxCloud === 'yes' ? await connectToNxCloudCommand(command) : false;
85
76
  await (0, ab_testing_1.recordStat)({
86
77
  command,
87
78
  nxVersion: versions_1.nxVersion,
@@ -23,6 +23,7 @@ export interface ProjectGraphClientResponse {
23
23
  exclude: string[];
24
24
  isPartial: boolean;
25
25
  errors?: GraphError[];
26
+ connectedToCloud?: boolean;
26
27
  }
27
28
  export interface TaskGraphClientResponse {
28
29
  taskGraphs: Record<string, TaskGraph>;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateGraph = void 0;
4
4
  const crypto_1 = require("crypto");
5
+ const node_child_process_1 = require("node:child_process");
5
6
  const fs_1 = require("fs");
6
7
  const fs_extra_1 = require("fs-extra");
7
8
  const http = require("http");
@@ -25,9 +26,10 @@ const native_1 = require("../../native");
25
26
  const transform_objects_1 = require("../../native/transform-objects");
26
27
  const affected_1 = require("../affected/affected");
27
28
  const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
28
- const create_task_hasher_1 = require("../../hasher/create-task-hasher");
29
29
  const task_hasher_1 = require("../../hasher/task-hasher");
30
+ const create_task_hasher_1 = require("../../hasher/create-task-hasher");
30
31
  const error_types_1 = require("../../project-graph/error-types");
32
+ const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
31
33
  // maps file extention to MIME types
32
34
  const mimeType = {
33
35
  '.ico': 'image/x-icon',
@@ -372,6 +374,20 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
372
374
  res.end(environmentJs);
373
375
  return;
374
376
  }
377
+ if (sanitizePath === 'help') {
378
+ const project = parsedUrl.searchParams.get('project');
379
+ const target = parsedUrl.searchParams.get('target');
380
+ try {
381
+ const text = getHelpTextFromTarget(project, target);
382
+ res.writeHead(200, { 'Content-Type': 'application/javascript' });
383
+ res.end(JSON.stringify({ text, success: true }));
384
+ }
385
+ catch (err) {
386
+ res.writeHead(200, { 'Content-Type': 'application/javascript' });
387
+ res.end(JSON.stringify({ text: err.message, success: false }));
388
+ }
389
+ return;
390
+ }
375
391
  let pathname = (0, path_1.join)(__dirname, '../../core/graph/', sanitizePath);
376
392
  // if the file is not found or is a directory, return index.html
377
393
  if (!(0, fs_1.existsSync)(pathname) || (0, fs_1.statSync)(pathname).isDirectory()) {
@@ -478,10 +494,12 @@ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
478
494
  let sourceMaps;
479
495
  let isPartial = false;
480
496
  let errors;
497
+ let connectedToCloud;
481
498
  try {
482
499
  const projectGraphAndSourceMaps = await (0, project_graph_1.createProjectGraphAndSourceMapsAsync)({ exitOnError: false });
483
500
  projectGraph = projectGraphAndSourceMaps.projectGraph;
484
501
  sourceMaps = projectGraphAndSourceMaps.sourceMaps;
502
+ connectedToCloud = (0, nx_cloud_utils_1.isNxCloudUsed)((0, configuration_1.readNxJson)());
485
503
  }
486
504
  catch (e) {
487
505
  if (e instanceof error_types_1.ProjectGraphError) {
@@ -509,7 +527,14 @@ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
509
527
  const projects = Object.values(graph.nodes);
510
528
  const dependencies = graph.dependencies;
511
529
  const hasher = (0, crypto_1.createHash)('sha256');
512
- hasher.update(JSON.stringify({ layout, projects, dependencies, sourceMaps, errors }));
530
+ hasher.update(JSON.stringify({
531
+ layout,
532
+ projects,
533
+ dependencies,
534
+ sourceMaps,
535
+ errors,
536
+ connectedToCloud,
537
+ }));
513
538
  const hash = hasher.digest('hex');
514
539
  perf_hooks_1.performance.mark('project graph response generation:end');
515
540
  perf_hooks_1.performance.measure('project graph watch calculation', 'project graph watch calculation:start', 'project graph watch calculation:end');
@@ -525,6 +550,7 @@ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
525
550
  fileMap,
526
551
  isPartial,
527
552
  errors,
553
+ connectedToCloud,
528
554
  },
529
555
  sourceMapResponse: sourceMaps,
530
556
  };
@@ -733,3 +759,21 @@ async function createJsonOutput(prunedGraph, rawGraph, projects, targets) {
733
759
  }
734
760
  return response;
735
761
  }
762
+ function getHelpTextFromTarget(projectName, targetName) {
763
+ if (!projectName)
764
+ throw new Error(`Missing project`);
765
+ if (!targetName)
766
+ throw new Error(`Missing target`);
767
+ const project = currentProjectGraphClientResponse.projects?.find((p) => p.name === projectName);
768
+ if (!project)
769
+ throw new Error(`Cannot find project ${projectName}`);
770
+ const target = project.data.targets[targetName];
771
+ if (!target)
772
+ throw new Error(`Cannot find target ${targetName}`);
773
+ const command = target.metadata?.help?.command;
774
+ if (!command)
775
+ throw new Error(`No help command found for ${projectName}:${targetName}`);
776
+ return (0, node_child_process_1.execSync)(command, {
777
+ cwd: (0, path_1.join)(workspace_root_1.workspaceRoot, project.data.root),
778
+ }).toString();
779
+ }
@@ -28,8 +28,9 @@ exports.yargsNxInfixCommand = {
28
28
  command: '$0 <target> [project] [_..]',
29
29
  describe: 'Run a target for a project',
30
30
  handler: async (args) => {
31
- await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
31
+ const exitCode = await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
32
32
  return (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args, 0));
33
33
  });
34
+ process.exit(exitCode);
34
35
  },
35
36
  };
@@ -113,6 +113,14 @@ export interface TargetMetadata {
113
113
  [k: string]: any;
114
114
  description?: string;
115
115
  technologies?: string[];
116
+ nonAtomizedTarget?: string;
117
+ help?: {
118
+ command: string;
119
+ example: {
120
+ options?: Record<string, unknown>;
121
+ args?: string[];
122
+ };
123
+ };
116
124
  }
117
125
  export interface TargetDependencyConfig {
118
126
  /**