nx 22.7.0-beta.12 → 22.7.0-beta.14

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 (68) hide show
  1. package/dist/schemas/nx-schema.json +25 -0
  2. package/dist/schemas/project-schema.json +25 -0
  3. package/dist/src/adapter/ngcli-adapter.js +11 -12
  4. package/dist/src/command-line/daemon/daemon.js +8 -4
  5. package/dist/src/command-line/graph/graph.js +8 -1
  6. package/dist/src/command-line/migrate/migrate.js +30 -0
  7. package/dist/src/command-line/show/show-target/utils.js +4 -3
  8. package/dist/src/command-line/yargs-utils/shared-options.js +5 -1
  9. package/dist/src/config/nx-json.d.ts +3 -1
  10. package/dist/src/config/workspace-json-project-json.d.ts +2 -1
  11. package/dist/src/core/graph/main.js +1 -1
  12. package/dist/src/daemon/client/client.d.ts +10 -3
  13. package/dist/src/daemon/client/client.js +21 -31
  14. package/dist/src/daemon/client/daemon-environment.d.ts +4 -0
  15. package/dist/src/daemon/client/daemon-environment.js +119 -0
  16. package/dist/src/daemon/client/daemon-socket-messenger.d.ts +2 -5
  17. package/dist/src/daemon/client/daemon-socket-messenger.js +1 -1
  18. package/dist/src/daemon/message-types/daemon-message.d.ts +6 -0
  19. package/dist/src/daemon/message-types/daemon-message.js +6 -0
  20. package/dist/src/daemon/server/handle-hash-tasks.d.ts +1 -1
  21. package/dist/src/daemon/server/handle-hash-tasks.js +1 -1
  22. package/dist/src/daemon/server/handle-outputs-tracking.d.ts +4 -4
  23. package/dist/src/daemon/server/handle-outputs-tracking.js +11 -11
  24. package/dist/src/daemon/server/outputs-tracking.d.ts +18 -3
  25. package/dist/src/daemon/server/outputs-tracking.js +49 -22
  26. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +2 -1
  27. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +20 -4
  28. package/dist/src/daemon/server/server.js +71 -40
  29. package/dist/src/executors/run-commands/running-tasks.js +2 -3
  30. package/dist/src/executors/run-script/run-script.impl.js +16 -8
  31. package/dist/src/hasher/hash-task.d.ts +9 -1
  32. package/dist/src/hasher/hash-task.js +41 -14
  33. package/dist/src/hasher/native-task-hasher-impl.d.ts +1 -1
  34. package/dist/src/hasher/native-task-hasher-impl.js +4 -6
  35. package/dist/src/hasher/task-hasher.d.ts +20 -9
  36. package/dist/src/hasher/task-hasher.js +34 -6
  37. package/dist/src/native/index.d.ts +34 -7
  38. package/dist/src/native/native-bindings.js +1 -1
  39. package/dist/src/native/nx.wasi-browser.js +0 -1
  40. package/dist/src/native/nx.wasi.cjs +0 -1
  41. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  42. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  43. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +19 -1
  44. package/dist/src/plugins/js/utils/register.js +83 -4
  45. package/dist/src/project-graph/error-types.js +31 -11
  46. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
  47. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +9 -0
  48. package/dist/src/project-graph/plugins/isolation/message-types.d.ts +1 -1
  49. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +9 -0
  50. package/dist/src/project-graph/plugins/isolation/messaging.js +2 -0
  51. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +36 -68
  52. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +6 -0
  53. package/dist/src/tasks-runner/cache.d.ts +6 -0
  54. package/dist/src/tasks-runner/cache.js +58 -0
  55. package/dist/src/tasks-runner/init-tasks-runner.js +13 -7
  56. package/dist/src/tasks-runner/run-command.js +13 -5
  57. package/dist/src/tasks-runner/task-env.js +17 -1
  58. package/dist/src/tasks-runner/task-orchestrator.d.ts +79 -7
  59. package/dist/src/tasks-runner/task-orchestrator.js +330 -120
  60. package/dist/src/tasks-runner/tasks-schedule.d.ts +5 -2
  61. package/dist/src/tasks-runner/tasks-schedule.js +31 -17
  62. package/dist/src/tasks-runner/utils.d.ts +3 -3
  63. package/dist/src/tasks-runner/utils.js +5 -6
  64. package/package.json +12 -12
  65. package/dist/src/daemon/client/exec-is-server-available.d.ts +0 -1
  66. package/dist/src/daemon/client/exec-is-server-available.js +0 -11
  67. package/dist/src/daemon/client/generate-help-output.d.ts +0 -1
  68. package/dist/src/daemon/client/generate-help-output.js +0 -26
@@ -772,6 +772,31 @@
772
772
  },
773
773
  "required": ["dependentTasksOutputFiles"],
774
774
  "additionalProperties": false
775
+ },
776
+ {
777
+ "type": "object",
778
+ "properties": {
779
+ "json": {
780
+ "type": "string",
781
+ "description": "Path to a JSON file. Must start with {workspaceRoot} or {projectRoot}. Supports globs."
782
+ },
783
+ "fields": {
784
+ "type": "array",
785
+ "items": {
786
+ "type": "string"
787
+ },
788
+ "description": "Allowlist of fields to include in the hash. Supports dot notation for nested paths (e.g. 'compilerOptions.target')."
789
+ },
790
+ "excludeFields": {
791
+ "type": "array",
792
+ "items": {
793
+ "type": "string"
794
+ },
795
+ "description": "Denylist of fields to exclude from the hash. Supports dot notation for nested paths."
796
+ }
797
+ },
798
+ "required": ["json"],
799
+ "additionalProperties": false
775
800
  }
776
801
  ]
777
802
  }
@@ -322,6 +322,31 @@
322
322
  },
323
323
  "required": ["dependentTasksOutputFiles"],
324
324
  "additionalProperties": false
325
+ },
326
+ {
327
+ "type": "object",
328
+ "properties": {
329
+ "json": {
330
+ "type": "string",
331
+ "description": "Path to a JSON file. Must start with {workspaceRoot} or {projectRoot}. Supports globs."
332
+ },
333
+ "fields": {
334
+ "type": "array",
335
+ "items": {
336
+ "type": "string"
337
+ },
338
+ "description": "Allowlist of fields to include in the hash. Supports dot notation for nested paths (e.g. 'compilerOptions.target')."
339
+ },
340
+ "excludeFields": {
341
+ "type": "array",
342
+ "items": {
343
+ "type": "string"
344
+ },
345
+ "description": "Denylist of fields to exclude from the hash. Supports dot notation for nested paths."
346
+ }
347
+ },
348
+ "required": ["json"],
349
+ "additionalProperties": false
325
350
  }
326
351
  ]
327
352
  }
@@ -40,6 +40,15 @@ function getProjectGraph() {
40
40
  return (0, project_graph_1.createProjectGraphAsync)();
41
41
  }
42
42
  }
43
+ function getUndefinedDefaultsTransform(isAngularBuild) {
44
+ // `addUndefinedObjectDefaults` was introduced in @angular-devkit/core v20.
45
+ // `@nx/angular` supports Angular >=19, so fall back to `addUndefinedDefaults`
46
+ // when the object-specific transform is unavailable.
47
+ if (isAngularBuild && core_1.schema.transforms.addUndefinedObjectDefaults) {
48
+ return core_1.schema.transforms.addUndefinedObjectDefaults;
49
+ }
50
+ return core_1.schema.transforms.addUndefinedDefaults;
51
+ }
43
52
  async function createBuilderContext(builderInfo, context) {
44
53
  require('./compat');
45
54
  const fsHost = new NxScopedHostForBuilders(context.root, context.projectGraph);
@@ -51,12 +60,7 @@ async function createBuilderContext(builderInfo, context) {
51
60
  const registry = new core_1.schema.CoreSchemaRegistry();
52
61
  const isAngularBuild = builderInfo.builderName.startsWith('@angular/build:') ||
53
62
  ['@nx/angular:application', '@nx/angular:unit-test'].includes(builderInfo.builderName);
54
- if (isAngularBuild) {
55
- registry.addPostTransform(core_1.schema.transforms.addUndefinedObjectDefaults);
56
- }
57
- else {
58
- registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
59
- }
63
+ registry.addPostTransform(getUndefinedDefaultsTransform(isAngularBuild));
60
64
  registry.addSmartDefaultProvider('unparsed', () => {
61
65
  // This happens when context.scheduleTarget is used to run a target using nx:run-commands
62
66
  return [];
@@ -150,12 +154,7 @@ async function scheduleTarget(root, opts, verbose, projectGraph) {
150
154
  const isAngularBuild = builderName.startsWith('@angular/build:') ||
151
155
  ['@nx/angular:application', '@nx/angular:unit-test'].includes(builderName);
152
156
  const registry = new core_1.schema.CoreSchemaRegistry();
153
- if (isAngularBuild) {
154
- registry.addPostTransform(core_1.schema.transforms.addUndefinedObjectDefaults);
155
- }
156
- else {
157
- registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
158
- }
157
+ registry.addPostTransform(getUndefinedDefaultsTransform(isAngularBuild));
159
158
  registry.addSmartDefaultProvider('unparsed', () => {
160
159
  // This happens when context.scheduleTarget is used to run a target using nx:run-commands
161
160
  return [];
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.daemonHandler = daemonHandler;
4
+ const cache_1 = require("../../daemon/cache");
4
5
  const tmp_dir_1 = require("../../daemon/tmp-dir");
5
6
  const handle_import_1 = require("../../utils/handle-import");
6
7
  const output_1 = require("../../utils/output");
7
- const generate_help_output_1 = require("../../daemon/client/generate-help-output");
8
8
  async function daemonHandler(args) {
9
+ const { daemonClient } = await (0, handle_import_1.handleImport)('../../daemon/client/client.js', __dirname);
9
10
  if (args.start) {
10
- const { daemonClient } = await (0, handle_import_1.handleImport)('../../daemon/client/client.js', __dirname);
11
11
  const pid = await daemonClient.startInBackground();
12
12
  output_1.output.log({
13
13
  title: `Daemon Server - Started in a background process...`,
@@ -17,11 +17,15 @@ async function daemonHandler(args) {
17
17
  });
18
18
  }
19
19
  else if (args.stop) {
20
- const { daemonClient } = await (0, handle_import_1.handleImport)('../../daemon/client/client.js', __dirname);
21
20
  await daemonClient.stop();
22
21
  output_1.output.log({ title: 'Daemon Server - Stopped' });
23
22
  }
23
+ else if (await daemonClient.isServerAvailable()) {
24
+ const pid = (0, cache_1.getDaemonProcessIdSync)();
25
+ console.log(`Nx Daemon is currently running:
26
+ - Logs: ${tmp_dir_1.DAEMON_OUTPUT_LOG_FILE}${pid ? `\n - Process ID: ${pid}` : ''}`);
27
+ }
24
28
  else {
25
- console.log((0, generate_help_output_1.generateDaemonHelpOutput)());
29
+ console.log('Nx Daemon is not running.');
26
30
  }
27
31
  }
@@ -31,6 +31,7 @@ const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
31
31
  const task_hasher_1 = require("../../hasher/task-hasher");
32
32
  const find_matching_projects_1 = require("../../utils/find-matching-projects");
33
33
  const create_task_hasher_1 = require("../../hasher/create-task-hasher");
34
+ const task_env_1 = require("../../tasks-runner/task-env");
34
35
  const error_types_1 = require("../../project-graph/error-types");
35
36
  const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
36
37
  // maps file extention to MIME types
@@ -942,7 +943,13 @@ async function createJsonOutput(prunedGraph, rawGraph, projects, targets) {
942
943
  const taskGraph = (0, create_task_graph_1.createTaskGraph)(rawGraph, {}, projects, targets, undefined, {});
943
944
  const hasher = (0, create_task_hasher_1.createTaskHasher)(rawGraph, (0, configuration_1.readNxJson)());
944
945
  let tasks = Object.values(taskGraph.tasks);
945
- const hashes = await hasher.hashTasks(tasks, taskGraph);
946
+ // Match the runtime path: each task is hashed against its own env so
947
+ // the graph-view hash matches the hash used when the task actually runs.
948
+ const perTaskEnvs = {};
949
+ for (const task of tasks) {
950
+ perTaskEnvs[task.id] = (0, task_env_1.getTaskSpecificEnv)(task, rawGraph);
951
+ }
952
+ const hashes = await hasher.hashTasks(tasks, taskGraph, perTaskEnvs);
946
953
  response.tasks = taskGraph;
947
954
  response.taskPlans = tasks.reduce((acc, task, index) => {
948
955
  acc[task.id] = Object.keys(hashes[index].details.nodes).sort();
@@ -741,7 +741,37 @@ async function downloadPackageMigrationsFromRegistry(packageName, packageVersion
741
741
  }
742
742
  return result;
743
743
  }
744
+ function createConcurrencyLimiter(concurrency) {
745
+ const queue = [];
746
+ let active = 0;
747
+ function next() {
748
+ while (queue.length > 0 && active < concurrency) {
749
+ active++;
750
+ queue.shift()();
751
+ }
752
+ }
753
+ return function limit(fn) {
754
+ return new Promise((resolve, reject) => {
755
+ queue.push(() => {
756
+ fn()
757
+ .then(resolve, reject)
758
+ .finally(() => {
759
+ active--;
760
+ next();
761
+ });
762
+ });
763
+ next();
764
+ });
765
+ };
766
+ }
767
+ const installConcurrencyLimit = process.env.NX_MIGRATE_INSTALL_CONCURRENCY
768
+ ? createConcurrencyLimiter(Math.max(1, Math.floor(Number(process.env.NX_MIGRATE_INSTALL_CONCURRENCY)) || 1))
769
+ : null;
744
770
  async function getPackageMigrationsUsingInstall(packageName, packageVersion) {
771
+ const run = () => getPackageMigrationsUsingInstallImpl(packageName, packageVersion);
772
+ return installConcurrencyLimit ? installConcurrencyLimit(run) : run();
773
+ }
774
+ async function getPackageMigrationsUsingInstallImpl(packageName, packageVersion) {
745
775
  const { dir, cleanup } = (0, package_manager_1.createTempNpmDirectory)();
746
776
  let result;
747
777
  if ((0, provenance_1.getNxPackageGroup)().includes(packageName)) {
@@ -140,15 +140,16 @@ function validateConfiguration(projectName, targetName, configuration, targetCon
140
140
  * standard input-based hashing is bypassed for this target.
141
141
  */
142
142
  function hasCustomHasher(projectName, targetName, graph) {
143
+ // Lazy require avoids a circular dependency with tasks-runner/utils.
144
+ const { getExecutorForTask } = require('../../../tasks-runner/utils');
143
145
  try {
144
- const { getExecutorForTask } = require('../../../tasks-runner/utils');
146
+ const { projects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(graph);
145
147
  const task = {
146
148
  id: `${projectName}:${targetName}`,
147
149
  target: { project: projectName, target: targetName },
148
150
  overrides: {},
149
151
  };
150
- const executorConfig = getExecutorForTask(task, graph);
151
- return !!executorConfig.hasherFactory;
152
+ return !!getExecutorForTask(task, projects).hasherFactory;
152
153
  }
153
154
  catch {
154
155
  return false;
@@ -93,7 +93,11 @@ function withRunOptions(yargs) {
93
93
  .option('nxBail', {
94
94
  describe: 'Stop command execution after the first failed task.',
95
95
  type: 'boolean',
96
- default: false,
96
+ })
97
+ .middleware((args) => {
98
+ if (args.nxBail === undefined) {
99
+ args.nxBail = process.env.NX_BAIL === 'true';
100
+ }
97
101
  })
98
102
  .option('nxIgnoreCycles', {
99
103
  describe: 'Ignore cycles in the task graph.',
@@ -799,7 +799,9 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
799
799
  */
800
800
  useInferencePlugins?: boolean;
801
801
  /**
802
- * Set this to true to disable connection to Nx Cloud
802
+ * Setting this to true will cause all attempts to setup your workspace to Nx Cloud to fail.
803
+ * This value does not prevent using Nx Cloud if already connected.
804
+ * Use NX_NO_CLOUD=true env var or the `--no-cloud` arg to prevent using Nx Cloud when running commands.
803
805
  */
804
806
  neverConnectToCloud?: boolean;
805
807
  /**
@@ -1,3 +1,4 @@
1
+ import type { JsonInput } from '../native';
1
2
  import type { PackageJson } from '../utils/package-json';
2
3
  import type { NxJsonConfiguration, NxReleaseDockerConfiguration, NxReleaseVersionConfiguration } from './nx-json';
3
4
  /**
@@ -195,7 +196,7 @@ export type InputDefinition = {
195
196
  env: string;
196
197
  } | {
197
198
  workingDirectory: 'relative' | 'absolute';
198
- };
199
+ } | JsonInput;
199
200
  /**
200
201
  * Target's configuration
201
202
  */