nx 19.5.1 → 19.5.3

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 (63) hide show
  1. package/bin/nx-cloud.d.ts +2 -1
  2. package/bin/nx-cloud.js +9 -17
  3. package/bin/nx.js +1 -1
  4. package/package.json +12 -12
  5. package/src/adapter/ngcli-adapter.js +7 -4
  6. package/src/command-line/connect/command-object.js +6 -0
  7. package/src/command-line/connect/connect-to-nx-cloud.d.ts +1 -1
  8. package/src/command-line/connect/connect-to-nx-cloud.js +11 -4
  9. package/src/command-line/connect/view-logs.js +1 -1
  10. package/src/command-line/list/list.js +10 -14
  11. package/src/command-line/migrate/command-object.js +1 -0
  12. package/src/command-line/release/command-object.js +5 -21
  13. package/src/command-line/reset/command-object.d.ts +1 -0
  14. package/src/command-line/reset/command-object.js +4 -0
  15. package/src/command-line/reset/reset.js +13 -0
  16. package/src/command-line/run/executor-utils.js +14 -5
  17. package/src/command-line/run/run.js +2 -14
  18. package/src/command-line/watch/watch.js +1 -1
  19. package/src/core/graph/main.js +1 -1
  20. package/src/daemon/socket-utils.js +1 -1
  21. package/src/daemon/tmp-dir.d.ts +1 -1
  22. package/src/daemon/tmp-dir.js +3 -2
  23. package/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -0
  24. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +1 -1
  25. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +3 -1
  26. package/src/native/nx.wasm32-wasi.wasm +0 -0
  27. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +4 -16
  28. package/src/nx-cloud/utilities/client.d.ts +10 -0
  29. package/src/nx-cloud/utilities/client.js +35 -0
  30. package/src/nx-cloud/utilities/get-cloud-options.d.ts +2 -0
  31. package/src/nx-cloud/utilities/get-cloud-options.js +8 -0
  32. package/src/nx-cloud/utilities/url-shorten.d.ts +2 -3
  33. package/src/nx-cloud/utilities/url-shorten.js +15 -11
  34. package/src/tasks-runner/run-command.d.ts +4 -4
  35. package/src/tasks-runner/run-command.js +22 -17
  36. package/src/tasks-runner/task-graph-utils.d.ts +3 -0
  37. package/src/tasks-runner/task-graph-utils.js +34 -0
  38. package/src/tasks-runner/utils.js +9 -6
  39. package/src/utils/ab-testing.d.ts +1 -1
  40. package/src/utils/ab-testing.js +2 -1
  41. package/src/utils/chunkify.d.ts +10 -0
  42. package/src/utils/chunkify.js +19 -12
  43. package/src/utils/command-line-utils.d.ts +3 -0
  44. package/src/utils/command-line-utils.js +11 -7
  45. package/src/utils/git-utils.js +14 -4
  46. package/src/utils/plugins/core-plugins.d.ts +6 -3
  47. package/src/utils/plugins/core-plugins.js +107 -115
  48. package/src/utils/plugins/index.d.ts +4 -4
  49. package/src/utils/plugins/index.js +7 -8
  50. package/src/utils/plugins/installed-plugins.d.ts +2 -3
  51. package/src/utils/plugins/installed-plugins.js +4 -31
  52. package/src/utils/plugins/local-plugins.d.ts +2 -3
  53. package/src/utils/plugins/local-plugins.js +2 -29
  54. package/src/utils/plugins/output.d.ts +5 -0
  55. package/src/utils/plugins/output.js +104 -0
  56. package/src/utils/plugins/plugin-capabilities.d.ts +12 -2
  57. package/src/utils/plugins/plugin-capabilities.js +2 -80
  58. package/src/utils/plugins/community-plugins.d.ts +0 -2
  59. package/src/utils/plugins/community-plugins.js +0 -28
  60. package/src/utils/plugins/models.d.ts +0 -22
  61. package/src/utils/plugins/models.js +0 -2
  62. package/src/utils/plugins/shared.d.ts +0 -1
  63. package/src/utils/plugins/shared.js +0 -7
@@ -25,7 +25,7 @@ const getForkedProcessOsSocketPath = (id) => {
25
25
  };
26
26
  exports.getForkedProcessOsSocketPath = getForkedProcessOsSocketPath;
27
27
  const getPluginOsSocketPath = (id) => {
28
- let path = (0, path_1.resolve)((0, path_1.join)((0, tmp_dir_1.getSocketDir)(), 'plugin' + id + '.sock'));
28
+ let path = (0, path_1.resolve)((0, path_1.join)((0, tmp_dir_1.getSocketDir)(true), 'plugin' + id + '.sock'));
29
29
  return exports.isWindows ? '\\\\.\\pipe\\nx\\' + (0, path_1.resolve)(path) : (0, path_1.resolve)(path);
30
30
  };
31
31
  exports.getPluginOsSocketPath = getPluginOsSocketPath;
@@ -8,5 +8,5 @@ export declare function isDaemonDisabled(): boolean;
8
8
  * We try to create a socket file in a tmp dir, but if it doesn't work because
9
9
  * for instance we don't have permissions, we create it in DAEMON_DIR_FOR_CURRENT_WORKSPACE
10
10
  */
11
- export declare function getSocketDir(): string;
11
+ export declare function getSocketDir(alreadyUnique?: boolean): string;
12
12
  export declare function removeSocketDir(): void;
@@ -51,9 +51,10 @@ function socketDirName() {
51
51
  * We try to create a socket file in a tmp dir, but if it doesn't work because
52
52
  * for instance we don't have permissions, we create it in DAEMON_DIR_FOR_CURRENT_WORKSPACE
53
53
  */
54
- function getSocketDir() {
54
+ function getSocketDir(alreadyUnique = false) {
55
55
  try {
56
- const dir = process.env.NX_DAEMON_SOCKET_DIR ?? socketDirName();
56
+ const dir = process.env.NX_DAEMON_SOCKET_DIR ??
57
+ (alreadyUnique ? tmp_1.tmpdir : socketDirName());
57
58
  (0, fs_extra_1.ensureDirSync)(dir);
58
59
  return dir;
59
60
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = default_1;
4
4
  const project_configuration_1 = require("../../generators/utils/project-configuration");
5
5
  const json_1 = require("../../generators/utils/json");
6
+ const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
6
7
  async function default_1(tree) {
7
8
  (0, json_1.updateJson)(tree, 'package.json', (json) => {
8
9
  if (json.dependencies && json.dependencies['@nrwl/nx-cloud']) {
@@ -24,4 +25,5 @@ async function default_1(tree) {
24
25
  }
25
26
  }
26
27
  (0, project_configuration_1.updateNxJson)(tree, nxJson);
28
+ await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
27
29
  }
@@ -1,2 +1,2 @@
1
1
  import { Tree } from '../../generators/tree';
2
- export default function migrate(tree: Tree): void;
2
+ export default function migrate(tree: Tree): Promise<void>;
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = migrate;
4
4
  const nx_json_1 = require("../../generators/utils/nx-json");
5
- function migrate(tree) {
5
+ const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
6
+ async function migrate(tree) {
6
7
  const nxJson = (0, nx_json_1.readNxJson)(tree);
7
8
  nxJson.useInferencePlugins = false;
8
9
  (0, nx_json_1.updateNxJson)(tree, nxJson);
10
+ await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
9
11
  }
Binary file
@@ -7,7 +7,7 @@ const json_1 = require("../../../generators/utils/json");
7
7
  const nx_json_1 = require("../../../generators/utils/nx-json");
8
8
  const format_changed_files_with_prettier_if_available_1 = require("../../../generators/internal-utils/format-changed-files-with-prettier-if-available");
9
9
  const url_shorten_1 = require("../../utilities/url-shorten");
10
- const git_utils_1 = require("../../../utils/git-utils");
10
+ const get_cloud_options_1 = require("../../utilities/get-cloud-options");
11
11
  const ora = require("ora");
12
12
  const open = require("open");
13
13
  function printCloudConnectionDisabledMessage() {
@@ -30,11 +30,6 @@ function getRootPackageName(tree) {
30
30
  catch (e) { }
31
31
  return packageJson?.name ?? 'my-workspace';
32
32
  }
33
- function removeTrailingSlash(apiUrl) {
34
- return apiUrl[apiUrl.length - 1] === '/'
35
- ? apiUrl.substr(0, apiUrl.length - 1)
36
- : apiUrl;
37
- }
38
33
  function getNxInitDate() {
39
34
  try {
40
35
  const nxInitIso = (0, child_process_1.execSync)('git log --diff-filter=A --follow --format=%aI -- nx.json | tail -1', { stdio: 'pipe' })
@@ -48,7 +43,7 @@ function getNxInitDate() {
48
43
  }
49
44
  }
50
45
  async function createNxCloudWorkspace(workspaceName, installationSource, nxInitDate) {
51
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
46
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
52
47
  const response = await require('axios').post(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
53
48
  workspaceName,
54
49
  installationSource,
@@ -59,7 +54,7 @@ async function createNxCloudWorkspace(workspaceName, installationSource, nxInitD
59
54
  }
60
55
  return response.data;
61
56
  }
62
- async function printSuccessMessage(url, token, installationSource, usesGithub, directory) {
57
+ async function printSuccessMessage(token, installationSource, usesGithub) {
63
58
  const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)(installationSource, token, usesGithub);
64
59
  if (installationSource === 'nx-connect' && usesGithub) {
65
60
  try {
@@ -92,12 +87,6 @@ async function printSuccessMessage(url, token, installationSource, usesGithub, d
92
87
  `${connectCloudUrl}`,
93
88
  ],
94
89
  });
95
- (0, git_utils_1.commitChanges)(`feat(nx): Added Nx Cloud token to your nx.json
96
-
97
- To connect your workspace to Nx Cloud, push your repository
98
- to your git hosting provider and go to the following URL:
99
-
100
- ${connectCloudUrl}`, directory);
101
90
  }
102
91
  else {
103
92
  output_1.output.note({
@@ -145,8 +134,7 @@ async function connectToNxCloud(tree, schema) {
145
134
  silent: schema.hideFormatLogs,
146
135
  });
147
136
  }
148
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
149
- return async () => await printSuccessMessage(responseFromCreateNxCloudWorkspace?.url ?? apiUrl, responseFromCreateNxCloudWorkspace?.token, schema.installationSource, usesGithub, schema.directory);
137
+ return async () => await printSuccessMessage(responseFromCreateNxCloudWorkspace?.token, schema.installationSource, usesGithub);
150
138
  }
151
139
  }
152
140
  function sleep(ms) {
@@ -0,0 +1,10 @@
1
+ import { CloudTaskRunnerOptions } from '../nx-cloud-tasks-runner-shell';
2
+ export declare class UnknownCommandError extends Error {
3
+ command: string;
4
+ availableCommands: string[];
5
+ constructor(command: string, availableCommands: string[]);
6
+ }
7
+ export declare function getCloudClient(options: CloudTaskRunnerOptions): Promise<{
8
+ invoke: (command: string) => void;
9
+ availableCommands: string[];
10
+ }>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnknownCommandError = void 0;
4
+ exports.getCloudClient = getCloudClient;
5
+ const resolution_helpers_1 = require("../resolution-helpers");
6
+ const update_manager_1 = require("../update-manager");
7
+ class UnknownCommandError extends Error {
8
+ constructor(command, availableCommands) {
9
+ super(`Unknown Command "${command}"`);
10
+ this.command = command;
11
+ this.availableCommands = availableCommands;
12
+ }
13
+ }
14
+ exports.UnknownCommandError = UnknownCommandError;
15
+ async function getCloudClient(options) {
16
+ const { nxCloudClient } = await (0, update_manager_1.verifyOrUpdateNxCloudClient)(options);
17
+ const paths = (0, resolution_helpers_1.findAncestorNodeModules)(__dirname, []);
18
+ nxCloudClient.configureLightClientRequire()(paths);
19
+ return {
20
+ invoke: (command) => {
21
+ if (command in nxCloudClient.commands) {
22
+ nxCloudClient.commands[command]()
23
+ .then(() => process.exit(0))
24
+ .catch((e) => {
25
+ console.error(e);
26
+ process.exit(1);
27
+ });
28
+ }
29
+ else {
30
+ throw new UnknownCommandError(command, Object.keys(nxCloudClient.commands));
31
+ }
32
+ },
33
+ availableCommands: Object.keys(nxCloudClient.commands),
34
+ };
35
+ }
@@ -1,2 +1,4 @@
1
1
  import { CloudTaskRunnerOptions } from '../nx-cloud-tasks-runner-shell';
2
2
  export declare function getCloudOptions(): CloudTaskRunnerOptions;
3
+ export declare function getCloudUrl(): string;
4
+ export declare function removeTrailingSlash(apiUrl: string): string;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCloudOptions = getCloudOptions;
4
+ exports.getCloudUrl = getCloudUrl;
5
+ exports.removeTrailingSlash = removeTrailingSlash;
4
6
  const nx_json_1 = require("../../config/nx-json");
5
7
  const run_command_1 = require("../../tasks-runner/run-command");
6
8
  function getCloudOptions() {
@@ -8,3 +10,9 @@ function getCloudOptions() {
8
10
  // TODO: The default is not always cloud? But it's not handled at the moment
9
11
  return (0, run_command_1.getRunnerOptions)('default', nxJson, {}, true);
10
12
  }
13
+ function getCloudUrl() {
14
+ return removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
15
+ }
16
+ function removeTrailingSlash(apiUrl) {
17
+ return apiUrl[apiUrl.length - 1] === '/' ? apiUrl.slice(0, -1) : apiUrl;
18
+ }
@@ -1,7 +1,6 @@
1
1
  export declare function shortenedCloudUrl(installationSource: string, accessToken?: string, usesGithub?: boolean): Promise<string>;
2
- export declare function repoUsesGithub(github?: boolean): Promise<boolean>;
3
- export declare function removeTrailingSlash(apiUrl: string): string;
4
- export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string, apiUrl: string, source: string, accessToken?: string): string;
2
+ export declare function repoUsesGithub(github?: boolean, githubSlug?: string, apiUrl?: string): Promise<boolean>;
3
+ export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string | null, apiUrl: string, source: string, accessToken?: string): string;
5
4
  export declare function getNxCloudVersion(apiUrl: string): Promise<string | null>;
6
5
  export declare function removeVersionModifier(versionString: string): string;
7
6
  export declare function versionIsValid(version: string): boolean;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shortenedCloudUrl = shortenedCloudUrl;
4
4
  exports.repoUsesGithub = repoUsesGithub;
5
- exports.removeTrailingSlash = removeTrailingSlash;
6
5
  exports.getURLifShortenFailed = getURLifShortenFailed;
7
6
  exports.getNxCloudVersion = getNxCloudVersion;
8
7
  exports.removeVersionModifier = removeVersionModifier;
@@ -10,9 +9,13 @@ exports.versionIsValid = versionIsValid;
10
9
  exports.compareCleanCloudVersions = compareCleanCloudVersions;
11
10
  const devkit_exports_1 = require("../../devkit-exports");
12
11
  const git_utils_1 = require("../../utils/git-utils");
12
+ const get_cloud_options_1 = require("./get-cloud-options");
13
13
  async function shortenedCloudUrl(installationSource, accessToken, usesGithub) {
14
14
  const githubSlug = (0, git_utils_1.getGithubSlugOrNull)();
15
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
15
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
16
+ if (usesGithub === undefined || usesGithub === null) {
17
+ usesGithub = await repoUsesGithub(undefined, githubSlug, apiUrl);
18
+ }
16
19
  try {
17
20
  const version = await getNxCloudVersion(apiUrl);
18
21
  if ((version && compareCleanCloudVersions(version, '2406.11.5') < 0) ||
@@ -31,7 +34,7 @@ async function shortenedCloudUrl(installationSource, accessToken, usesGithub) {
31
34
  type: usesGithub ? 'GITHUB' : 'MANUAL',
32
35
  source,
33
36
  accessToken: usesGithub ? null : accessToken,
34
- selectedRepositoryName: githubSlug,
37
+ selectedRepositoryName: githubSlug === 'github' ? null : githubSlug,
35
38
  });
36
39
  if (!response?.data || response.data.message) {
37
40
  throw new Error(response?.data?.message ?? 'Failed to shorten Nx Cloud URL');
@@ -41,21 +44,22 @@ async function shortenedCloudUrl(installationSource, accessToken, usesGithub) {
41
44
  catch (e) {
42
45
  devkit_exports_1.logger.verbose(`Failed to shorten Nx Cloud URL.
43
46
  ${e}`);
44
- return getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source, accessToken);
47
+ return getURLifShortenFailed(usesGithub, githubSlug === 'github' ? null : githubSlug, apiUrl, source, accessToken);
45
48
  }
46
49
  }
47
- async function repoUsesGithub(github) {
48
- const githubSlug = (0, git_utils_1.getGithubSlugOrNull)();
49
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
50
+ async function repoUsesGithub(github, githubSlug, apiUrl) {
51
+ if (!apiUrl) {
52
+ apiUrl = (0, get_cloud_options_1.getCloudUrl)();
53
+ }
54
+ if (!githubSlug) {
55
+ githubSlug = (0, git_utils_1.getGithubSlugOrNull)();
56
+ }
50
57
  const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl);
51
- return ((githubSlug || github) &&
58
+ return ((!!githubSlug || !!github) &&
52
59
  (apiUrl.includes('cloud.nx.app') ||
53
60
  apiUrl.includes('eu.nx.app') ||
54
61
  installationSupportsGitHub));
55
62
  }
56
- function removeTrailingSlash(apiUrl) {
57
- return apiUrl[apiUrl.length - 1] === '/' ? apiUrl.slice(0, -1) : apiUrl;
58
- }
59
63
  function getSource(installationSource) {
60
64
  if (installationSource.includes('nx-init')) {
61
65
  return 'nx-init';
@@ -1,10 +1,10 @@
1
- import { TasksRunner } from './tasks-runner';
2
- import { NxArgs } from '../utils/command-line-utils';
3
- import { LifeCycle } from './life-cycle';
4
- import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
5
1
  import { NxJsonConfiguration } from '../config/nx-json';
2
+ import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
6
3
  import { Task, TaskGraph } from '../config/task-graph';
7
4
  import { TargetDependencyConfig } from '../config/workspace-json-project-json';
5
+ import { NxArgs } from '../utils/command-line-utils';
6
+ import { LifeCycle } from './life-cycle';
7
+ import { TasksRunner } from './tasks-runner';
8
8
  export declare function runCommand(projectsToRun: ProjectGraphProjectNode[], projectGraph: ProjectGraph, { nxJson }: {
9
9
  nxJson: NxJsonConfiguration;
10
10
  }, nxArgs: NxArgs, overrides: any, initiatingProject: string | null, extraTargetDependencies: Record<string, (TargetDependencyConfig | string)[]>, extraOptions: {
@@ -5,28 +5,28 @@ exports.invokeTasksRunner = invokeTasksRunner;
5
5
  exports.getRunner = getRunner;
6
6
  exports.getRunnerOptions = getRunnerOptions;
7
7
  const path_1 = require("path");
8
- const workspace_root_1 = require("../utils/workspace-root");
8
+ const nx_json_1 = require("../config/nx-json");
9
+ const client_1 = require("../daemon/client/client");
10
+ const create_task_hasher_1 = require("../hasher/create-task-hasher");
11
+ const hash_task_1 = require("../hasher/hash-task");
9
12
  const fileutils_1 = require("../utils/fileutils");
13
+ const is_ci_1 = require("../utils/is-ci");
14
+ const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
10
15
  const output_1 = require("../utils/output");
11
- const utils_1 = require("./utils");
16
+ const params_1 = require("../utils/params");
17
+ const workspace_root_1 = require("../utils/workspace-root");
18
+ const create_task_graph_1 = require("./create-task-graph");
12
19
  const life_cycle_1 = require("./life-cycle");
13
- const static_run_many_terminal_output_life_cycle_1 = require("./life-cycles/static-run-many-terminal-output-life-cycle");
14
- const static_run_one_terminal_output_life_cycle_1 = require("./life-cycles/static-run-one-terminal-output-life-cycle");
15
- const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
16
20
  const dynamic_run_many_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-many-terminal-output-life-cycle");
17
- const task_profiling_life_cycle_1 = require("./life-cycles/task-profiling-life-cycle");
18
- const is_ci_1 = require("../utils/is-ci");
19
21
  const dynamic_run_one_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-one-terminal-output-life-cycle");
20
- const nx_json_1 = require("../config/nx-json");
21
- const create_task_graph_1 = require("./create-task-graph");
22
- const task_graph_utils_1 = require("./task-graph-utils");
23
- const params_1 = require("../utils/params");
24
- const hash_task_1 = require("../hasher/hash-task");
25
- const client_1 = require("../daemon/client/client");
22
+ const static_run_many_terminal_output_life_cycle_1 = require("./life-cycles/static-run-many-terminal-output-life-cycle");
23
+ const static_run_one_terminal_output_life_cycle_1 = require("./life-cycles/static-run-one-terminal-output-life-cycle");
26
24
  const store_run_information_life_cycle_1 = require("./life-cycles/store-run-information-life-cycle");
27
- const create_task_hasher_1 = require("../hasher/create-task-hasher");
28
25
  const task_history_life_cycle_1 = require("./life-cycles/task-history-life-cycle");
29
- const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
26
+ const task_profiling_life_cycle_1 = require("./life-cycles/task-profiling-life-cycle");
27
+ const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
28
+ const task_graph_utils_1 = require("./task-graph-utils");
29
+ const utils_1 = require("./utils");
30
30
  async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, nxArgs, nxJson, overrides) {
31
31
  const { runnerOptions } = getRunner(nxArgs, nxJson);
32
32
  const isRunOne = initiatingProject != null;
@@ -64,7 +64,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks
64
64
  }
65
65
  }
66
66
  }
67
- function createTaskGraphAndValidateCycles(projectGraph, extraTargetDependencies, projectNames, nxArgs, overrides, extraOptions) {
67
+ function createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies, projectNames, nxArgs, overrides, extraOptions) {
68
68
  const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph, extraTargetDependencies, projectNames, nxArgs.targets, nxArgs.configuration, overrides, extraOptions.excludeTaskDependencies);
69
69
  const cycle = (0, task_graph_utils_1.findCycle)(taskGraph);
70
70
  if (cycle) {
@@ -83,12 +83,17 @@ function createTaskGraphAndValidateCycles(projectGraph, extraTargetDependencies,
83
83
  process.exit(1);
84
84
  }
85
85
  }
86
+ // validate that no atomized tasks like e2e-ci are used without Nx Cloud
87
+ if (!(0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)()) &&
88
+ !process.env['NX_SKIP_ATOMIZER_VALIDATION']) {
89
+ (0, task_graph_utils_1.validateNoAtomizedTasks)(taskGraph, projectGraph);
90
+ }
86
91
  return taskGraph;
87
92
  }
88
93
  async function runCommand(projectsToRun, projectGraph, { nxJson }, nxArgs, overrides, initiatingProject, extraTargetDependencies, extraOptions) {
89
94
  const status = await (0, params_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true', async () => {
90
95
  const projectNames = projectsToRun.map((t) => t.name);
91
- const taskGraph = createTaskGraphAndValidateCycles(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
96
+ const taskGraph = createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
92
97
  const tasks = Object.values(taskGraph.tasks);
93
98
  const { lifeCycle, renderIsDone } = await getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, nxArgs, nxJson, overrides);
94
99
  const status = await invokeTasksRunner({
@@ -1,3 +1,5 @@
1
+ import { ProjectGraph } from '../config/project-graph';
2
+ import { TaskGraph } from '../config/task-graph';
1
3
  export declare function findCycle(graph: {
2
4
  dependencies: Record<string, string[]>;
3
5
  }): string[] | null;
@@ -5,3 +7,4 @@ export declare function makeAcyclic(graph: {
5
7
  roots: string[];
6
8
  dependencies: Record<string, string[]>;
7
9
  }): void;
10
+ export declare function validateNoAtomizedTasks(taskGraph: TaskGraph, projectGraph: ProjectGraph): void;
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findCycle = findCycle;
4
4
  exports.makeAcyclic = makeAcyclic;
5
+ exports.validateNoAtomizedTasks = validateNoAtomizedTasks;
6
+ const output_1 = require("../utils/output");
5
7
  function _findCycle(graph, id, visited, path) {
6
8
  if (visited[id])
7
9
  return null;
@@ -52,3 +54,35 @@ function makeAcyclic(graph) {
52
54
  }
53
55
  graph.roots = Object.keys(graph.dependencies).filter((t) => graph.dependencies[t].length === 0);
54
56
  }
57
+ function validateNoAtomizedTasks(taskGraph, projectGraph) {
58
+ const getNonAtomizedTargetForTask = (task) => projectGraph.nodes[task.target.project]?.data?.targets?.[task.target.target]
59
+ ?.metadata?.nonAtomizedTarget;
60
+ const atomizedRootTasks = Object.values(taskGraph.tasks).filter((task) => getNonAtomizedTargetForTask(task) !== undefined);
61
+ if (atomizedRootTasks.length === 0) {
62
+ return;
63
+ }
64
+ const nonAtomizedTasks = atomizedRootTasks
65
+ .map((t) => `"${getNonAtomizedTargetForTask(t)}"`)
66
+ .filter((item, index, arr) => arr.indexOf(item) === index);
67
+ const moreInfoLines = [
68
+ `Please enable Nx Cloud or use the slower ${nonAtomizedTasks.join(',')} task${nonAtomizedTasks.length > 1 ? 's' : ''}.`,
69
+ 'Learn more at https://nx.dev/ci/features/split-e2e-tasks#use-atomizer-only-with-nx-cloud-distribution',
70
+ ];
71
+ if (atomizedRootTasks.length === 1) {
72
+ output_1.output.error({
73
+ title: `The ${atomizedRootTasks[0].id} task should only be run with Nx Cloud.`,
74
+ bodyLines: [...moreInfoLines],
75
+ });
76
+ }
77
+ else {
78
+ output_1.output.error({
79
+ title: `The following tasks should only be run with Nx Cloud:`,
80
+ bodyLines: [
81
+ ...atomizedRootTasks.map((task) => ` - ${task.id}`),
82
+ '',
83
+ ...moreInfoLines,
84
+ ],
85
+ });
86
+ }
87
+ process.exit(1);
88
+ }
@@ -136,7 +136,6 @@ function normalizeTargetDependencyWithStringProjects(dependencyConfig) {
136
136
  else if (dependencyConfig.projects === 'dependencies') {
137
137
  dependencyConfig.dependencies = true;
138
138
  delete dependencyConfig.projects;
139
- return;
140
139
  /** LERNA SUPPORT END - Remove in v20 */
141
140
  }
142
141
  else {
@@ -216,16 +215,20 @@ function getOutputsForTargetAndConfiguration(taskTargetOrTask, overridesOrNode,
216
215
  };
217
216
  if (targetConfiguration?.outputs) {
218
217
  validateOutputs(targetConfiguration.outputs);
219
- return targetConfiguration.outputs
220
- .map((output) => {
221
- return interpolate(output, {
218
+ const result = new Set();
219
+ for (const output of targetConfiguration.outputs) {
220
+ const interpolatedOutput = interpolate(output, {
222
221
  projectRoot: node.data.root,
223
222
  projectName: node.name,
224
223
  project: { ...node.data, name: node.name }, // this is legacy
225
224
  options,
226
225
  });
227
- })
228
- .filter((output) => !!output && !output.match(/{(projectRoot|workspaceRoot|(options.*))}/));
226
+ if (!!interpolatedOutput &&
227
+ !interpolatedOutput.match(/{(projectRoot|workspaceRoot|(options.*))}/)) {
228
+ result.add(interpolatedOutput);
229
+ }
230
+ }
231
+ return Array.from(result);
229
232
  }
230
233
  // Keep backwards compatibility in case `outputs` doesn't exist
231
234
  if (options.outputPath) {
@@ -46,6 +46,6 @@ export declare function recordStat(opts: {
46
46
  command: string;
47
47
  nxVersion: string;
48
48
  useCloud: boolean;
49
- meta: string;
49
+ meta?: string;
50
50
  }): Promise<void>;
51
51
  export {};
@@ -5,6 +5,7 @@ exports.recordStat = recordStat;
5
5
  const node_child_process_1 = require("node:child_process");
6
6
  const is_ci_1 = require("./is-ci");
7
7
  const package_manager_1 = require("./package-manager");
8
+ const get_cloud_options_1 = require("../nx-cloud/utilities/get-cloud-options");
8
9
  const messageOptions = {
9
10
  setupNxCloud: [
10
11
  {
@@ -72,7 +73,7 @@ async function recordStat(opts) {
72
73
  const axios = require('axios');
73
74
  await (axios['default'] ?? axios)
74
75
  .create({
75
- baseURL: 'https://cloud.nx.app',
76
+ baseURL: (0, get_cloud_options_1.getCloudUrl)(),
76
77
  timeout: 400,
77
78
  })
78
79
  .post('/nx-cloud/stats', {
@@ -1 +1,11 @@
1
1
  export declare function chunkify(target: string[], maxChunkLength?: number): string[][];
2
+ /**
3
+ * Get the maximum length of a command-line argument string based on current platform
4
+ *
5
+ * https://serverfault.com/questions/69430/what-is-the-maximum-length-of-a-command-line-in-mac-os-x
6
+ * https://support.microsoft.com/en-us/help/830473/command-prompt-cmd-exe-command-line-string-limitation
7
+ * https://unix.stackexchange.com/a/120652
8
+ *
9
+ * Taken from: https://github.com/lint-staged/lint-staged/blob/adf50b00669f6aac2eeca25dd28ff86a9a3c2a48/lib/index.js#L21-L37
10
+ */
11
+ export declare function getMaxArgLength(): 262144 | 8191 | 131072;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.chunkify = chunkify;
4
- const child_process_1 = require("child_process");
5
- const TERMINAL_SIZE = process.platform === 'win32' ? 8192 : getUnixTerminalSize();
4
+ exports.getMaxArgLength = getMaxArgLength;
5
+ const TERMINAL_SIZE = getMaxArgLength();
6
6
  function chunkify(target, maxChunkLength = TERMINAL_SIZE - 500) {
7
7
  const chunks = [];
8
8
  let currentChunk = [];
@@ -23,15 +23,22 @@ function chunkify(target, maxChunkLength = TERMINAL_SIZE - 500) {
23
23
  chunks.push(currentChunk);
24
24
  return chunks;
25
25
  }
26
- function getUnixTerminalSize() {
27
- try {
28
- const argMax = (0, child_process_1.execSync)('getconf ARG_MAX').toString().trim();
29
- return Number.parseInt(argMax);
30
- }
31
- catch {
32
- // This number varies by system, but 100k seems like a safe
33
- // number from some research...
34
- // https://stackoverflow.com/questions/19354870/bash-command-line-and-input-limit
35
- return 100000;
26
+ /**
27
+ * Get the maximum length of a command-line argument string based on current platform
28
+ *
29
+ * https://serverfault.com/questions/69430/what-is-the-maximum-length-of-a-command-line-in-mac-os-x
30
+ * https://support.microsoft.com/en-us/help/830473/command-prompt-cmd-exe-command-line-string-limitation
31
+ * https://unix.stackexchange.com/a/120652
32
+ *
33
+ * Taken from: https://github.com/lint-staged/lint-staged/blob/adf50b00669f6aac2eeca25dd28ff86a9a3c2a48/lib/index.js#L21-L37
34
+ */
35
+ function getMaxArgLength() {
36
+ switch (process.platform) {
37
+ case 'darwin':
38
+ return 262144;
39
+ case 'win32':
40
+ return 8191;
41
+ default:
42
+ return 131072;
36
43
  }
37
44
  }
@@ -41,6 +41,9 @@ export declare function splitArgsIntoNxArgsAndOverrides(args: {
41
41
  __overrides_unparsed__: string[];
42
42
  };
43
43
  };
44
+ export declare function readParallelFromArgsAndEnv(args: {
45
+ [k: string]: any;
46
+ }): number;
44
47
  export declare function parseFiles(options: NxArgs): {
45
48
  files: string[];
46
49
  };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createOverrides = createOverrides;
4
4
  exports.splitArgsIntoNxArgsAndOverrides = splitArgsIntoNxArgsAndOverrides;
5
+ exports.readParallelFromArgsAndEnv = readParallelFromArgsAndEnv;
5
6
  exports.parseFiles = parseFiles;
6
7
  exports.getProjectRoots = getProjectRoots;
7
8
  exports.readGraphFileFromGraphArg = readGraphFileFromGraphArg;
@@ -112,23 +113,26 @@ function splitArgsIntoNxArgsAndOverrides(args, mode, options = { printWarnings:
112
113
  nxArgs.skipNxCache = process.env.NX_SKIP_NX_CACHE === 'true';
113
114
  }
114
115
  normalizeNxArgsRunner(nxArgs, nxJson, options);
116
+ nxArgs['parallel'] = readParallelFromArgsAndEnv(args);
117
+ return { nxArgs, overrides };
118
+ }
119
+ function readParallelFromArgsAndEnv(args) {
115
120
  if (args['parallel'] === 'false' || args['parallel'] === false) {
116
- nxArgs['parallel'] = 1;
121
+ return 1;
117
122
  }
118
123
  else if (args['parallel'] === 'true' ||
119
124
  args['parallel'] === true ||
120
125
  args['parallel'] === '' ||
121
- process.env.NX_PARALLEL // dont require passing --parallel if NX_PARALLEL is set
122
- ) {
123
- nxArgs['parallel'] = Number(nxArgs['maxParallel'] ||
124
- nxArgs['max-parallel'] ||
126
+ // dont require passing --parallel if NX_PARALLEL is set, but allow overriding it
127
+ (process.env.NX_PARALLEL && args['parallel'] === undefined)) {
128
+ return Number(args['maxParallel'] ||
129
+ args['max-parallel'] ||
125
130
  process.env.NX_PARALLEL ||
126
131
  3);
127
132
  }
128
133
  else if (args['parallel'] !== undefined) {
129
- nxArgs['parallel'] = Number(args['parallel']);
134
+ return Number(args['parallel']);
130
135
  }
131
- return { nxArgs, overrides };
132
136
  }
133
137
  function normalizeNxArgsRunner(nxArgs, nxJson, options) {
134
138
  if (!nxArgs.runner) {
@@ -9,26 +9,36 @@ const devkit_exports_1 = require("../devkit-exports");
9
9
  function getGithubSlugOrNull() {
10
10
  try {
11
11
  const gitRemote = (0, child_process_1.execSync)('git remote -v').toString();
12
+ // If there are no remotes, we default to github
13
+ if (!gitRemote || gitRemote.length === 0) {
14
+ return 'github';
15
+ }
12
16
  return extractUserAndRepoFromGitHubUrl(gitRemote);
13
17
  }
14
18
  catch (e) {
15
- return null;
19
+ // Probably git is not set up, so we default to github
20
+ return 'github';
16
21
  }
17
22
  }
18
23
  function extractUserAndRepoFromGitHubUrl(gitRemotes) {
19
24
  const regex = /^\s*(\w+)\s+(git@github\.com:|https:\/\/github\.com\/)([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\.git/gm;
25
+ const remotesPriority = ['origin', 'upstream', 'base'];
26
+ const foundRemotes = {};
20
27
  let firstGitHubUrl = null;
21
28
  let match;
22
29
  while ((match = regex.exec(gitRemotes)) !== null) {
23
30
  const remoteName = match[1];
24
31
  const url = match[2] + match[3] + '/' + match[4] + '.git';
25
- if (remoteName === 'origin') {
26
- return parseGitHubUrl(url);
27
- }
32
+ foundRemotes[remoteName] = url;
28
33
  if (!firstGitHubUrl) {
29
34
  firstGitHubUrl = url;
30
35
  }
31
36
  }
37
+ for (const remote of remotesPriority) {
38
+ if (foundRemotes[remote]) {
39
+ return parseGitHubUrl(foundRemotes[remote]);
40
+ }
41
+ }
32
42
  return firstGitHubUrl ? parseGitHubUrl(firstGitHubUrl) : null;
33
43
  }
34
44
  function parseGitHubUrl(url) {