nx 22.7.1 → 22.7.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.
Files changed (51) hide show
  1. package/dist/bin/nx.d.ts +1 -0
  2. package/dist/bin/nx.js +3 -0
  3. package/dist/src/ai/clone-ai-config-repo.js +20 -3
  4. package/dist/src/analytics/analytics.js +10 -1
  5. package/dist/src/command-line/format/format.js +15 -5
  6. package/dist/src/command-line/graph/graph.js +0 -1
  7. package/dist/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
  8. package/dist/src/command-line/release/config/use-legacy-versioning.js +8 -0
  9. package/dist/src/command-line/report/report.js +0 -1
  10. package/dist/src/config/misc-interfaces.d.ts +6 -0
  11. package/dist/src/config/schema-utils.js +2 -1
  12. package/dist/src/core/graph/main.js +1 -1
  13. package/dist/src/core/graph/styles.css +1 -1
  14. package/dist/src/core/graph/styles.js +1 -1
  15. package/dist/src/daemon/server/latest-nx.js +2 -0
  16. package/dist/src/daemon/server/start.d.ts +1 -1
  17. package/dist/src/daemon/server/start.js +2 -0
  18. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  19. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  20. package/dist/src/plugins/js/lock-file/npm-parser.js +37 -19
  21. package/dist/src/plugins/js/lock-file/pnpm-parser.js +51 -4
  22. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +12 -4
  23. package/dist/src/plugins/js/utils/typescript.d.ts +7 -0
  24. package/dist/src/plugins/js/utils/typescript.js +39 -0
  25. package/dist/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
  26. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +2 -0
  27. package/dist/src/project-graph/plugins/resolve-plugin.d.ts +7 -4
  28. package/dist/src/project-graph/plugins/resolve-plugin.js +152 -33
  29. package/dist/src/project-graph/plugins/utils.js +13 -7
  30. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +13 -2
  31. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.js +16 -5
  32. package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +11 -2
  33. package/dist/src/tasks-runner/run-command.js +8 -1
  34. package/dist/src/tasks-runner/task-orchestrator.js +20 -4
  35. package/dist/src/tasks-runner/tasks-schedule.js +3 -3
  36. package/dist/src/utils/ab-testing.js +12 -0
  37. package/dist/src/utils/compile-cache.d.ts +24 -0
  38. package/dist/src/utils/compile-cache.js +49 -0
  39. package/dist/src/utils/enable-compile-cache.d.ts +1 -0
  40. package/dist/src/utils/enable-compile-cache.js +7 -0
  41. package/dist/src/utils/has-nx-js-plugin.d.ts +9 -0
  42. package/dist/src/utils/has-nx-js-plugin.js +24 -0
  43. package/dist/src/utils/logger.d.ts +12 -1
  44. package/dist/src/utils/logger.js +57 -36
  45. package/dist/src/utils/nx-key.d.ts +0 -1
  46. package/dist/src/utils/nx-key.js +20 -23
  47. package/dist/src/utils/output.d.ts +3 -2
  48. package/dist/src/utils/output.js +29 -28
  49. package/dist/src/utils/package-json.js +2 -13
  50. package/dist/src/utils/perf-logging.js +3 -1
  51. package/package.json +22 -15
package/dist/bin/nx.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
+ import '../src/utils/enable-compile-cache';
2
3
  import '../src/utils/perf-logging';
package/dist/bin/nx.js CHANGED
@@ -8,6 +8,8 @@ if (process.env.FORCE_COLOR === '0') {
8
8
  process.env.NO_COLOR = '1';
9
9
  delete process.env.FORCE_COLOR;
10
10
  }
11
+ // Must be the first import — see enable-compile-cache.ts.
12
+ require("../src/utils/enable-compile-cache");
11
13
  const find_workspace_root_1 = require("../src/utils/find-workspace-root");
12
14
  const pc = tslib_1.__importStar(require("picocolors"));
13
15
  const output_1 = require("../src/utils/output");
@@ -52,6 +54,7 @@ async function main() {
52
54
  process.argv[2] === '_migrate' ||
53
55
  process.argv[2] === 'init' ||
54
56
  process.argv[2] === 'configure-ai-agents' ||
57
+ process.argv[2] === 'mcp' ||
55
58
  (process.argv[2] === 'graph' && !workspace)) {
56
59
  process.env.NX_DAEMON = 'false';
57
60
  (await import('nx/src/command-line/nx-commands')).commandsObject.argv;
@@ -125,14 +125,31 @@ function cleanupOldCaches(currentCommitHash) {
125
125
  function getAiConfigRepoPath() {
126
126
  // 1. Get latest commit hash (first 10 chars)
127
127
  const commitHash = getLatestCommitHash();
128
- // 2. Check if cached version exists
128
+ // 2. Reuse cached version if it still has content (macOS may have
129
+ // swept its files but left the directory tree).
129
130
  const cachedPath = (0, path_1.join)(CACHE_DIR, commitHash);
130
- if ((0, fs_1.existsSync)(cachedPath)) {
131
+ if (hasRootFile(cachedPath)) {
131
132
  return cachedPath;
132
133
  }
133
- // 3. Clone fresh
134
+ // 3. Wipe any empty skeleton, then clone fresh
135
+ if ((0, fs_1.existsSync)(cachedPath)) {
136
+ (0, fs_1.rmSync)(cachedPath, { recursive: true, force: true });
137
+ }
134
138
  cloneRepo(cachedPath);
135
139
  // 4. Clean up old cached versions
136
140
  cleanupOldCaches(commitHash);
137
141
  return cachedPath;
138
142
  }
143
+ /**
144
+ * The repo always has at least one regular file at its root (e.g. README).
145
+ * If everything at the root is a directory, the cache was swept by macOS
146
+ * tmp cleanup and we should re-clone.
147
+ */
148
+ function hasRootFile(dir) {
149
+ try {
150
+ return (0, fs_1.readdirSync)(dir, { withFileTypes: true }).some((e) => e.isFile());
151
+ }
152
+ catch {
153
+ return false;
154
+ }
155
+ }
@@ -16,6 +16,7 @@ const native_1 = require("../native");
16
16
  const package_manager_1 = require("../utils/package-manager");
17
17
  const semver_1 = require("semver");
18
18
  const os = tslib_1.__importStar(require("os"));
19
+ const crypto_1 = require("crypto");
19
20
  const machine_id_cache_1 = require("../utils/machine-id-cache");
20
21
  const is_ci_1 = require("../utils/is-ci");
21
22
  const analytics_prompt_1 = require("../utils/analytics-prompt");
@@ -56,7 +57,7 @@ async function startAnalytics() {
56
57
  return;
57
58
  }
58
59
  const isNxCloud = !!(nxJson?.nxCloudId ?? nxJson?.nxCloudAccessToken);
59
- const userId = await (0, machine_id_cache_1.getCurrentMachineId)();
60
+ const userId = await getTelemetryUserId(workspaceId);
60
61
  const packageManagerInfo = getPackageManagerInfo();
61
62
  const nodeVersion = (0, semver_1.parse)(process.version);
62
63
  const nodeVersionString = nodeVersion
@@ -225,3 +226,11 @@ function isAnalyticsEnabled() {
225
226
  const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
226
227
  return nxJson?.analytics === true;
227
228
  }
229
+ // Mix workspace id in: shared Docker images (Gitpod, Cypress, etc.) bake
230
+ // in /etc/machine-id, so machine-id alone collapses many users into one.
231
+ async function getTelemetryUserId(workspaceId) {
232
+ const machineId = await (0, machine_id_cache_1.getCurrentMachineId)();
233
+ return (0, crypto_1.createHash)('sha256')
234
+ .update(`${machineId}|${workspaceId}`)
235
+ .digest('hex');
236
+ }
@@ -34,10 +34,15 @@ async function format(command, args) {
34
34
  process.exit(1);
35
35
  }
36
36
  const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', { printWarnings: false }, (0, configuration_1.readNxJson)());
37
- const patterns = (await getPatterns(prettier, { ...args, ...nxArgs })).map(
38
- // prettier removes one of the \
39
- // prettier-ignore
40
- (p) => `"${p.replace(/\$/g, '\\\$')}"`);
37
+ const patterns = (await getPatterns(prettier, { ...args, ...nxArgs })).map((p) => {
38
+ // On non-Windows, escape $ to prevent shell variable interpolation
39
+ // (the shell consumes one \, so \\$ becomes \$ which the shell treats as literal $)
40
+ // On Windows (cmd.exe), $ is not a special character, so escaping it would
41
+ // cause prettier to look for a file with a literal \$ in the name
42
+ // prettier-ignore
43
+ const escaped = process.platform !== 'win32' ? p.replace(/\$/g, '\\\$') : p;
44
+ return `"${escaped}"`;
45
+ });
41
46
  // Chunkify the patterns array to prevent crashing the windows terminal
42
47
  const chunkList = (0, chunkify_1.chunkify)(patterns);
43
48
  switch (command) {
@@ -204,7 +209,12 @@ function getPrettierPath() {
204
209
  return prettierPath;
205
210
  }
206
211
  const { packageJson, path: packageJsonPath } = (0, package_json_1.readModulePackageJson)('prettier');
207
- prettierPath = path.resolve(path.dirname(packageJsonPath), packageJson.bin);
212
+ const bin = packageJson.bin;
213
+ const binPath = typeof bin === 'string' ? bin : bin?.['prettier'];
214
+ if (!binPath) {
215
+ throw new Error(`Could not find prettier binary in ${packageJsonPath}`);
216
+ }
217
+ prettierPath = path.resolve(path.dirname(packageJsonPath), binPath);
208
218
  return prettierPath;
209
219
  }
210
220
  let useListDifferent;
@@ -402,7 +402,6 @@ async function startServer(html, environmentJs, host, port = 4211, watchForChang
402
402
  // Avoid https://en.wikipedia.org/wiki/Directory_traversal_attack
403
403
  // e.g curl --path-as-is http://localhost:9000/../fileInDanger.txt
404
404
  // by limiting the path to current directory only
405
- res.setHeader('Access-Control-Allow-Origin', '*');
406
405
  const sanitizePath = (0, node_path_1.basename)(parsedUrl.pathname);
407
406
  if (sanitizePath === 'project-graph.json') {
408
407
  const requestFull = parsedUrl.searchParams.get('full') === 'true';
@@ -0,0 +1,2 @@
1
+ /** @deprecated Compat shim for `@nx/js@21`. */
2
+ export declare function shouldUseLegacyVersioning(releaseConfig: any): boolean;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldUseLegacyVersioning = shouldUseLegacyVersioning;
4
+ // TODO(v23): remove — kept only so `@nx/js@21`'s library generator can load via `ensurePackage`.
5
+ /** @deprecated Compat shim for `@nx/js@21`. */
6
+ function shouldUseLegacyVersioning(releaseConfig) {
7
+ return releaseConfig?.version?.useLegacyVersioning ?? false;
8
+ }
@@ -383,7 +383,6 @@ function findRegisteredPluginsBeingUsed(nxJson) {
383
383
  }
384
384
  function findInstalledPackagesWeCareAbout() {
385
385
  const packagesWeMayCareAbout = {};
386
- // TODO (v20): Remove workaround for hiding @nrwl packages when matching @nx package is found.
387
386
  for (const pkg of exports.packagesWeCareAbout) {
388
387
  const v = readPackageVersion(pkg);
389
388
  if (v) {
@@ -148,6 +148,12 @@ export type TaskResult = {
148
148
  terminalOutput: string;
149
149
  startTime?: number;
150
150
  endTime?: number;
151
+ /**
152
+ * Explicit status. When set, takes precedence over `success`. Required for
153
+ * batch executors that need to distinguish `'skipped'` peers (tasks that
154
+ * never ran because a sibling failed) from real failures.
155
+ */
156
+ status?: 'success' | 'failure' | 'skipped';
151
157
  };
152
158
  export type BatchExecutorResult = Record<string, TaskResult>;
153
159
  export type BatchExecutorTaskResult = {
@@ -8,6 +8,7 @@ const path_1 = require("path");
8
8
  const resolve_exports_1 = require("resolve.exports");
9
9
  const packages_1 = require("../plugins/js/utils/packages");
10
10
  const plugins_1 = require("../project-graph/plugins");
11
+ const typescript_1 = require("../plugins/js/utils/typescript");
11
12
  const path_2 = require("../utils/path");
12
13
  /**
13
14
  * This function is used to get the implementation factory of an executor or generator.
@@ -92,7 +93,7 @@ function tryResolveFromSource(path, directory, packageName, projects) {
92
93
  const fromExports = (0, resolve_exports_1.resolve)({
93
94
  name: localProject.metadata.js.packageName,
94
95
  exports: localProject.metadata.js.packageExports,
95
- }, path, { conditions: ['development'] });
96
+ }, path, { conditions: (0, typescript_1.getRootTsConfigResolveExportsConditions)() });
96
97
  if (fromExports && fromExports.length) {
97
98
  for (const exportPath of fromExports) {
98
99
  if ((0, fs_1.existsSync)((0, path_1.join)(directory, exportPath))) {