@smoothbricks/nx-plugin 0.6.2 → 0.6.3-0
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/README.md +281 -73
- package/dist/.build-inputs.json +20 -14
- package/dist/bin/smoo-nx-publish.d.ts +3 -0
- package/dist/bin/smoo-nx-publish.d.ts.map +1 -0
- package/dist/bin/smoo-nx-publish.js +3 -0
- package/dist/cargo-retention-hook.d.ts +6 -2
- package/dist/cargo-retention-hook.d.ts.map +1 -1
- package/dist/cargo-retention-hook.js +13 -7
- package/dist/eslint-file-set.d.ts +4 -1
- package/dist/eslint-file-set.d.ts.map +1 -1
- package/dist/eslint-sources.d.ts +25 -0
- package/dist/eslint-sources.d.ts.map +1 -0
- package/dist/eslint-sources.js +99 -0
- package/dist/executors/all-verdicts/executor.d.ts +2 -1
- package/dist/executors/all-verdicts/executor.d.ts.map +1 -1
- package/dist/executors/all-verdicts/executor.js +48 -2
- package/dist/executors/all-verdicts/schema.d.ts +13 -0
- package/dist/executors/all-verdicts/schema.d.ts.map +1 -1
- package/dist/executors/all-verdicts/schema.js +7 -0
- package/dist/executors/bounded-exec/bounds.d.ts +57 -8
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +100 -11
- package/dist/executors/bounded-exec/executor.d.ts +2 -1
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +270 -27
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +2 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +2 -2
- package/dist/executors/bounded-exec/mbx-pool.d.ts +20 -3
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +84 -4
- package/dist/executors/bounded-exec/mbx-queue.d.ts +30 -0
- package/dist/executors/bounded-exec/mbx-queue.d.ts.map +1 -0
- package/dist/executors/bounded-exec/mbx-queue.js +229 -0
- package/dist/executors/bounded-exec/progress.d.ts +9 -2
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +148 -22
- package/dist/executors/bounded-exec/test-result-writer.d.ts +30 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -0
- package/dist/executors/bounded-exec/test-result-writer.js +126 -0
- package/dist/executors/bounded-exec/test-results.d.ts +33 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -0
- package/dist/executors/bounded-exec/test-results.js +33 -0
- package/dist/executors/bounded-exec/verdict.d.ts +20 -2
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +102 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -65
- package/dist/nx-publish.d.ts +24 -0
- package/dist/nx-publish.d.ts.map +1 -0
- package/dist/nx-publish.js +150 -0
- package/dist/runtime-input-policy.d.ts +14 -0
- package/dist/runtime-input-policy.d.ts.map +1 -1
- package/dist/runtime-input-policy.js +1 -1
- package/dist/tool-bins.d.ts +6 -8
- package/dist/tool-bins.d.ts.map +1 -1
- package/dist/tool-bins.js +7 -5
- package/dist/workspace-index.d.ts +7 -0
- package/dist/workspace-index.d.ts.map +1 -1
- package/dist/workspace-index.js +11 -0
- package/executors.json +1 -1
- package/managed/raw/patches/ttsc@0.34.1.patch +75 -0
- package/managed/raw/tooling/devenv +1 -2
- package/managed/raw/tooling/direnv/developer-links.ts +3 -0
- package/managed/raw/tooling/direnv/devenv.smoo.nix +34 -15
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -10
- package/managed/raw/tooling/direnv/setup-environment.ts +35 -20
- package/managed/raw/tooling/direnv/ttsc-env.sh +8 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +12 -11
- package/package.json +223 -7
- package/runtime/nx-publish/cache_adapter.js +45 -0
- package/runtime/nx-publish/nx_publish.js +60 -0
- package/runtime-input.sh +12 -3
- package/src/bin/smoo-nx-publish.ts +4 -0
- package/src/cargo-retention-hook.ts +16 -10
- package/src/eslint-file-set.ts +4 -1
- package/src/eslint-sources.ts +134 -0
- package/src/executors/all-verdicts/executor.ts +58 -3
- package/src/executors/all-verdicts/schema.json +4 -0
- package/src/executors/all-verdicts/schema.ts +14 -0
- package/src/executors/bounded-exec/bounds.ts +132 -15
- package/src/executors/bounded-exec/executor.ts +303 -27
- package/src/executors/bounded-exec/hang-diagnostics.ts +3 -2
- package/src/executors/bounded-exec/mbx-pool.ts +82 -5
- package/src/executors/bounded-exec/mbx-queue.ts +170 -0
- package/src/executors/bounded-exec/progress.ts +168 -15
- package/src/executors/bounded-exec/test-result-writer.ts +152 -0
- package/src/executors/bounded-exec/test-results.ts +39 -0
- package/src/executors/bounded-exec/verdict.ts +108 -5
- package/src/index.ts +74 -70
- package/src/nx-publish.ts +157 -0
- package/src/runtime-input-policy.ts +1 -1
- package/src/tool-bins.ts +13 -9
- package/src/workspace-index.ts +12 -0
- package/test-timings.json +8 -3
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import typia from 'typia';
|
|
3
4
|
import type { CpuWaitRow } from './lease-wait.js';
|
|
4
5
|
import { describeHolders, type LockWait, type Opener } from './lock-wait.js';
|
|
6
|
+
import type { MbxQueuedRequest } from './mbx-queue.js';
|
|
7
|
+
import type { NativeTestResult } from './test-result-writer.js';
|
|
8
|
+
import { TEST_FAILURES_FILE, TEST_RESULTS_FILE } from './test-results.js';
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Why one bounded run ended, recorded per Nx task so a caller can tell a load-sensitive bound
|
|
@@ -21,11 +25,14 @@ import { describeHolders, type LockWait, type Opener } from './lock-wait.js';
|
|
|
21
25
|
* - `no-space`: the run failed and its output said a write found no space (ENOSPC). Whatever its tests then reported,
|
|
22
26
|
* they failed on the disk, not on their own: the verdict names the line that said so and, when the task held one,
|
|
23
27
|
* its RAM temp volume as it stood when that line arrived.
|
|
28
|
+
* - `queued`: the command failed before any admission after a live task PID was explicitly seen waiting in mbx.
|
|
29
|
+
* Its observed wait and public queue positions describe admission pressure, never a wedged test.
|
|
24
30
|
* - `failed`: anything else that did not pass. That includes an assertion named in the report,
|
|
25
31
|
* or a non-zero exit with no report to say why.
|
|
26
32
|
*/
|
|
27
33
|
export type BoundedExecVerdict =
|
|
28
34
|
| { readonly outcome: 'passed' }
|
|
35
|
+
| ({ readonly outcome: 'queued'; readonly exitCode: number } & AdmissionQueueWait)
|
|
29
36
|
| {
|
|
30
37
|
readonly outcome: 'bound';
|
|
31
38
|
readonly bound: 'total' | 'fixture';
|
|
@@ -44,6 +51,13 @@ export type BoundedExecVerdict =
|
|
|
44
51
|
| ({ readonly outcome: 'no-space'; readonly exitCode: number; readonly tests: readonly string[] } & NoSpaceSighting)
|
|
45
52
|
| { readonly outcome: 'failed'; readonly exitCode: number; readonly tests: readonly string[] };
|
|
46
53
|
|
|
54
|
+
/** Observed admission wait, supplied only while the command has never received a grant. */
|
|
55
|
+
export interface AdmissionQueueWait {
|
|
56
|
+
readonly waitedMs: number;
|
|
57
|
+
readonly requests: readonly MbxQueuedRequest[];
|
|
58
|
+
}
|
|
59
|
+
const isQueuedVerdict = typia.createIs<Extract<BoundedExecVerdict, { outcome: 'queued' }>>();
|
|
60
|
+
|
|
47
61
|
/**
|
|
48
62
|
* The task's RAM temp volume, read when a line saying ENOSPC arrived: the writer's own lease and the space left on the
|
|
49
63
|
* volume it was taken on (`measured`), or why there was none to measure: the lease was no longer on that volume
|
|
@@ -178,6 +192,64 @@ export function junitFailures(xml: string): JunitFailures {
|
|
|
178
192
|
return { timedOut, cancelled, failed };
|
|
179
193
|
}
|
|
180
194
|
|
|
195
|
+
/** Bun's nested suites carry the describe chain; testcase.classname is in the reverse order. */
|
|
196
|
+
export function bunJunitResults(xml: string): NativeTestResult[] {
|
|
197
|
+
const results: NativeTestResult[] = [];
|
|
198
|
+
const suites: string[] = [];
|
|
199
|
+
let current: { attributes: string; body: string } | null = null;
|
|
200
|
+
const text = xml;
|
|
201
|
+
const tags =
|
|
202
|
+
/<!\[CDATA\[[\s\S]*?\]\]>|<!--[\s\S]*?-->|<(\/?)(testsuite|testcase)\b((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/g;
|
|
203
|
+
let end = 0;
|
|
204
|
+
const close = (): void => {
|
|
205
|
+
if (current === null) return;
|
|
206
|
+
const name = attribute(current.attributes, 'name');
|
|
207
|
+
const file = attribute(current.attributes, 'file');
|
|
208
|
+
if (name !== null && file !== null) {
|
|
209
|
+
const failed = /<(?:failure|error)\b/.test(current.body);
|
|
210
|
+
const skipped = /<skipped\b/.test(current.body);
|
|
211
|
+
const line = attribute(current.attributes, 'line');
|
|
212
|
+
const time = attribute(current.attributes, 'time');
|
|
213
|
+
const seconds = time === null ? Number.NaN : Number(time);
|
|
214
|
+
const output =
|
|
215
|
+
/<(?:failure|error)\b((?:[^>"']|"[^"]*"|'[^']*')*?)(?:\/>|>((?:<!\[CDATA\[[\s\S]*?\]\]>|(?!<!\[CDATA\[|<\/(?:failure|error)>)[\s\S])*)<\/(?:failure|error)>)/.exec(
|
|
216
|
+
current.body,
|
|
217
|
+
);
|
|
218
|
+
const failureOutput =
|
|
219
|
+
output === null
|
|
220
|
+
? null
|
|
221
|
+
: output[2] === undefined || output[2] === ''
|
|
222
|
+
? (attribute(output[1] ?? '', 'message') ?? '')
|
|
223
|
+
: decodeJunitText(output[2]);
|
|
224
|
+
results.push({
|
|
225
|
+
id: `${file}::${[...suites.slice(1), name].join(' > ')}`,
|
|
226
|
+
status: failed ? 'fail' : skipped ? 'skip' : 'pass',
|
|
227
|
+
source: 'junit',
|
|
228
|
+
durationMs: Number.isFinite(seconds) && seconds >= 0 ? seconds * 1000 : null,
|
|
229
|
+
sourceRef: line === null ? null : `${file}:${line}`,
|
|
230
|
+
failureOutput,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
current = null;
|
|
234
|
+
};
|
|
235
|
+
for (const match of text.matchAll(tags)) {
|
|
236
|
+
if (current !== null) current.body += text.slice(end, match.index);
|
|
237
|
+
end = match.index + match[0].length;
|
|
238
|
+
const [, slash, tag, attributes = '', selfClosing] = match;
|
|
239
|
+
if (tag === undefined) {
|
|
240
|
+
if (current !== null) current.body += match[0];
|
|
241
|
+
} else if (tag === 'testsuite') {
|
|
242
|
+
if (slash === '/') suites.pop();
|
|
243
|
+
else if (selfClosing !== '/') suites.push(attribute(attributes, 'name') ?? '');
|
|
244
|
+
} else if (slash === '/') close();
|
|
245
|
+
else {
|
|
246
|
+
close();
|
|
247
|
+
current = { attributes, body: '' };
|
|
248
|
+
if (selfClosing === '/') close();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return results;
|
|
252
|
+
}
|
|
181
253
|
/** One test case of a JUnit report: nextest's binary id (its `classname`), the test's name and its seconds. */
|
|
182
254
|
export interface JunitCaseTime {
|
|
183
255
|
readonly binary: string;
|
|
@@ -209,6 +281,16 @@ function attribute(attributes: string, name: string): string | null {
|
|
|
209
281
|
return decodeEntities(match[2] ?? match[3] ?? '');
|
|
210
282
|
}
|
|
211
283
|
|
|
284
|
+
function decodeJunitText(value: string): string {
|
|
285
|
+
let text = '';
|
|
286
|
+
let end = 0;
|
|
287
|
+
for (const match of value.matchAll(/<!\[CDATA\[([\s\S]*?)\]\]>|<!--[\s\S]*?-->/g)) {
|
|
288
|
+
text += decodeEntities(value.slice(end, match.index));
|
|
289
|
+
text += match[1] ?? '';
|
|
290
|
+
end = match.index + match[0].length;
|
|
291
|
+
}
|
|
292
|
+
return text + decodeEntities(value.slice(end));
|
|
293
|
+
}
|
|
212
294
|
function decodeEntities(value: string): string {
|
|
213
295
|
return value.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g, (_, entity: string) => {
|
|
214
296
|
switch (entity) {
|
|
@@ -255,6 +337,8 @@ export interface RunEnd {
|
|
|
255
337
|
readonly noSpace: NoSpaceSighting | null;
|
|
256
338
|
/** The lock waits the expiry's snapshot named; empty when none, or when that capture did not complete. */
|
|
257
339
|
readonly lockWaits: readonly LockWait[];
|
|
340
|
+
/** Explicit observed queue evidence before first admission; absent after any grant. */
|
|
341
|
+
readonly admissionQueue?: AdmissionQueueWait | null;
|
|
258
342
|
}
|
|
259
343
|
|
|
260
344
|
/**
|
|
@@ -270,6 +354,9 @@ export function judgeRun(run: RunEnd): BoundedExecVerdict {
|
|
|
270
354
|
const tests = run.report === null ? [] : [...run.report.failed, ...run.report.timedOut, ...run.report.cancelled];
|
|
271
355
|
return { outcome: 'no-space', exitCode: run.exitCode === 0 ? 1 : run.exitCode, tests, ...run.noSpace };
|
|
272
356
|
}
|
|
357
|
+
if (run.admissionQueue != null && run.exitCode !== 0) {
|
|
358
|
+
return { outcome: 'queued', exitCode: run.exitCode, ...run.admissionQueue };
|
|
359
|
+
}
|
|
273
360
|
if (run.expiry?.kind === 'idle') {
|
|
274
361
|
const tests = [...new Set([...run.expiry.tests, ...(run.report?.cancelled ?? [])])];
|
|
275
362
|
return { outcome: 'wedged', idleMs: run.expiry.limitMs, elapsedMs: run.elapsedMs, tests, lockWaits: run.lockWaits };
|
|
@@ -367,6 +454,8 @@ export async function clearTaskDirectory(directory: string): Promise<void> {
|
|
|
367
454
|
await Promise.all([
|
|
368
455
|
rm(join(directory, VERDICT_FILE), { force: true }),
|
|
369
456
|
rm(join(directory, JUNIT_FILE), { force: true }),
|
|
457
|
+
rm(join(directory, TEST_RESULTS_FILE), { force: true }),
|
|
458
|
+
rm(join(directory, TEST_FAILURES_FILE), { force: true }),
|
|
370
459
|
]);
|
|
371
460
|
}
|
|
372
461
|
|
|
@@ -392,13 +481,16 @@ export async function readRecord(directory: string): Promise<BoundedExecRecord |
|
|
|
392
481
|
}
|
|
393
482
|
|
|
394
483
|
/** The JUnit report a command wrote into `directory`, or `null` when it wrote none. */
|
|
395
|
-
export async function readJunitReport(
|
|
484
|
+
export async function readJunitReport(
|
|
485
|
+
directory: string,
|
|
486
|
+
bunClosed?: (results: readonly NativeTestResult[]) => void,
|
|
487
|
+
): Promise<JunitFailures | null> {
|
|
396
488
|
try {
|
|
397
|
-
|
|
489
|
+
const xml = await readFile(join(directory, JUNIT_FILE), 'utf8');
|
|
490
|
+
bunClosed?.(bunJunitResults(xml));
|
|
491
|
+
return junitFailures(xml);
|
|
398
492
|
} catch (error) {
|
|
399
|
-
if (isNotFound(error))
|
|
400
|
-
return null;
|
|
401
|
-
}
|
|
493
|
+
if (isNotFound(error)) return null;
|
|
402
494
|
throw error;
|
|
403
495
|
}
|
|
404
496
|
}
|
|
@@ -419,6 +511,9 @@ function parseVerdict(value: unknown): BoundedExecVerdict {
|
|
|
419
511
|
switch (value.outcome) {
|
|
420
512
|
case 'passed':
|
|
421
513
|
return { outcome: 'passed' };
|
|
514
|
+
case 'queued':
|
|
515
|
+
if (isQueuedVerdict(value)) return value;
|
|
516
|
+
break;
|
|
422
517
|
case 'bound':
|
|
423
518
|
if (
|
|
424
519
|
(value.bound === 'total' || value.bound === 'fixture') &&
|
|
@@ -568,10 +663,18 @@ export async function failedTasksOfRun(runJson: unknown, workspaceData: string):
|
|
|
568
663
|
return failed;
|
|
569
664
|
}
|
|
570
665
|
|
|
666
|
+
/** The same honest admission diagnostic in live output and a terminal verdict. */
|
|
667
|
+
export function describeAdmissionQueue(wait: AdmissionQueueWait): string {
|
|
668
|
+
return `queued for admission ${(wait.waitedMs / 1_000).toFixed(1)} s; mbx ${wait.requests
|
|
669
|
+
.map((request) => `pid=${request.pid} ticket=${request.ticket} queue position=${request.queuePosition}`)
|
|
670
|
+
.join(', ')}`;
|
|
671
|
+
}
|
|
571
672
|
export function describeVerdict(verdict: BoundedExecVerdict): string {
|
|
572
673
|
switch (verdict.outcome) {
|
|
573
674
|
case 'passed':
|
|
574
675
|
return 'passed';
|
|
676
|
+
case 'queued':
|
|
677
|
+
return `${describeAdmissionQueue(verdict)}; exited ${verdict.exitCode} before first admission`;
|
|
575
678
|
case 'bound':
|
|
576
679
|
return verdict.bound === 'test'
|
|
577
680
|
? `per-test timeout only: ${verdict.tests.join(', ')}`
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
} from 'nx/src/devkit-exports.js';
|
|
24
24
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
25
25
|
import { parse as parseToml } from 'smol-toml';
|
|
26
|
-
import { type ParsedCommandLine, parseJsonConfigFileContent, readConfigFile, sys as typescriptSys } from 'typescript';
|
|
27
26
|
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
|
|
28
27
|
import { refuseOverlappingOutputs } from './build-state-output-policy.js';
|
|
29
28
|
import { bunLockDependencies, bunLockInput, bunLockNode } from './bun-lock-scope.js';
|
|
@@ -78,7 +77,12 @@ import {
|
|
|
78
77
|
} from './cross-check-policy.js';
|
|
79
78
|
import { eslintConfigClosure } from './eslint-config-closure.js';
|
|
80
79
|
import type { EslintFileSet } from './eslint-file-set.js';
|
|
81
|
-
import {
|
|
80
|
+
import { ESLINT_SOURCES_GLOB, eslintSources } from './eslint-sources.js';
|
|
81
|
+
import {
|
|
82
|
+
ALL_VERDICTS_EXECUTOR,
|
|
83
|
+
type AllVerdictsOptions,
|
|
84
|
+
ESLINT_SOURCES_TOKEN,
|
|
85
|
+
} from './executors/all-verdicts/schema.js';
|
|
82
86
|
import { closeRunCpuPool, serveRunCpuPool } from './executors/bounded-exec/run-cpu-pool.js';
|
|
83
87
|
import { ffiPathProblem } from './executors/scriptc-native/ffi-paths.js';
|
|
84
88
|
import type { ScriptcNativeFfi } from './executors/scriptc-native/schema.js';
|
|
@@ -90,7 +94,6 @@ import {
|
|
|
90
94
|
preTasksExecution as preProducerReceipts,
|
|
91
95
|
} from './producer-receipts.js';
|
|
92
96
|
import { runtimeInput, shellWord } from './runtime-input.js';
|
|
93
|
-
import { isNonSourceDirectory } from './source-directories.js';
|
|
94
97
|
import { inferredTaskKind, refuseBuildTestDependencies } from './task-graph-policy.js';
|
|
95
98
|
import { postTasksExecution as postTaskResults, preTasksExecution as preTaskResults } from './task-results.js';
|
|
96
99
|
import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite } from './test-timings.js';
|
|
@@ -371,9 +374,6 @@ const ESLINT_CONFIG_FILES = [
|
|
|
371
374
|
'eslint.config.cts',
|
|
372
375
|
];
|
|
373
376
|
|
|
374
|
-
/** Every JavaScript and TypeScript module kind ESLint is handed. */
|
|
375
|
-
const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
|
|
376
|
-
|
|
377
377
|
/** What ESLint lints in this workspace and what its configuration loads. */
|
|
378
378
|
interface EslintWorkspace {
|
|
379
379
|
/** The JavaScript and TypeScript files of Nx's workspace file index. */
|
|
@@ -386,14 +386,15 @@ interface EslintWorkspace {
|
|
|
386
386
|
* The ESLint sources and config closure of Nx's workspace file index, listed
|
|
387
387
|
* once per graph computation; `null` when no workspace ESLint config enables ESLint.
|
|
388
388
|
*
|
|
389
|
-
* The
|
|
390
|
-
* inputs
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
389
|
+
* The lists the graph records for a project (its lint target's metadata, and
|
|
390
|
+
* the inputs that name its program files) are drawn from the index, not from a
|
|
391
|
+
* walk of the tree. A walk also listed gitignored generated modules a build had
|
|
392
|
+
* left on disk, so every such task's key depended on whether a build had run in
|
|
393
|
+
* that checkout: one workspace's graph listed them and a fresh fork's did not,
|
|
394
|
+
* which alone re-keyed 197 of 510 gate tasks. Drawing them from the index makes
|
|
395
|
+
* the plugin and the hasher agree on one file set. What the lint command runs
|
|
396
|
+
* on is in no graph: the executor reads it when the command runs
|
|
397
|
+
* (eslint-sources.ts).
|
|
397
398
|
*
|
|
398
399
|
* The configs key every lint target with exactly the workspace files they
|
|
399
400
|
* load (eslint-config-closure.ts): a glob over the directory holding a
|
|
@@ -410,18 +411,6 @@ async function eslintWorkspace(workspaceRoot: string): Promise<EslintWorkspace |
|
|
|
410
411
|
};
|
|
411
412
|
}
|
|
412
413
|
|
|
413
|
-
/**
|
|
414
|
-
* Read a tsconfig with this plugin's own TypeScript. `@nx/js`'s readTsConfig does an
|
|
415
|
-
* undeclared `require('typescript')` resolved from its own location: where that lands on the
|
|
416
|
-
* TypeScript 7 native package (whose entry exports only its version), `sys` is undefined and
|
|
417
|
-
* graph construction dies reading `sys.readFile`. The plugin declares TypeScript 6, whose
|
|
418
|
-
* `sys` this uses, so the resolution is the one this package's manifest promises.
|
|
419
|
-
*/
|
|
420
|
-
function readTestTsConfig(testConfig: string): ParsedCommandLine {
|
|
421
|
-
const readResult = readConfigFile(testConfig, typescriptSys.readFile);
|
|
422
|
-
return parseJsonConfigFileContent(readResult.config, typescriptSys, dirname(testConfig));
|
|
423
|
-
}
|
|
424
|
-
|
|
425
414
|
function projectLintCommands(
|
|
426
415
|
projectRoot: string,
|
|
427
416
|
workspaceRoot: string,
|
|
@@ -430,54 +419,22 @@ function projectLintCommands(
|
|
|
430
419
|
const commands: string[] = [];
|
|
431
420
|
const inputs: string[] = [];
|
|
432
421
|
let eslintFileSet: EslintFileSet | null = null;
|
|
433
|
-
const absoluteProjectRoot = join(workspaceRoot, projectRoot);
|
|
434
422
|
const quote = (path: string) => `'${path.replaceAll("'", "'\"'\"'")}'`;
|
|
435
423
|
if (BIOME_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) {
|
|
436
424
|
commands.push(`biome check --files-ignore-unknown=true ${quote(projectRoot)}`);
|
|
437
425
|
}
|
|
438
426
|
if (eslint !== null) {
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
sourceFiles.add(path);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
const testConfig = join(absoluteProjectRoot, 'tsconfig.test.json');
|
|
450
|
-
if (existsSync(testConfig)) {
|
|
451
|
-
// A test program can live anywhere the declaration selects, not just src.
|
|
452
|
-
// Use the compiler's file set and the existing declaration-chain hasher,
|
|
453
|
-
// so inherited includes and files outside this project keep their keys.
|
|
454
|
-
const program: ParsedCommandLine = readTestTsConfig(testConfig);
|
|
455
|
-
const errors = program.errors.filter(({ code }) => code !== 18003);
|
|
456
|
-
if (errors.length > 0) {
|
|
457
|
-
throw new Error(
|
|
458
|
-
`${testConfig}: ${errors.map(({ code, messageText }) => `TS${code}: ${JSON.stringify(messageText)}`).join('; ')}`,
|
|
459
|
-
);
|
|
460
|
-
}
|
|
461
|
-
inputs.push('{projectRoot}/tsconfig.test.json');
|
|
462
|
-
for (const file of program.fileNames) {
|
|
463
|
-
const path = relative(workspaceRoot, file).split(sep).join('/');
|
|
464
|
-
if (path === '..' || path.startsWith('../') || isAbsolute(path)) {
|
|
465
|
-
throw new Error(`${testConfig}: test source ${file} is outside the workspace and cannot be hashed`);
|
|
466
|
-
}
|
|
467
|
-
// Only a module Nx indexes is linted and keyed. An ignored one is build
|
|
468
|
-
// output that a fresh checkout lacks; a JSON file is not ESLint's.
|
|
469
|
-
if (!eslint.sources.has(path) || path.split('/').some(isNonSourceDirectory)) continue;
|
|
470
|
-
sourceFiles.add(path);
|
|
471
|
-
inputs.push(`{workspaceRoot}/${path}`);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
if (sourceFiles.size > 0) {
|
|
475
|
-
const files = [...sourceFiles].sort();
|
|
476
|
-
eslintFileSet = { command: `eslint ${files.map(quote).join(' ')}`, files };
|
|
427
|
+
const sources = eslintSources(workspaceRoot, projectRoot, eslint.sources);
|
|
428
|
+
inputs.push(...sources.inputs);
|
|
429
|
+
// The command names no file: a graph the daemon serves past a deletion or an addition would hand ESLint a pattern
|
|
430
|
+
// no file matches, or leave a new file unlinted. The all-verdicts executor resolves the token when it runs, and the
|
|
431
|
+
// list beside the command is the file set this graph resolved, for the inspectors that read it.
|
|
432
|
+
if (sources.files.length > 0) {
|
|
433
|
+
eslintFileSet = { command: `eslint ${ESLINT_SOURCES_TOKEN}`, files: sources.files };
|
|
477
434
|
commands.push(eslintFileSet.command);
|
|
478
435
|
}
|
|
479
436
|
}
|
|
480
|
-
return { commands, inputs
|
|
437
|
+
return { commands, inputs, eslintFileSet };
|
|
481
438
|
}
|
|
482
439
|
|
|
483
440
|
type NapiArchitecture = 'arm64' | 'x64';
|
|
@@ -1188,8 +1145,9 @@ function isBuildOutputPackageJson(packageJsonPath: string): boolean {
|
|
|
1188
1145
|
* hint and the opt-in producer completion receipts. Each sees the same options and run context; neither reads the
|
|
1189
1146
|
* other's output. The hint is recorded first so a producer-receipt bug cannot cost the controller its evidence. The
|
|
1190
1147
|
* pair also serves a run that inherits no CPU pool its own, which every task inherits (`run-cpu-pool.ts`), and closes
|
|
1191
|
-
* it when the run ends. Last, once every task has finished, the post hook
|
|
1192
|
-
* superseded Cargo unit generations of each Cargo workspace the run built into
|
|
1148
|
+
* it when the run ends. Last, once every task has finished, the post hook starts the reclaim of the
|
|
1149
|
+
* superseded Cargo unit generations of each Cargo workspace the run built into, in a process of its own, never on
|
|
1150
|
+
* Nx's thread (`@smoothbricks/cargo-retain`).
|
|
1193
1151
|
*/
|
|
1194
1152
|
export const preTasksExecution: PreTasksExecution<ProducerReceiptsOptions> = async (options, context) => {
|
|
1195
1153
|
// Before any task is hashed: a workspace that declares the test-walk check
|
|
@@ -2354,12 +2312,56 @@ async function createProjectTargets(
|
|
|
2354
2312
|
],
|
|
2355
2313
|
...(lintCommands.length > 0
|
|
2356
2314
|
? {
|
|
2357
|
-
options: {
|
|
2315
|
+
options: {
|
|
2316
|
+
commands: lintCommands,
|
|
2317
|
+
cwd: '.',
|
|
2318
|
+
...(eslintFileSet === null ? {} : { eslintProjectRoot: projectRoot }),
|
|
2319
|
+
} satisfies AllVerdictsOptions,
|
|
2358
2320
|
}
|
|
2359
2321
|
: {}),
|
|
2360
2322
|
};
|
|
2361
2323
|
}
|
|
2362
2324
|
|
|
2325
|
+
// The process-lineage entry has no full API-generator dependency: the generator check itself is bounded work.
|
|
2326
|
+
const lineageProducer = nativeToolDependsOn(nativeTools, 'cowshed', 'lineage-js');
|
|
2327
|
+
if (lineageProducer.length > 0 && packageJson.name === '@smoothbricks/nx-plugin') {
|
|
2328
|
+
for (const name of ['tsc-js', 'typecheck', 'typecheck-tests']) {
|
|
2329
|
+
const target = targets[name];
|
|
2330
|
+
if (target === undefined) continue;
|
|
2331
|
+
target.dependsOn = [...(target.dependsOn ?? []), ...lineageProducer];
|
|
2332
|
+
target.inputs = [
|
|
2333
|
+
...(target.inputs ?? ['production']),
|
|
2334
|
+
{ dependentTasksOutputFiles: '**/dist/lineage/**/*', transitive: false },
|
|
2335
|
+
];
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
// Runtime observers need the local addon, not the package aggregate (which can deliberately build only JS).
|
|
2340
|
+
// Declarations retain these prerequisites and output inputs with Nx's ordinary "..." merge token.
|
|
2341
|
+
// The canonical release-check instead judges prebuilt shipping artifacts and must remain dependency-free.
|
|
2342
|
+
const observerProducers = [...nativeToolDependsOn(nativeTools, 'cowshed'), ...lineageProducer];
|
|
2343
|
+
if (observerProducers.length > 0) {
|
|
2344
|
+
for (const name of new Set([...Object.keys(targets), ...Object.keys(declaredTargets)])) {
|
|
2345
|
+
const declared = declaredTargets[name];
|
|
2346
|
+
const executor =
|
|
2347
|
+
isRecord(declared) && declared.executor !== undefined ? declared.executor : targets[name]?.executor;
|
|
2348
|
+
if (executor !== '@smoothbricks/nx-plugin:bounded-exec' || name === 'release-check') continue;
|
|
2349
|
+
// Nx discards an incompatible executor's inferred configuration; only the observer prerequisites belong below it.
|
|
2350
|
+
if (targets[name]?.executor !== undefined && targets[name]?.executor !== executor) {
|
|
2351
|
+
targets[name] = {};
|
|
2352
|
+
}
|
|
2353
|
+
targets[name] ??= {};
|
|
2354
|
+
const target = targets[name];
|
|
2355
|
+
target.dependsOn = [...(target.dependsOn ?? []), ...observerProducers];
|
|
2356
|
+
const inputs =
|
|
2357
|
+
target.inputs ?? (isRecord(declared) && Array.isArray(declared.inputs) ? [] : ['default', '^production']);
|
|
2358
|
+
target.inputs = [
|
|
2359
|
+
...inputs,
|
|
2360
|
+
{ dependentTasksOutputFiles: '**/*.node', transitive: true },
|
|
2361
|
+
{ dependentTasksOutputFiles: '**/dist/lineage/**/*.js', transitive: true },
|
|
2362
|
+
];
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2363
2365
|
// Publish each inferred target's semantic kind (`inferredTaskKind`) as metadata. Nx merges metadata beneath a
|
|
2364
2366
|
// declaration, so the final graph still says which tasks are build and which are test work after a package rewrites
|
|
2365
2367
|
// one. Fresh objects: `CARGO_PRODUCER_METADATA` is shared by every producer.
|
|
@@ -2386,7 +2388,9 @@ async function createProjectTargets(
|
|
|
2386
2388
|
[VERSIONLESS_PRODUCTION_INPUT]: ['production', ...versionlessProjectInputs],
|
|
2387
2389
|
[VERSIONLESS_DEFAULT_INPUT]: ['default', ...versionlessProjectInputs],
|
|
2388
2390
|
}),
|
|
2389
|
-
...(Object.keys(targets)
|
|
2391
|
+
...([...Object.keys(targets), ...Object.keys(declaredTargets)].some(
|
|
2392
|
+
(name) => name.startsWith('cargo-') || name.startsWith('napi-'),
|
|
2393
|
+
)
|
|
2390
2394
|
? { [CARGO_TOOLCHAIN_NAMED_INPUT]: cargoToolchainInputs() }
|
|
2391
2395
|
: {}),
|
|
2392
2396
|
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Accepted-task publication for declared gates (specs/cowshed/05_gateway.md, "Publication").
|
|
2
|
+
// Capture each successful Nx invocation before another overwrites run.json; publish the captured lists only after
|
|
3
|
+
// the entire gate passes. Ordinary shed clients remain read-only.
|
|
4
|
+
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { isAbsolute, join } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const USAGE = 'usage: smoo-nx-publish hashes RUN_JSON SINCE_EPOCH | publish CHECKOUT HASHES_JSON\n';
|
|
11
|
+
|
|
12
|
+
/** A task hash as the gateway's cache route takes it (05_gateway.md). */
|
|
13
|
+
const TASK_HASH = /^[A-Za-z0-9_-]{1,128}$/;
|
|
14
|
+
|
|
15
|
+
// One cached producer copies the unchanged canonical cowshed scripts outside the TypeScript output tree.
|
|
16
|
+
const PUBLISH_ASSETS = fileURLToPath(new URL('../runtime/nx-publish/', import.meta.url));
|
|
17
|
+
|
|
18
|
+
/** A refusal says why: a malformed summary or hash list is never guessed at. */
|
|
19
|
+
export type HashList =
|
|
20
|
+
| { readonly kind: 'hashes'; readonly hashes: readonly string[] }
|
|
21
|
+
| { readonly kind: 'refused'; readonly why: string };
|
|
22
|
+
|
|
23
|
+
const refusal = (why: string): HashList => ({ kind: 'refused', why });
|
|
24
|
+
|
|
25
|
+
function errorMessage(error: unknown): string {
|
|
26
|
+
return error instanceof Error ? error.message : String(error);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function isRecord(value: unknown): value is Record<string, unknown> {
|
|
30
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isTaskHash(value: unknown): value is string {
|
|
34
|
+
return typeof value === 'string' && TASK_HASH.test(value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Why a run summary's `run` is not of the invocation that began at `since` (epoch milliseconds), or undefined when it
|
|
39
|
+
* is. A summary Nx began before the gate is an earlier invocation's: its tasks are not the gate's.
|
|
40
|
+
*/
|
|
41
|
+
export function staleSummary(run: Record<string, unknown>, since: number): string | undefined {
|
|
42
|
+
const started = run.startTime;
|
|
43
|
+
const startedAt = typeof started === 'string' ? Date.parse(started) : Number.NaN;
|
|
44
|
+
if (Number.isNaN(startedAt)) return `the run summary has no start time: ${JSON.stringify(started)}`;
|
|
45
|
+
if (startedAt >= since) return undefined;
|
|
46
|
+
return `the run summary is of an invocation that began at ${started}, before this gate began at ${new Date(since).toISOString()}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The distinct hashes of the run's succeeded tasks (status 0), in run order, from a summary Nx began at or after
|
|
51
|
+
* `since` (epoch milliseconds). Every task must be well formed, failed or not.
|
|
52
|
+
*/
|
|
53
|
+
export function succeededHashes(since: number, summaryJson: string): HashList {
|
|
54
|
+
let summary: unknown;
|
|
55
|
+
try {
|
|
56
|
+
summary = JSON.parse(summaryJson);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return refusal(`the run summary is not JSON: ${errorMessage(error)}`);
|
|
59
|
+
}
|
|
60
|
+
if (!isRecord(summary) || !isRecord(summary.run) || !Array.isArray(summary.tasks)) {
|
|
61
|
+
return refusal('the run summary has no run object or no tasks array');
|
|
62
|
+
}
|
|
63
|
+
const stale = staleSummary(summary.run, since);
|
|
64
|
+
if (stale !== undefined) return refusal(stale);
|
|
65
|
+
const tasks: readonly unknown[] = summary.tasks;
|
|
66
|
+
const hashes = new Set<string>();
|
|
67
|
+
for (const task of tasks) {
|
|
68
|
+
if (!isRecord(task) || typeof task.status !== 'number') {
|
|
69
|
+
return refusal(`the run summary has a task without a numeric status: ${JSON.stringify(task)}`);
|
|
70
|
+
}
|
|
71
|
+
if (!isTaskHash(task.hash)) {
|
|
72
|
+
return refusal(`the run summary has an invalid task hash: ${JSON.stringify(task.hash)}`);
|
|
73
|
+
}
|
|
74
|
+
if (task.status === 0) hashes.add(task.hash);
|
|
75
|
+
}
|
|
76
|
+
return { kind: 'hashes', hashes: [...hashes] };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The hash list 'hashes' printed: a JSON array of distinct, well-formed task hashes. 'publish' checks it before spawning. */
|
|
80
|
+
export function hashList(text: string): HashList {
|
|
81
|
+
let value: unknown;
|
|
82
|
+
try {
|
|
83
|
+
value = JSON.parse(text);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return refusal(`the hash list is not JSON: ${errorMessage(error)}`);
|
|
86
|
+
}
|
|
87
|
+
if (!Array.isArray(value) || !value.every(isTaskHash)) {
|
|
88
|
+
return refusal('the hash list is not a JSON array of valid task hashes');
|
|
89
|
+
}
|
|
90
|
+
if (new Set(value).size !== value.length) return refusal('the hash list repeats a task hash');
|
|
91
|
+
return { kind: 'hashes', hashes: value };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** cache_adapter.js first: it defines the cache nx_publish.js calls. Both go to 'node -' as one program. */
|
|
95
|
+
function bridgeProgram(): string {
|
|
96
|
+
const adapter = readFileSync(join(PUBLISH_ASSETS, 'cache_adapter.js'), 'utf8');
|
|
97
|
+
const publisher = readFileSync(join(PUBLISH_ASSETS, 'nx_publish.js'), 'utf8');
|
|
98
|
+
return `${adapter}\n${publisher}`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Runs the bridge as 'node - ARGS' with the program on stdin. Its stderr is ours; its stdout comes back. */
|
|
102
|
+
function runBridge(args: readonly string[]): Promise<{ readonly status: number; readonly stdout: string }> {
|
|
103
|
+
// Read before spawning: a read that threw after the spawn would leave node waiting on a stdin that never closes.
|
|
104
|
+
const program = bridgeProgram();
|
|
105
|
+
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: the accepted-result archive command lasts as long as its work; node close/error settles this wait, and the operator's interrupt or the enclosing cowshed job or test-runner lifecycle ends a hung one (05_gateway.md, "Deadlines", "Enforcement")
|
|
106
|
+
return new Promise((resolve, reject) => {
|
|
107
|
+
const child = spawn('node', ['-', ...args], { stdio: ['pipe', 'pipe', 'inherit'] });
|
|
108
|
+
let stdout = '';
|
|
109
|
+
child.stdout.setEncoding('utf8');
|
|
110
|
+
child.stdout.on('data', (chunk: string) => {
|
|
111
|
+
stdout += chunk;
|
|
112
|
+
});
|
|
113
|
+
child.on('error', reject);
|
|
114
|
+
child.on('close', (status, signal) => {
|
|
115
|
+
if (status === null) reject(new Error(`node ended by signal ${String(signal)}`));
|
|
116
|
+
else resolve({ status, stdout });
|
|
117
|
+
});
|
|
118
|
+
child.stdin.on('error', reject);
|
|
119
|
+
child.stdin.end(program);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function fail(why: string): number {
|
|
124
|
+
process.stderr.write(`smoo-nx-publish: ${why}\n`);
|
|
125
|
+
return 1;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function main(argv: readonly string[]): Promise<number> {
|
|
129
|
+
const [verb, first, second] = argv;
|
|
130
|
+
if (verb === 'hashes' && argv.length === 3 && first !== undefined && second !== undefined) {
|
|
131
|
+
const since = Number(second);
|
|
132
|
+
if (!Number.isInteger(since)) return fail(`SINCE must be whole epoch seconds, not ${second}`);
|
|
133
|
+
const result = succeededHashes(since * 1000, readFileSync(first, 'utf8'));
|
|
134
|
+
if (result.kind === 'refused') return fail(result.why);
|
|
135
|
+
process.stdout.write(`${JSON.stringify(result.hashes)}\n`);
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
if (verb === 'publish' && argv.length === 3 && first !== undefined && second !== undefined) {
|
|
139
|
+
if (!isAbsolute(first)) return fail(`the checkout must be an absolute path, not ${first}`);
|
|
140
|
+
const list = hashList(readFileSync(second, 'utf8'));
|
|
141
|
+
if (list.kind === 'refused') return fail(list.why);
|
|
142
|
+
const bridge = await runBridge([first, JSON.stringify(list.hashes)]);
|
|
143
|
+
process.stdout.write(bridge.stdout);
|
|
144
|
+
return bridge.status;
|
|
145
|
+
}
|
|
146
|
+
process.stderr.write(USAGE);
|
|
147
|
+
return 64;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Run the packaged publisher, returning a failure status and diagnostic for operational refusals. */
|
|
151
|
+
export async function runNxPublish(argv: readonly string[]): Promise<number> {
|
|
152
|
+
try {
|
|
153
|
+
return await main(argv);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
return fail(errorMessage(error));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -107,7 +107,7 @@ function closingBracket(text: string, from: number, open: string, close: string)
|
|
|
107
107
|
* The shell tokens of `script`. A command substitution is part of its word, and the programs it runs are appended to
|
|
108
108
|
* `nested`; quoting is removed from the words, which are only inspected, never run.
|
|
109
109
|
*/
|
|
110
|
-
function shellTokens(script: string, nested: string[]): Token[] {
|
|
110
|
+
export function shellTokens(script: string, nested: string[]): Token[] {
|
|
111
111
|
const tokens: Token[] = [];
|
|
112
112
|
let word: string | undefined;
|
|
113
113
|
const flush = (): void => {
|
package/src/tool-bins.ts
CHANGED
|
@@ -23,18 +23,16 @@ function toolCommand(cwd: string, tool: string, file: string): string {
|
|
|
23
23
|
return `${posix.join(posix.relative(cwd, '.'), PLUGIN_LINK)}/../${tool}/${file}`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/** The tool packages whose
|
|
27
|
-
const NATIVE_TOOL_PACKAGES = ['build-inputs', 'cargo-retain', 'nextest-extract'] as const;
|
|
26
|
+
/** The tool packages whose native artifacts inferred commands consume. */
|
|
27
|
+
const NATIVE_TOOL_PACKAGES = ['build-inputs', 'cargo-retain', 'nextest-extract', 'cowshed'] as const;
|
|
28
28
|
|
|
29
29
|
export type NativeToolPackage = (typeof NATIVE_TOOL_PACKAGES)[number];
|
|
30
30
|
|
|
31
31
|
type TargetDependency = NonNullable<TargetConfiguration['dependsOn']>[number];
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* that is a project of the workspace being inferred (a checkout of the repository that builds it) has only what its
|
|
37
|
-
* `scriptc-<arch>-<family>` target last wrote, so a command running it depends on that target.
|
|
34
|
+
* Native tools as the inferring host consumes them. Installed packages already ship their artifacts; a workspace
|
|
35
|
+
* package needs its declared producer. Scriptc tools use the host platform target, cowshed its napi-native addon.
|
|
38
36
|
*/
|
|
39
37
|
export interface NativeTools {
|
|
40
38
|
/** The host's directory under a tool package's `dist/bin`. */
|
|
@@ -101,8 +99,14 @@ export function nativeToolCommand(
|
|
|
101
99
|
return toolCommand(cwd, tool, `dist/bin/${tools.platform}/${bin}`);
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
/** The task
|
|
105
|
-
export function nativeToolDependsOn(
|
|
102
|
+
/** The task producing a tool artifact, only when this workspace owns its package. */
|
|
103
|
+
export function nativeToolDependsOn(
|
|
104
|
+
tools: NativeTools | null,
|
|
105
|
+
tool: NativeToolPackage,
|
|
106
|
+
target?: string,
|
|
107
|
+
): TargetDependency[] {
|
|
106
108
|
const project = tools?.projects.get(tool);
|
|
107
|
-
return project === undefined || tools === null
|
|
109
|
+
return project === undefined || tools === null
|
|
110
|
+
? []
|
|
111
|
+
: [{ projects: [project], target: target ?? (tool === 'cowshed' ? 'napi-native' : tools.target) }];
|
|
108
112
|
}
|
package/src/workspace-index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import native from 'nx/src/native/index.js';
|
|
2
|
+
import { workspaceDataDirectoryForWorkspace } from 'nx/src/utils/cache-directory.js';
|
|
1
3
|
import { globWithWorkspaceContext, globWithWorkspaceContextSync } from 'nx/src/utils/workspace-context.js';
|
|
2
4
|
import { workspaceRoot as daemonWorkspaceRoot } from 'nx/src/utils/workspace-root.js';
|
|
3
5
|
|
|
@@ -16,3 +18,13 @@ export async function globIndexedFiles(workspaceRoot: string, globs: string[]):
|
|
|
16
18
|
? globWithWorkspaceContext(workspaceRoot, globs)
|
|
17
19
|
: globWithWorkspaceContextSync(workspaceRoot, globs);
|
|
18
20
|
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Like {@link globIndexedFiles}, read from the filesystem now: a new native context, the same walk and the same ignore
|
|
24
|
+
* rules, never the table of this process or of the daemon. A table only learns of a write when a watcher event reaches
|
|
25
|
+
* it, so one the watcher missed leaves a deleted file listed and an added one unlisted until that process ends. What
|
|
26
|
+
* runs on the files as they are asks here; what describes a graph asks {@link globIndexedFiles}.
|
|
27
|
+
*/
|
|
28
|
+
export function freshIndexedFiles(workspaceRoot: string, globs: string[]): string[] {
|
|
29
|
+
return new native.WorkspaceContext(workspaceRoot, workspaceDataDirectoryForWorkspace(workspaceRoot)).glob(globs);
|
|
30
|
+
}
|