nx 17.0.0-beta.2 → 17.0.0-beta.5

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.
Files changed (73) hide show
  1. package/bin/nx-cloud.d.ts +2 -0
  2. package/bin/nx-cloud.js +49 -0
  3. package/executors.json +0 -12
  4. package/generators.json +10 -0
  5. package/migrations.json +1 -1
  6. package/package.json +16 -14
  7. package/src/adapter/ngcli-adapter.d.ts +0 -21
  8. package/src/adapter/ngcli-adapter.js +1 -23
  9. package/src/command-line/affected/command-object.js +1 -1
  10. package/src/command-line/connect/command-object.d.ts +2 -1
  11. package/src/command-line/connect/command-object.js +7 -3
  12. package/src/command-line/connect/connect-to-nx-cloud.d.ts +5 -1
  13. package/src/command-line/connect/connect-to-nx-cloud.js +5 -18
  14. package/src/command-line/connect/view-logs.js +1 -14
  15. package/src/command-line/graph/graph.d.ts +1 -0
  16. package/src/command-line/graph/graph.js +23 -4
  17. package/src/command-line/init/implementation/add-nx-to-monorepo.js +1 -1
  18. package/src/command-line/init/implementation/add-nx-to-nest.js +1 -1
  19. package/src/command-line/init/implementation/add-nx-to-npm-repo.js +1 -1
  20. package/src/command-line/init/implementation/angular/index.js +3 -3
  21. package/src/command-line/init/implementation/angular/integrated-workspace.js +1 -1
  22. package/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -5
  23. package/src/command-line/init/implementation/utils.d.ts +1 -1
  24. package/src/command-line/init/implementation/utils.js +2 -5
  25. package/src/command-line/migrate/migrate.js +4 -1
  26. package/src/command-line/nx-commands.js +4 -6
  27. package/src/command-line/run/command-object.js +1 -1
  28. package/src/command-line/run-many/command-object.js +1 -1
  29. package/src/command-line/yargs-utils/documentation.d.ts +1 -1
  30. package/src/command-line/yargs-utils/shared-options.d.ts +2 -0
  31. package/src/command-line/yargs-utils/shared-options.js +11 -1
  32. package/src/daemon/tmp-dir.js +1 -1
  33. package/src/hasher/task-hasher.js +7 -6
  34. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +24 -0
  35. package/src/native/index.d.ts +47 -22
  36. package/src/native/index.js +2 -1
  37. package/src/native/{transform-project-graph.js → transform-objects.js} +3 -1
  38. package/src/nx-cloud/debug-logger.d.ts +1 -0
  39. package/src/nx-cloud/debug-logger.js +9 -0
  40. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +7 -0
  41. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +102 -0
  42. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +22 -0
  43. package/src/nx-cloud/nx-cloud-tasks-runner-shell.d.ts +15 -0
  44. package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +41 -0
  45. package/src/nx-cloud/resolution-helpers.d.ts +1 -0
  46. package/src/nx-cloud/resolution-helpers.js +20 -0
  47. package/src/nx-cloud/update-manager.d.ts +17 -0
  48. package/src/nx-cloud/update-manager.js +238 -0
  49. package/src/nx-cloud/utilities/axios.d.ts +2 -0
  50. package/src/nx-cloud/utilities/axios.js +24 -0
  51. package/src/nx-cloud/utilities/environment.d.ts +3 -0
  52. package/src/nx-cloud/utilities/environment.js +47 -0
  53. package/src/nx-cloud/utilities/get-cloud-options.d.ts +2 -0
  54. package/src/nx-cloud/utilities/get-cloud-options.js +11 -0
  55. package/src/tasks-runner/cache.js +1 -1
  56. package/src/tasks-runner/default-tasks-runner.d.ts +1 -0
  57. package/src/tasks-runner/run-command.d.ts +1 -0
  58. package/src/tasks-runner/run-command.js +31 -10
  59. package/src/tasks-runner/task-env.d.ts +1 -4
  60. package/src/tasks-runner/task-orchestrator.d.ts +7 -0
  61. package/src/tasks-runner/task-orchestrator.js +48 -13
  62. package/src/tasks-runner/tasks-schedule.d.ts +4 -0
  63. package/src/tasks-runner/tasks-schedule.js +7 -3
  64. package/src/utils/command-line-utils.d.ts +1 -0
  65. package/src/command-line/workspace-lint/command-object.d.ts +0 -5
  66. package/src/command-line/workspace-lint/command-object.js +0 -15
  67. package/src/command-line/workspace-lint/workspace-lint.d.ts +0 -1
  68. package/src/command-line/workspace-lint/workspace-lint.js +0 -14
  69. package/src/executors/run-commands/compat.d.ts +0 -2
  70. package/src/executors/run-commands/compat.js +0 -5
  71. package/src/executors/run-script/compat.d.ts +0 -2
  72. package/src/executors/run-script/compat.js +0 -5
  73. /package/src/native/{transform-project-graph.d.ts → transform-objects.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const resolution_helpers_1 = require("../src/nx-cloud/resolution-helpers");
5
+ const get_cloud_options_1 = require("../src/nx-cloud/utilities/get-cloud-options");
6
+ const update_manager_1 = require("../src/nx-cloud/update-manager");
7
+ const output_1 = require("../src/utils/output");
8
+ const command = process.argv[2];
9
+ const options = (0, get_cloud_options_1.getCloudOptions)();
10
+ Promise.resolve().then(async () => invokeCommandWithNxCloudClient(options));
11
+ async function invokeCommandWithNxCloudClient(options) {
12
+ try {
13
+ const { nxCloudClient } = await (0, update_manager_1.verifyOrUpdateNxCloudClient)(options);
14
+ const paths = (0, resolution_helpers_1.findAncestorNodeModules)(__dirname, []);
15
+ nxCloudClient.configureLightClientRequire()(paths);
16
+ if (command in nxCloudClient.commands) {
17
+ nxCloudClient.commands[command]()
18
+ .then(() => process.exit(0))
19
+ .catch((e) => {
20
+ console.error(e);
21
+ process.exit(1);
22
+ });
23
+ }
24
+ else {
25
+ output_1.output.error({
26
+ title: `Unknown Command "${command}"`,
27
+ });
28
+ output_1.output.log({
29
+ title: 'Available Commands:',
30
+ bodyLines: Object.keys(nxCloudClient.commands).map((c) => `- ${c}`),
31
+ });
32
+ process.exit(1);
33
+ }
34
+ }
35
+ catch (e) {
36
+ const body = ['Cannot run commands from the `nx-cloud` CLI.'];
37
+ if (e instanceof update_manager_1.NxCloudEnterpriseOutdatedError) {
38
+ body.push('If you are an Nx Enterprise customer, please reach out to your assigned Developer Productivity Engineer.', 'If you are NOT an Nx Enterprise customer but are seeing this message, please reach out to cloud-support@nrwl.io.');
39
+ }
40
+ if (e instanceof update_manager_1.NxCloudClientUnavailableError) {
41
+ body.unshift('You may be offline. Please try again when you are back online.');
42
+ }
43
+ output_1.output.error({
44
+ title: e.message,
45
+ bodyLines: body,
46
+ });
47
+ process.exit(1);
48
+ }
49
+ }
package/executors.json CHANGED
@@ -1,16 +1,4 @@
1
1
  {
2
- "builders": {
3
- "run-commands": {
4
- "implementation": "./src/executors/run-commands/compat",
5
- "schema": "./src/executors/run-commands/schema.json",
6
- "description": "Run any custom commands with Nx."
7
- },
8
- "run-script": {
9
- "implementation": "./src/executors/run-script/compat",
10
- "schema": "./src/executors/run-script/schema.json",
11
- "description": "Run an NPM script using Nx."
12
- }
13
- },
14
2
  "executors": {
15
3
  "noop": {
16
4
  "implementation": "./src/executors/noop/noop.impl",
@@ -0,0 +1,10 @@
1
+ {
2
+ "generators": {
3
+ "connect-to-nx-cloud": {
4
+ "factory": "./src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud",
5
+ "schema": "./src/nx-cloud/generators/connect-to-nx-cloud/schema.json",
6
+ "description": "Connect a workspace to Nx Cloud",
7
+ "x-hidden": true
8
+ }
9
+ }
10
+ }
package/migrations.json CHANGED
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "17.0.0-use-minimal-config-for-tasks-runner-options": {
70
70
  "cli": "nx",
71
- "version": "17.0.0-beta.2",
71
+ "version": "17.0.0-beta.3",
72
72
  "description": "Use minimal config for tasksRunnerOptions",
73
73
  "implementation": "./src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options"
74
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "17.0.0-beta.2",
3
+ "version": "17.0.0-beta.5",
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": {
@@ -23,7 +23,8 @@
23
23
  "CLI"
24
24
  ],
25
25
  "bin": {
26
- "nx": "./bin/nx.js"
26
+ "nx": "./bin/nx.js",
27
+ "nx-cloud": "./bin/nx-cloud.js"
27
28
  },
28
29
  "author": "Victor Savkin",
29
30
  "license": "MIT",
@@ -36,7 +37,7 @@
36
37
  "@yarnpkg/lockfile": "^1.1.0",
37
38
  "@yarnpkg/parsers": "3.0.0-rc.46",
38
39
  "@zkochan/js-yaml": "0.0.6",
39
- "axios": "^1.0.0",
40
+ "axios": "^1.5.1",
40
41
  "chalk": "^4.1.0",
41
42
  "cli-cursor": "3.1.0",
42
43
  "cli-spinners": "2.6.1",
@@ -67,7 +68,7 @@
67
68
  "yargs": "^17.6.2",
68
69
  "yargs-parser": "21.1.1",
69
70
  "node-machine-id": "1.1.12",
70
- "@nrwl/tao": "17.0.0-beta.2"
71
+ "@nrwl/tao": "17.0.0-beta.5"
71
72
  },
72
73
  "peerDependencies": {
73
74
  "@swc-node/register": "^1.6.7",
@@ -82,16 +83,16 @@
82
83
  }
83
84
  },
84
85
  "optionalDependencies": {
85
- "@nx/nx-darwin-x64": "17.0.0-beta.2",
86
- "@nx/nx-darwin-arm64": "17.0.0-beta.2",
87
- "@nx/nx-linux-x64-gnu": "17.0.0-beta.2",
88
- "@nx/nx-linux-x64-musl": "17.0.0-beta.2",
89
- "@nx/nx-win32-x64-msvc": "17.0.0-beta.2",
90
- "@nx/nx-linux-arm64-gnu": "17.0.0-beta.2",
91
- "@nx/nx-linux-arm64-musl": "17.0.0-beta.2",
92
- "@nx/nx-linux-arm-gnueabihf": "17.0.0-beta.2",
93
- "@nx/nx-win32-arm64-msvc": "17.0.0-beta.2",
94
- "@nx/nx-freebsd-x64": "17.0.0-beta.2"
86
+ "@nx/nx-darwin-x64": "17.0.0-beta.5",
87
+ "@nx/nx-darwin-arm64": "17.0.0-beta.5",
88
+ "@nx/nx-linux-x64-gnu": "17.0.0-beta.5",
89
+ "@nx/nx-linux-x64-musl": "17.0.0-beta.5",
90
+ "@nx/nx-win32-x64-msvc": "17.0.0-beta.5",
91
+ "@nx/nx-linux-arm64-gnu": "17.0.0-beta.5",
92
+ "@nx/nx-linux-arm64-musl": "17.0.0-beta.5",
93
+ "@nx/nx-linux-arm-gnueabihf": "17.0.0-beta.5",
94
+ "@nx/nx-win32-arm64-msvc": "17.0.0-beta.5",
95
+ "@nx/nx-freebsd-x64": "17.0.0-beta.5"
95
96
  },
96
97
  "nx-migrations": {
97
98
  "migrations": "./migrations.json",
@@ -154,6 +155,7 @@
154
155
  }
155
156
  ]
156
157
  },
158
+ "generators": "./generators.json",
157
159
  "executors": "./executors.json",
158
160
  "builders": "./executors.json",
159
161
  "publishConfig": {
@@ -46,27 +46,6 @@ export declare function runMigration(root: string, packageName: string, migratio
46
46
  loggingQueue: string[];
47
47
  madeChanges: boolean;
48
48
  }>;
49
- /**
50
- * By default, Angular Devkit schematic collections will be resolved using the Node resolution.
51
- * This doesn't work if you are testing schematics that refer to other schematics in the
52
- * same repo.
53
- *
54
- * This function can can be used to override the resolution behaviour.
55
- *
56
- * Example:
57
- *
58
- * ```typescript
59
- * overrideCollectionResolutionForTesting({
60
- * '@nx/workspace': path.join(__dirname, '../../../../workspace/generators.json'),
61
- * '@nx/angular': path.join(__dirname, '../../../../angular/generators.json'),
62
- * '@nx/linter': path.join(__dirname, '../../../../linter/generators.json')
63
- * });
64
- *
65
- * ```
66
- */
67
- export declare function overrideCollectionResolutionForTesting(collections: {
68
- [name: string]: string;
69
- }): void;
70
49
  /**
71
50
  * If you have an Nx Devkit generator invoking the wrapped Angular Devkit schematic,
72
51
  * and you don't want the Angular Devkit schematic to run, you can mock it up using this function.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.overrideCollectionResolutionForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
3
+ exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const node_1 = require("@angular-devkit/core/node");
6
6
  const chalk = require("chalk");
@@ -528,28 +528,6 @@ function resolveMigrationsCollection(name) {
528
528
  }
529
529
  let collectionResolutionOverrides = null;
530
530
  let mockedSchematics = null;
531
- /**
532
- * By default, Angular Devkit schematic collections will be resolved using the Node resolution.
533
- * This doesn't work if you are testing schematics that refer to other schematics in the
534
- * same repo.
535
- *
536
- * This function can can be used to override the resolution behaviour.
537
- *
538
- * Example:
539
- *
540
- * ```typescript
541
- * overrideCollectionResolutionForTesting({
542
- * '@nx/workspace': path.join(__dirname, '../../../../workspace/generators.json'),
543
- * '@nx/angular': path.join(__dirname, '../../../../angular/generators.json'),
544
- * '@nx/linter': path.join(__dirname, '../../../../linter/generators.json')
545
- * });
546
- *
547
- * ```
548
- */
549
- function overrideCollectionResolutionForTesting(collections) {
550
- collectionResolutionOverrides = collections;
551
- }
552
- exports.overrideCollectionResolutionForTesting = overrideCollectionResolutionForTesting;
553
531
  /**
554
532
  * If you have an Nx Devkit generator invoking the wrapped Angular Devkit schematic,
555
533
  * and you don't want the Angular Devkit schematic to run, you can mock it up using this function.
@@ -6,7 +6,7 @@ const shared_options_1 = require("../yargs-utils/shared-options");
6
6
  exports.yargsAffectedCommand = {
7
7
  command: 'affected',
8
8
  describe: 'Run target for affected projects',
9
- builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withTargetAndConfigurationOption)(yargs))))
9
+ builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withTargetAndConfigurationOption)((0, shared_options_1.withBatch)(yargs)))))
10
10
  .option('all', {
11
11
  type: 'boolean',
12
12
  deprecated: 'Use `nx run-many` instead',
@@ -1,3 +1,4 @@
1
1
  import { CommandModule } from 'yargs';
2
- export declare const yargsConnectCommand: CommandModule;
2
+ import type { ConnectToNxCloudOptions } from './connect-to-nx-cloud';
3
+ export declare const yargsConnectCommand: CommandModule<{}, ConnectToNxCloudOptions>;
3
4
  export declare const yargsViewLogsCommand: CommandModule;
@@ -6,9 +6,13 @@ exports.yargsConnectCommand = {
6
6
  command: 'connect',
7
7
  aliases: ['connect-to-nx-cloud'],
8
8
  describe: `Connect workspace to Nx Cloud`,
9
- builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)(yargs, 'connect-to-nx-cloud'),
10
- handler: async () => {
11
- await (await Promise.resolve().then(() => require('./connect-to-nx-cloud'))).connectToNxCloudCommand();
9
+ builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)(yargs.option('interactive', {
10
+ type: 'boolean',
11
+ description: 'Prompt for confirmation',
12
+ default: true,
13
+ }), 'connect-to-nx-cloud'),
14
+ handler: async (options) => {
15
+ await (await Promise.resolve().then(() => require('./connect-to-nx-cloud'))).connectToNxCloudCommand(options);
12
16
  process.exit(0);
13
17
  },
14
18
  };
@@ -2,4 +2,8 @@ import { NxJsonConfiguration } from '../../config/nx-json';
2
2
  import { NxArgs } from '../../utils/command-line-utils';
3
3
  export declare function onlyDefaultRunnerIsUsed(nxJson: NxJsonConfiguration): boolean;
4
4
  export declare function connectToNxCloudIfExplicitlyAsked(opts: NxArgs): Promise<void>;
5
- export declare function connectToNxCloudCommand(promptOverride?: string): Promise<boolean>;
5
+ export interface ConnectToNxCloudOptions {
6
+ interactive: boolean;
7
+ promptOverride?: string;
8
+ }
9
+ export declare function connectToNxCloudCommand({ promptOverride, interactive, }: ConnectToNxCloudOptions): Promise<boolean>;
@@ -2,11 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.connectToNxCloudCommand = exports.connectToNxCloudIfExplicitlyAsked = exports.onlyDefaultRunnerIsUsed = void 0;
4
4
  const output_1 = require("../../utils/output");
5
- const package_manager_1 = require("../../utils/package-manager");
6
- const child_process_1 = require("child_process");
7
5
  const configuration_1 = require("../../config/configuration");
8
6
  const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
9
- const child_process_2 = require("../../utils/child-process");
7
+ const child_process_1 = require("../../utils/child-process");
10
8
  function onlyDefaultRunnerIsUsed(nxJson) {
11
9
  if (!nxJson.tasksRunnerOptions) {
12
10
  // No tasks runner options:
@@ -30,7 +28,7 @@ async function connectToNxCloudIfExplicitlyAsked(opts) {
30
28
  output_1.output.log({
31
29
  title: '--cloud requires the workspace to be connected to Nx Cloud.',
32
30
  });
33
- (0, child_process_2.runNxSync)(`connect-to-nx-cloud`, {
31
+ (0, child_process_1.runNxSync)(`connect-to-nx-cloud`, {
34
32
  stdio: [0, 1, 2],
35
33
  });
36
34
  output_1.output.success({
@@ -40,7 +38,7 @@ async function connectToNxCloudIfExplicitlyAsked(opts) {
40
38
  }
41
39
  }
42
40
  exports.connectToNxCloudIfExplicitlyAsked = connectToNxCloudIfExplicitlyAsked;
43
- async function connectToNxCloudCommand(promptOverride) {
41
+ async function connectToNxCloudCommand({ promptOverride, interactive, }) {
44
42
  const nxJson = (0, configuration_1.readNxJson)();
45
43
  if ((0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) {
46
44
  output_1.output.log({
@@ -55,21 +53,10 @@ async function connectToNxCloudCommand(promptOverride) {
55
53
  });
56
54
  return false;
57
55
  }
58
- const res = await connectToNxCloudPrompt(promptOverride);
56
+ const res = interactive ? await connectToNxCloudPrompt(promptOverride) : true;
59
57
  if (!res)
60
58
  return false;
61
- const pmc = (0, package_manager_1.getPackageManagerCommand)();
62
- if (pmc) {
63
- (0, child_process_1.execSync)(`${pmc.addDev} nx-cloud@latest`);
64
- }
65
- else {
66
- const nxJson = (0, configuration_1.readNxJson)();
67
- if (nxJson.installation) {
68
- nxJson.installation.plugins ??= {};
69
- nxJson.installation.plugins['nx-cloud'] = (0, child_process_1.execSync)(`npm view nx-cloud@latest version`).toString();
70
- }
71
- }
72
- (0, child_process_2.runNxSync)(`g nx-cloud:init`, {
59
+ (0, child_process_1.runNxSync)(`g nx:connect-to-nx-cloud --quiet --no-interactive`, {
73
60
  stdio: [0, 1, 2],
74
61
  });
75
62
  return true;
@@ -40,24 +40,11 @@ async function viewLogs() {
40
40
  if (!installCloud)
41
41
  return;
42
42
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
43
- try {
44
- output_1.output.log({
45
- title: 'Installing nx-cloud',
46
- });
47
- (0, child_process_1.execSync)(`${pmc.addDev} nx-cloud@latest`, { stdio: 'ignore' });
48
- }
49
- catch (e) {
50
- output_1.output.log({
51
- title: 'Installation failed',
52
- });
53
- console.log(e);
54
- return 1;
55
- }
56
43
  try {
57
44
  output_1.output.log({
58
45
  title: 'Connecting to Nx Cloud',
59
46
  });
60
- (0, child_process_2.runNxSync)(`g nx-cloud:init --installation-source=view-logs`, {
47
+ (0, child_process_2.runNxSync)(`g nx:connect-to-nx-cloud --installation-source=view-logs --quiet --no-interactive`, {
61
48
  stdio: 'ignore',
62
49
  });
63
50
  }
@@ -16,6 +16,7 @@ export interface ProjectGraphClientResponse {
16
16
  }
17
17
  export interface TaskGraphClientResponse {
18
18
  taskGraphs: Record<string, TaskGraph>;
19
+ plans?: Record<string, string[]>;
19
20
  errors: Record<string, string>;
20
21
  }
21
22
  export declare function generateGraph(args: {
@@ -20,6 +20,8 @@ const client_1 = require("../../daemon/client/client");
20
20
  const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
21
21
  const affected_1 = require("../affected/affected");
22
22
  const command_line_utils_1 = require("../../utils/command-line-utils");
23
+ const native_1 = require("../../native");
24
+ const transform_objects_1 = require("../../native/transform-objects");
23
25
  // maps file extention to MIME types
24
26
  const mimeType = {
25
27
  '.ico': 'image/x-icon',
@@ -405,17 +407,34 @@ async function createDepGraphClientResponse(affected = []) {
405
407
  }
406
408
  async function createTaskGraphClientResponse() {
407
409
  let graph = (0, operators_1.pruneExternalNodes)(await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true }));
410
+ const nxJson = (0, configuration_1.readNxJson)();
408
411
  perf_hooks_1.performance.mark('task graph generation:start');
409
- const taskGraphs = getAllTaskGraphsForWorkspace(graph);
412
+ const taskGraphs = getAllTaskGraphsForWorkspace(nxJson, graph);
410
413
  perf_hooks_1.performance.mark('task graph generation:end');
414
+ const planner = new native_1.HashPlanner(workspace_root_1.workspaceRoot, nxJson, (0, transform_objects_1.transformProjectGraphForRust)(graph));
415
+ perf_hooks_1.performance.mark('task hash plan generation:start');
416
+ const plans = {};
417
+ for (const individualTaskGraph of Object.values(taskGraphs.taskGraphs)) {
418
+ for (const task of Object.values(individualTaskGraph.tasks)) {
419
+ if (plans[task.id]) {
420
+ continue;
421
+ }
422
+ plans[task.id] = planner.getPlans([task.id], individualTaskGraph)[task.id];
423
+ }
424
+ }
425
+ perf_hooks_1.performance.mark('task hash plan generation:end');
411
426
  perf_hooks_1.performance.measure('task graph generation', 'task graph generation:start', 'task graph generation:end');
412
- return taskGraphs;
427
+ perf_hooks_1.performance.measure('task hash plan generation', 'task hash plan generation:start', 'task hash plan generation:end');
428
+ return {
429
+ ...taskGraphs,
430
+ plans,
431
+ };
413
432
  }
414
- function getAllTaskGraphsForWorkspace(projectGraph) {
415
- const nxJson = (0, configuration_1.readNxJson)();
433
+ function getAllTaskGraphsForWorkspace(nxJson, projectGraph) {
416
434
  const defaultDependencyConfigs = (0, create_task_graph_1.mapTargetDefaultsToDependencies)(nxJson.targetDefaults);
417
435
  const taskGraphs = {};
418
436
  const taskGraphErrors = {};
437
+ // TODO(cammisuli): improve performance here. Cache results or something.
419
438
  for (const projectName in projectGraph.nodes) {
420
439
  const project = projectGraph.nodes[projectName];
421
440
  const targets = Object.keys(project.data.targets);
@@ -57,7 +57,7 @@ async function addNxToMonorepo(options) {
57
57
  (options.interactive ? await (0, utils_1.askAboutNxCloud)() : false);
58
58
  }
59
59
  (0, utils_1.createNxJsonFile)(repoRoot, targetDefaults, cacheableOperations, scriptOutputs);
60
- (0, utils_1.addDepsToPackageJson)(repoRoot, useNxCloud);
60
+ (0, utils_1.addDepsToPackageJson)(repoRoot);
61
61
  output_1.output.log({ title: '📦 Installing dependencies' });
62
62
  (0, utils_1.runInstall)(repoRoot);
63
63
  if (useNxCloud) {
@@ -71,7 +71,7 @@ async function addNxToNest(options, packageJson) {
71
71
  }
72
72
  (0, utils_1.createNxJsonFile)(repoRoot, [], [...cacheableOperations, ...nestCacheableScripts], {});
73
73
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
74
- (0, utils_1.addDepsToPackageJson)(repoRoot, useNxCloud);
74
+ (0, utils_1.addDepsToPackageJson)(repoRoot);
75
75
  addNestPluginToPackageJson(repoRoot);
76
76
  (0, utils_1.markRootPackageJsonAsNxProject)(repoRoot, cacheableOperations, scriptOutputs, pmc);
77
77
  createProjectJson(repoRoot, packageJson, nestCLIConfiguration);
@@ -46,7 +46,7 @@ async function addNxToNpmRepo(options) {
46
46
  }
47
47
  (0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations, {});
48
48
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
49
- (0, utils_1.addDepsToPackageJson)(repoRoot, useNxCloud);
49
+ (0, utils_1.addDepsToPackageJson)(repoRoot);
50
50
  (0, utils_1.markRootPackageJsonAsNxProject)(repoRoot, cacheableOperations, scriptOutputs, pmc);
51
51
  output_1.output.log({ title: '📦 Installing dependencies' });
52
52
  (0, utils_1.runInstall)(repoRoot, pmc);
@@ -37,7 +37,7 @@ async function addNxToAngularCliRepo(options) {
37
37
  : [];
38
38
  const useNxCloud = options.nxCloud ?? (options.interactive ? await (0, utils_1.askAboutNxCloud)() : false);
39
39
  output_1.output.log({ title: '📦 Installing dependencies' });
40
- installDependencies(useNxCloud);
40
+ installDependencies();
41
41
  output_1.output.log({ title: '📝 Setting up workspace' });
42
42
  await setupWorkspace(cacheableOperations, options.integrated);
43
43
  if (useNxCloud) {
@@ -77,8 +77,8 @@ async function collectCacheableOperations(options) {
77
77
  }
78
78
  return cacheableOperations;
79
79
  }
80
- function installDependencies(useNxCloud) {
81
- (0, utils_1.addDepsToPackageJson)(repoRoot, useNxCloud);
80
+ function installDependencies() {
81
+ (0, utils_1.addDepsToPackageJson)(repoRoot);
82
82
  addPluginDependencies();
83
83
  (0, utils_1.runInstall)(repoRoot);
84
84
  }
@@ -5,6 +5,6 @@ const child_process_1 = require("child_process");
5
5
  const package_manager_1 = require("../../../../utils/package-manager");
6
6
  function setupIntegratedWorkspace() {
7
7
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
8
- (0, child_process_1.execSync)(`${pmc.exec} ng g @nx/angular:ng-add`, { stdio: [0, 1, 2] });
8
+ (0, child_process_1.execSync)(`${pmc.exec} nx g @nx/angular:ng-add`, { stdio: [0, 1, 2] });
9
9
  }
10
10
  exports.setupIntegratedWorkspace = setupIntegratedWorkspace;
@@ -101,11 +101,6 @@ async function installDependencies(repoRoot, pkgInfo, useNxCloud, pmc) {
101
101
  json.devDependencies[`${pkgInfo.pkgScope}/cli`] = pkgInfo.pkgVersion;
102
102
  json.devDependencies[`${pkgInfo.pkgScope}/tao`] = pkgInfo.pkgVersion;
103
103
  }
104
- if (useNxCloud) {
105
- // get the latest nx-cloud version compatible with the Nx major
106
- // version being installed
107
- json.devDependencies['nx-cloud'] = await resolvePackageVersion('nx-cloud', `^${(0, semver_1.major)(pkgInfo.pkgVersion)}.0.0`);
108
- }
109
104
  json.devDependencies = (0, object_sort_1.sortObjectByKeys)(json.devDependencies);
110
105
  if (pkgInfo.unscopedPkgName === 'angular') {
111
106
  json.dependencies ??= {};
@@ -3,7 +3,7 @@ export declare function askAboutNxCloud(): Promise<boolean>;
3
3
  export declare function createNxJsonFile(repoRoot: string, topologicalTargets: string[], cacheableOperations: string[], scriptOutputs: {
4
4
  [name: string]: string;
5
5
  }): void;
6
- export declare function addDepsToPackageJson(repoRoot: string, useCloud: boolean): void;
6
+ export declare function addDepsToPackageJson(repoRoot: string): void;
7
7
  export declare function runInstall(repoRoot: string, pmc?: PackageManagerCommands): void;
8
8
  export declare function initCloud(repoRoot: string, installationSource: 'nx-init-angular' | 'nx-init-cra' | 'nx-init-monorepo' | 'nx-init-nest' | 'nx-init-npm-repo'): void;
9
9
  export declare function addVsCodeRecommendedExtensions(repoRoot: string, extensions: string[]): void;
@@ -99,15 +99,12 @@ function deduceDefaultBase() {
99
99
  }
100
100
  }
101
101
  }
102
- function addDepsToPackageJson(repoRoot, useCloud) {
102
+ function addDepsToPackageJson(repoRoot) {
103
103
  const path = (0, path_2.joinPathFragments)(repoRoot, `package.json`);
104
104
  const json = (0, fileutils_1.readJsonFile)(path);
105
105
  if (!json.devDependencies)
106
106
  json.devDependencies = {};
107
107
  json.devDependencies['nx'] = versions_1.nxVersion;
108
- if (useCloud) {
109
- json.devDependencies['nx-cloud'] = 'latest';
110
- }
111
108
  (0, fileutils_1.writeJsonFile)(path, json);
112
109
  }
113
110
  exports.addDepsToPackageJson = addDepsToPackageJson;
@@ -116,7 +113,7 @@ function runInstall(repoRoot, pmc = (0, package_manager_1.getPackageManagerComma
116
113
  }
117
114
  exports.runInstall = runInstall;
118
115
  function initCloud(repoRoot, installationSource) {
119
- (0, child_process_2.runNxSync)(`g nx-cloud:init --installationSource=${installationSource}`, {
116
+ (0, child_process_2.runNxSync)(`g nx:connect-to-nx-cloud --installationSource=${installationSource} --quiet --no-interactive`, {
120
117
  stdio: [0, 1, 2],
121
118
  cwd: repoRoot,
122
119
  });
@@ -750,7 +750,10 @@ async function generateMigrationsJsonAndUpdatePackageJson(root, opts) {
750
750
  (await isMigratingToNewMajor(from, opts.targetVersion)) &&
751
751
  !(0, is_ci_1.isCI)() &&
752
752
  !(0, nx_cloud_utils_1.isNxCloudUsed)(originalNxJson)) {
753
- const useCloud = await (0, connect_to_nx_cloud_1.connectToNxCloudCommand)(ab_testing_1.messages.getPromptMessage('nxCloudMigration'));
753
+ const useCloud = await (0, connect_to_nx_cloud_1.connectToNxCloudCommand)({
754
+ promptOverride: ab_testing_1.messages.getPromptMessage('nxCloudMigration'),
755
+ interactive: true,
756
+ });
754
757
  await (0, ab_testing_1.recordStat)({
755
758
  command: 'migrate',
756
759
  nxVersion: versions_1.nxVersion,
@@ -20,9 +20,8 @@ const command_object_14 = require("./run/command-object");
20
20
  const command_object_15 = require("./run-many/command-object");
21
21
  const command_object_16 = require("./show/command-object");
22
22
  const command_object_17 = require("./watch/command-object");
23
- const command_object_18 = require("./workspace-lint/command-object");
24
- const command_object_19 = require("./reset/command-object");
25
- const command_object_20 = require("./release/command-object");
23
+ const command_object_18 = require("./reset/command-object");
24
+ const command_object_19 = require("./release/command-object");
26
25
  // Ensure that the output takes up the available width of the terminal.
27
26
  yargs.wrap(yargs.terminalWidth());
28
27
  exports.parserConfiguration = {
@@ -58,16 +57,15 @@ exports.commandsObject = yargs
58
57
  .command(command_object_10.yargsMigrateCommand)
59
58
  .command(command_object_11.yargsNewCommand)
60
59
  .command(command_object_1.yargsPrintAffectedCommand)
61
- .command(command_object_20.yargsReleaseCommand)
60
+ .command(command_object_19.yargsReleaseCommand)
62
61
  .command(command_object_12.yargsRepairCommand)
63
62
  .command(command_object_13.yargsReportCommand)
64
- .command(command_object_19.yargsResetCommand)
63
+ .command(command_object_18.yargsResetCommand)
65
64
  .command(command_object_14.yargsRunCommand)
66
65
  .command(command_object_15.yargsRunManyCommand)
67
66
  .command(command_object_16.yargsShowCommand)
68
67
  .command(command_object_2.yargsViewLogsCommand)
69
68
  .command(command_object_17.yargsWatchCommand)
70
- .command(command_object_18.yargsWorkspaceLintCommand)
71
69
  .scriptName('nx')
72
70
  .help()
73
71
  // NOTE: we handle --version in nx.ts, this just tells yargs that the option exists
@@ -11,6 +11,6 @@ exports.yargsRunCommand = {
11
11
  (e.g., nx serve myapp --configuration=production)
12
12
 
13
13
  You can skip the use of Nx cache by using the --skip-nx-cache option.`,
14
- builder: (yargs) => (0, shared_options_1.withRunOneOptions)(yargs),
14
+ builder: (yargs) => (0, shared_options_1.withRunOneOptions)((0, shared_options_1.withBatch)(yargs)),
15
15
  handler: async (args) => (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args)),
16
16
  };
@@ -6,6 +6,6 @@ const shared_options_1 = require("../yargs-utils/shared-options");
6
6
  exports.yargsRunManyCommand = {
7
7
  command: 'run-many',
8
8
  describe: 'Run target for multiple listed projects',
9
- builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withRunManyOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withTargetAndConfigurationOption)(yargs))), 'run-many'),
9
+ builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withRunManyOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withTargetAndConfigurationOption)((0, shared_options_1.withBatch)(yargs)))), 'run-many'),
10
10
  handler: async (args) => (await Promise.resolve().then(() => require('./run-many'))).runMany((0, shared_options_1.withOverrides)(args)),
11
11
  };
@@ -1,2 +1,2 @@
1
1
  import yargs = require('yargs');
2
- export declare function linkToNxDevAndExamples(yargs: yargs.Argv, command: string): yargs.Argv<{}>;
2
+ export declare function linkToNxDevAndExamples<T>(yargs: yargs.Argv<T>, command: string): yargs.Argv<T>;
@@ -16,6 +16,7 @@ export interface RunOptions {
16
16
  skipNxCache: boolean;
17
17
  cloud: boolean;
18
18
  dte: boolean;
19
+ batch: boolean;
19
20
  }
20
21
  export declare function withRunOptions<T>(yargs: Argv<T>): Argv<T & RunOptions>;
21
22
  export declare function withTargetAndConfigurationOption(yargs: Argv, demandOption?: boolean): Argv<{
@@ -26,6 +27,7 @@ export declare function withTargetAndConfigurationOption(yargs: Argv, demandOpti
26
27
  export declare function withConfiguration(yargs: Argv): Argv<{
27
28
  configuration: string;
28
29
  }>;
30
+ export declare function withBatch(yargs: Argv): any;
29
31
  export declare function withAffectedOptions(yargs: Argv): Argv<ExcludeOptions & {
30
32
  files: string;
31
33
  } & {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseCSV = exports.withRunOneOptions = exports.withDepGraphOptions = exports.withOutputStyleOption = exports.withOverrides = exports.withRunManyOptions = exports.withAffectedOptions = exports.withConfiguration = exports.withTargetAndConfigurationOption = exports.withRunOptions = exports.withExcludeOption = void 0;
3
+ exports.parseCSV = exports.withRunOneOptions = exports.withDepGraphOptions = exports.withOutputStyleOption = exports.withOverrides = exports.withRunManyOptions = exports.withAffectedOptions = exports.withBatch = exports.withConfiguration = exports.withTargetAndConfigurationOption = exports.withRunOptions = exports.withExcludeOption = void 0;
4
4
  function withExcludeOption(yargs) {
5
5
  return yargs.option('exclude', {
6
6
  describe: 'Exclude certain projects from being processed',
@@ -91,6 +91,16 @@ function withConfiguration(yargs) {
91
91
  });
92
92
  }
93
93
  exports.withConfiguration = withConfiguration;
94
+ function withBatch(yargs) {
95
+ return yargs.options('batch', {
96
+ type: 'boolean',
97
+ coerce: (v) => {
98
+ return v || process.env.BATCH_MODE === 'true';
99
+ },
100
+ default: false,
101
+ });
102
+ }
103
+ exports.withBatch = withBatch;
94
104
  function withAffectedOptions(yargs) {
95
105
  return withExcludeOption(yargs)
96
106
  .parserConfiguration({