nx 20.3.0-canary.20241218-fb40366 → 20.3.0-canary.20241220-0980006

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.
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{6395:()=>{}},s=>{var e;e=6395,s(s.s=e)}]);
1
+ "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{69552:()=>{}},s=>{var e;e=69552,s(s.s=e)}]);
@@ -115,10 +115,8 @@ class DaemonClient {
115
115
  }
116
116
  async getProjectGraphAndSourceMaps() {
117
117
  let spinner;
118
- if (delayed_spinner_1.SHOULD_SHOW_SPINNERS) {
119
- // If the graph takes a while to load, we want to show a spinner.
120
- spinner = new delayed_spinner_1.DelayedSpinner('Calculating the project graph on the Nx Daemon', 500).scheduleMessageUpdate('Calculating the project graph on the Nx Daemon is taking longer than expected. Re-run with NX_DAEMON=false to see more details.', 30_000);
121
- }
118
+ // If the graph takes a while to load, we want to show a spinner.
119
+ spinner = new delayed_spinner_1.DelayedSpinner('Calculating the project graph on the Nx Daemon').scheduleMessageUpdate('Calculating the project graph on the Nx Daemon is taking longer than expected. Re-run with NX_DAEMON=false to see more details.', { ciDelay: 60_000, delay: 30_000 });
122
120
  try {
123
121
  const response = await this.sendToDaemonViaQueue({
124
122
  type: 'REQUEST_PROJECT_GRAPH',
Binary file
@@ -190,25 +190,23 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins,
190
190
  let spinner;
191
191
  const inProgressPlugins = new Set();
192
192
  function updateSpinner() {
193
- if (!spinner) {
193
+ if (!spinner || inProgressPlugins.size === 0) {
194
194
  return;
195
195
  }
196
196
  if (inProgressPlugins.size === 1) {
197
- return `Creating project graph dependencies with ${inProgressPlugins.keys()[0]}`;
197
+ spinner.setMessage(`Creating project graph dependencies with ${inProgressPlugins.values().next().value}`);
198
198
  }
199
199
  else if (process.env.NX_VERBOSE_LOGGING === 'true') {
200
- return [
200
+ spinner.setMessage([
201
201
  `Creating project graph dependencies with ${inProgressPlugins.size} plugins`,
202
202
  ...Array.from(inProgressPlugins).map((p) => ` - ${p}`),
203
- ].join('\n');
203
+ ].join('\n'));
204
204
  }
205
205
  else {
206
- return `Creating project graph dependencies with ${inProgressPlugins.size} plugins`;
206
+ spinner.setMessage(`Creating project graph dependencies with ${inProgressPlugins.size} plugins`);
207
207
  }
208
208
  }
209
- if (delayed_spinner_1.SHOULD_SHOW_SPINNERS) {
210
- spinner = new delayed_spinner_1.DelayedSpinner(`Creating project graph dependencies with ${plugins.length} plugins`);
211
- }
209
+ spinner = new delayed_spinner_1.DelayedSpinner(`Creating project graph dependencies with ${plugins.length} plugins`);
212
210
  await Promise.all(createDependencyPlugins.map(async (plugin) => {
213
211
  perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - start`);
214
212
  inProgressPlugins.add(plugin.name);
@@ -265,25 +263,23 @@ async function applyProjectMetadata(graph, plugins, context, sourceMap) {
265
263
  let spinner;
266
264
  const inProgressPlugins = new Set();
267
265
  function updateSpinner() {
268
- if (!spinner) {
266
+ if (!spinner || inProgressPlugins.size === 0) {
269
267
  return;
270
268
  }
271
269
  if (inProgressPlugins.size === 1) {
272
- return `Creating project metadata with ${inProgressPlugins.keys()[0]}`;
270
+ spinner.setMessage(`Creating project metadata with ${inProgressPlugins.values().next().value}`);
273
271
  }
274
272
  else if (process.env.NX_VERBOSE_LOGGING === 'true') {
275
- return [
273
+ spinner.setMessage([
276
274
  `Creating project metadata with ${inProgressPlugins.size} plugins`,
277
275
  ...Array.from(inProgressPlugins).map((p) => ` - ${p}`),
278
- ].join('\n');
276
+ ].join('\n'));
279
277
  }
280
278
  else {
281
- return `Creating project metadata with ${inProgressPlugins.size} plugins`;
279
+ spinner.setMessage(`Creating project metadata with ${inProgressPlugins.size} plugins`);
282
280
  }
283
281
  }
284
- if (delayed_spinner_1.SHOULD_SHOW_SPINNERS) {
285
- spinner = new delayed_spinner_1.DelayedSpinner(`Creating project metadata with ${plugins.length} plugins`);
286
- }
282
+ spinner = new delayed_spinner_1.DelayedSpinner(`Creating project metadata with ${plugins.length} plugins`);
287
283
  const promises = plugins.map(async (plugin) => {
288
284
  if (plugin.createMetadata) {
289
285
  perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - start`);
@@ -228,25 +228,23 @@ plugins) {
228
228
  let spinner;
229
229
  const inProgressPlugins = new Set();
230
230
  function updateSpinner() {
231
- if (!spinner) {
231
+ if (!spinner || inProgressPlugins.size === 0) {
232
232
  return;
233
233
  }
234
234
  if (inProgressPlugins.size === 1) {
235
- return `Creating project graph nodes with ${inProgressPlugins.keys()[0]}`;
235
+ spinner.setMessage(`Creating project graph nodes with ${inProgressPlugins.values().next().value}`);
236
236
  }
237
237
  else if (process.env.NX_VERBOSE_LOGGING === 'true') {
238
- return [
238
+ spinner.setMessage([
239
239
  `Creating project graph nodes with ${inProgressPlugins.size} plugins`,
240
240
  ...Array.from(inProgressPlugins).map((p) => ` - ${p}`),
241
- ].join('\n');
241
+ ].join('\n'));
242
242
  }
243
243
  else {
244
- return `Creating project graph nodes with ${inProgressPlugins.size} plugins`;
244
+ spinner.setMessage(`Creating project graph nodes with ${inProgressPlugins.size} plugins`);
245
245
  }
246
246
  }
247
- if (delayed_spinner_1.SHOULD_SHOW_SPINNERS) {
248
- spinner = new delayed_spinner_1.DelayedSpinner(`Creating project graph nodes with ${plugins.length} plugins`);
249
- }
247
+ spinner = new delayed_spinner_1.DelayedSpinner(`Creating project graph nodes with ${plugins.length} plugins`);
250
248
  const results = [];
251
249
  const errors = [];
252
250
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
@@ -1,4 +1,8 @@
1
1
  import * as ora from 'ora';
2
+ export type DelayedSpinnerOptions = {
3
+ delay?: number;
4
+ ciDelay?: number;
5
+ };
2
6
  /**
3
7
  * A class that allows to delay the creation of a spinner, as well
4
8
  * as schedule updates to the message of the spinner. Useful for
@@ -8,14 +12,14 @@ import * as ora from 'ora';
8
12
  export declare class DelayedSpinner {
9
13
  spinner: ora.Ora;
10
14
  timeouts: NodeJS.Timeout[];
11
- initial: number;
15
+ private lastMessage;
16
+ private ready;
12
17
  /**
13
18
  * Constructs a new {@link DelayedSpinner} instance.
14
19
  *
15
- * @param message The message to display in the spinner
16
- * @param ms The number of milliseconds to wait before creating the spinner
20
+ * @param opts The options for the spinner
17
21
  */
18
- constructor(message: string, ms?: number);
22
+ constructor(message: string, opts?: DelayedSpinnerOptions);
19
23
  /**
20
24
  * Sets the message to display in the spinner.
21
25
  *
@@ -27,14 +31,12 @@ export declare class DelayedSpinner {
27
31
  * Schedules an update to the message of the spinner. Useful for
28
32
  * changing the message after a certain amount of time has passed.
29
33
  *
30
- * @param message The message to display in the spinner
31
- * @param delay How long to wait before updating the message
34
+ * @param opts The options for the update
32
35
  * @returns The {@link DelayedSpinner} instance
33
36
  */
34
- scheduleMessageUpdate(message: string, delay: number): this;
37
+ scheduleMessageUpdate(message: string, opts?: DelayedSpinnerOptions): this;
35
38
  /**
36
39
  * Stops the spinner and cleans up any scheduled timeouts.
37
40
  */
38
41
  cleanup(): void;
39
42
  }
40
- export declare const SHOULD_SHOW_SPINNERS: boolean;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SHOULD_SHOW_SPINNERS = exports.DelayedSpinner = void 0;
3
+ exports.DelayedSpinner = void 0;
4
4
  const ora = require("ora");
5
+ const is_ci_1 = require("./is-ci");
5
6
  /**
6
7
  * A class that allows to delay the creation of a spinner, as well
7
8
  * as schedule updates to the message of the spinner. Useful for
@@ -12,15 +13,22 @@ class DelayedSpinner {
12
13
  /**
13
14
  * Constructs a new {@link DelayedSpinner} instance.
14
15
  *
15
- * @param message The message to display in the spinner
16
- * @param ms The number of milliseconds to wait before creating the spinner
16
+ * @param opts The options for the spinner
17
17
  */
18
- constructor(message, ms = 500) {
18
+ constructor(message, opts) {
19
19
  this.timeouts = [];
20
- this.initial = Date.now();
20
+ opts = normalizeDelayedSpinnerOpts(opts);
21
+ const delay = SHOULD_SHOW_SPINNERS ? opts.delay : opts.ciDelay;
21
22
  this.timeouts.push(setTimeout(() => {
22
- this.spinner = ora(message);
23
- }, ms).unref());
23
+ this.ready = true;
24
+ if (!SHOULD_SHOW_SPINNERS) {
25
+ console.warn(this.lastMessage);
26
+ }
27
+ else {
28
+ this.spinner = ora(this.lastMessage).start();
29
+ }
30
+ this.lastMessage = message;
31
+ }, delay).unref());
24
32
  }
25
33
  /**
26
34
  * Sets the message to display in the spinner.
@@ -29,21 +37,29 @@ class DelayedSpinner {
29
37
  * @returns The {@link DelayedSpinner} instance
30
38
  */
31
39
  setMessage(message) {
32
- this.spinner.text = message;
40
+ if (SHOULD_SHOW_SPINNERS) {
41
+ if (this.spinner) {
42
+ this.spinner.text = message;
43
+ }
44
+ }
45
+ else if (this.ready && this.lastMessage && this.lastMessage !== message) {
46
+ console.warn(message);
47
+ }
48
+ this.lastMessage = message;
33
49
  return this;
34
50
  }
35
51
  /**
36
52
  * Schedules an update to the message of the spinner. Useful for
37
53
  * changing the message after a certain amount of time has passed.
38
54
  *
39
- * @param message The message to display in the spinner
40
- * @param delay How long to wait before updating the message
55
+ * @param opts The options for the update
41
56
  * @returns The {@link DelayedSpinner} instance
42
57
  */
43
- scheduleMessageUpdate(message, delay) {
58
+ scheduleMessageUpdate(message, opts) {
59
+ opts = normalizeDelayedSpinnerOpts(opts);
44
60
  this.timeouts.push(setTimeout(() => {
45
- this.spinner.text = message;
46
- }, delay).unref());
61
+ this.setMessage(message);
62
+ }, SHOULD_SHOW_SPINNERS ? opts.delay : opts.ciDelay).unref());
47
63
  return this;
48
64
  }
49
65
  /**
@@ -55,4 +71,10 @@ class DelayedSpinner {
55
71
  }
56
72
  }
57
73
  exports.DelayedSpinner = DelayedSpinner;
58
- exports.SHOULD_SHOW_SPINNERS = process.stdout.isTTY;
74
+ const SHOULD_SHOW_SPINNERS = process.stdout.isTTY && !(0, is_ci_1.isCI)();
75
+ function normalizeDelayedSpinnerOpts(opts) {
76
+ opts ??= {};
77
+ opts.delay ??= 500;
78
+ opts.ciDelay ??= 30_000;
79
+ return opts;
80
+ }