nx 19.7.0-canary.20240903-9039e5e → 19.7.0-canary.20240905-ccda7f9

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -42,6 +42,18 @@ function getNxInitDate() {
42
42
  return null;
43
43
  }
44
44
  }
45
+ async function createNxCloudWorkspaceV1(workspaceName, installationSource, nxInitDate) {
46
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
47
+ const response = await require('axios').post(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
48
+ workspaceName,
49
+ installationSource,
50
+ nxInitDate,
51
+ });
52
+ if (response.data.message) {
53
+ throw new Error(response.data.message);
54
+ }
55
+ return response.data;
56
+ }
45
57
  async function createNxCloudWorkspaceV2(workspaceName, installationSource, nxInitDate) {
46
58
  const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
47
59
  const response = await require('axios').post(`${apiUrl}/nx-cloud/v2/create-org-and-workspace`, {
@@ -69,6 +81,19 @@ async function printSuccessMessage(token, installationSource, usesGithub) {
69
81
  });
70
82
  return connectCloudUrl;
71
83
  }
84
+ function addNxCloudOptionsToNxJson(tree, token, directory = '') {
85
+ const nxJsonPath = (0, path_1.join)(directory, 'nx.json');
86
+ if (tree.exists(nxJsonPath)) {
87
+ (0, json_1.updateJson)(tree, (0, path_1.join)(directory, 'nx.json'), (nxJson) => {
88
+ const overrideUrl = process.env.NX_CLOUD_API || process.env.NRWL_API;
89
+ if (overrideUrl) {
90
+ nxJson.nxCloudUrl = overrideUrl;
91
+ }
92
+ nxJson.nxCloudAccessToken = token;
93
+ return nxJson;
94
+ });
95
+ }
96
+ }
72
97
  function addNxCloudIdToNxJson(tree, nxCloudId, directory = '') {
73
98
  const nxJsonPath = (0, path_1.join)(directory, 'nx.json');
74
99
  if (tree.exists(nxJsonPath)) {
@@ -89,6 +114,7 @@ async function connectToNxCloud(tree, schema, nxJson = (0, nx_json_1.readNxJson)
89
114
  return null;
90
115
  }
91
116
  const isGitHubDetected = schema.github ?? (await (0, url_shorten_1.repoUsesGithub)(schema.github));
117
+ let responseFromCreateNxCloudWorkspaceV1;
92
118
  let responseFromCreateNxCloudWorkspaceV2;
93
119
  /**
94
120
  * Do not create an Nx Cloud token if the user is using GitHub and
@@ -98,12 +124,22 @@ async function connectToNxCloud(tree, schema, nxJson = (0, nx_json_1.readNxJson)
98
124
  isGitHubDetected &&
99
125
  schema.installationSource === 'nx-connect')
100
126
  return null;
101
- responseFromCreateNxCloudWorkspaceV2 = await createNxCloudWorkspaceV2(getRootPackageName(tree), schema.installationSource, getNxInitDate());
102
- addNxCloudIdToNxJson(tree, responseFromCreateNxCloudWorkspaceV2?.nxCloudId, schema.directory);
103
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
104
- silent: schema.hideFormatLogs,
105
- });
106
- return responseFromCreateNxCloudWorkspaceV2.nxCloudId;
127
+ if (process.env.NX_ENABLE_LOGIN === 'true') {
128
+ responseFromCreateNxCloudWorkspaceV2 = await createNxCloudWorkspaceV2(getRootPackageName(tree), schema.installationSource, getNxInitDate());
129
+ addNxCloudIdToNxJson(tree, responseFromCreateNxCloudWorkspaceV2?.nxCloudId, schema.directory);
130
+ await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
131
+ silent: schema.hideFormatLogs,
132
+ });
133
+ return responseFromCreateNxCloudWorkspaceV2.nxCloudId;
134
+ }
135
+ else {
136
+ responseFromCreateNxCloudWorkspaceV1 = await createNxCloudWorkspaceV1(getRootPackageName(tree), schema.installationSource, getNxInitDate());
137
+ addNxCloudOptionsToNxJson(tree, responseFromCreateNxCloudWorkspaceV1?.token, schema.directory);
138
+ await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
139
+ silent: schema.hideFormatLogs,
140
+ });
141
+ return responseFromCreateNxCloudWorkspaceV1.token;
142
+ }
107
143
  }
108
144
  async function connectToNxCloudGenerator(tree, options) {
109
145
  await connectToNxCloud(tree, options);
@@ -120,6 +120,9 @@ async function runCommand(projectsToRun, currentProjectGraph, { nxJson }, nxArgs
120
120
  }
121
121
  async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions) {
122
122
  let taskGraph = createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
123
+ if (nxArgs.skipSync) {
124
+ return { projectGraph, taskGraph };
125
+ }
123
126
  // collect unique syncGenerators from the tasks
124
127
  const uniqueSyncGenerators = (0, sync_generators_1.collectEnabledTaskSyncGeneratorsFromTaskGraph)(taskGraph, projectGraph, nxJson);
125
128
  if (!uniqueSyncGenerators.size) {
@@ -134,7 +137,7 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
134
137
  }
135
138
  const outOfSyncTitle = 'The workspace is out of sync';
136
139
  const resultBodyLines = [...(0, sync_generators_1.syncGeneratorResultsToMessageLines)(results), ''];
137
- const fixMessage = 'You can manually run `nx sync` to update your workspace or you can set `sync.applyChanges` to `true` in your `nx.json` to apply the changes automatically when running tasks.';
140
+ const fixMessage = 'You can manually run `nx sync` to update your workspace or you can set `sync.applyChanges` to `true` in your `nx.json` to apply the changes automatically when running tasks in interactive environments.';
138
141
  const willErrorOnCiMessage = 'Please note that this will be an error on CI.';
139
142
  if ((0, is_ci_1.isCI)() || !process.stdout.isTTY) {
140
143
  // If the user is running in CI or is running in a non-TTY environment we
@@ -30,6 +30,7 @@ export interface NxArgs {
30
30
  type?: string;
31
31
  batch?: boolean;
32
32
  excludeTaskDependencies?: boolean;
33
+ skipSync?: boolean;
33
34
  }
34
35
  export declare function createOverrides(__overrides_unparsed__?: string[]): Record<string, any>;
35
36
  export declare function getBaseRef(nxJson: NxJsonConfiguration): string;