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.
- package/dist/src/command-line/format/format.js +2 -18
- package/dist/src/command-line/graph/graph.js +42 -3
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
- package/dist/src/command-line/init/implementation/angular/index.js +0 -3
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
- package/dist/src/command-line/init/implementation/format.js +2 -3
- package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
- package/dist/src/command-line/init/implementation/utils.js +0 -8
- package/dist/src/command-line/init/init-v2.js +0 -3
- package/dist/src/command-line/migrate/agentic/definitions.js +75 -19
- package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
- package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +27 -17
- package/dist/src/command-line/migrate/agentic/handoff.js +107 -24
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +21 -0
- package/dist/src/command-line/migrate/agentic/instruction-files.js +36 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +16 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +70 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
- package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
- package/dist/src/command-line/migrate/agentic/runner.d.ts +17 -8
- package/dist/src/command-line/migrate/agentic/runner.js +110 -55
- package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
- package/dist/src/command-line/migrate/agentic/types.js +10 -7
- package/dist/src/command-line/migrate/migrate-commits.d.ts +1 -0
- package/dist/src/command-line/migrate/migrate-commits.js +9 -0
- package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
- package/dist/src/command-line/migrate/migrate-output.js +3 -7
- package/dist/src/command-line/migrate/migrate.js +21 -8
- package/dist/src/command-line/migrate/run/agent-output.d.ts +10 -0
- package/dist/src/command-line/migrate/run/agent-output.js +16 -2
- package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
- package/dist/src/command-line/migrate/run/agent-work-payload.js +142 -0
- package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
- package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
- package/dist/src/command-line/migrate/run/index.d.ts +1 -1
- package/dist/src/command-line/migrate/run/issues.d.ts +106 -0
- package/dist/src/command-line/migrate/run/issues.js +980 -0
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +1 -0
- package/dist/src/command-line/migrate/run/orchestrator.js +662 -105
- package/dist/src/command-line/migrate/run/run-state.d.ts +43 -8
- package/dist/src/command-line/migrate/run/run-state.js +184 -20
- package/dist/src/command-line/migrate/run/runbook.d.ts +17 -0
- package/dist/src/command-line/migrate/run/runbook.js +97 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +2 -2
- package/dist/src/command-line/migrate/run/state-lock.js +2 -2
- package/dist/src/command-line/migrate/run/state-machine.d.ts +5 -1
- package/dist/src/command-line/migrate/run/state-machine.js +27 -1
- package/dist/src/command-line/migrate/run/worker.js +206 -56
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
- package/dist/src/command-line/release/publish.js +11 -4
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +3 -3
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +2 -0
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +35 -0
- package/dist/src/command-line/report/report.d.ts +2 -0
- package/dist/src/command-line/report/report.js +28 -1
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
- package/dist/src/command-line/yargs-utils/shared-options.js +22 -4
- package/dist/src/config/workspace-json-project-json.d.ts +2 -0
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/daemon/client/client.d.ts +6 -2
- package/dist/src/daemon/client/client.js +27 -11
- package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
- package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
- package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
- package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
- package/dist/src/daemon/server/handle-hash-tasks.d.ts +8 -2
- package/dist/src/daemon/server/handle-hash-tasks.js +16 -3
- package/dist/src/daemon/server/handle-outputs-changes.d.ts +2 -2
- package/dist/src/daemon/server/handle-outputs-changes.js +21 -6
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/server/outputs-tracking.d.ts +6 -0
- package/dist/src/daemon/server/outputs-tracking.js +18 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +100 -70
- package/dist/src/daemon/server/restart-checks.d.ts +22 -0
- package/dist/src/daemon/server/restart-checks.js +77 -0
- package/dist/src/daemon/server/server.js +33 -18
- package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
- package/dist/src/daemon/server/shutdown-utils.js +3 -26
- package/dist/src/hasher/hash-task.js +20 -16
- package/dist/src/hasher/native-task-hasher-impl.d.ts +8 -0
- package/dist/src/hasher/native-task-hasher-impl.js +46 -3
- package/dist/src/hasher/task-hasher.d.ts +9 -0
- package/dist/src/hasher/task-hasher.js +14 -0
- package/dist/src/native/index.d.ts +222 -21
- package/dist/src/native/index.js +3 -3
- package/dist/src/native/native-bindings.js +4 -1
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
- package/dist/src/plugins/js/utils/register.js +2 -1
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +19 -26
- package/dist/src/project-graph/error-types.d.ts +5 -0
- package/dist/src/project-graph/error-types.js +44 -5
- package/dist/src/project-graph/file-utils.d.ts +2 -0
- package/dist/src/project-graph/file-utils.js +6 -1
- package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
- package/dist/src/project-graph/nx-deps-cache.js +4 -4
- package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
- package/dist/src/project-graph/plugins/get-plugins.js +60 -82
- package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
- package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
- package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
- package/dist/src/project-graph/plugins/isolation/index.js +3 -1
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
- package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
- package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
- package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
- package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
- package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
- package/dist/src/project-graph/project-graph.js +43 -42
- package/dist/src/tasks-runner/batch/run-batch.js +15 -0
- package/dist/src/tasks-runner/cache.d.ts +35 -0
- package/dist/src/tasks-runner/cache.js +40 -0
- package/dist/src/tasks-runner/create-task-graph.js +1 -0
- package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.js +8 -7
- package/dist/src/tasks-runner/init-tasks-runner.js +5 -1
- package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
- package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
- package/dist/src/tasks-runner/life-cycle.js +7 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
- package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
- package/dist/src/tasks-runner/prune-task-graph.js +45 -0
- package/dist/src/tasks-runner/run-command.js +14 -3
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
- package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
- package/dist/src/tasks-runner/task-orchestrator.d.ts +64 -2
- package/dist/src/tasks-runner/task-orchestrator.js +232 -46
- package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
- package/dist/src/tasks-runner/terminal-output-path.js +18 -0
- package/dist/src/tasks-runner/utils.js +5 -2
- package/dist/src/utils/ab-testing.d.ts +4 -1
- package/dist/src/utils/ab-testing.js +11 -7
- package/dist/src/utils/chunkify.d.ts +1 -7
- package/dist/src/utils/chunkify.js +2 -8
- package/dist/src/utils/command-line-utils.d.ts +19 -0
- package/dist/src/utils/command-line-utils.js +10 -3
- package/dist/src/utils/formatters/index.d.ts +6 -0
- package/dist/src/utils/formatters/index.js +5 -0
- package/dist/src/utils/formatters/prettier.d.ts +0 -8
- package/dist/src/utils/formatters/prettier.js +4 -26
- package/dist/src/utils/handle-errors.js +5 -43
- package/dist/src/utils/installed-nx-version.js +2 -48
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/output.d.ts +22 -3
- package/dist/src/utils/output.js +28 -5
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +41 -6
- package/dist/src/utils/package-manager.d.ts +6 -0
- package/dist/src/utils/package-manager.js +10 -0
- package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
- package/dist/src/utils/provenance.js +20 -4
- package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
- package/dist/src/utils/workspace-context.d.ts +47 -3
- package/dist/src/utils/workspace-context.js +162 -10
- package/package.json +12 -13
- package/schemas/nx-schema.json +4 -0
- package/schemas/project-schema.json +4 -0
- package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
- package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
- package/dist/src/daemon/server/watcher.d.ts +0 -18
- package/dist/src/daemon/server/watcher.js +0 -126
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.currentSourceMaps = exports.currentProjectGraph = exports.currentProjectFileMapCache = exports.fileMapWithFiles = void 0;
|
|
4
4
|
exports.getCachedSerializedProjectGraphPromise = getCachedSerializedProjectGraphPromise;
|
|
5
|
+
exports.routeAppliedChanges = routeAppliedChanges;
|
|
6
|
+
exports.flushPendingWorkspaceChanges = flushPendingWorkspaceChanges;
|
|
5
7
|
exports.scheduleProjectGraphRecomputation = scheduleProjectGraphRecomputation;
|
|
8
|
+
exports.scheduleInitialProjectGraphComputation = scheduleInitialProjectGraphComputation;
|
|
6
9
|
exports.registerProjectGraphRecomputationListener = registerProjectGraphRecomputationListener;
|
|
7
10
|
exports.invalidateGraphCache = invalidateGraphCache;
|
|
8
11
|
exports.getRecomputationGeneration = getRecomputationGeneration;
|
|
9
|
-
exports.isKnownWorkspaceFile = isKnownWorkspaceFile;
|
|
10
12
|
const perf_hooks_1 = require("perf_hooks");
|
|
11
13
|
const nx_json_1 = require("../../config/nx-json");
|
|
12
14
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
@@ -25,7 +27,7 @@ const dotenv_graph_changes_1 = require("./dotenv-graph-changes");
|
|
|
25
27
|
const file_change_events_1 = require("./file-watching/file-change-events");
|
|
26
28
|
const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
|
|
27
29
|
const project_graph_listener_sockets_1 = require("./project-graph-listener-sockets");
|
|
28
|
-
const
|
|
30
|
+
const restart_checks_1 = require("./restart-checks");
|
|
29
31
|
const logger_1 = require("../logger");
|
|
30
32
|
let cachedSerializedProjectGraphPromise;
|
|
31
33
|
// Maps file path to a version counter that increments on each modification.
|
|
@@ -136,7 +138,7 @@ async function getCachedSerializedProjectGraphPromise(socket) {
|
|
|
136
138
|
// that already arrived in the watcher's accumulator but hasn't
|
|
137
139
|
// flushed past IDLE_WINDOW yet would be invisible to the staleness
|
|
138
140
|
// check below — the daemon would return a stale graph.
|
|
139
|
-
await
|
|
141
|
+
await flushPendingWorkspaceChanges();
|
|
140
142
|
await resetInternalStateIfNxDepsMissing();
|
|
141
143
|
// Yield one macrotask boundary so any TSFN-queued watcher callbacks
|
|
142
144
|
// run before we read collected*. Without this, an event that left
|
|
@@ -222,38 +224,96 @@ async function getCachedSerializedProjectGraphPromise(socket) {
|
|
|
222
224
|
}
|
|
223
225
|
}
|
|
224
226
|
}
|
|
227
|
+
const SUMMARY_CAP = 10;
|
|
228
|
+
function summarize(files) {
|
|
229
|
+
if (files.length === 0)
|
|
230
|
+
return '(none)';
|
|
231
|
+
const listed = files.slice(0, SUMMARY_CAP).map((f) => ` - ${f}`);
|
|
232
|
+
if (files.length > SUMMARY_CAP) {
|
|
233
|
+
listed.push(` ... and ${files.length - SUMMARY_CAP} more`);
|
|
234
|
+
}
|
|
235
|
+
return listed.join('\n');
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Takes in changes the workspace context handed out: restarts the daemon if
|
|
239
|
+
* an ignore file changed, otherwise schedules the recomputation.
|
|
240
|
+
*/
|
|
241
|
+
function routeAppliedChanges(batch) {
|
|
242
|
+
if (!(0, workspace_context_1.isEmptyBatch)(batch)) {
|
|
243
|
+
if ((0, restart_checks_1.restartDaemonIfIgnoreFilesChanged)((0, restart_checks_1.changedPaths)(batch))) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
logger_1.serverLogger.watcherLog(`File changes detected (seq ${batch.seq}):\n` +
|
|
247
|
+
`Created:\n${summarize((0, restart_checks_1.fileNames)(batch.createdFiles))}\n` +
|
|
248
|
+
`Updated:\n${summarize((0, restart_checks_1.fileNames)(batch.updatedFiles))}\n` +
|
|
249
|
+
`Deleted:\n${summarize(batch.deletedFiles)}`);
|
|
250
|
+
}
|
|
251
|
+
scheduleAppliedChanges(batch);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Applies everything the workspace watcher has seen and routes what changed.
|
|
255
|
+
* Call before serving a cached project graph, so a change the watcher already
|
|
256
|
+
* saw is never missed.
|
|
257
|
+
*/
|
|
258
|
+
async function flushPendingWorkspaceChanges() {
|
|
259
|
+
if (!(0, workspace_context_1.isWatchingWorkspaceContext)())
|
|
260
|
+
return;
|
|
261
|
+
const batch = (0, workspace_context_1.settleWorkspaceContext)(workspace_root_1.workspaceRoot);
|
|
262
|
+
// An empty settle must not reach the routing: it would schedule the first
|
|
263
|
+
// graph computation here rather than where the request handler reports it.
|
|
264
|
+
if ((0, workspace_context_1.isEmptyBatch)(batch)) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
routeAppliedChanges(batch);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Applies changes a caller learned of on its own to the workspace context,
|
|
271
|
+
* then schedules the recomputation as for a batch the context applied.
|
|
272
|
+
*
|
|
273
|
+
* The caller is a sync generator, whose writes the watch would report anyway;
|
|
274
|
+
* this makes them visible before the generator returns rather than by the next
|
|
275
|
+
* settle. Whether that guarantee is still needed is NXC-4996.
|
|
276
|
+
*/
|
|
225
277
|
function scheduleProjectGraphRecomputation(createdFiles, updatedFiles, deletedFiles) {
|
|
278
|
+
if (!createdFiles.length && !updatedFiles.length && !deletedFiles.length) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
// Hashed once here, not inside the recompute, so a stale retry does not see
|
|
282
|
+
// "no change" after the first pass already updated the context.
|
|
283
|
+
perf_hooks_1.performance.mark('hash-reported-changes-start');
|
|
284
|
+
const batch = (0, workspace_context_1.updateFilesInContext)(workspace_root_1.workspaceRoot, [...createdFiles, ...updatedFiles], deletedFiles);
|
|
285
|
+
perf_hooks_1.performance.mark('hash-reported-changes-end');
|
|
286
|
+
perf_hooks_1.performance.measure('hash reported file changes', 'hash-reported-changes-start', 'hash-reported-changes-end');
|
|
287
|
+
// A watching context hands every applied change out once, from one place.
|
|
288
|
+
routeAppliedChanges((0, workspace_context_1.isWatchingWorkspaceContext)()
|
|
289
|
+
? (0, workspace_context_1.takeAppliedWorkspaceChanges)(workspace_root_1.workspaceRoot)
|
|
290
|
+
: batch);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Schedules a recomputation for changes the workspace context has applied:
|
|
294
|
+
* no-op rewrites are already dropped, deleted directories expanded, and every
|
|
295
|
+
* created or updated file carries its hash.
|
|
296
|
+
*/
|
|
297
|
+
function scheduleAppliedChanges(batch) {
|
|
226
298
|
++fileChangeCounter;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
// even though the bytes are identical. updateFilesInContext updates the
|
|
232
|
-
// workspace context and returns only the files whose content actually
|
|
233
|
-
// changed. Hashing here — once per watcher batch — rather than inside the
|
|
234
|
-
// recompute keeps it off the stale-retry path, which would otherwise see
|
|
235
|
-
// "no change" after the first pass already updated the context hashes.
|
|
236
|
-
perf_hooks_1.performance.mark('hash-watched-changes-start');
|
|
237
|
-
const changedFileHashes = createdFiles.length > 0 ||
|
|
238
|
-
updatedFiles.length > 0 ||
|
|
239
|
-
deletedFiles.length > 0
|
|
240
|
-
? ((0, workspace_context_1.updateFilesInContext)(workspace_root_1.workspaceRoot, [...createdFiles, ...updatedFiles], deletedFiles) ?? {})
|
|
241
|
-
: {};
|
|
242
|
-
perf_hooks_1.performance.mark('hash-watched-changes-end');
|
|
243
|
-
perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
|
|
244
|
-
for (const [f, hash] of Object.entries(changedFileHashes)) {
|
|
245
|
-
collectedDeletedFiles.delete(f);
|
|
246
|
-
collectedUpdatedFiles.set(f, { version: fileChangeCounter, hash });
|
|
299
|
+
const { createdFiles, updatedFiles, deletedFiles } = batch;
|
|
300
|
+
for (const { file, hash } of [...createdFiles, ...updatedFiles]) {
|
|
301
|
+
collectedDeletedFiles.delete(file);
|
|
302
|
+
collectedUpdatedFiles.set(file, { version: fileChangeCounter, hash });
|
|
247
303
|
}
|
|
248
|
-
for (
|
|
249
|
-
collectedUpdatedFiles.delete(
|
|
250
|
-
collectedDeletedFiles.set(
|
|
304
|
+
for (const file of deletedFiles) {
|
|
305
|
+
collectedUpdatedFiles.delete(file);
|
|
306
|
+
collectedDeletedFiles.set(file, fileChangeCounter);
|
|
251
307
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
(0, file_change_events_1.notifyFileChangeListeners)({
|
|
256
|
-
|
|
308
|
+
if (!(0, workspace_context_1.isEmptyBatch)(batch)) {
|
|
309
|
+
const createdFileNames = (0, restart_checks_1.fileNames)(createdFiles);
|
|
310
|
+
const updatedFileNames = (0, restart_checks_1.fileNames)(updatedFiles);
|
|
311
|
+
(0, file_change_events_1.notifyFileChangeListeners)({
|
|
312
|
+
createdFiles: createdFileNames,
|
|
313
|
+
updatedFiles: updatedFileNames,
|
|
314
|
+
deletedFiles,
|
|
315
|
+
});
|
|
316
|
+
(0, file_watcher_sockets_1.notifyFileWatcherSockets)(createdFileNames, updatedFileNames, deletedFiles);
|
|
257
317
|
// Bump generation synchronously so any in-flight compute fails its
|
|
258
318
|
// next isStale() check and chains to the newer one. kickOffRecompute
|
|
259
319
|
// would also bump on first resume, but only after its first await —
|
|
@@ -262,10 +322,14 @@ function scheduleProjectGraphRecomputation(createdFiles, updatedFiles, deletedFi
|
|
|
262
322
|
kickOffRecompute();
|
|
263
323
|
}
|
|
264
324
|
else {
|
|
265
|
-
//
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
325
|
+
// Nothing changed, but a daemon with no graph yet still needs one.
|
|
326
|
+
scheduleInitialProjectGraphComputation();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** Computes the first project graph, unless one is already on its way. */
|
|
330
|
+
function scheduleInitialProjectGraphComputation() {
|
|
331
|
+
if (!cachedSerializedProjectGraphPromise) {
|
|
332
|
+
kickOffRecompute();
|
|
269
333
|
}
|
|
270
334
|
}
|
|
271
335
|
function registerProjectGraphRecomputationListener(listener) {
|
|
@@ -337,36 +401,6 @@ function invalidateGraphCache() {
|
|
|
337
401
|
function getRecomputationGeneration() {
|
|
338
402
|
return recomputationGeneration;
|
|
339
403
|
}
|
|
340
|
-
// isKnownWorkspaceFile's membership set, derived lazily from the map object it
|
|
341
|
-
// was built from; every `fileMapWithFiles` write clears it, so a replaced map
|
|
342
|
-
// generation is not retained through the memo.
|
|
343
|
-
let knownWorkspaceFiles;
|
|
344
|
-
let knownWorkspaceFilesSource;
|
|
345
|
-
/**
|
|
346
|
-
* Whether the ignore-filtered workspace file map knows `path`. The workspace
|
|
347
|
-
* watcher applies the same ignore rules, so a change to a known file also
|
|
348
|
-
* reaches scheduleProjectGraphRecomputation; an unknown file is either
|
|
349
|
-
* ignored, or created since the last recompute committed.
|
|
350
|
-
*/
|
|
351
|
-
function isKnownWorkspaceFile(path) {
|
|
352
|
-
if (!exports.fileMapWithFiles) {
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
if (knownWorkspaceFilesSource !== exports.fileMapWithFiles) {
|
|
356
|
-
const { projectFileMap, nonProjectFiles } = exports.fileMapWithFiles.fileMap;
|
|
357
|
-
knownWorkspaceFiles = new Set();
|
|
358
|
-
for (const { file } of nonProjectFiles) {
|
|
359
|
-
knownWorkspaceFiles.add(file);
|
|
360
|
-
}
|
|
361
|
-
for (const files of Object.values(projectFileMap)) {
|
|
362
|
-
for (const { file } of files) {
|
|
363
|
-
knownWorkspaceFiles.add(file);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
knownWorkspaceFilesSource = exports.fileMapWithFiles;
|
|
367
|
-
}
|
|
368
|
-
return knownWorkspaceFiles.has(path);
|
|
369
|
-
}
|
|
370
404
|
async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
|
|
371
405
|
const plugins = [
|
|
372
406
|
...separatedPlugins.specifiedPlugins,
|
|
@@ -442,8 +476,6 @@ async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
|
|
|
442
476
|
// chainToLatest above without touching `fileMapWithFiles`, so they
|
|
443
477
|
// can't clobber a newer compute's write.
|
|
444
478
|
exports.fileMapWithFiles = fileMapUpdate.fileMap;
|
|
445
|
-
knownWorkspaceFiles = undefined;
|
|
446
|
-
knownWorkspaceFilesSource = undefined;
|
|
447
479
|
storedWorkspaceConfigHash = fileMapUpdate.configHash;
|
|
448
480
|
if (fileMapUpdate.knownExternalNodes) {
|
|
449
481
|
knownExternalNodes = fileMapUpdate.knownExternalNodes;
|
|
@@ -556,7 +588,7 @@ function persistProjectGraphToDisk(result) {
|
|
|
556
588
|
!result.sourceMaps) {
|
|
557
589
|
return;
|
|
558
590
|
}
|
|
559
|
-
(0, nx_deps_cache_1.writeCache)(result.projectFileMapCache, result.projectGraph, result.sourceMaps, extractErrors(result.error));
|
|
591
|
+
(0, nx_deps_cache_1.writeCache)(result.projectFileMapCache, result.projectGraph, result.sourceMaps, extractErrors(result.error), Date.now());
|
|
560
592
|
cacheHasBeenPersisted = true;
|
|
561
593
|
}
|
|
562
594
|
function copyFileData(d) {
|
|
@@ -616,8 +648,6 @@ async function resetInternalState() {
|
|
|
616
648
|
servedGraphState = null;
|
|
617
649
|
servedGraphCandidate = null;
|
|
618
650
|
exports.fileMapWithFiles = undefined;
|
|
619
|
-
knownWorkspaceFiles = undefined;
|
|
620
|
-
knownWorkspaceFilesSource = undefined;
|
|
621
651
|
exports.currentProjectFileMapCache = undefined;
|
|
622
652
|
exports.currentProjectGraph = undefined;
|
|
623
653
|
exports.currentSourceMaps = undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Server, Socket } from 'net';
|
|
2
|
+
import type { ChangeBatch, FileData, WatchEvent } from '../../native';
|
|
3
|
+
export declare function registerDaemonForRestartChecks(server: Server, sockets: Iterable<Socket>): void;
|
|
4
|
+
/**
|
|
5
|
+
* The daemon's own process file, workspace-relative. It lives under the
|
|
6
|
+
* hardcoded-ignored .nx/workspace-data, so the watch admits it explicitly;
|
|
7
|
+
* that is how a daemon learns it has been replaced.
|
|
8
|
+
*/
|
|
9
|
+
export declare const relativeServerProcess: string;
|
|
10
|
+
/** The paths out of a list of files and their hashes. */
|
|
11
|
+
export declare function fileNames(files: FileData[]): string[];
|
|
12
|
+
export declare function changedPaths(batch: ChangeBatch): string[];
|
|
13
|
+
/**
|
|
14
|
+
* The watch's ignore rules are fixed when it starts, so an ignore-file edit
|
|
15
|
+
* needs a daemon restart to take effect. True when it stopped the daemon.
|
|
16
|
+
*/
|
|
17
|
+
export declare function restartDaemonIfIgnoreFilesChanged(paths: string[]): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Stops this daemon when the events show another process has written the
|
|
20
|
+
* daemon's process file. True when it stopped the daemon.
|
|
21
|
+
*/
|
|
22
|
+
export declare function stopDaemonIfReplaced(events: WatchEvent[]): boolean;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.relativeServerProcess = void 0;
|
|
4
|
+
exports.registerDaemonForRestartChecks = registerDaemonForRestartChecks;
|
|
5
|
+
exports.fileNames = fileNames;
|
|
6
|
+
exports.changedPaths = changedPaths;
|
|
7
|
+
exports.restartDaemonIfIgnoreFilesChanged = restartDaemonIfIgnoreFilesChanged;
|
|
8
|
+
exports.stopDaemonIfReplaced = stopDaemonIfReplaced;
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const path_2 = require("../../utils/path");
|
|
11
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
12
|
+
const cache_1 = require("../cache");
|
|
13
|
+
const shutdown_utils_1 = require("./shutdown-utils");
|
|
14
|
+
// Kept apart from server.ts: the recomputation module needs these, and
|
|
15
|
+
// importing server.ts starts a server.
|
|
16
|
+
let daemon;
|
|
17
|
+
function registerDaemonForRestartChecks(server, sockets) {
|
|
18
|
+
daemon = { server, sockets };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The daemon's own process file, workspace-relative. It lives under the
|
|
22
|
+
* hardcoded-ignored .nx/workspace-data, so the watch admits it explicitly;
|
|
23
|
+
* that is how a daemon learns it has been replaced.
|
|
24
|
+
*/
|
|
25
|
+
exports.relativeServerProcess = (0, path_2.normalizePath)((0, path_1.relative)(workspace_root_1.workspaceRoot, cache_1.serverProcessJsonPath));
|
|
26
|
+
/** The paths out of a list of files and their hashes. */
|
|
27
|
+
function fileNames(files) {
|
|
28
|
+
return files.map(({ file }) => file);
|
|
29
|
+
}
|
|
30
|
+
function changedPaths(batch) {
|
|
31
|
+
return [
|
|
32
|
+
...fileNames(batch.createdFiles),
|
|
33
|
+
...fileNames(batch.updatedFiles),
|
|
34
|
+
...batch.deletedFiles,
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
// Mirrors the per-directory ignore files create_filter reads (watch_filterer.rs).
|
|
38
|
+
// The sources it honours that cannot trigger a restart from here — because they
|
|
39
|
+
// are never watched — only take effect on the next daemon start: .git/info/exclude
|
|
40
|
+
// (under the hardcoded-ignored .git), the global core.excludesFile (outside the
|
|
41
|
+
// tree), and parent .gitignore files above the workspace root.
|
|
42
|
+
const IGNORE_FILE_NAMES = ['.gitignore', '.nxignore'];
|
|
43
|
+
/**
|
|
44
|
+
* The watch's ignore rules are fixed when it starts, so an ignore-file edit
|
|
45
|
+
* needs a daemon restart to take effect. True when it stopped the daemon.
|
|
46
|
+
*/
|
|
47
|
+
function restartDaemonIfIgnoreFilesChanged(paths) {
|
|
48
|
+
for (const path of paths) {
|
|
49
|
+
const basename = path.slice(path.lastIndexOf('/') + 1);
|
|
50
|
+
if (IGNORE_FILE_NAMES.includes(basename)) {
|
|
51
|
+
stopDaemon('Stopping the daemon the set of ignored files changed (native)');
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Stops this daemon when the events show another process has written the
|
|
59
|
+
* daemon's process file. True when it stopped the daemon.
|
|
60
|
+
*/
|
|
61
|
+
function stopDaemonIfReplaced(events) {
|
|
62
|
+
const replaced = events.some((event) => event.path === exports.relativeServerProcess &&
|
|
63
|
+
(0, cache_1.getDaemonProcessIdSync)() !== process.pid);
|
|
64
|
+
if (replaced) {
|
|
65
|
+
stopDaemon('this process is no longer the current daemon (native)');
|
|
66
|
+
}
|
|
67
|
+
return replaced;
|
|
68
|
+
}
|
|
69
|
+
function stopDaemon(reason) {
|
|
70
|
+
if (!daemon)
|
|
71
|
+
return;
|
|
72
|
+
(0, shutdown_utils_1.handleServerProcessTermination)({
|
|
73
|
+
server: daemon.server,
|
|
74
|
+
reason,
|
|
75
|
+
sockets: daemon.sockets,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -14,7 +14,6 @@ const native_1 = require("../../native");
|
|
|
14
14
|
const consume_messages_from_socket_1 = require("../../utils/consume-messages-from-socket");
|
|
15
15
|
require("../../utils/perf-logging");
|
|
16
16
|
const versions_1 = require("../../utils/versions");
|
|
17
|
-
const workspace_context_1 = require("../../utils/workspace-context");
|
|
18
17
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
19
18
|
const cache_1 = require("../cache");
|
|
20
19
|
const is_nx_version_mismatch_1 = require("../is-nx-version-mismatch");
|
|
@@ -28,6 +27,7 @@ const get_context_file_data_1 = require("../message-types/get-context-file-data"
|
|
|
28
27
|
const get_files_in_directory_1 = require("../message-types/get-files-in-directory");
|
|
29
28
|
const get_nx_workspace_files_1 = require("../message-types/get-nx-workspace-files");
|
|
30
29
|
const get_registered_sync_generators_1 = require("../message-types/get-registered-sync-generators");
|
|
30
|
+
const get_plugin_capabilities_1 = require("../message-types/get-plugin-capabilities");
|
|
31
31
|
const get_sync_generator_changes_1 = require("../message-types/get-sync-generator-changes");
|
|
32
32
|
const glob_1 = require("../message-types/glob");
|
|
33
33
|
const hash_glob_1 = require("../message-types/hash-glob");
|
|
@@ -38,7 +38,6 @@ const task_history_1 = require("../message-types/task-history");
|
|
|
38
38
|
const update_workspace_context_1 = require("../message-types/update-workspace-context");
|
|
39
39
|
const socket_utils_1 = require("../socket-utils");
|
|
40
40
|
const file_change_events_1 = require("./file-watching/file-change-events");
|
|
41
|
-
const route_workspace_changes_1 = require("./file-watching/route-workspace-changes");
|
|
42
41
|
const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
|
|
43
42
|
const handle_configure_ai_agents_1 = require("./handle-configure-ai-agents");
|
|
44
43
|
const handle_context_file_data_1 = require("./handle-context-file-data");
|
|
@@ -47,6 +46,7 @@ const handle_force_shutdown_1 = require("./handle-force-shutdown");
|
|
|
47
46
|
const handle_client_env_1 = require("./handle-client-env");
|
|
48
47
|
const handle_get_files_in_directory_1 = require("./handle-get-files-in-directory");
|
|
49
48
|
const handle_get_registered_sync_generators_1 = require("./handle-get-registered-sync-generators");
|
|
49
|
+
const handle_get_plugin_capabilities_1 = require("./handle-get-plugin-capabilities");
|
|
50
50
|
const handle_get_sync_generator_changes_1 = require("./handle-get-sync-generator-changes");
|
|
51
51
|
const handle_glob_1 = require("./handle-glob");
|
|
52
52
|
const handle_hash_glob_1 = require("./handle-hash-glob");
|
|
@@ -62,10 +62,11 @@ const handle_tasks_execution_hooks_1 = require("./handle-tasks-execution-hooks")
|
|
|
62
62
|
const handle_update_workspace_context_1 = require("./handle-update-workspace-context");
|
|
63
63
|
const handle_outputs_changes_1 = require("./handle-outputs-changes");
|
|
64
64
|
const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
|
|
65
|
+
const restart_checks_1 = require("./restart-checks");
|
|
65
66
|
const project_graph_listener_sockets_1 = require("./project-graph-listener-sockets");
|
|
66
67
|
const shutdown_utils_1 = require("./shutdown-utils");
|
|
67
68
|
const sync_generators_1 = require("./sync-generators");
|
|
68
|
-
const
|
|
69
|
+
const workspace_context_1 = require("../../utils/workspace-context");
|
|
69
70
|
let workspaceWatcherError;
|
|
70
71
|
global.NX_DAEMON = true;
|
|
71
72
|
process.env.NX_DAEMON_PROCESS = 'true';
|
|
@@ -146,6 +147,9 @@ async function handleMessage(socket, data) {
|
|
|
146
147
|
else if (payload.type === 'HASH_TASKS') {
|
|
147
148
|
await handleResult(socket, 'HASH_TASKS', () => (0, handle_hash_tasks_1.handleHashTasks)(payload), mode);
|
|
148
149
|
}
|
|
150
|
+
else if (payload.type === 'HASH_TASKS_UPFRONT') {
|
|
151
|
+
await handleResult(socket, 'HASH_TASKS_UPFRONT', () => (0, handle_hash_tasks_1.handleHashTasksUpfront)(payload), mode);
|
|
152
|
+
}
|
|
149
153
|
else if (payload.type === 'PROCESS_IN_BACKGROUND') {
|
|
150
154
|
await handleResult(socket, 'PROCESS_IN_BACKGROUND', () => (0, handle_process_in_background_1.handleProcessInBackground)(payload), mode);
|
|
151
155
|
}
|
|
@@ -206,6 +210,9 @@ async function handleMessage(socket, data) {
|
|
|
206
210
|
else if ((0, get_registered_sync_generators_1.isHandleGetRegisteredSyncGeneratorsMessage)(payload)) {
|
|
207
211
|
await handleResult(socket, get_registered_sync_generators_1.GET_REGISTERED_SYNC_GENERATORS, () => (0, handle_get_registered_sync_generators_1.handleGetRegisteredSyncGenerators)(), mode);
|
|
208
212
|
}
|
|
213
|
+
else if ((0, get_plugin_capabilities_1.isHandleGetPluginCapabilitiesMessage)(payload)) {
|
|
214
|
+
await handleResult(socket, get_plugin_capabilities_1.GET_PLUGIN_CAPABILITIES, () => (0, handle_get_plugin_capabilities_1.handleGetPluginCapabilities)(), mode);
|
|
215
|
+
}
|
|
209
216
|
else if ((0, update_workspace_context_1.isHandleUpdateWorkspaceContextMessage)(payload)) {
|
|
210
217
|
await handleResult(socket, update_workspace_context_1.UPDATE_WORKSPACE_CONTEXT, () => (0, handle_update_workspace_context_1.handleUpdateWorkspaceContext)(payload.createdFiles, payload.updatedFiles, payload.deletedFiles), mode);
|
|
211
218
|
}
|
|
@@ -323,7 +330,7 @@ function lockFileHashChanged() {
|
|
|
323
330
|
* we need to recompute the cached serialized project graph so that it is readily
|
|
324
331
|
* available for the next client request to the server.
|
|
325
332
|
*/
|
|
326
|
-
const handleWorkspaceChanges =
|
|
333
|
+
const handleWorkspaceChanges = (err, batch) => {
|
|
327
334
|
if (workspaceWatcherError) {
|
|
328
335
|
logger_1.serverLogger.watcherLog('Skipping handleWorkspaceChanges because of a previously recorded watcher error.');
|
|
329
336
|
return;
|
|
@@ -338,8 +345,7 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
|
|
|
338
345
|
(0, file_watcher_sockets_1.notifyFileWatcherSocketsOfError)(error);
|
|
339
346
|
return;
|
|
340
347
|
}
|
|
341
|
-
|
|
342
|
-
(0, route_workspace_changes_1.routeWorkspaceChanges)(changeEvents);
|
|
348
|
+
(0, project_graph_incremental_recomputation_1.routeAppliedChanges)(batch);
|
|
343
349
|
}
|
|
344
350
|
catch (err) {
|
|
345
351
|
logger_1.serverLogger.watcherLog(`Unexpected workspace error`, err.message);
|
|
@@ -349,14 +355,17 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
|
|
|
349
355
|
}
|
|
350
356
|
};
|
|
351
357
|
async function startServer() {
|
|
352
|
-
//
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
(0,
|
|
358
|
+
// The workspace context owns the daemon's one watch and starts it before
|
|
359
|
+
// it scans, so a file written during boot is visible to one or the other.
|
|
360
|
+
if (!(0, workspace_context_1.isWatchingWorkspaceContext)()) {
|
|
361
|
+
(0, restart_checks_1.registerDaemonForRestartChecks)(server, exports.openSockets);
|
|
362
|
+
(0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot, {
|
|
363
|
+
watch: true,
|
|
364
|
+
alwaysWatch: [restart_checks_1.relativeServerProcess],
|
|
365
|
+
});
|
|
366
|
+
(0, workspace_context_1.subscribeToWorkspaceChanges)(workspace_root_1.workspaceRoot, handleWorkspaceChanges);
|
|
357
367
|
logger_1.serverLogger.watcherLog(`Subscribed to changes within: ${workspace_root_1.workspaceRoot} (native)`);
|
|
358
368
|
}
|
|
359
|
-
(0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
|
|
360
369
|
// Initialize analytics for daemon process
|
|
361
370
|
await (0, analytics_1.startAnalytics)();
|
|
362
371
|
const socketPath = (0, socket_utils_1.getFullOsSocketPath)();
|
|
@@ -434,15 +443,21 @@ async function startServer() {
|
|
|
434
443
|
}
|
|
435
444
|
// this triggers the storage of the lock file hash
|
|
436
445
|
daemonIsOutdated();
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
446
|
+
// Every event the watch delivers, gitignored outputs and dotenv
|
|
447
|
+
// files included.
|
|
448
|
+
(0, workspace_context_1.subscribeToWatchEvents)(workspace_root_1.workspaceRoot, (err, events) => {
|
|
449
|
+
if (!err && events && (0, restart_checks_1.stopDaemonIfReplaced)(events)) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
if (err || events?.length) {
|
|
453
|
+
(0, handle_outputs_changes_1.handleOutputsChanges)(err, events);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
440
456
|
// listen for project graph recomputation events to collect and schedule sync generators
|
|
441
457
|
(0, project_graph_incremental_recomputation_1.registerProjectGraphRecomputationListener)(sync_generators_1.collectAndScheduleSyncGenerators);
|
|
442
458
|
// register file change listener to invalidate sync generator cache
|
|
443
459
|
(0, file_change_events_1.registerFileChangeListener)(sync_generators_1.clearSyncGeneratorsCache);
|
|
444
|
-
|
|
445
|
-
(0, project_graph_incremental_recomputation_1.scheduleProjectGraphRecomputation)([], [], []);
|
|
460
|
+
(0, project_graph_incremental_recomputation_1.scheduleInitialProjectGraphComputation)();
|
|
446
461
|
// Kick off Nx Console check in background to prime the cache
|
|
447
462
|
(0, handle_nx_console_1.handleGetNxConsoleStatus)().catch(() => {
|
|
448
463
|
// Ignore errors, this is a background operation
|
|
@@ -454,7 +469,7 @@ async function startServer() {
|
|
|
454
469
|
return resolve(server);
|
|
455
470
|
}
|
|
456
471
|
catch (err) {
|
|
457
|
-
await handleWorkspaceChanges(err,
|
|
472
|
+
await handleWorkspaceChanges(err, null);
|
|
458
473
|
}
|
|
459
474
|
});
|
|
460
475
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Server, Socket } from 'net';
|
|
2
|
-
import type { Watcher } from '../../native';
|
|
3
2
|
export declare const SERVER_INACTIVITY_TIMEOUT_MS: 10800000;
|
|
4
|
-
export declare function storeWatcherInstance(instance: Watcher): void;
|
|
5
|
-
export declare function getWatcherInstance(): Watcher;
|
|
6
|
-
export declare function storeOutputWatcherInstance(instance: Watcher): void;
|
|
7
|
-
export declare function getOutputWatcherInstance(): Watcher;
|
|
8
3
|
interface HandleServerProcessTerminationParams {
|
|
9
4
|
server: Server;
|
|
10
5
|
reason: string;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SERVER_INACTIVITY_TIMEOUT_MS = void 0;
|
|
4
|
-
exports.storeWatcherInstance = storeWatcherInstance;
|
|
5
|
-
exports.getWatcherInstance = getWatcherInstance;
|
|
6
|
-
exports.storeOutputWatcherInstance = storeOutputWatcherInstance;
|
|
7
|
-
exports.getOutputWatcherInstance = getOutputWatcherInstance;
|
|
8
4
|
exports.handleServerProcessTermination = handleServerProcessTermination;
|
|
9
5
|
exports.handleServerProcessTerminationWithRestart = handleServerProcessTerminationWithRestart;
|
|
10
6
|
exports.resetInactivityTimeout = resetInactivityTimeout;
|
|
@@ -15,6 +11,7 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
|
15
11
|
const logger_1 = require("../logger");
|
|
16
12
|
const socket_utils_1 = require("../socket-utils");
|
|
17
13
|
const cache_1 = require("../cache");
|
|
14
|
+
const workspace_context_1 = require("../../utils/workspace-context");
|
|
18
15
|
const error_types_1 = require("../../project-graph/error-types");
|
|
19
16
|
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
|
20
17
|
const consume_messages_from_socket_1 = require("../../utils/consume-messages-from-socket");
|
|
@@ -61,20 +58,6 @@ async function startNewDaemonInBackground() {
|
|
|
61
58
|
backgroundProcess.unref();
|
|
62
59
|
logger_1.serverLogger.log('Started new daemon process in background');
|
|
63
60
|
}
|
|
64
|
-
let watcherInstance;
|
|
65
|
-
function storeWatcherInstance(instance) {
|
|
66
|
-
watcherInstance = instance;
|
|
67
|
-
}
|
|
68
|
-
function getWatcherInstance() {
|
|
69
|
-
return watcherInstance;
|
|
70
|
-
}
|
|
71
|
-
let outputWatcherInstance;
|
|
72
|
-
function storeOutputWatcherInstance(instance) {
|
|
73
|
-
outputWatcherInstance = instance;
|
|
74
|
-
}
|
|
75
|
-
function getOutputWatcherInstance() {
|
|
76
|
-
return outputWatcherInstance;
|
|
77
|
-
}
|
|
78
61
|
async function handleServerProcessTermination({ server, reason, sockets, }) {
|
|
79
62
|
await performShutdown(server, reason, sockets);
|
|
80
63
|
}
|
|
@@ -95,14 +78,8 @@ async function performShutdown(server, reason, sockets) {
|
|
|
95
78
|
socket.destroy();
|
|
96
79
|
}
|
|
97
80
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
logger_1.serverLogger.watcherLog(`Stopping the watcher for ${workspace_root_1.workspaceRoot} (sources)`);
|
|
101
|
-
}
|
|
102
|
-
if (outputWatcherInstance) {
|
|
103
|
-
await outputWatcherInstance.stop();
|
|
104
|
-
logger_1.serverLogger.watcherLog(`Stopping the watcher for ${workspace_root_1.workspaceRoot} (outputs)`);
|
|
105
|
-
}
|
|
81
|
+
(0, workspace_context_1.stopWatchingWorkspaceContext)();
|
|
82
|
+
logger_1.serverLogger.watcherLog(`Stopping the watch for ${workspace_root_1.workspaceRoot}`);
|
|
106
83
|
(0, cache_1.deleteDaemonJsonProcessCache)();
|
|
107
84
|
(0, get_plugins_1.cleanupPlugins)();
|
|
108
85
|
// Clean up shared latest Nx installation
|
|
@@ -31,29 +31,29 @@ async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGrap
|
|
|
31
31
|
const customHasher = (0, utils_1.getCustomHasher)(task, projects);
|
|
32
32
|
return { task, customHasher };
|
|
33
33
|
}));
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
(0, task_hasher_1.getInputs)(task, projectGraph, nxJson).depsOutputs.length > 0);
|
|
42
|
-
})
|
|
34
|
+
// Custom hashers can read other tasks' outputs, so they hash at run time,
|
|
35
|
+
// and so does a task whose own inputs read them. The hasher still decides
|
|
36
|
+
// for the rest: outputs also arrive through a dependency's named input or
|
|
37
|
+
// a continuous server, which only planning reveals.
|
|
38
|
+
const candidates = tasksWithHashers
|
|
39
|
+
.filter(({ task, customHasher }) => !customHasher &&
|
|
40
|
+
!readsDependencyOutputs(task, taskGraph, projectGraph, nxJson))
|
|
43
41
|
.map((t) => t.task);
|
|
44
42
|
const perTaskEnvs = {};
|
|
45
|
-
for (const task of
|
|
43
|
+
for (const task of candidates) {
|
|
46
44
|
perTaskEnvs[task.id] = (0, task_env_1.getTaskSpecificEnv)(task, projectGraph);
|
|
47
45
|
}
|
|
48
|
-
const hashes = await hasher.
|
|
46
|
+
const hashes = await hasher.hashTasksUpfront(candidates, taskGraph, perTaskEnvs);
|
|
47
|
+
const tasksToHash = candidates.filter((task) => task.id in hashes);
|
|
49
48
|
const ioService = (0, task_io_service_1.getTaskIOService)();
|
|
50
49
|
const hasInputSubscribers = ioService.hasTaskInputSubscribers();
|
|
51
|
-
for (
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
for (const task of tasksToHash) {
|
|
51
|
+
const hash = hashes[task.id];
|
|
52
|
+
task.hash = hash.value;
|
|
53
|
+
task.hashDetails = hash.details;
|
|
54
54
|
// Notify TaskIOService of hash inputs
|
|
55
|
-
if (hasInputSubscribers &&
|
|
56
|
-
ioService.notifyTaskInputs(
|
|
55
|
+
if (hasInputSubscribers && hash.inputs) {
|
|
56
|
+
ioService.notifyTaskInputs(task.id, hash.inputs);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
if (tasksDetails?.recordTaskDetails) {
|
|
@@ -67,6 +67,10 @@ async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGrap
|
|
|
67
67
|
performance.mark('hashMultipleTasks:end');
|
|
68
68
|
performance.measure('hashMultipleTasks', 'hashMultipleTasks:start', 'hashMultipleTasks:end');
|
|
69
69
|
}
|
|
70
|
+
function readsDependencyOutputs(task, taskGraph, projectGraph, nxJson) {
|
|
71
|
+
return (taskGraph.dependencies[task.id]?.length > 0 &&
|
|
72
|
+
(0, task_hasher_1.getInputs)(task, projectGraph, nxJson).depsOutputs.length > 0);
|
|
73
|
+
}
|
|
70
74
|
async function hashTask(hasher, projectGraph, taskGraph, task, env, taskDetails) {
|
|
71
75
|
performance.mark('hashSingleTask:start');
|
|
72
76
|
const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
@@ -2,6 +2,7 @@ import { NxJsonConfiguration } from '../config/nx-json';
|
|
|
2
2
|
import { ProjectGraph } from '../config/project-graph';
|
|
3
3
|
import { Task, TaskGraph } from '../config/task-graph';
|
|
4
4
|
import { ExternalObject, FileData, HasherOptions, HashPlanner, ProjectGraph as NativeProjectGraph, NxWorkspaceFilesExternals, TaskHasher } from '../native';
|
|
5
|
+
import type { IgnoredIndexReader } from '../native';
|
|
5
6
|
import { PartialHash, TaskHasherImpl } from './task-hasher';
|
|
6
7
|
export declare class NativeTaskHasherImpl implements TaskHasherImpl {
|
|
7
8
|
hasher: TaskHasher;
|
|
@@ -9,10 +10,17 @@ export declare class NativeTaskHasherImpl implements TaskHasherImpl {
|
|
|
9
10
|
projectGraphRef: ExternalObject<NativeProjectGraph>;
|
|
10
11
|
allWorkspaceFilesRef: ExternalObject<FileData[]>;
|
|
11
12
|
projectFileMapRef: ExternalObject<Record<string, FileData[]>>;
|
|
13
|
+
ignoredIndexRef: ExternalObject<IgnoredIndexReader>;
|
|
12
14
|
options: HasherOptions | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Plans of the last up-front batch and the task graph they were built for.
|
|
17
|
+
* The tasks that batch deferred hash from them later without planning again.
|
|
18
|
+
*/
|
|
19
|
+
private upfrontPlans;
|
|
13
20
|
constructor(workspaceRoot: string, nxJson: NxJsonConfiguration, projectGraph: ProjectGraph, externals: NxWorkspaceFilesExternals, options: {
|
|
14
21
|
selectivelyHashTsConfig: boolean;
|
|
15
22
|
});
|
|
16
23
|
hashTask(task: Task, taskGraph: TaskGraph, env: NodeJS.ProcessEnv, cwd?: string, collectInputs?: boolean): Promise<PartialHash>;
|
|
17
24
|
hashTasks(tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>, cwd?: string, collectInputs?: boolean): Promise<PartialHash[]>;
|
|
25
|
+
hashTasksUpfront(tasks: Task[], taskGraph: TaskGraph, perTaskEnvs: Record<string, NodeJS.ProcessEnv>, cwd?: string, collectInputs?: boolean): Promise<Record<string, PartialHash>>;
|
|
18
26
|
}
|