nx 23.3.0-beta.0 → 23.3.0-beta.2

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 (184) hide show
  1. package/dist/src/command-line/format/format.js +2 -18
  2. package/dist/src/command-line/graph/graph.js +42 -3
  3. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
  4. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
  5. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
  6. package/dist/src/command-line/init/implementation/angular/index.js +0 -3
  7. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
  8. package/dist/src/command-line/init/implementation/format.js +2 -3
  9. package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
  10. package/dist/src/command-line/init/implementation/utils.js +0 -8
  11. package/dist/src/command-line/init/init-v2.js +0 -3
  12. package/dist/src/command-line/migrate/agentic/definitions.js +75 -19
  13. package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
  14. package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
  15. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
  16. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
  17. package/dist/src/command-line/migrate/agentic/handoff.d.ts +27 -17
  18. package/dist/src/command-line/migrate/agentic/handoff.js +107 -24
  19. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +21 -0
  20. package/dist/src/command-line/migrate/agentic/instruction-files.js +36 -0
  21. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +16 -0
  22. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +70 -0
  23. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
  24. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
  25. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
  26. package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
  27. package/dist/src/command-line/migrate/agentic/runner.d.ts +17 -8
  28. package/dist/src/command-line/migrate/agentic/runner.js +110 -55
  29. package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
  30. package/dist/src/command-line/migrate/agentic/types.js +10 -7
  31. package/dist/src/command-line/migrate/migrate-commits.d.ts +1 -0
  32. package/dist/src/command-line/migrate/migrate-commits.js +9 -0
  33. package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
  34. package/dist/src/command-line/migrate/migrate-output.js +3 -7
  35. package/dist/src/command-line/migrate/migrate.js +21 -8
  36. package/dist/src/command-line/migrate/run/agent-output.d.ts +10 -0
  37. package/dist/src/command-line/migrate/run/agent-output.js +16 -2
  38. package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
  39. package/dist/src/command-line/migrate/run/agent-work-payload.js +142 -0
  40. package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
  41. package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
  42. package/dist/src/command-line/migrate/run/index.d.ts +1 -1
  43. package/dist/src/command-line/migrate/run/issues.d.ts +106 -0
  44. package/dist/src/command-line/migrate/run/issues.js +980 -0
  45. package/dist/src/command-line/migrate/run/orchestrator.d.ts +1 -0
  46. package/dist/src/command-line/migrate/run/orchestrator.js +662 -105
  47. package/dist/src/command-line/migrate/run/run-state.d.ts +43 -8
  48. package/dist/src/command-line/migrate/run/run-state.js +184 -20
  49. package/dist/src/command-line/migrate/run/runbook.d.ts +17 -0
  50. package/dist/src/command-line/migrate/run/runbook.js +97 -0
  51. package/dist/src/command-line/migrate/run/state-lock.d.ts +2 -2
  52. package/dist/src/command-line/migrate/run/state-lock.js +2 -2
  53. package/dist/src/command-line/migrate/run/state-machine.d.ts +5 -1
  54. package/dist/src/command-line/migrate/run/state-machine.js +27 -1
  55. package/dist/src/command-line/migrate/run/worker.js +206 -56
  56. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
  57. package/dist/src/command-line/release/publish.js +11 -4
  58. package/dist/src/command-line/release/utils/remote-release-clients/github.js +3 -3
  59. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
  60. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +2 -0
  61. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +35 -0
  62. package/dist/src/command-line/report/report.d.ts +2 -0
  63. package/dist/src/command-line/report/report.js +28 -1
  64. package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
  65. package/dist/src/command-line/yargs-utils/shared-options.js +22 -4
  66. package/dist/src/config/workspace-json-project-json.d.ts +2 -0
  67. package/dist/src/core/graph/main.js +1 -1
  68. package/dist/src/daemon/client/client.d.ts +6 -2
  69. package/dist/src/daemon/client/client.js +27 -11
  70. package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
  71. package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
  72. package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
  73. package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
  74. package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
  75. package/dist/src/daemon/server/handle-hash-tasks.d.ts +8 -2
  76. package/dist/src/daemon/server/handle-hash-tasks.js +16 -3
  77. package/dist/src/daemon/server/handle-outputs-changes.d.ts +2 -2
  78. package/dist/src/daemon/server/handle-outputs-changes.js +21 -6
  79. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
  80. package/dist/src/daemon/server/outputs-tracking.d.ts +6 -0
  81. package/dist/src/daemon/server/outputs-tracking.js +18 -0
  82. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
  83. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +100 -70
  84. package/dist/src/daemon/server/restart-checks.d.ts +22 -0
  85. package/dist/src/daemon/server/restart-checks.js +77 -0
  86. package/dist/src/daemon/server/server.js +33 -18
  87. package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
  88. package/dist/src/daemon/server/shutdown-utils.js +3 -26
  89. package/dist/src/hasher/hash-task.js +20 -16
  90. package/dist/src/hasher/native-task-hasher-impl.d.ts +8 -0
  91. package/dist/src/hasher/native-task-hasher-impl.js +46 -3
  92. package/dist/src/hasher/task-hasher.d.ts +9 -0
  93. package/dist/src/hasher/task-hasher.js +14 -0
  94. package/dist/src/native/index.d.ts +222 -21
  95. package/dist/src/native/index.js +3 -3
  96. package/dist/src/native/native-bindings.js +4 -1
  97. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  98. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  99. package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
  100. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
  101. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
  102. package/dist/src/plugins/js/utils/register.js +2 -1
  103. package/dist/src/project-graph/affected/locators/project-glob-changes.js +19 -26
  104. package/dist/src/project-graph/error-types.d.ts +5 -0
  105. package/dist/src/project-graph/error-types.js +44 -5
  106. package/dist/src/project-graph/file-utils.d.ts +2 -0
  107. package/dist/src/project-graph/file-utils.js +6 -1
  108. package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
  109. package/dist/src/project-graph/nx-deps-cache.js +4 -4
  110. package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
  111. package/dist/src/project-graph/plugins/get-plugins.js +60 -82
  112. package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
  113. package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
  114. package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
  115. package/dist/src/project-graph/plugins/isolation/index.js +3 -1
  116. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
  117. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
  118. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
  119. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
  120. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
  121. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
  122. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
  123. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
  124. package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
  125. package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
  126. package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
  127. package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
  128. package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
  129. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
  130. package/dist/src/project-graph/project-graph.js +43 -42
  131. package/dist/src/tasks-runner/batch/run-batch.js +15 -0
  132. package/dist/src/tasks-runner/cache.d.ts +35 -0
  133. package/dist/src/tasks-runner/cache.js +40 -0
  134. package/dist/src/tasks-runner/create-task-graph.js +1 -0
  135. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  136. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
  137. package/dist/src/tasks-runner/forked-process-task-runner.js +8 -7
  138. package/dist/src/tasks-runner/init-tasks-runner.js +5 -1
  139. package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
  140. package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
  141. package/dist/src/tasks-runner/life-cycle.js +7 -0
  142. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
  143. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
  144. package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
  145. package/dist/src/tasks-runner/prune-task-graph.js +45 -0
  146. package/dist/src/tasks-runner/run-command.js +14 -3
  147. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
  148. package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
  149. package/dist/src/tasks-runner/task-orchestrator.d.ts +64 -2
  150. package/dist/src/tasks-runner/task-orchestrator.js +232 -46
  151. package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
  152. package/dist/src/tasks-runner/terminal-output-path.js +18 -0
  153. package/dist/src/tasks-runner/utils.js +5 -2
  154. package/dist/src/utils/ab-testing.d.ts +4 -1
  155. package/dist/src/utils/ab-testing.js +11 -7
  156. package/dist/src/utils/chunkify.d.ts +1 -7
  157. package/dist/src/utils/chunkify.js +2 -8
  158. package/dist/src/utils/command-line-utils.d.ts +19 -0
  159. package/dist/src/utils/command-line-utils.js +10 -3
  160. package/dist/src/utils/formatters/index.d.ts +6 -0
  161. package/dist/src/utils/formatters/index.js +5 -0
  162. package/dist/src/utils/formatters/prettier.d.ts +0 -8
  163. package/dist/src/utils/formatters/prettier.js +4 -26
  164. package/dist/src/utils/handle-errors.js +5 -43
  165. package/dist/src/utils/installed-nx-version.js +2 -48
  166. package/dist/src/utils/min-release-age/packument.js +1 -1
  167. package/dist/src/utils/output.d.ts +22 -3
  168. package/dist/src/utils/output.js +28 -5
  169. package/dist/src/utils/package-json.d.ts +25 -0
  170. package/dist/src/utils/package-json.js +41 -6
  171. package/dist/src/utils/package-manager.d.ts +6 -0
  172. package/dist/src/utils/package-manager.js +10 -0
  173. package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
  174. package/dist/src/utils/provenance.js +20 -4
  175. package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
  176. package/dist/src/utils/workspace-context.d.ts +47 -3
  177. package/dist/src/utils/workspace-context.js +162 -10
  178. package/package.json +12 -13
  179. package/schemas/nx-schema.json +4 -0
  180. package/schemas/project-schema.json +4 -0
  181. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
  182. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
  183. package/dist/src/daemon/server/watcher.d.ts +0 -18
  184. package/dist/src/daemon/server/watcher.js +0 -126
@@ -8,9 +8,15 @@ const task_io_service_1 = require("../tasks-runner/task-io-service");
8
8
  const fileutils_1 = require("../utils/fileutils");
9
9
  class NativeTaskHasherImpl {
10
10
  constructor(workspaceRoot, nxJson, projectGraph, externals, options) {
11
+ /**
12
+ * Plans of the last up-front batch and the task graph they were built for.
13
+ * The tasks that batch deferred hash from them later without planning again.
14
+ */
15
+ this.upfrontPlans = null;
11
16
  this.projectGraphRef = (0, native_1.transferProjectGraph)((0, transform_objects_1.transformProjectGraphForRust)(projectGraph));
12
17
  this.allWorkspaceFilesRef = externals.allWorkspaceFiles;
13
18
  this.projectFileMapRef = externals.projectFiles;
19
+ this.ignoredIndexRef = externals.ignoredIndex;
14
20
  let tsconfig = {};
15
21
  let paths = {};
16
22
  let rootTsConfigPath = (0, typescript_1.getRootTsConfigPath)();
@@ -22,17 +28,54 @@ class NativeTaskHasherImpl {
22
28
  }
23
29
  }
24
30
  this.planner = new native_1.HashPlanner(nxJson, this.projectGraphRef);
25
- this.hasher = new native_1.TaskHasher(workspaceRoot, this.projectGraphRef, this.projectFileMapRef, this.allWorkspaceFilesRef, Buffer.from(JSON.stringify(tsconfig)), paths, rootTsConfigPath, options);
31
+ this.hasher = new native_1.TaskHasher(workspaceRoot, this.projectGraphRef, this.projectFileMapRef, this.allWorkspaceFilesRef, Buffer.from(JSON.stringify(tsconfig)), paths, rootTsConfigPath, options, this.ignoredIndexRef);
26
32
  }
27
33
  async hashTask(task, taskGraph, env, cwd, collectInputs) {
28
34
  const hashes = await this.hashTasks([task], taskGraph, { [task.id]: env }, cwd, collectInputs);
29
35
  return hashes[0];
30
36
  }
31
37
  async hashTasks(tasks, taskGraph, perTaskEnvs, cwd, collectInputs) {
32
- const plans = this.planner.getPlansReference(tasks.map((t) => t.id), taskGraph);
38
+ const envs = perTaskEnvs;
33
39
  const shouldCollectInputs = collectInputs ?? (0, task_io_service_1.getTaskIOService)().hasTaskInputSubscribers();
34
- const hashes = this.hasher.hashPlans(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs);
40
+ const resolvedCwd = cwd ?? process.cwd();
41
+ const hashes = {};
42
+ let unplanned = tasks.map((t) => t.id);
43
+ if (this.upfrontPlans &&
44
+ unplanned.some((id) => this.upfrontPlans.taskIds.has(id)) &&
45
+ this.upfrontPlans.fingerprint === taskGraphFingerprint(taskGraph)) {
46
+ Object.assign(hashes, this.hasher.hashPlansFor(this.upfrontPlans.plans, unplanned, envs, resolvedCwd, shouldCollectInputs));
47
+ unplanned = unplanned.filter((id) => !(id in hashes));
48
+ }
49
+ if (unplanned.length > 0) {
50
+ const plans = this.planner.getPlansReference(unplanned, taskGraph);
51
+ Object.assign(hashes, this.hasher.hashPlans(plans, envs, resolvedCwd, shouldCollectInputs));
52
+ }
35
53
  return tasks.map((t) => hashes[t.id]);
36
54
  }
55
+ async hashTasksUpfront(tasks, taskGraph, perTaskEnvs, cwd, collectInputs) {
56
+ const plans = this.planner.getPlansReference(tasks.map((t) => t.id), taskGraph);
57
+ this.upfrontPlans = {
58
+ fingerprint: taskGraphFingerprint(taskGraph),
59
+ taskIds: new Set(tasks.map((t) => t.id)),
60
+ plans,
61
+ };
62
+ const shouldCollectInputs = collectInputs ?? (0, task_io_service_1.getTaskIOService)().hasTaskInputSubscribers();
63
+ return this.hasher.hashPlansUpfront(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs);
64
+ }
37
65
  }
38
66
  exports.NativeTaskHasherImpl = NativeTaskHasherImpl;
67
+ /**
68
+ * Everything the planner reads from a task graph: each task's target and
69
+ * outputs, and the graph's edges. The project graph and nx.json are fixed for
70
+ * the life of a hasher, so equal fingerprints mean equal plans. A run's
71
+ * results (hash, timings) are left out so hashing one task does not
72
+ * invalidate the plans of the rest.
73
+ */
74
+ function taskGraphFingerprint(taskGraph) {
75
+ const parts = [];
76
+ for (const id of Object.keys(taskGraph.tasks).sort()) {
77
+ const task = taskGraph.tasks[id];
78
+ parts.push(id, task.target.project, task.target.target, task.target.configuration ?? '', (task.outputs ?? []).join(','), (taskGraph.dependencies[id] ?? []).join(','), (taskGraph.continuousDependencies[id] ?? []).join(','));
79
+ }
80
+ return (0, native_1.hashArray)(parts);
81
+ }
@@ -60,6 +60,12 @@ export interface TaskHasher {
60
60
  * tasks actually differ.
61
61
  */
62
62
  hashTasks(tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>, cwd?: string): Promise<Hash[]>;
63
+ /**
64
+ * Hash the tasks whose hash needs no output of another task, keyed by
65
+ * task id. A task absent from the result hashes once the tasks it reads
66
+ * from have run.
67
+ */
68
+ hashTasksUpfront(tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>, cwd?: string): Promise<Record<string, Hash>>;
63
69
  }
64
70
  export interface TaskHasherImpl {
65
71
  /**
@@ -70,6 +76,7 @@ export interface TaskHasherImpl {
70
76
  */
71
77
  hashTasks(tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>, cwd?: string, collectInputs?: boolean): Promise<PartialHash[]>;
72
78
  hashTask(task: Task, taskGraph: TaskGraph, env: NodeJS.ProcessEnv, cwd?: string, collectInputs?: boolean): Promise<PartialHash>;
79
+ hashTasksUpfront(tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>, cwd?: string, collectInputs?: boolean): Promise<Record<string, PartialHash>>;
73
80
  }
74
81
  export type Hasher = TaskHasher;
75
82
  export declare class DaemonBasedTaskHasher implements TaskHasher {
@@ -77,6 +84,7 @@ export declare class DaemonBasedTaskHasher implements TaskHasher {
77
84
  private readonly runnerOptions;
78
85
  constructor(daemonClient: DaemonClient, runnerOptions: any);
79
86
  hashTasks(tasks: Task[], taskGraph: TaskGraph, envOrPerTaskEnvs: NodeJS.ProcessEnv | Record<string, NodeJS.ProcessEnv>): Promise<Hash[]>;
87
+ hashTasksUpfront(tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>): Promise<Record<string, Hash>>;
80
88
  hashTask(task: Task, taskGraph?: TaskGraph, env?: NodeJS.ProcessEnv): Promise<Hash>;
81
89
  }
82
90
  export declare class InProcessTaskHasher implements TaskHasher {
@@ -87,6 +95,7 @@ export declare class InProcessTaskHasher implements TaskHasher {
87
95
  private taskHasher;
88
96
  constructor(projectGraph: ProjectGraph, nxJson: NxJsonConfiguration, externalRustReferences: NxWorkspaceFilesExternals | null, options: any);
89
97
  hashTasks(tasks: Task[], taskGraph: TaskGraph, envOrPerTaskEnvs: NodeJS.ProcessEnv | Record<string, NodeJS.ProcessEnv>, cwd?: string, collectInputs?: boolean): Promise<Hash[]>;
98
+ hashTasksUpfront(tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>, cwd?: string, collectInputs?: boolean): Promise<Record<string, Hash>>;
90
99
  hashTask(task: Task, taskGraph?: TaskGraph, env?: NodeJS.ProcessEnv, cwd?: string, collectInputs?: boolean): Promise<Hash>;
91
100
  private createHashDetails;
92
101
  private hashCommand;
@@ -52,6 +52,10 @@ class DaemonBasedTaskHasher {
52
52
  const collectInputs = (0, task_io_service_1.getTaskIOService)().hasTaskInputSubscribers();
53
53
  return this.daemonClient.hashTasks(this.runnerOptions, tasks, taskGraph, normalizePerTaskEnvs(tasks, envOrPerTaskEnvs), process.cwd(), collectInputs);
54
54
  }
55
+ async hashTasksUpfront(tasks, taskGraph, perTaskEnvs) {
56
+ const collectInputs = (0, task_io_service_1.getTaskIOService)().hasTaskInputSubscribers();
57
+ return this.daemonClient.hashTasksUpfront(this.runnerOptions, tasks, taskGraph, perTaskEnvs, process.cwd(), collectInputs);
58
+ }
55
59
  async hashTask(task, taskGraph, env) {
56
60
  return (await this.hashTasks([task], taskGraph, {
57
61
  [task.id]: env ?? process.env,
@@ -73,6 +77,16 @@ class InProcessTaskHasher {
73
77
  const hashes = await this.taskHasher.hashTasks(tasks, taskGraph, normalizePerTaskEnvs(tasks, envOrPerTaskEnvs), cwd ?? process.cwd(), collectInputs);
74
78
  return tasks.map((task, index) => this.createHashDetails(task, hashes[index]));
75
79
  }
80
+ async hashTasksUpfront(tasks, taskGraph, perTaskEnvs, cwd, collectInputs) {
81
+ const hashes = await this.taskHasher.hashTasksUpfront(tasks, taskGraph, perTaskEnvs, cwd ?? process.cwd(), collectInputs);
82
+ const result = {};
83
+ for (const task of tasks) {
84
+ if (hashes[task.id]) {
85
+ result[task.id] = this.createHashDetails(task, hashes[task.id]);
86
+ }
87
+ }
88
+ return result;
89
+ }
76
90
  async hashTask(task, taskGraph, env, cwd, collectInputs) {
77
91
  const res = await this.taskHasher.hashTask(task, taskGraph, env ?? process.env, cwd ?? process.cwd(), collectInputs);
78
92
  return this.createHashDetails(task, res);
@@ -75,6 +75,8 @@ export declare class FileLock {
75
75
  check(): boolean
76
76
  wait(): Promise<void>
77
77
  lock(): void
78
+ /** Takes the lock without blocking; false means another handle holds it. */
79
+ tryLock(): boolean
78
80
  }
79
81
 
80
82
  export declare class HashPlanInspector {
@@ -104,6 +106,14 @@ export declare class HttpRemoteCache {
104
106
  store(hash: string, cacheDirectory: string, terminalOutput: string, code: number): Promise<boolean>
105
107
  }
106
108
 
109
+ /**
110
+ * The hasher's handle on an index: lists only after catching up with the
111
+ * watch behind it.
112
+ */
113
+ export declare class IgnoredIndexReader {
114
+
115
+ }
116
+
107
117
  export declare class ImportResult {
108
118
  file: string
109
119
  sourceProject: string
@@ -122,6 +132,25 @@ export declare class NxCache {
122
132
  getBatch(hashes: Array<string>): Array<CachedResult | undefined | null>
123
133
  put(hash: string, terminalOutput: string, outputs: Array<string>, code: number): Array<string>
124
134
  applyRemoteCacheResults(hash: string, result: CachedResult, outputs?: Array<string> | undefined | null): void
135
+ /**
136
+ * Register terminal outputs that were written without a cache entry —
137
+ * uncacheable tasks, and cacheable ones run with `--skip-nx-cache`.
138
+ *
139
+ * Without a row the file is invisible to `remove_old_cache_records`,
140
+ * which only ever walks hashes it finds in the database, so these files
141
+ * would accumulate forever. The row carries `is_cache_entry = FALSE` so it
142
+ * can never be served as a cache hit.
143
+ *
144
+ * On conflict `accessed_at` always moves: the reads filter these rows out,
145
+ * so they would otherwise age from the first write and be collected out
146
+ * from under a task that is still being run daily. `size` moves only while
147
+ * the row is still output-only (`NOT is_cache_entry`), so a task rerun with
148
+ * a longer log stops undercounting against `maxCacheSize`. `is_cache_entry`
149
+ * is never touched, and a row that already has artifacts keeps the size
150
+ * `put` recorded, so a rewrite can neither demote a real entry nor replace
151
+ * its whole-entry size with the terminal output's.
152
+ */
153
+ recordTerminalOutputs(records: Array<TerminalOutputRecord>): void
125
154
  getTaskOutputsPath(hash: string): string
126
155
  getCacheSize(): number
127
156
  copyFilesFromCache(cachedResult: CachedResult, outputs: Array<string>): number
@@ -135,6 +164,16 @@ export declare class NxConsolePreferences {
135
164
  setAutoInstallPreference(autoInstall: boolean): void
136
165
  }
137
166
 
167
+ export declare class NxPluginCapabilities {
168
+ constructor(db: ExternalObject<NxDbConnection>)
169
+ record(computedAt: number, capabilities: Array<CachedPluginCapabilities>): void
170
+ /**
171
+ * The capabilities recorded with the graph computed at `computed_at`, or
172
+ * null when what is recorded belongs to another build or nothing is.
173
+ */
174
+ get(computedAt: number): Array<CachedPluginCapabilities> | null
175
+ }
176
+
138
177
  export declare class NxTaskHistory {
139
178
  constructor(db: ExternalObject<NxDbConnection>)
140
179
  recordTaskRuns(taskRuns: Array<TaskRun>): void
@@ -204,7 +243,7 @@ export declare class TaskDetails {
204
243
  }
205
244
 
206
245
  export declare class TaskHasher {
207
- constructor(workspaceRoot: string, projectGraph: ExternalObject<ProjectGraph>, projectFileMap: ExternalObject<Record<string, Array<FileData>>>, allWorkspaceFiles: ExternalObject<Array<FileData>>, tsConfig: Buffer, tsConfigPaths: Record<string, Array<string>>, rootTsconfigPath?: string | undefined | null, options?: HasherOptions | undefined | null)
246
+ constructor(workspaceRoot: string, projectGraph: ExternalObject<ProjectGraph>, projectFileMap: ExternalObject<Record<string, Array<FileData>>>, allWorkspaceFiles: ExternalObject<Array<FileData>>, tsConfig: Buffer, tsConfigPaths: Record<string, Array<string>>, rootTsconfigPath: string | undefined | null, options: HasherOptions | undefined | null, ignoredIndex: ExternalObject<IgnoredIndexReader>)
208
247
  /**
209
248
  * Hash each task's instructions using the env map keyed by `task.id`.
210
249
  * Every task in `hash_plans` must have an entry in `per_task_envs` —
@@ -214,6 +253,21 @@ export declare class TaskHasher {
214
253
  * every task id.
215
254
  */
216
255
  hashPlans(hashPlans: ExternalObject<Record<string, Array<HashInstruction>>>, perTaskEnvs: Record<string, Record<string, string>>, cwd: string, collectTaskInputs?: boolean | undefined | null): Record<string, HashDetails>
256
+ /**
257
+ * Like `hash_plans`, but only for the plans the planner did not defer
258
+ * (`HashPlans::deferred`: a task that reads another task's outputs, or a
259
+ * disk-backed fileset whose directory contains, or sits inside, an
260
+ * upstream task's output). The rest are left out and hash once those
261
+ * tasks have run; their ids are absent from the result and need no entry
262
+ * in `per_task_envs`.
263
+ */
264
+ hashPlansUpfront(hashPlans: ExternalObject<Record<string, Array<HashInstruction>>>, perTaskEnvs: Record<string, Record<string, string>>, cwd: string, collectTaskInputs?: boolean | undefined | null): Record<string, HashDetails>
265
+ /**
266
+ * Hashes `task_ids` from plans built earlier, so a task the up-front batch
267
+ * deferred needs no second planning pass. Ids without a plan are absent
268
+ * from the result.
269
+ */
270
+ hashPlansFor(hashPlans: ExternalObject<Record<string, Array<HashInstruction>>>, taskIds: Array<string>, perTaskEnvs: Record<string, Record<string, string>>, cwd: string, collectTaskInputs?: boolean | undefined | null): Record<string, HashDetails>
217
271
  }
218
272
 
219
273
  export declare class TaskInvocationTracker {
@@ -228,28 +282,39 @@ export declare class TaskInvocationTracker {
228
282
  cleanupStale(): void
229
283
  }
230
284
 
231
- export declare class Watcher {
232
- origin: string
285
+ export declare class WorkspaceContext {
286
+ workspaceRoot: string
287
+ constructor(workspaceRoot: string, cacheDir: string, options?: WorkspaceContextOptions | undefined | null)
233
288
  /**
234
- * Always applies HARDCODED_IGNORE_PATTERNS plus watcher-specific
235
- * patterns (vite/vitest timestamp files), regardless of `use_ignore`.
289
+ * Loads the files the last walk recorded instead of walking. For a
290
+ * process whose host already walked, such as a plugin worker.
236
291
  */
237
- constructor(origin: string, additionalGlobs?: Array<string> | undefined | null, useIgnore?: boolean | undefined | null)
238
- watch(callbackTsfn: (err: string | null, events: WatchEvent[]) => void): void
239
- stop(): Promise<void>
292
+ static fromArchive(workspaceRoot: string, cacheDir: string, options?: WorkspaceContextOptions | undefined | null): WorkspaceContext
240
293
  /**
241
- * Synchronously drains the accumulator. Used by the daemon before
242
- * serving a cached project graph so events buffered inside the
243
- * IDLE_WINDOW debounce don't go missing. Returns an empty vec if
244
- * the watcher hasn't started, the loop has exited, or no events
245
- * are buffered.
294
+ * Bumped once per applied batch that changed anything. Equal values
295
+ * mean equal files, so a consumer that remembers the value it computed
296
+ * from can skip recomputing.
246
297
  */
247
- forceFlushPending(): Array<WatchEvent>
248
- }
249
-
250
- export declare class WorkspaceContext {
251
- workspaceRoot: string
252
- constructor(workspaceRoot: string, cacheDir: string)
298
+ changeSeq(): number
299
+ /**
300
+ * Walks the workspace again into this context, so it and the archive
301
+ * include writes made since the last walk. Does nothing while a walk is
302
+ * in progress. Await `ready()` before reading. What the walk finds
303
+ * changed goes to the subscriber.
304
+ *
305
+ * For a graph built without the daemon, where nothing watches: see
306
+ * `refreshWorkspaceContext`, called by
307
+ * `buildProjectGraphAndSourceMapsWithoutDaemon`.
308
+ */
309
+ refresh(): boolean
310
+ /**
311
+ * Resolves once the files behind this context exist. The readers below
312
+ * block the calling thread until they do; awaiting this first keeps a
313
+ * plugin host responsive while its workers are connecting.
314
+ */
315
+ ready(): Promise<void>
316
+ /** On wasm the files are gathered when the context is constructed. */
317
+ ready(): void
253
318
  getWorkspaceFiles(projectRootMap: Record<string, string>): NxWorkspaceFiles
254
319
  glob(globs: Array<string>, exclude?: Array<string> | undefined | null): Array<string>
255
320
  /**
@@ -261,10 +326,60 @@ export declare class WorkspaceContext {
261
326
  multiGlob(globs: Array<string>, exclude?: Array<string> | undefined | null): Array<Array<string>>
262
327
  hashFilesMatchingGlobs(globGroups: Array<Array<string>>): Array<string>
263
328
  hashFilesMatchingGlob(globs: Array<string>, exclude?: Array<string> | undefined | null): string
264
- incrementalUpdate(updatedFiles: Array<string>, deletedFiles: Array<string>): Record<string, string>
329
+ /**
330
+ * Applies changes a caller learned of on its own. Waits through a walk in
331
+ * progress so the answer reflects them. Returns what really changed; the
332
+ * batch is not published to subscribers.
333
+ */
334
+ incrementalUpdate(updatedFiles: Array<string>, deletedFiles: Array<string>): ChangeBatch
265
335
  updateProjectFiles(projectRootMappings: Record<string, string>, projectFiles: ExternalObject<Record<string, Array<FileData>>>, globalFiles: ExternalObject<Array<FileData>>, updatedFiles: Record<string, string>, deletedFiles: Array<string>): UpdatedWorkspaceFiles
266
336
  allFileData(): Array<FileData>
337
+ /**
338
+ * Recover from dropped watch events: re-walk, and report what changed
339
+ * against the files this context was holding. The fresh files are
340
+ * adopted, so the caller only has to feed the returned changes through
341
+ * its normal recomputation path; subscribers do not see them.
342
+ */
343
+ rescanAndDiff(): ChangeBatch
344
+ /**
345
+ * The subset of `paths` the file map holds: what the watch tracks, with
346
+ * the ignore rules applied. A path it does not hold is gitignored, gone,
347
+ * or not yet reported. Applies what the watch delivered first, as every
348
+ * other read of the files does, so a write already reported counts.
349
+ */
350
+ trackedFiles(paths: Array<string>): Array<string>
267
351
  getFilesInDirectory(directory: string): Array<string>
352
+ /**
353
+ * Subscribes to the context's changes: the callback is called whenever
354
+ * something was applied or delivered, with everything not yet taken by
355
+ * it or by `settle`. Replaces any earlier subscriber.
356
+ */
357
+ onChanges(callback: (err: Error | null, batch: ChangeBatch | null) => void): void
358
+ /**
359
+ * Subscribes to every event the watch delivers, whether or not it
360
+ * concerns the files: writes under ignored directories included, and
361
+ * the `rescan` marker when the kernel dropped events. Replaces any
362
+ * earlier subscriber. Batches applied to the files are `onChanges`.
363
+ */
364
+ onWatchEvents(callback: (err: Error | null, events: WatchEvent[] | null) => void): void
365
+ /**
366
+ * Applies everything the watch has delivered, waiting out the kernel hop,
367
+ * then takes every change applied and not yet taken, one entry per path
368
+ * at its latest state. The change subscriber takes from the same place,
369
+ * so no change is handed out twice.
370
+ */
371
+ settle(): ChangeBatch
372
+ /**
373
+ * Takes every change applied and not yet taken, without waiting for the
374
+ * watch: for a caller that just applied changes itself, through
375
+ * `incrementalUpdate` or `rescanAndDiff`.
376
+ */
377
+ takeAppliedChanges(): ChangeBatch
378
+ /**
379
+ * Stops the watcher and forgets the subscribers. The files stay as they
380
+ * were; reads no longer pull anything in.
381
+ */
382
+ stopWatching(): void
268
383
  }
269
384
 
270
385
  export interface BatchInfo {
@@ -278,6 +393,14 @@ export declare const enum BatchStatus {
278
393
  Failure = 'Failure'
279
394
  }
280
395
 
396
+ export interface CachedPluginCapabilities {
397
+ createNodesPattern?: string
398
+ hasCreateDependencies: boolean
399
+ hasCreateMetadata: boolean
400
+ hasPreTasksExecution: boolean
401
+ hasPostTasksExecution: boolean
402
+ }
403
+
281
404
  export interface CachedResult {
282
405
  code: number
283
406
  terminalOutput?: string
@@ -298,6 +421,20 @@ export declare function canInstallNxConsole(): Promise<boolean>
298
421
 
299
422
  export declare function canInstallNxConsoleForEditor(editor: SupportedEditor): Promise<boolean>
300
423
 
424
+ /**
425
+ * What one application of changes did to the files. `seq` is the context's
426
+ * change sequence afterwards; it is unchanged, and the lists empty, when
427
+ * nothing the batch reported was really different. A path can reach a
428
+ * consumer in more than one batch (see `settle`): the one with the higher
429
+ * `seq` holds its later state.
430
+ */
431
+ export interface ChangeBatch {
432
+ seq: number
433
+ createdFiles: Array<FileData>
434
+ updatedFiles: Array<FileData>
435
+ deletedFiles: Array<string>
436
+ }
437
+
301
438
  export declare function closeDbConnection(connection: ExternalObject<NxDbConnection>): void
302
439
 
303
440
  export declare function connectToNxDb(cacheDir: string, dbName?: string | undefined | null): ExternalObject<NxDbConnection>
@@ -357,9 +494,17 @@ export interface EventDimensions {
357
494
  export declare const enum EventType {
358
495
  delete = 'delete',
359
496
  update = 'update',
360
- create = 'create'
497
+ create = 'create',
498
+ /**
499
+ * The kernel dropped events (e.g. an inotify queue overflow); per-path
500
+ * events cannot be trusted complete and consumers must re-walk.
501
+ */
502
+ rescan = 'rescan'
361
503
  }
362
504
 
505
+ /** The files an `includeIgnored` fileset group matches on disk, sorted. */
506
+ export declare function expandFilesInput(workspaceRoot: string, globs: Array<string>): Array<string>
507
+
363
508
  export declare function expandOutputs(directory: string, entries: Array<string>): Array<string>
364
509
 
365
510
  export interface ExternalDependenciesInput {
@@ -385,6 +530,11 @@ export interface FileMap {
385
530
  export interface FileSetInput {
386
531
  fileset: string
387
532
  dependencies?: boolean
533
+ /**
534
+ * Hash the glob straight from disk (so gitignored/generated files count)
535
+ * instead of the workspace file map.
536
+ */
537
+ includeIgnored?: boolean
388
538
  }
389
539
 
390
540
  export declare function findImports(projectFileMap: Record<string, Array<string>>): Array<ImportResult>
@@ -624,6 +774,7 @@ export interface NxWorkspaceFilesExternals {
624
774
  projectFiles: ExternalObject<Record<string, Array<FileData>>>
625
775
  globalFiles: ExternalObject<Array<FileData>>
626
776
  allWorkspaceFiles: ExternalObject<Array<FileData>>
777
+ ignoredIndex: ExternalObject<IgnoredIndexReader>
627
778
  }
628
779
 
629
780
  export declare function parseTaskStatus(stringStatus: string): TaskStatus
@@ -702,6 +853,31 @@ export declare const enum SupportedEditor {
702
853
  Unknown = 5
703
854
  }
704
855
 
856
+ /**
857
+ * A free function, not a method: `BatchProcess` writes these logs whichever
858
+ * cache implementation is active, so the sweep must not be reachable only
859
+ * through the DB-backed one.
860
+ *
861
+ * Deletes batch logs by age, then oldest-first while the directory is over
862
+ * budget.
863
+ *
864
+ * No database rows: nothing looks a batch log up by key, so a row would be
865
+ * write-only bookkeeping that a hard-killed process could skip, orphaning
866
+ * the file forever. The filesystem cannot drift from itself, and the file
867
+ * is appended to for the life of its batch, so a size recorded anywhere
868
+ * else is wrong until that batch ends.
869
+ *
870
+ * The budget is separate from `maxCacheSize` on purpose: these are debug
871
+ * artifacts, and sharing a budget would let one evict a replayable cache
872
+ * entry — trading a rebuild for a text file.
873
+ *
874
+ * The age sweep deletes at `BATCH_OUTPUT_MAX_AGE`; the eviction skips
875
+ * anything written within `BATCH_OUTPUT_MIN_EVICTION_AGE`. That is
876
+ * last-write, not creation, so a batch silent through a long quiet phase is
877
+ * not protected.
878
+ */
879
+ export declare function sweepBatchOutputs(cachePath: string): void
880
+
705
881
  /** System information (static system-level data) */
706
882
  export interface SystemInfo {
707
883
  cpuCores: number
@@ -811,6 +987,15 @@ export interface TaskTarget {
811
987
  configuration?: string
812
988
  }
813
989
 
990
+ export interface TerminalOutputRecord {
991
+ hash: string
992
+ /**
993
+ * Byte length of the terminal output written for this hash, so these
994
+ * files are counted against `maxCacheSize` like any other cache content.
995
+ */
996
+ size: number
997
+ }
998
+
814
999
  export declare function testOnlyTransferFileMap(projectFiles: Record<string, Array<FileData>>, nonProjectFiles: Array<FileData>): NxWorkspaceFilesExternals
815
1000
 
816
1001
  /** Track an event using the global telemetry instance */
@@ -851,6 +1036,22 @@ export interface WorkingDirectoryInput {
851
1036
  workingDirectory: string
852
1037
  }
853
1038
 
1039
+ export interface WorkspaceContextOptions {
1040
+ /**
1041
+ * Keep the files current from a watcher the context owns. Watching
1042
+ * starts before the scan, so nothing written after construction is
1043
+ * missed. Off by default; ignored on wasm, which has no watcher.
1044
+ */
1045
+ watch?: boolean
1046
+ /**
1047
+ * Paths the watch reports even though a hardcoded ignore covers them,
1048
+ * as the daemon does for its own process file. They reach the event
1049
+ * stream only, never the files: the workspace ignore rules still decide
1050
+ * what enters those.
1051
+ */
1052
+ alwaysWatch?: Array<string>
1053
+ }
1054
+
854
1055
  /** Public NAPI error codes that are for Node */
855
1056
  export declare const enum WorkspaceErrors {
856
1057
  ParseError = 'ParseError',
@@ -210,7 +210,7 @@ Module._load = function (request, parent, isMain) {
210
210
 
211
211
  const indexModulePath = require.resolve('./native-bindings.js');
212
212
  delete require.cache[indexModulePath];
213
- const indexModule = require('./native-bindings.js');
214
-
215
- module.exports = indexModule;
213
+ // A direct re-export: node's CommonJS export lexer follows this form, so ESM
214
+ // importers see the named exports. Assigning via a variable hides them.
215
+ module.exports = require('./native-bindings.js');
216
216
  Module._load = originalLoad;
@@ -582,9 +582,11 @@ module.exports.FileLock = nativeBinding.FileLock
582
582
  module.exports.HashPlanInspector = nativeBinding.HashPlanInspector
583
583
  module.exports.HashPlanner = nativeBinding.HashPlanner
584
584
  module.exports.HttpRemoteCache = nativeBinding.HttpRemoteCache
585
+ module.exports.IgnoredIndexReader = nativeBinding.IgnoredIndexReader
585
586
  module.exports.ImportResult = nativeBinding.ImportResult
586
587
  module.exports.NxCache = nativeBinding.NxCache
587
588
  module.exports.NxConsolePreferences = nativeBinding.NxConsolePreferences
589
+ module.exports.NxPluginCapabilities = nativeBinding.NxPluginCapabilities
588
590
  module.exports.NxTaskHistory = nativeBinding.NxTaskHistory
589
591
  module.exports.ProcessMetricsCollector = nativeBinding.ProcessMetricsCollector
590
592
  module.exports.RunningTasksService = nativeBinding.RunningTasksService
@@ -592,7 +594,6 @@ module.exports.RustPseudoTerminal = nativeBinding.RustPseudoTerminal
592
594
  module.exports.TaskDetails = nativeBinding.TaskDetails
593
595
  module.exports.TaskHasher = nativeBinding.TaskHasher
594
596
  module.exports.TaskInvocationTracker = nativeBinding.TaskInvocationTracker
595
- module.exports.Watcher = nativeBinding.Watcher
596
597
  module.exports.WorkspaceContext = nativeBinding.WorkspaceContext
597
598
  module.exports.BatchStatus = nativeBinding.BatchStatus
598
599
  module.exports.canInstallNxConsole = nativeBinding.canInstallNxConsole
@@ -602,6 +603,7 @@ module.exports.connectToNxDb = nativeBinding.connectToNxDb
602
603
  module.exports.copy = nativeBinding.copy
603
604
  module.exports.detectAiAgent = nativeBinding.detectAiAgent
604
605
  module.exports.EventType = nativeBinding.EventType
606
+ module.exports.expandFilesInput = nativeBinding.expandFilesInput
605
607
  module.exports.expandOutputs = nativeBinding.expandOutputs
606
608
  module.exports.findImports = nativeBinding.findImports
607
609
  module.exports.flushTelemetry = nativeBinding.flushTelemetry
@@ -633,6 +635,7 @@ module.exports.remove = nativeBinding.remove
633
635
  module.exports.restoreTerminal = nativeBinding.restoreTerminal
634
636
  module.exports.RunMode = nativeBinding.RunMode
635
637
  module.exports.SupportedEditor = nativeBinding.SupportedEditor
638
+ module.exports.sweepBatchOutputs = nativeBinding.sweepBatchOutputs
636
639
  module.exports.TaskStatus = nativeBinding.TaskStatus
637
640
  module.exports.testOnlyTransferFileMap = nativeBinding.testOnlyTransferFileMap
638
641
  module.exports.trackEvent = nativeBinding.trackEvent
Binary file
@@ -663,7 +663,7 @@ function stringifyPnpmLockfile(graph, rootLockFileContent, packageJson, workspac
663
663
  }
664
664
  output.packages = (0, object_sort_1.sortObjectByKeys)(output.packages);
665
665
  stripStandaloneLockfileConfig(output);
666
- return (0, pnpm_normalizer_1.stringifyToPnpmYaml)(output);
666
+ return (0, pnpm_normalizer_1.joinPnpmLockfileDocuments)((0, pnpm_normalizer_1.extractEnvLockfileDocument)(rootLockFileContent), (0, pnpm_normalizer_1.stringifyToPnpmYaml)(output));
667
667
  }
668
668
  /**
669
669
  * Removes settings a standalone, pruned lockfile cannot satisfy on its own.
@@ -15,6 +15,8 @@ export declare function loadPnpmHoistedDepsDefinition(): any;
15
15
  */
16
16
  export declare function parseAndNormalizePnpmLockfile(content: string): Lockfile;
17
17
  export declare function extractMainLockfileDocument(content: string): string;
18
+ export declare function extractEnvLockfileDocument(content: string): string | null;
19
+ export declare function joinPnpmLockfileDocuments(envDocument: string | null, mainDocument: string): string;
18
20
  /**
19
21
  * Mapping and writing logic from pnpm lockfile `write` function
20
22
  */
@@ -9,6 +9,8 @@ exports.usesLeadingDash = usesLeadingDash;
9
9
  exports.loadPnpmHoistedDepsDefinition = loadPnpmHoistedDepsDefinition;
10
10
  exports.parseAndNormalizePnpmLockfile = parseAndNormalizePnpmLockfile;
11
11
  exports.extractMainLockfileDocument = extractMainLockfileDocument;
12
+ exports.extractEnvLockfileDocument = extractEnvLockfileDocument;
13
+ exports.joinPnpmLockfileDocuments = joinPnpmLockfileDocuments;
12
14
  exports.stringifyToPnpmYaml = stringifyToPnpmYaml;
13
15
  const node_fs_1 = require("node:fs");
14
16
  const semver_1 = require("semver");
@@ -68,6 +70,26 @@ function extractMainLockfileDocument(content) {
68
70
  }
69
71
  return content.slice(separatorIndex + YAML_DOCUMENT_SEPARATOR.length);
70
72
  }
73
+ // The package-manager document (`packageManagerDependencies`) must ship with a
74
+ // pruned lockfile whenever the pruned manifest keeps `packageManager`: pnpm
75
+ // refuses a frozen install when the pin is not recorded in the lockfile.
76
+ function extractEnvLockfileDocument(content) {
77
+ content = content.replace(/\r\n/g, '\n');
78
+ if (!content.startsWith(YAML_DOCUMENT_START)) {
79
+ return null;
80
+ }
81
+ const separatorIndex = content.indexOf(YAML_DOCUMENT_SEPARATOR, YAML_DOCUMENT_START.length);
82
+ if (separatorIndex === -1) {
83
+ return null;
84
+ }
85
+ return content.slice(YAML_DOCUMENT_START.length, separatorIndex);
86
+ }
87
+ function joinPnpmLockfileDocuments(envDocument, mainDocument) {
88
+ if (envDocument === null) {
89
+ return mainDocument;
90
+ }
91
+ return `${YAML_DOCUMENT_START}${envDocument}${YAML_DOCUMENT_SEPARATOR}${mainDocument}`;
92
+ }
71
93
  // https://github.com/pnpm/pnpm/blob/50e37072f42bcca6d393a74bed29f7f0e029805d/lockfile/lockfile-file/src/write.ts#L22
72
94
  const LOCKFILE_YAML_FORMAT = {
73
95
  blankLines: true,
@@ -24,6 +24,7 @@ exports.registerTsConfigPaths = registerTsConfigPaths;
24
24
  exports.getTsNodeCompilerOptions = getTsNodeCompilerOptions;
25
25
  const path_1 = require("path");
26
26
  const fs_1 = require("fs");
27
+ const fileutils_1 = require("../../../utils/fileutils");
27
28
  const logger_1 = require("../../../utils/logger");
28
29
  const workspace_root_1 = require("../../../utils/workspace-root");
29
30
  const typescript_1 = require("./typescript");
@@ -1208,7 +1209,7 @@ function resolvePathsBaseUrl(tsconfigPath) {
1208
1209
  const absolute = (0, path_1.resolve)(queue.shift());
1209
1210
  const dir = (0, path_1.dirname)(absolute);
1210
1211
  try {
1211
- const raw = JSON.parse((0, fs_1.readFileSync)(absolute, 'utf-8'));
1212
+ const raw = (0, fileutils_1.readJsonFile)(absolute);
1212
1213
  chain.push({ dir, raw });
1213
1214
  const exts = raw.extends
1214
1215
  ? Array.isArray(raw.extends)