nx 19.6.0-canary.20240720-9410164 → 19.6.0-canary.20240724-684d2a9

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.
Binary file
@@ -7,6 +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 get_cloud_options_1 = require("../../utilities/get-cloud-options");
10
11
  const git_utils_1 = require("../../../utils/git-utils");
11
12
  const ora = require("ora");
12
13
  const open = require("open");
@@ -30,11 +31,6 @@ function getRootPackageName(tree) {
30
31
  catch (e) { }
31
32
  return packageJson?.name ?? 'my-workspace';
32
33
  }
33
- function removeTrailingSlash(apiUrl) {
34
- return apiUrl[apiUrl.length - 1] === '/'
35
- ? apiUrl.substr(0, apiUrl.length - 1)
36
- : apiUrl;
37
- }
38
34
  function getNxInitDate() {
39
35
  try {
40
36
  const nxInitIso = (0, child_process_1.execSync)('git log --diff-filter=A --follow --format=%aI -- nx.json | tail -1', { stdio: 'pipe' })
@@ -48,7 +44,7 @@ function getNxInitDate() {
48
44
  }
49
45
  }
50
46
  async function createNxCloudWorkspace(workspaceName, installationSource, nxInitDate) {
51
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
47
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
52
48
  const response = await require('axios').post(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
53
49
  workspaceName,
54
50
  installationSource,
@@ -145,7 +141,7 @@ async function connectToNxCloud(tree, schema) {
145
141
  silent: schema.hideFormatLogs,
146
142
  });
147
143
  }
148
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
144
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
149
145
  return async () => await printSuccessMessage(responseFromCreateNxCloudWorkspace?.url ?? apiUrl, responseFromCreateNxCloudWorkspace?.token, schema.installationSource, usesGithub, schema.directory);
150
146
  }
151
147
  }
@@ -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,6 +1,5 @@
1
1
  export declare function shortenedCloudUrl(installationSource: string, accessToken?: string, usesGithub?: boolean): Promise<string>;
2
2
  export declare function repoUsesGithub(github?: boolean): Promise<boolean>;
3
- export declare function removeTrailingSlash(apiUrl: string): string;
4
3
  export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string, 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;
@@ -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,10 @@ 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
16
  try {
17
17
  const version = await getNxCloudVersion(apiUrl);
18
18
  if ((version && compareCleanCloudVersions(version, '2406.11.5') < 0) ||
@@ -46,16 +46,13 @@ async function shortenedCloudUrl(installationSource, accessToken, usesGithub) {
46
46
  }
47
47
  async function repoUsesGithub(github) {
48
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`);
49
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
50
50
  const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl);
51
51
  return ((githubSlug || github) &&
52
52
  (apiUrl.includes('cloud.nx.app') ||
53
53
  apiUrl.includes('eu.nx.app') ||
54
54
  installationSupportsGitHub));
55
55
  }
56
- function removeTrailingSlash(apiUrl) {
57
- return apiUrl[apiUrl.length - 1] === '/' ? apiUrl.slice(0, -1) : apiUrl;
58
- }
59
56
  function getSource(installationSource) {
60
57
  if (installationSource.includes('nx-init')) {
61
58
  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
+ }
@@ -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', {