nx 18.1.2 → 18.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "18.1.2",
3
+ "version": "18.1.3",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "yargs-parser": "21.1.1",
67
67
  "node-machine-id": "1.1.12",
68
68
  "ora": "5.3.0",
69
- "@nrwl/tao": "18.1.2"
69
+ "@nrwl/tao": "18.1.3"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@swc-node/register": "^1.8.0",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-x64": "18.1.2",
85
- "@nx/nx-darwin-arm64": "18.1.2",
86
- "@nx/nx-linux-x64-gnu": "18.1.2",
87
- "@nx/nx-linux-x64-musl": "18.1.2",
88
- "@nx/nx-win32-x64-msvc": "18.1.2",
89
- "@nx/nx-linux-arm64-gnu": "18.1.2",
90
- "@nx/nx-linux-arm64-musl": "18.1.2",
91
- "@nx/nx-linux-arm-gnueabihf": "18.1.2",
92
- "@nx/nx-win32-arm64-msvc": "18.1.2",
93
- "@nx/nx-freebsd-x64": "18.1.2"
84
+ "@nx/nx-darwin-x64": "18.1.3",
85
+ "@nx/nx-darwin-arm64": "18.1.3",
86
+ "@nx/nx-linux-x64-gnu": "18.1.3",
87
+ "@nx/nx-linux-x64-musl": "18.1.3",
88
+ "@nx/nx-win32-x64-msvc": "18.1.3",
89
+ "@nx/nx-linux-arm64-gnu": "18.1.3",
90
+ "@nx/nx-linux-arm64-musl": "18.1.3",
91
+ "@nx/nx-linux-arm-gnueabihf": "18.1.3",
92
+ "@nx/nx-win32-arm64-msvc": "18.1.3",
93
+ "@nx/nx-freebsd-x64": "18.1.3"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -55,7 +55,7 @@ async function installPackage(pkgName, version) {
55
55
  nxJson.installation.plugins[pkgName] = version;
56
56
  (0, fileutils_1.writeJsonFile)('nx.json', nxJson);
57
57
  try {
58
- await (0, child_process_2.runNxAsync)('');
58
+ await (0, child_process_2.runNxAsync)('--help', { silent: true });
59
59
  }
60
60
  catch (e) {
61
61
  // revert adding the plugin to nx.json
@@ -32,6 +32,12 @@ async function initHandler(options) {
32
32
  console.log('Setting Nx up installation in `.nx`. You can run Nx commands like: `./nx.bat --help`');
33
33
  }
34
34
  (0, add_nx_scripts_1.generateDotNxSetup)(version);
35
+ const { plugins } = await detectPlugins();
36
+ plugins.forEach((plugin) => {
37
+ (0, child_process_2.execSync)(`./nx add ${plugin}`, {
38
+ stdio: 'inherit',
39
+ });
40
+ });
35
41
  // invokes the wrapper, thus invoking the initial installation process
36
42
  (0, child_process_1.runNxSync)('--version', { stdio: 'ignore' });
37
43
  return;
@@ -45,8 +51,8 @@ async function initHandler(options) {
45
51
  return;
46
52
  }
47
53
  output_1.output.log({ title: '🧐 Checking dependencies' });
48
- const detectPluginsResponse = await detectPlugins();
49
- if (!detectPluginsResponse?.plugins.length) {
54
+ const { plugins, updatePackageScripts } = await detectPlugins();
55
+ if (!plugins.length) {
50
56
  // If no plugins are detected/chosen, guide users to setup
51
57
  // their targetDefaults correctly so their package scripts will work.
52
58
  const packageJson = (0, fileutils_1.readJsonFile)('package.json');
@@ -66,19 +72,17 @@ async function initHandler(options) {
66
72
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
67
73
  (0, utils_1.createNxJsonFile)(repoRoot, [], [], {});
68
74
  (0, utils_1.updateGitIgnore)(repoRoot);
69
- (0, utils_1.addDepsToPackageJson)(repoRoot, detectPluginsResponse.plugins);
75
+ (0, utils_1.addDepsToPackageJson)(repoRoot, plugins);
70
76
  output_1.output.log({ title: '📦 Installing Nx' });
71
77
  (0, utils_1.runInstall)(repoRoot, pmc);
72
78
  output_1.output.log({ title: '🔨 Configuring plugins' });
73
- for (const plugin of detectPluginsResponse.plugins) {
74
- (0, child_process_2.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${detectPluginsResponse.updatePackageScripts
75
- ? '--updatePackageScripts'
76
- : ''} --no-interactive`, {
79
+ for (const plugin of plugins) {
80
+ (0, child_process_2.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${updatePackageScripts ? '--updatePackageScripts' : ''} --no-interactive`, {
77
81
  stdio: [0, 1, 2],
78
82
  cwd: repoRoot,
79
83
  });
80
84
  }
81
- if (!detectPluginsResponse.updatePackageScripts) {
85
+ if (!updatePackageScripts) {
82
86
  const rootPackageJsonPath = (0, path_1.join)(repoRoot, 'package.json');
83
87
  const json = (0, fileutils_1.readJsonFile)(rootPackageJsonPath);
84
88
  json.nx = { includedScripts: [] };
@@ -146,9 +150,16 @@ async function detectPlugins() {
146
150
  }
147
151
  }
148
152
  }
153
+ if ((0, fs_1.existsSync)('gradlew') || (0, fs_1.existsSync)('gradlew.bat')) {
154
+ detectedPlugins.add('@nx/gradle');
155
+ }
149
156
  const plugins = Array.from(detectedPlugins);
150
- if (plugins.length === 0)
151
- return undefined;
157
+ if (plugins.length === 0) {
158
+ return {
159
+ plugins: [],
160
+ updatePackageScripts: false,
161
+ };
162
+ }
152
163
  output_1.output.log({
153
164
  title: `Recommended Plugins:`,
154
165
  bodyLines: [
@@ -165,25 +176,26 @@ async function detectPlugins() {
165
176
  },
166
177
  ]).then((r) => r.plugins);
167
178
  if (pluginsToInstall?.length === 0)
168
- return undefined;
169
- const updatePackageScripts = await (0, enquirer_1.prompt)([
170
- {
171
- name: 'updatePackageScripts',
172
- type: 'autocomplete',
173
- message: `Do you want to start using Nx in your package.json scripts?`,
174
- choices: [
175
- {
176
- name: 'Yes',
177
- },
178
- {
179
- name: 'No',
180
- },
181
- ],
182
- initial: 0,
183
- },
184
- ]).then((r) => r.updatePackageScripts === 'Yes');
185
- return {
186
- plugins: pluginsToInstall,
187
- updatePackageScripts,
188
- };
179
+ return {
180
+ plugins: [],
181
+ updatePackageScripts: false,
182
+ };
183
+ const updatePackageScripts = (0, fs_1.existsSync)('package.json') &&
184
+ (await (0, enquirer_1.prompt)([
185
+ {
186
+ name: 'updatePackageScripts',
187
+ type: 'autocomplete',
188
+ message: `Do you want to start using Nx in your package.json scripts?`,
189
+ choices: [
190
+ {
191
+ name: 'Yes',
192
+ },
193
+ {
194
+ name: 'No',
195
+ },
196
+ ],
197
+ initial: 0,
198
+ },
199
+ ]).then((r) => r.updatePackageScripts === 'Yes'));
200
+ return { plugins: pluginsToInstall, updatePackageScripts };
189
201
  }
@@ -267,7 +267,11 @@ function processEnv(color, cwd, env) {
267
267
  ...localEnv,
268
268
  ...env,
269
269
  };
270
- res.PATH = localEnv.PATH; // need to override PATH to make sure we are using the local node_modules
270
+ // need to override PATH to make sure we are using the local node_modules
271
+ if (localEnv.PATH)
272
+ res.PATH = localEnv.PATH; // UNIX-like
273
+ if (localEnv.Path)
274
+ res.Path = localEnv.Path; // Windows
271
275
  if (color) {
272
276
  res.FORCE_COLOR = `${color}`;
273
277
  }
@@ -215,18 +215,21 @@ class Cache {
215
215
  }
216
216
  tryAndRetry(fn) {
217
217
  let attempts = 0;
218
- const baseTimeout = 100;
218
+ const baseTimeout = 5;
219
+ // Generate a random number between 2 and 4 to raise to the power of attempts
220
+ const baseExponent = Math.random() * 2 + 2;
219
221
  const _try = async () => {
220
222
  try {
221
223
  attempts++;
222
224
  return await fn();
223
225
  }
224
226
  catch (e) {
225
- if (attempts === 10) {
227
+ // Max time is 5 * 4^3 = 20480ms
228
+ if (attempts === 6) {
226
229
  // After enough attempts, throw the error
227
230
  throw e;
228
231
  }
229
- await new Promise((res) => setTimeout(res, baseTimeout * attempts));
232
+ await new Promise((res) => setTimeout(res, baseExponent ** attempts));
230
233
  return await _try();
231
234
  }
232
235
  };