nx 23.1.0-beta.5 → 23.1.0-beta.7

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.
@@ -348,7 +348,7 @@ async function runInit(options, baseMeta) {
348
348
  }
349
349
  else {
350
350
  nxCloudChoice = options.interactive
351
- ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
351
+ ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)('init', 'setupNxCloud', false)
352
352
  : 'skip';
353
353
  }
354
354
  if (nxCloudChoice === 'yes') {
@@ -9,5 +9,5 @@ export declare function connectToNxCloudCommand(options: {
9
9
  generateToken?: boolean;
10
10
  checkRemote?: boolean;
11
11
  }, command?: string): Promise<boolean>;
12
- export declare function connectExistingRepoToNxCloudPrompt(command?: string, key?: MessageKey): Promise<MessageOptionKey>;
12
+ export declare function connectExistingRepoToNxCloudPrompt(command?: string, key?: MessageKey, recordCompletion?: boolean): Promise<MessageOptionKey>;
13
13
  export declare function connectToNxCloudWithPrompt(command: string): Promise<void>;
@@ -180,27 +180,34 @@ async function runConnectToNxCloud(options, command) {
180
180
  function sleep(ms) {
181
181
  return new Promise((resolve) => setTimeout(resolve, ms));
182
182
  }
183
- async function connectExistingRepoToNxCloudPrompt(command = 'init', key = 'setupNxCloud') {
184
- const res = await nxCloudPrompt(key, utmMediumForCommand(command));
185
- await (0, ab_testing_1.recordStat)({
186
- command,
187
- nxVersion: versions_1.nxVersion,
188
- useCloud: res === 'yes',
189
- meta: {
190
- type: 'complete',
191
- setupCloudPrompt: ab_testing_1.messages.codeOfSelectedPromptMessage(key) || '',
192
- nxCloudArg: res,
193
- nodeVersion: process.versions.node,
194
- os: process.platform,
195
- packageManager: (0, package_manager_1.detectPackageManager)(),
196
- aiAgent: (0, native_1.isAiAgent)(),
197
- isCI: (0, is_ci_1.isCI)(),
198
- },
199
- });
183
+ async function connectExistingRepoToNxCloudPrompt(command = 'init', key = 'setupNxCloud', recordCompletion = true) {
184
+ const res = await nxCloudPrompt(key, utmContentForCommand(command));
185
+ // TODO: once legacy init-v1 (the NX_ADD_PLUGINS=false / useInferencePlugins:false path) is
186
+ // removed, drop this recordStat and the recordCompletion flag entirely - init-v2 records its
187
+ // own complete, and view-logs should record its own stat, so this shared helper won't record.
188
+ // init-v2 records its own init "complete" stat, so it opts out here to avoid double-counting.
189
+ // Other callers (e.g. view-logs, legacy init-v1) rely on this as their only completion event.
190
+ if (recordCompletion) {
191
+ await (0, ab_testing_1.recordStat)({
192
+ command,
193
+ nxVersion: versions_1.nxVersion,
194
+ useCloud: res === 'yes',
195
+ meta: {
196
+ type: 'complete',
197
+ setupCloudPrompt: ab_testing_1.messages.codeOfSelectedPromptMessage(key) || '',
198
+ nxCloudArg: res,
199
+ nodeVersion: process.versions.node,
200
+ os: process.platform,
201
+ packageManager: (0, package_manager_1.detectPackageManager)(),
202
+ aiAgent: (0, native_1.isAiAgent)(),
203
+ isCI: (0, is_ci_1.isCI)(),
204
+ },
205
+ });
206
+ }
200
207
  return res;
201
208
  }
202
209
  async function connectToNxCloudWithPrompt(command) {
203
- const setNxCloud = await nxCloudPrompt('setupNxCloud', utmMediumForCommand(command));
210
+ const setNxCloud = await nxCloudPrompt('setupNxCloud', utmContentForCommand(command));
204
211
  let useCloud = false;
205
212
  if (setNxCloud === 'yes') {
206
213
  useCloud = await connectToNxCloudCommand({ generateToken: false }, command);
@@ -229,7 +236,7 @@ async function connectToNxCloudWithPrompt(command) {
229
236
  },
230
237
  });
231
238
  }
232
- function utmMediumForCommand(command) {
239
+ function utmContentForCommand(command) {
233
240
  switch (command) {
234
241
  case 'migrate':
235
242
  return 'nx-migrate';
@@ -239,7 +246,7 @@ function utmMediumForCommand(command) {
239
246
  return 'nx-init';
240
247
  }
241
248
  }
242
- async function nxCloudPrompt(key, utmMedium) {
249
+ async function nxCloudPrompt(key, utmContent) {
243
250
  const { message, choices, initial, footer, hint } = ab_testing_1.messages.getPrompt(key);
244
251
  const promptConfig = {
245
252
  name: 'NxCloud',
@@ -249,7 +256,7 @@ async function nxCloudPrompt(key, utmMedium) {
249
256
  initial,
250
257
  }; // meeroslav: types in enquirer are not up to date
251
258
  if (footer) {
252
- promptConfig.footer = () => pc.dim(`${footer} ${(0, ab_testing_1.nxCloudHyperlink)(utmMedium)}`);
259
+ promptConfig.footer = () => pc.dim(`${footer} ${(0, ab_testing_1.nxCloudHyperlink)(utmContent)}`);
253
260
  }
254
261
  if (hint) {
255
262
  promptConfig.hint = () => pc.dim(hint);