nx 23.0.0-beta.21 → 23.0.0-beta.23

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 (82) hide show
  1. package/dist/plugins/package-json.js +1 -1
  2. package/dist/src/adapter/angular-json.d.ts +2 -2
  3. package/dist/src/adapter/angular-json.js +0 -1
  4. package/dist/src/adapter/compat.d.ts +1 -1
  5. package/dist/src/adapter/compat.js +1 -0
  6. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +2 -1
  7. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +1 -1
  8. package/dist/src/command-line/examples.js +4 -4
  9. package/dist/src/command-line/graph/graph.js +1 -1
  10. package/dist/src/command-line/init/init-v2.js +1 -1
  11. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +5 -0
  12. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +1 -0
  13. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +5 -0
  14. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +1 -0
  15. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +5 -0
  16. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +1 -0
  17. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +1 -0
  18. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +15 -0
  19. package/dist/src/command-line/migrate/agentic/run-step.d.ts +7 -0
  20. package/dist/src/command-line/migrate/agentic/run-step.js +3 -1
  21. package/dist/src/command-line/migrate/agentic/select.js +120 -32
  22. package/dist/src/command-line/migrate/command-object.d.ts +42 -0
  23. package/dist/src/command-line/migrate/command-object.js +38 -8
  24. package/dist/src/command-line/migrate/migrate-config.d.ts +27 -0
  25. package/dist/src/command-line/migrate/migrate-config.js +103 -0
  26. package/dist/src/command-line/migrate/migrate.d.ts +39 -2
  27. package/dist/src/command-line/migrate/migrate.js +203 -41
  28. package/dist/src/command-line/migrate/multi-major.js +5 -2
  29. package/dist/src/command-line/release/changelog/version-plan-filtering.d.ts +3 -1
  30. package/dist/src/command-line/release/changelog/version-plan-filtering.js +7 -3
  31. package/dist/src/command-line/release/changelog.d.ts +7 -0
  32. package/dist/src/command-line/release/changelog.js +22 -9
  33. package/dist/src/command-line/release/release.js +65 -55
  34. package/dist/src/command-line/release/utils/git.d.ts +6 -0
  35. package/dist/src/command-line/release/utils/git.js +33 -0
  36. package/dist/src/command-line/release/version/derive-specifier-from-conventional-commits.js +3 -2
  37. package/dist/src/command-line/release/version.d.ts +3 -0
  38. package/dist/src/command-line/release/version.js +13 -3
  39. package/dist/src/config/misc-interfaces.d.ts +8 -0
  40. package/dist/src/config/nx-json.d.ts +49 -0
  41. package/dist/src/core/graph/main.js +1 -1
  42. package/dist/src/daemon/server/latest-nx.js +3 -1
  43. package/dist/src/devkit-exports.d.ts +11 -11
  44. package/dist/src/devkit-exports.js +7 -4
  45. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  46. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  47. package/dist/src/plugins/js/index.d.ts +2 -2
  48. package/dist/src/plugins/js/index.js +4 -4
  49. package/dist/src/plugins/js/lock-file/lock-file.d.ts +7 -2
  50. package/dist/src/plugins/js/lock-file/lock-file.js +35 -25
  51. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +2 -4
  52. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +121 -43
  53. package/dist/src/plugins/js/utils/register.d.ts +52 -0
  54. package/dist/src/plugins/js/utils/register.js +195 -0
  55. package/dist/src/plugins/package-json/create-nodes.d.ts +2 -2
  56. package/dist/src/plugins/package-json/create-nodes.js +2 -2
  57. package/dist/src/plugins/project-json/build-nodes/project-json.d.ts +2 -2
  58. package/dist/src/plugins/project-json/build-nodes/project-json.js +1 -1
  59. package/dist/src/project-graph/error-types.d.ts +6 -6
  60. package/dist/src/project-graph/error-types.js +1 -1
  61. package/dist/src/project-graph/file-utils.d.ts +7 -0
  62. package/dist/src/project-graph/file-utils.js +78 -10
  63. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +2 -2
  64. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +2 -2
  65. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +3 -3
  66. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +6 -4
  67. package/dist/src/project-graph/plugins/public-api.d.ts +31 -12
  68. package/dist/src/project-graph/plugins/transpiler.js +11 -0
  69. package/dist/src/project-graph/plugins/utils.d.ts +3 -3
  70. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +1 -1
  71. package/dist/src/project-graph/utils/project-configuration-utils.js +6 -17
  72. package/dist/src/tasks-runner/init-tasks-runner.d.ts +2 -2
  73. package/dist/src/tasks-runner/init-tasks-runner.js +6 -6
  74. package/dist/src/tasks-runner/task-orchestrator.d.ts +2 -2
  75. package/dist/src/tasks-runner/task-orchestrator.js +6 -6
  76. package/dist/src/utils/package-json.d.ts +3 -3
  77. package/dist/src/utils/package-json.js +9 -11
  78. package/dist/src/utils/package-manager.d.ts +13 -0
  79. package/dist/src/utils/package-manager.js +27 -0
  80. package/migrations.json +18 -9
  81. package/package.json +11 -11
  82. package/schemas/nx-schema.json +41 -0
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLatestNxTmpPath = getLatestNxTmpPath;
4
4
  exports.cleanupLatestNx = cleanupLatestNx;
5
5
  const devkit_internals_1 = require("../../devkit-internals");
6
+ const package_manager_1 = require("../../utils/package-manager");
6
7
  const provenance_1 = require("../../utils/provenance");
8
+ const workspace_root_1 = require("../../utils/workspace-root");
7
9
  const logger_1 = require("../logger");
8
10
  // Module-level state - persists across invocations within daemon lifecycle
9
11
  let latestNxTmpPath = null;
@@ -26,7 +28,7 @@ async function getLatestNxTmpPath() {
26
28
  try {
27
29
  logger_1.serverLogger.log('[LATEST-NX]: Pulling latest Nx...');
28
30
  await (0, provenance_1.ensurePackageHasProvenance)('nx', 'latest');
29
- const result = await (0, devkit_internals_1.installPackageToTmpAsync)('nx', 'latest');
31
+ const result = await (0, devkit_internals_1.installPackageToTmpAsync)('nx', 'latest', (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot));
30
32
  latestNxTmpPath = result.tempDir;
31
33
  cleanupFn = result.cleanup;
32
34
  logger_1.serverLogger.log('[LATEST-NX]: Successfully pulled latest Nx to', latestNxTmpPath);
@@ -5,17 +5,17 @@
5
5
  /**
6
6
  * @category Tree
7
7
  */
8
- export type { Tree, FileChange } from './generators/tree';
8
+ export type { FileChange, Tree } from './generators/tree';
9
9
  /**
10
10
  * @category Workspace
11
11
  */
12
- export type { WorkspaceJsonConfiguration, ProjectsConfigurations, TargetDependencyConfig, TargetConfiguration, ProjectConfiguration, ProjectType, Workspace, } from './config/workspace-json-project-json';
12
+ export type { ProjectConfiguration, ProjectsConfigurations, ProjectType, TargetConfiguration, TargetDependencyConfig, Workspace, WorkspaceJsonConfiguration, } from './config/workspace-json-project-json';
13
13
  /**
14
14
  * @category Workspace
15
15
  */
16
- export type { Generator, Migration, MigrationReturnObject, GeneratorCallback, PromiseExecutor, AsyncIteratorExecutor, Executor, ExecutorContext, TaskGraphExecutor, GeneratorsJson, ExecutorsJson, MigrationsJson, CustomHasher, HasherContext, } from './config/misc-interfaces';
16
+ export type { AsyncIteratorExecutor, CustomHasher, Executor, ExecutorContext, ExecutorsJson, Generator, GeneratorCallback, GeneratorsJson, HasherContext, Migration, MigrationReturnObject, MigrationsJson, PromiseExecutor, TaskGraphExecutor, } from './config/misc-interfaces';
17
17
  export { workspaceLayout } from './config/configuration';
18
- export type { NxPlugin, NxPluginV2, CreateNodesResult, CreateNodesContextV2, CreateNodesFunctionV2, CreateNodesResultV2, CreateNodesV2, CreateDependencies, CreateDependenciesContext, CreateMetadata, CreateMetadataContext, ProjectsMetadata, PreTasksExecution, PreTasksExecutionContext, PostTasksExecution, PostTasksExecutionContext, } from './project-graph/plugins';
18
+ export type * from './project-graph/plugins/public-api';
19
19
  export { AggregateCreateNodesError, StaleProjectGraphCacheError, } from './project-graph/error-types';
20
20
  export { createNodesFromFiles } from './project-graph/plugins';
21
21
  /**
@@ -29,7 +29,7 @@ export type { TaskResult, TaskResults } from './tasks-runner/life-cycle';
29
29
  /**
30
30
  * @category Workspace
31
31
  */
32
- export type { ImplicitDependencyEntry, ImplicitJsonSubsetDependency, NxJsonConfiguration, PluginConfiguration, ExpandedPluginConfiguration, TargetDefaults, TargetDefaultEntry, TargetDefaultsRecord, NxAffectedConfig, } from './config/nx-json';
32
+ export type { ExpandedPluginConfiguration, ImplicitDependencyEntry, ImplicitJsonSubsetDependency, NxAffectedConfig, NxJsonConfiguration, PluginConfiguration, TargetDefaults, TargetDefaultEntry, TargetDefaultsRecord, } from './config/nx-json';
33
33
  /**
34
34
  * @category Logger
35
35
  */
@@ -45,7 +45,7 @@ export type { PackageManager } from './utils/package-manager';
45
45
  /**
46
46
  * @category Package Manager
47
47
  */
48
- export { getPackageManagerCommand, detectPackageManager, getPackageManagerVersion, isWorkspacesEnabled, } from './utils/package-manager';
48
+ export { detectPackageManager, getPackageManagerCommand, getPackageManagerVersion, isWorkspacesEnabled, } from './utils/package-manager';
49
49
  /**
50
50
  * @category Commands
51
51
  */
@@ -57,7 +57,7 @@ export { runExecutor } from './command-line/run/run';
57
57
  /**
58
58
  * @category Generators
59
59
  */
60
- export { addProjectConfiguration, readProjectConfiguration, removeProjectConfiguration, updateProjectConfiguration, getProjects, } from './generators/utils/project-configuration';
60
+ export { addProjectConfiguration, getProjects, readProjectConfiguration, removeProjectConfiguration, updateProjectConfiguration, } from './generators/utils/project-configuration';
61
61
  /**
62
62
  * @category Generators
63
63
  */
@@ -69,7 +69,7 @@ export { readNxJson, updateNxJson, } from './generators/utils/project-configurat
69
69
  /**
70
70
  * @category Project Graph
71
71
  */
72
- export type { ProjectFileMap, FileMap, FileData, ProjectGraph, ProjectGraphDependency, ProjectGraphProjectNode, ProjectGraphExternalNode, } from './config/project-graph';
72
+ export type { FileData, FileMap, ProjectFileMap, ProjectGraph, ProjectGraphDependency, ProjectGraphExternalNode, ProjectGraphProjectNode, } from './config/project-graph';
73
73
  export type { GraphJson } from './command-line/graph/graph';
74
74
  /**
75
75
  * @category Project Graph
@@ -78,11 +78,11 @@ export { DependencyType } from './config/project-graph';
78
78
  /**
79
79
  * @category Project Graph
80
80
  */
81
- export { RawProjectGraphDependency, DynamicDependency, ImplicitDependency, StaticDependency, validateDependency, } from './project-graph/project-graph-builder';
81
+ export { DynamicDependency, ImplicitDependency, RawProjectGraphDependency, StaticDependency, validateDependency, } from './project-graph/project-graph-builder';
82
82
  /**
83
83
  * @category Generators
84
84
  */
85
- export { readJson, writeJson, updateJson } from './generators/utils/json';
85
+ export { readJson, updateJson, writeJson } from './generators/utils/json';
86
86
  /**
87
87
  * @category Utils
88
88
  */
@@ -126,8 +126,8 @@ export { defaultTasksRunner, DefaultTasksRunnerOptions, RemoteCache, } from './t
126
126
  /**
127
127
  * @category Utils
128
128
  */
129
- export { Hash, TaskHasher, Hasher } from './hasher/task-hasher';
130
129
  export { hashArray } from './hasher/file-hasher';
130
+ export { Hash, Hasher, TaskHasher } from './hasher/task-hasher';
131
131
  /**
132
132
  * @category Utils
133
133
  */
@@ -4,7 +4,7 @@
4
4
  * Try hard to not add to this API to reduce the surface area we need to maintain.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.isDaemonEnabled = exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.globAsync = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.isWorkspacesEnabled = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.createNodesFromFiles = exports.StaleProjectGraphCacheError = exports.AggregateCreateNodesError = exports.workspaceLayout = void 0;
7
+ exports.isDaemonEnabled = exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.writeJson = exports.updateJson = exports.readJson = exports.validateDependency = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.globAsync = exports.glob = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.getProjects = exports.addProjectConfiguration = exports.runExecutor = exports.isWorkspacesEnabled = exports.getPackageManagerVersion = exports.getPackageManagerCommand = exports.detectPackageManager = exports.output = exports.logger = exports.createNodesFromFiles = exports.StaleProjectGraphCacheError = exports.AggregateCreateNodesError = exports.workspaceLayout = void 0;
8
8
  var configuration_1 = require("./config/configuration");
9
9
  Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_1.workspaceLayout; } });
10
10
  var error_types_1 = require("./project-graph/error-types");
@@ -26,8 +26,8 @@ Object.defineProperty(exports, "output", { enumerable: true, get: function () {
26
26
  * @category Package Manager
27
27
  */
28
28
  var package_manager_1 = require("./utils/package-manager");
29
- Object.defineProperty(exports, "getPackageManagerCommand", { enumerable: true, get: function () { return package_manager_1.getPackageManagerCommand; } });
30
29
  Object.defineProperty(exports, "detectPackageManager", { enumerable: true, get: function () { return package_manager_1.detectPackageManager; } });
30
+ Object.defineProperty(exports, "getPackageManagerCommand", { enumerable: true, get: function () { return package_manager_1.getPackageManagerCommand; } });
31
31
  Object.defineProperty(exports, "getPackageManagerVersion", { enumerable: true, get: function () { return package_manager_1.getPackageManagerVersion; } });
32
32
  Object.defineProperty(exports, "isWorkspacesEnabled", { enumerable: true, get: function () { return package_manager_1.isWorkspacesEnabled; } });
33
33
  /**
@@ -40,10 +40,10 @@ Object.defineProperty(exports, "runExecutor", { enumerable: true, get: function
40
40
  */
41
41
  var project_configuration_1 = require("./generators/utils/project-configuration");
42
42
  Object.defineProperty(exports, "addProjectConfiguration", { enumerable: true, get: function () { return project_configuration_1.addProjectConfiguration; } });
43
+ Object.defineProperty(exports, "getProjects", { enumerable: true, get: function () { return project_configuration_1.getProjects; } });
43
44
  Object.defineProperty(exports, "readProjectConfiguration", { enumerable: true, get: function () { return project_configuration_1.readProjectConfiguration; } });
44
45
  Object.defineProperty(exports, "removeProjectConfiguration", { enumerable: true, get: function () { return project_configuration_1.removeProjectConfiguration; } });
45
46
  Object.defineProperty(exports, "updateProjectConfiguration", { enumerable: true, get: function () { return project_configuration_1.updateProjectConfiguration; } });
46
- Object.defineProperty(exports, "getProjects", { enumerable: true, get: function () { return project_configuration_1.getProjects; } });
47
47
  /**
48
48
  * @category Generators
49
49
  */
@@ -71,8 +71,8 @@ Object.defineProperty(exports, "validateDependency", { enumerable: true, get: fu
71
71
  */
72
72
  var json_1 = require("./generators/utils/json");
73
73
  Object.defineProperty(exports, "readJson", { enumerable: true, get: function () { return json_1.readJson; } });
74
- Object.defineProperty(exports, "writeJson", { enumerable: true, get: function () { return json_1.writeJson; } });
75
74
  Object.defineProperty(exports, "updateJson", { enumerable: true, get: function () { return json_1.updateJson; } });
75
+ Object.defineProperty(exports, "writeJson", { enumerable: true, get: function () { return json_1.writeJson; } });
76
76
  /**
77
77
  * @category Utils
78
78
  */
@@ -124,6 +124,9 @@ Object.defineProperty(exports, "getOutputsForTargetAndConfiguration", { enumerab
124
124
  */
125
125
  var default_tasks_runner_1 = require("./tasks-runner/default-tasks-runner");
126
126
  Object.defineProperty(exports, "defaultTasksRunner", { enumerable: true, get: function () { return default_tasks_runner_1.defaultTasksRunner; } });
127
+ /**
128
+ * @category Utils
129
+ */
127
130
  var file_hasher_1 = require("./hasher/file-hasher");
128
131
  Object.defineProperty(exports, "hashArray", { enumerable: true, get: function () { return file_hasher_1.hashArray; } });
129
132
  /**
Binary file
@@ -1,4 +1,4 @@
1
- import { CreateDependencies, CreateNodesV2 } from '../../project-graph/plugins';
1
+ import { CreateDependencies, CreateNodes } from '../../project-graph/plugins';
2
2
  export declare const name = "nx/js/dependencies-and-lockfile";
3
- export declare const createNodesV2: CreateNodesV2;
3
+ export declare const createNodes: CreateNodes;
4
4
  export declare const createDependencies: CreateDependencies;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDependencies = exports.createNodesV2 = exports.name = void 0;
3
+ exports.createDependencies = exports.createNodes = exports.name = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const perf_hooks_1 = require("perf_hooks");
@@ -8,10 +8,10 @@ const file_hasher_1 = require("../../hasher/file-hasher");
8
8
  const plugins_1 = require("../../project-graph/plugins");
9
9
  const cache_directory_1 = require("../../utils/cache-directory");
10
10
  const globs_1 = require("../../utils/globs");
11
- const package_manager_1 = require("../../utils/package-manager");
12
- const versions_1 = require("../../utils/versions");
13
11
  const logger_1 = require("../../utils/logger");
12
+ const package_manager_1 = require("../../utils/package-manager");
14
13
  const plugin_cache_utils_1 = require("../../utils/plugin-cache-utils");
14
+ const versions_1 = require("../../utils/versions");
15
15
  const workspace_root_1 = require("../../utils/workspace-root");
16
16
  const bun_parser_1 = require("./lock-file/bun-parser");
17
17
  const lock_file_1 = require("./lock-file/lock-file");
@@ -21,7 +21,7 @@ exports.name = 'nx/js/dependencies-and-lockfile';
21
21
  // Separate in-memory caches
22
22
  let cachedExternalNodes;
23
23
  let cachedKeyMap;
24
- exports.createNodesV2 = [
24
+ exports.createNodes = [
25
25
  (0, globs_1.combineGlobPatterns)(lock_file_1.LOCKFILES),
26
26
  (files, _, context) => {
27
27
  return (0, plugins_1.createNodesFromFiles)(internalCreateNodes, files, _, context);
@@ -3,15 +3,20 @@
3
3
  * It encapsulates the package manager specific logic and implementation details.
4
4
  */
5
5
  import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
6
- import { CreateDependenciesContext, CreateNodesContextV2 } from '../../../project-graph/plugins';
6
+ import { CreateDependenciesContext, CreateNodesContext } from '../../../project-graph/plugins';
7
7
  import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
8
8
  import { PackageJson } from '../../../utils/package-json';
9
9
  import { PackageManager } from '../../../utils/package-manager';
10
10
  export declare const LOCKFILES: string[];
11
+ export declare const AUTO_AFFECTED_LOCK_FILES: readonly ["yarn.lock", "package-lock.json", "pnpm-lock.yaml", "pnpm-lock.yml", "bun.lockb", "bun.lock"];
11
12
  /**
12
13
  * Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
13
14
  */
14
- export declare function getLockFileNodes(packageManager: PackageManager, contents: string, lockFileHash: string, context: CreateNodesContextV2): {
15
+ export declare function getLockFileNodes(packageManager: PackageManager, contents: string, lockFileHash: string, context: CreateNodesContext): {
16
+ nodes: Record<string, ProjectGraphExternalNode>;
17
+ keyMap: Map<string, any>;
18
+ };
19
+ export declare function getLockFileNodesForName(lockFile: string, contents: string, lockFileHash: string, packageJson?: PackageJson): {
15
20
  nodes: Record<string, ProjectGraphExternalNode>;
16
21
  keyMap: Map<string, any>;
17
22
  };
@@ -4,8 +4,9 @@
4
4
  * It encapsulates the package manager specific logic and implementation details.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.LOCKFILES = void 0;
7
+ exports.AUTO_AFFECTED_LOCK_FILES = exports.LOCKFILES = void 0;
8
8
  exports.getLockFileNodes = getLockFileNodes;
9
+ exports.getLockFileNodesForName = getLockFileNodesForName;
9
10
  exports.getLockFileDependencies = getLockFileDependencies;
10
11
  exports.lockFileExists = lockFileExists;
11
12
  exports.getLockFileName = getLockFileName;
@@ -28,6 +29,7 @@ const yarn_parser_1 = require("./yarn-parser");
28
29
  const YARN_LOCK_FILE = 'yarn.lock';
29
30
  const NPM_LOCK_FILE = 'package-lock.json';
30
31
  const PNPM_LOCK_FILE = 'pnpm-lock.yaml';
32
+ const PNPM_LOCK_FILE_LEGACY = 'pnpm-lock.yml';
31
33
  exports.LOCKFILES = [
32
34
  YARN_LOCK_FILE,
33
35
  NPM_LOCK_FILE,
@@ -35,6 +37,14 @@ exports.LOCKFILES = [
35
37
  bun_parser_1.BUN_LOCK_FILE,
36
38
  bun_parser_1.BUN_TEXT_LOCK_FILE,
37
39
  ];
40
+ exports.AUTO_AFFECTED_LOCK_FILES = [
41
+ YARN_LOCK_FILE,
42
+ NPM_LOCK_FILE,
43
+ PNPM_LOCK_FILE,
44
+ PNPM_LOCK_FILE_LEGACY,
45
+ bun_parser_1.BUN_LOCK_FILE,
46
+ bun_parser_1.BUN_TEXT_LOCK_FILE,
47
+ ];
38
48
  const YARN_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, YARN_LOCK_FILE);
39
49
  const NPM_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, NPM_LOCK_FILE);
40
50
  const PNPM_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, PNPM_LOCK_FILE);
@@ -45,29 +55,10 @@ const BUN_TEXT_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot,
45
55
  */
46
56
  function getLockFileNodes(packageManager, contents, lockFileHash, context) {
47
57
  try {
48
- if (packageManager === 'yarn') {
49
- const packageJson = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(context.workspaceRoot, 'package.json'));
50
- return (0, yarn_parser_1.getYarnLockfileNodes)(contents, lockFileHash, packageJson);
51
- }
52
- if (packageManager === 'pnpm') {
53
- return (0, pnpm_parser_1.getPnpmLockfileNodes)(contents, lockFileHash);
54
- }
55
- if (packageManager === 'npm') {
56
- return (0, npm_parser_1.getNpmLockfileNodes)(contents, lockFileHash);
57
- }
58
- if (packageManager === 'bun') {
59
- const lockFilePath = getLockFilePath(packageManager);
60
- if (lockFilePath.endsWith(bun_parser_1.BUN_TEXT_LOCK_FILE)) {
61
- // Use new text-based parser
62
- const nodes = (0, bun_parser_1.getBunTextLockfileNodes)(contents, lockFileHash);
63
- return { nodes, keyMap: new Map() };
64
- }
65
- else {
66
- // Fallback to yarn parser for binary format
67
- const packageJson = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(context.workspaceRoot, 'package.json'));
68
- return (0, yarn_parser_1.getYarnLockfileNodes)(contents, lockFileHash, packageJson);
69
- }
70
- }
58
+ const packageJson = packageManager === 'yarn' || packageManager === 'bun'
59
+ ? (0, fileutils_1.readJsonFile)((0, node_path_1.join)(context.workspaceRoot, 'package.json'))
60
+ : undefined;
61
+ return getLockFileNodesForName(getLockFileName(packageManager), contents, lockFileHash, packageJson);
71
62
  }
72
63
  catch (e) {
73
64
  if (!isPostInstallProcess()) {
@@ -80,6 +71,25 @@ function getLockFileNodes(packageManager, contents, lockFileHash, context) {
80
71
  }
81
72
  throw new Error(`Unknown package manager: ${packageManager}`);
82
73
  }
74
+ function getLockFileNodesForName(lockFile, contents, lockFileHash, packageJson) {
75
+ if (lockFile === YARN_LOCK_FILE || lockFile === bun_parser_1.BUN_LOCK_FILE) {
76
+ // yarn-parser only reads optional fields plus an unused `name` for the
77
+ // synthetic root workspace node, which is identical across base/head and
78
+ // therefore irrelevant for affected diffing.
79
+ return (0, yarn_parser_1.getYarnLockfileNodes)(contents, lockFileHash, packageJson ?? {});
80
+ }
81
+ if (lockFile === PNPM_LOCK_FILE || lockFile === PNPM_LOCK_FILE_LEGACY) {
82
+ return (0, pnpm_parser_1.getPnpmLockfileNodes)(contents, lockFileHash);
83
+ }
84
+ if (lockFile === NPM_LOCK_FILE) {
85
+ return (0, npm_parser_1.getNpmLockfileNodes)(contents, lockFileHash);
86
+ }
87
+ if (lockFile === bun_parser_1.BUN_TEXT_LOCK_FILE) {
88
+ const nodes = (0, bun_parser_1.getBunTextLockfileNodes)(contents, lockFileHash);
89
+ return { nodes, keyMap: new Map() };
90
+ }
91
+ throw new Error(`Unknown lock file: ${lockFile}`);
92
+ }
83
93
  /**
84
94
  * Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
85
95
  */
@@ -233,7 +243,7 @@ function createLockFile(packageJson, graph, packageManager = (0, package_manager
233
243
  additionalInfo.push('If you run `pnpm install --lockfile-only` in your output folder it will regenerate the correct pruned lockfile.');
234
244
  }
235
245
  output_1.output.error({
236
- title: 'An error occured while creating pruned lockfile',
246
+ title: 'An error occurred while creating pruned lockfile',
237
247
  bodyLines: errorBodyLines(e, additionalInfo),
238
248
  });
239
249
  }
@@ -1,5 +1,3 @@
1
1
  import { TouchedProjectLocator } from '../../../../project-graph/affected/affected-project-graph-models';
2
- import { WholeFileChange } from '../../../../project-graph/file-utils';
3
- import { JsonChange } from '../../../../utils/json-diff';
4
- export declare const PNPM_LOCK_FILES: string[];
5
- export declare const getTouchedProjectsFromLockFile: TouchedProjectLocator<WholeFileChange | JsonChange>;
2
+ import { LockFileChange, WholeFileChange } from '../../../../project-graph/file-utils';
3
+ export declare const getTouchedProjectsFromLockFile: TouchedProjectLocator<WholeFileChange | LockFileChange>;
@@ -1,26 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTouchedProjectsFromLockFile = exports.PNPM_LOCK_FILES = void 0;
4
- const configuration_1 = require("../../../../config/configuration");
5
- const json_diff_1 = require("../../../../utils/json-diff");
3
+ exports.getTouchedProjectsFromLockFile = void 0;
4
+ const file_utils_1 = require("../../../../project-graph/file-utils");
6
5
  const config_1 = require("../../utils/config");
7
6
  const find_matching_projects_1 = require("../../../../utils/find-matching-projects");
8
- exports.PNPM_LOCK_FILES = ['pnpm-lock.yaml', 'pnpm-lock.yml'];
9
- const ALL_LOCK_FILES = [
10
- ...exports.PNPM_LOCK_FILES,
11
- 'package-lock.json',
12
- 'yarn.lock',
13
- 'bun.lockb',
14
- 'bun.lock',
15
- ];
16
- const getTouchedProjectsFromLockFile = (fileChanges, projectGraphNodes) => {
17
- const nxJson = (0, configuration_1.readNxJson)();
7
+ const file_hasher_1 = require("../../../../hasher/file-hasher");
8
+ const output_1 = require("../../../../utils/output");
9
+ const lock_file_1 = require("../../lock-file/lock-file");
10
+ const getTouchedProjectsFromLockFile = (fileChanges, projectGraphNodes, nxJson, packageJson, projectGraph) => {
18
11
  const { projectsAffectedByDependencyUpdates } = (0, config_1.jsPluginConfig)(nxJson);
19
- const changedLockFile = fileChanges.find((f) => ALL_LOCK_FILES.includes(f.file));
12
+ const changedLockFile = fileChanges.find((f) => lock_file_1.AUTO_AFFECTED_LOCK_FILES.includes(f.file));
20
13
  if (projectsAffectedByDependencyUpdates === 'auto') {
21
- const changedProjectPaths = getProjectPathsAffectedByDependencyUpdates(changedLockFile);
22
- const changedProjectNames = getProjectsNamesFromPaths(projectGraphNodes, changedProjectPaths);
23
- return changedProjectNames;
14
+ return getAutoAffected(changedLockFile, projectGraphNodes, projectGraph, packageJson);
24
15
  }
25
16
  else if (Array.isArray(projectsAffectedByDependencyUpdates)) {
26
17
  return (0, find_matching_projects_1.findMatchingProjects)(projectsAffectedByDependencyUpdates, projectGraphNodes);
@@ -32,41 +23,128 @@ const getTouchedProjectsFromLockFile = (fileChanges, projectGraphNodes) => {
32
23
  };
33
24
  exports.getTouchedProjectsFromLockFile = getTouchedProjectsFromLockFile;
34
25
  /**
35
- * For pnpm projects, check lock file for changes to importers and return the project paths that have changes.
26
+ * In auto mode, parse the lock file at the base and head revisions
27
+ * using Nx's existing lock file parsers, then diff the resulting
28
+ * external-node maps to determine which packages actually changed.
29
+ *
30
+ * Returns external node names (e.g. "npm:lodash@4.17.21") so the
31
+ * graph reversal in filterAffected can walk back to workspace projects.
36
32
  */
37
- const getProjectPathsAffectedByDependencyUpdates = (changedLockFile) => {
33
+ function getAutoAffected(changedLockFile, projectGraphNodes, projectGraph, packageJson) {
34
+ const allProjectNames = Object.values(projectGraphNodes).map((p) => p.name);
38
35
  if (!changedLockFile) {
39
36
  return [];
40
37
  }
41
- const changedProjectPaths = new Set();
42
- if (exports.PNPM_LOCK_FILES.includes(changedLockFile.file)) {
43
- for (const change of changedLockFile.getChanges()) {
44
- if ((0, json_diff_1.isJsonChange)(change) &&
45
- change.path[0] === 'importers' &&
46
- change.path[1] !== undefined) {
47
- changedProjectPaths.add(change.path[1]);
38
+ const changes = changedLockFile.getChanges();
39
+ // A WholeFileChange means we were unable to read both revisions of
40
+ // the lock file (e.g. missing base revision, git error). Fall back
41
+ // to marking all projects affected.
42
+ if (!changes.every(file_utils_1.isLockFileChange)) {
43
+ return allProjectNames;
44
+ }
45
+ const changedPackageNames = getChangedPackageNames(changedLockFile.file, changes, packageJson);
46
+ if (changedPackageNames === null) {
47
+ return allProjectNames;
48
+ }
49
+ if (changedPackageNames.size === 0) {
50
+ return [];
51
+ }
52
+ // Look up the changed packages in the project graph's external nodes
53
+ // and return the external node names. The graph reversal in
54
+ // filterAffected walks from these nodes to workspace projects.
55
+ const { touchedNodeNames, missingPackageNames } = findExternalNodesByPackageName(changedPackageNames, projectGraph.externalNodes ?? {});
56
+ if (missingPackageNames.size > 0) {
57
+ return allProjectNames;
58
+ }
59
+ return touchedNodeNames;
60
+ }
61
+ /**
62
+ * Parse the base and head revisions of the lock file with Nx's
63
+ * existing parsers and diff the resulting package -> version maps.
64
+ *
65
+ * Returns the set of changed package names, or null if parsing
66
+ * failed (in which case the caller should fall back to all projects).
67
+ */
68
+ function getChangedPackageNames(file, changes, packageJson) {
69
+ try {
70
+ const changed = new Set();
71
+ // calculateFileChanges emits a single LockFileChange per lock file, but
72
+ // the iteration keeps the contract open in case multiple ranges are ever
73
+ // emitted for the same file.
74
+ for (const change of changes) {
75
+ const baseFingerprints = collectPackageFingerprints((0, lock_file_1.getLockFileNodesForName)(file, change.baseContent, (0, file_hasher_1.hashArray)([change.baseContent]), packageJson).nodes);
76
+ const headFingerprints = collectPackageFingerprints((0, lock_file_1.getLockFileNodesForName)(file, change.headContent, (0, file_hasher_1.hashArray)([change.headContent]), packageJson).nodes);
77
+ for (const [name, fingerprints] of headFingerprints) {
78
+ const baseSet = baseFingerprints.get(name);
79
+ if (!baseSet || !setsEqual(baseSet, fingerprints)) {
80
+ changed.add(name);
81
+ }
82
+ }
83
+ for (const name of baseFingerprints.keys()) {
84
+ if (!headFingerprints.has(name)) {
85
+ changed.add(name);
86
+ }
48
87
  }
49
88
  }
89
+ return changed;
50
90
  }
51
- return Array.from(changedProjectPaths);
52
- };
53
- const getProjectsNamesFromPaths = (projectGraphNodes, projectPaths) => {
54
- if (!projectPaths.length) {
55
- return [];
91
+ catch (e) {
92
+ output_1.output.warn({
93
+ title: `Failed to parse "${file}" for projectsAffectedByDependencyUpdates "auto" mode. All projects will be marked as affected.`,
94
+ bodyLines: [e instanceof Error ? e.message : String(e)],
95
+ });
96
+ return null;
56
97
  }
57
- const lookup = new RootPathLookup(projectGraphNodes);
58
- return projectPaths
59
- .map((path) => lookup.findNodeNameByRoot(path))
60
- .filter(Boolean);
61
- };
62
- class RootPathLookup {
63
- constructor(nodes) {
64
- this.rootToNameMap = new Map();
65
- Object.entries(nodes).forEach(([name, node]) => {
66
- this.rootToNameMap.set(node.data.root, name);
98
+ }
99
+ /**
100
+ * Build a map of packageName -> set of versions present in the
101
+ * external-node record returned by a lock-file parser. We include both
102
+ * version and hash so patched/tarball/integrity-only changes still
103
+ * count as lockfile changes even when the semver stays the same.
104
+ */
105
+ function collectPackageFingerprints(nodes) {
106
+ const fingerprints = new Map();
107
+ for (const node of Object.values(nodes ?? {})) {
108
+ const name = node.data?.packageName;
109
+ if (!name)
110
+ continue;
111
+ const fingerprint = JSON.stringify({
112
+ version: node.data.version ?? '',
113
+ hash: node.data.hash ?? '',
67
114
  });
115
+ let set = fingerprints.get(name);
116
+ if (!set) {
117
+ set = new Set();
118
+ fingerprints.set(name, set);
119
+ }
120
+ set.add(fingerprint);
68
121
  }
69
- findNodeNameByRoot(root) {
70
- return this.rootToNameMap.get(root);
122
+ return fingerprints;
123
+ }
124
+ function setsEqual(a, b) {
125
+ if (a.size !== b.size)
126
+ return false;
127
+ for (const value of a) {
128
+ if (!b.has(value))
129
+ return false;
130
+ }
131
+ return true;
132
+ }
133
+ /**
134
+ * Given a set of package names, find all matching external node names
135
+ * in the project graph.
136
+ */
137
+ function findExternalNodesByPackageName(packageNames, externalNodes) {
138
+ const touchedNodeNames = [];
139
+ const matchedPackageNames = new Set();
140
+ for (const [name, node] of Object.entries(externalNodes)) {
141
+ if (packageNames.has(node.data.packageName)) {
142
+ touchedNodeNames.push(name);
143
+ matchedPackageNames.add(node.data.packageName);
144
+ }
71
145
  }
146
+ return {
147
+ touchedNodeNames,
148
+ missingPackageNames: new Set(Array.from(packageNames).filter((name) => !matchedPackageNames.has(name))),
149
+ };
72
150
  }
@@ -23,6 +23,58 @@ import type { CompilerOptions } from 'typescript';
23
23
  * Throws if neither `@swc-node/register` nor `ts-node` is installed.
24
24
  */
25
25
  export declare function forceRegisterEsmLoader(): void;
26
+ /**
27
+ * Source of a minimal ESM resolution hook that rewrites TypeScript NodeNext
28
+ * `.js`/`.mjs`/`.cjs` relative specifiers to their `.ts`/`.mts`/`.cts` sources.
29
+ * Inlined as a string so it can be registered as a self-contained `data:`
30
+ * module - it relies only on Node's default resolver (no ts-node/swc-node) and
31
+ * defers loading to Node's native TypeScript stripping. The ESM counterpart to
32
+ * the CJS `ensureCjsResolverPatched`.
33
+ *
34
+ * Only rewrites when the default resolution fails with ERR_MODULE_NOT_FOUND,
35
+ * the importing module is itself TypeScript, and the specifier is relative, so
36
+ * it never hijacks resolution that would otherwise succeed.
37
+ *
38
+ * Exported so the hook can be exercised directly in unit tests.
39
+ */
40
+ export declare const NODENEXT_ESM_RESOLVER_SOURCE = "\nconst EXT_FALLBACK = { '.js': ['.ts', '.tsx'], '.mjs': ['.mts'], '.cjs': ['.cts'] };\nconst TS_PARENT_RE = /\\.(?:ts|tsx|mts|cts)(?:$|\\?)/;\nexport async function resolve(specifier, context, nextResolve) {\n try {\n return await nextResolve(specifier, context);\n } catch (err) {\n if (err?.code !== 'ERR_MODULE_NOT_FOUND') throw err;\n const parent = context.parentURL;\n if (!parent || !TS_PARENT_RE.test(parent)) throw err;\n if (!(specifier.startsWith('./') || specifier.startsWith('../') || specifier.startsWith('file:'))) throw err;\n const m = specifier.match(/(\\.(?:js|mjs|cjs))($|\\?)/);\n if (!m) throw err;\n const fallbacks = EXT_FALLBACK[m[1]];\n if (!fallbacks) throw err;\n const base = specifier.slice(0, m.index);\n const suffix = specifier.slice(m.index + m[1].length);\n for (const ext of fallbacks) {\n try { return await nextResolve(base + ext + suffix, context); } catch {}\n }\n throw err;\n }\n}\n";
41
+ /**
42
+ * Register a self-contained ESM resolution hook (via `Module.register`) that
43
+ * rewrites TypeScript NodeNext-style `.js`/`.mjs`/`.cjs` relative specifiers to
44
+ * their `.ts`/`.mts`/`.cts` sources. This is the ESM counterpart to
45
+ * `ensureCjsResolverPatched`: Node's native type stripping loads the `.ts`
46
+ * file, but neither native strip nor Node's ESM resolver rewrites the
47
+ * extension, so `import './foo.js'` from a `.ts` source where only `foo.ts`
48
+ * exists fails with ERR_MODULE_NOT_FOUND without it.
49
+ *
50
+ * The hook is inlined as a `data:` module (see `NODENEXT_ESM_RESOLVER_SOURCE`)
51
+ * and relies only on Node's default resolver, so it needs no ts-node/swc-node.
52
+ *
53
+ * Idempotent and best-effort: a no-op when `Module.register` is unavailable,
54
+ * when a TypeScript transpiler is already preloaded (see
55
+ * `isTsTranspilerPreloaded`), or if registration fails.
56
+ */
57
+ export declare function ensureNodeNextEsmResolverRegistered(): void;
58
+ /**
59
+ * Patches Node's CJS resolver to fall back from `.js`/`.mjs`/`.cjs` to the
60
+ * corresponding TypeScript source extension (`.ts`/`.tsx`, `.mts`, `.cts`)
61
+ * when the requesting file is itself a `.ts`/`.tsx`/`.mts`/`.cts` source.
62
+ *
63
+ * Required for TypeScript NodeNext-style relative imports: `import './foo.js'`
64
+ * inside a `.ts` file resolves to `./foo.ts` at compile time, but the `.js`
65
+ * specifier survives transpilation to CJS. Node's native CJS resolver doesn't
66
+ * rewrite extensions and there is no officially-supported Node API for this —
67
+ * Node's native strip-types deliberately doesn't either — so a resolver patch
68
+ * is the prevailing solution in the ecosystem (used by `tsx` and ts-node's
69
+ * `experimentalResolver`).
70
+ *
71
+ * Patches `Module._resolveFilename` (not `_findPath`, matching tsx's narrower
72
+ * surface). Gates on the requesting file being TS so vanilla `.js` code
73
+ * requesting missing `.js` files keeps failing — no silent hijack. Only fires
74
+ * the fallback on `MODULE_NOT_FOUND` so existing `.js` resolution is
75
+ * unaffected when both files exist. Idempotent on repeat calls.
76
+ */
77
+ export declare function ensureCjsResolverPatched(): void;
26
78
  /**
27
79
  * Whether Nx will defer to Node's native TypeScript stripping for the next
28
80
  * `.ts` load. Mirrors the gate used by `loadTsFile`/`registerTsProject` so