@smoothbricks/nx-plugin 0.6.1 → 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 +264 -55
- package/dist/.build-inputs.json +21 -15
- 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 +14 -3
- package/dist/cargo-retention-hook.d.ts.map +1 -1
- package/dist/cargo-retention-hook.js +25 -8
- 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 +27 -3
- 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/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +6 -0
- 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/envrc +15 -0
- 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 +15 -1
- package/managed/raw/tooling/direnv/devenv.smoo.nix +45 -13
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -10
- package/managed/raw/tooling/direnv/linked-snapshots.ts +50 -13
- package/managed/raw/tooling/direnv/setup-environment.ts +36 -9
- package/managed/raw/tooling/direnv/ttsc-env.sh +8 -6
- package/managed/raw/tooling/git-hooks/pre-push.sh +4 -1
- package/managed/raw/tooling/git-reword-commit +151 -0
- 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 +226 -10
- 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 +28 -11
- 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 +31 -3
- 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/managed-files/files.ts +6 -0
- 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 -2
|
@@ -1,6 +1,14 @@
|
|
|
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 { describeHolders } from './lock-wait.js';
|
|
5
|
+
import { TEST_FAILURES_FILE, TEST_RESULTS_FILE } from './test-results.js';
|
|
6
|
+
const isQueuedVerdict = (() => {
|
|
7
|
+
const _io0 = input => _io1(input) && ("queued" === input.outcome && "number" === typeof input.exitCode);
|
|
8
|
+
const _io1 = input => "number" === typeof input.waitedMs && (Array.isArray(input.requests) && input.requests.every(elem => "object" === typeof elem && null !== elem && _io2(elem)));
|
|
9
|
+
const _io2 = input => "number" === typeof input.pid && "number" === typeof input.ticket && "number" === typeof input.queuePosition;
|
|
10
|
+
return input => "object" === typeof input && null !== input && _io0(input);
|
|
11
|
+
})();
|
|
4
12
|
/** The environment variable naming the absolute path a command writes its JUnit report to. */
|
|
5
13
|
export const JUNIT_REPORT_ENV = 'BOUNDED_EXEC_JUNIT';
|
|
6
14
|
/**
|
|
@@ -69,6 +77,68 @@ export function junitFailures(xml) {
|
|
|
69
77
|
close();
|
|
70
78
|
return { timedOut, cancelled, failed };
|
|
71
79
|
}
|
|
80
|
+
/** Bun's nested suites carry the describe chain; testcase.classname is in the reverse order. */
|
|
81
|
+
export function bunJunitResults(xml) {
|
|
82
|
+
const results = [];
|
|
83
|
+
const suites = [];
|
|
84
|
+
let current = null;
|
|
85
|
+
const text = xml;
|
|
86
|
+
const tags = /<!\[CDATA\[[\s\S]*?\]\]>|<!--[\s\S]*?-->|<(\/?)(testsuite|testcase)\b((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/g;
|
|
87
|
+
let end = 0;
|
|
88
|
+
const close = () => {
|
|
89
|
+
if (current === null)
|
|
90
|
+
return;
|
|
91
|
+
const name = attribute(current.attributes, 'name');
|
|
92
|
+
const file = attribute(current.attributes, 'file');
|
|
93
|
+
if (name !== null && file !== null) {
|
|
94
|
+
const failed = /<(?:failure|error)\b/.test(current.body);
|
|
95
|
+
const skipped = /<skipped\b/.test(current.body);
|
|
96
|
+
const line = attribute(current.attributes, 'line');
|
|
97
|
+
const time = attribute(current.attributes, 'time');
|
|
98
|
+
const seconds = time === null ? Number.NaN : Number(time);
|
|
99
|
+
const output = /<(?:failure|error)\b((?:[^>"']|"[^"]*"|'[^']*')*?)(?:\/>|>((?:<!\[CDATA\[[\s\S]*?\]\]>|(?!<!\[CDATA\[|<\/(?:failure|error)>)[\s\S])*)<\/(?:failure|error)>)/.exec(current.body);
|
|
100
|
+
const failureOutput = output === null
|
|
101
|
+
? null
|
|
102
|
+
: output[2] === undefined || output[2] === ''
|
|
103
|
+
? (attribute(output[1] ?? '', 'message') ?? '')
|
|
104
|
+
: decodeJunitText(output[2]);
|
|
105
|
+
results.push({
|
|
106
|
+
id: `${file}::${[...suites.slice(1), name].join(' > ')}`,
|
|
107
|
+
status: failed ? 'fail' : skipped ? 'skip' : 'pass',
|
|
108
|
+
source: 'junit',
|
|
109
|
+
durationMs: Number.isFinite(seconds) && seconds >= 0 ? seconds * 1000 : null,
|
|
110
|
+
sourceRef: line === null ? null : `${file}:${line}`,
|
|
111
|
+
failureOutput,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
current = null;
|
|
115
|
+
};
|
|
116
|
+
for (const match of text.matchAll(tags)) {
|
|
117
|
+
if (current !== null)
|
|
118
|
+
current.body += text.slice(end, match.index);
|
|
119
|
+
end = match.index + match[0].length;
|
|
120
|
+
const [, slash, tag, attributes = '', selfClosing] = match;
|
|
121
|
+
if (tag === undefined) {
|
|
122
|
+
if (current !== null)
|
|
123
|
+
current.body += match[0];
|
|
124
|
+
}
|
|
125
|
+
else if (tag === 'testsuite') {
|
|
126
|
+
if (slash === '/')
|
|
127
|
+
suites.pop();
|
|
128
|
+
else if (selfClosing !== '/')
|
|
129
|
+
suites.push(attribute(attributes, 'name') ?? '');
|
|
130
|
+
}
|
|
131
|
+
else if (slash === '/')
|
|
132
|
+
close();
|
|
133
|
+
else {
|
|
134
|
+
close();
|
|
135
|
+
current = { attributes, body: '' };
|
|
136
|
+
if (selfClosing === '/')
|
|
137
|
+
close();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return results;
|
|
141
|
+
}
|
|
72
142
|
/** Every test case of a JUnit document with the `time` it ran for; a case without one is not timed and not listed. */
|
|
73
143
|
export function junitCaseTimes(xml) {
|
|
74
144
|
const text = xml.replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, '').replace(/<!--[\s\S]*?-->/g, '');
|
|
@@ -91,6 +161,16 @@ function attribute(attributes, name) {
|
|
|
91
161
|
}
|
|
92
162
|
return decodeEntities(match[2] ?? match[3] ?? '');
|
|
93
163
|
}
|
|
164
|
+
function decodeJunitText(value) {
|
|
165
|
+
let text = '';
|
|
166
|
+
let end = 0;
|
|
167
|
+
for (const match of value.matchAll(/<!\[CDATA\[([\s\S]*?)\]\]>|<!--[\s\S]*?-->/g)) {
|
|
168
|
+
text += decodeEntities(value.slice(end, match.index));
|
|
169
|
+
text += match[1] ?? '';
|
|
170
|
+
end = match.index + match[0].length;
|
|
171
|
+
}
|
|
172
|
+
return text + decodeEntities(value.slice(end));
|
|
173
|
+
}
|
|
94
174
|
function decodeEntities(value) {
|
|
95
175
|
return value.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g, (_, entity) => {
|
|
96
176
|
switch (entity) {
|
|
@@ -122,6 +202,9 @@ export function judgeRun(run) {
|
|
|
122
202
|
const tests = run.report === null ? [] : [...run.report.failed, ...run.report.timedOut, ...run.report.cancelled];
|
|
123
203
|
return { outcome: 'no-space', exitCode: run.exitCode === 0 ? 1 : run.exitCode, tests, ...run.noSpace };
|
|
124
204
|
}
|
|
205
|
+
if (run.admissionQueue != null && run.exitCode !== 0) {
|
|
206
|
+
return { outcome: 'queued', exitCode: run.exitCode, ...run.admissionQueue };
|
|
207
|
+
}
|
|
125
208
|
if (run.expiry?.kind === 'idle') {
|
|
126
209
|
const tests = [...new Set([...run.expiry.tests, ...(run.report?.cancelled ?? [])])];
|
|
127
210
|
return { outcome: 'wedged', idleMs: run.expiry.limitMs, elapsedMs: run.elapsedMs, tests, lockWaits: run.lockWaits };
|
|
@@ -208,6 +291,8 @@ export async function clearTaskDirectory(directory) {
|
|
|
208
291
|
await Promise.all([
|
|
209
292
|
rm(join(directory, VERDICT_FILE), { force: true }),
|
|
210
293
|
rm(join(directory, JUNIT_FILE), { force: true }),
|
|
294
|
+
rm(join(directory, TEST_RESULTS_FILE), { force: true }),
|
|
295
|
+
rm(join(directory, TEST_FAILURES_FILE), { force: true }),
|
|
211
296
|
]);
|
|
212
297
|
}
|
|
213
298
|
export async function writeRecord(directory, record) {
|
|
@@ -231,14 +316,15 @@ export async function readRecord(directory) {
|
|
|
231
316
|
return parseRecord(JSON.parse(text));
|
|
232
317
|
}
|
|
233
318
|
/** The JUnit report a command wrote into `directory`, or `null` when it wrote none. */
|
|
234
|
-
export async function readJunitReport(directory) {
|
|
319
|
+
export async function readJunitReport(directory, bunClosed) {
|
|
235
320
|
try {
|
|
236
|
-
|
|
321
|
+
const xml = await readFile(join(directory, JUNIT_FILE), 'utf8');
|
|
322
|
+
bunClosed?.(bunJunitResults(xml));
|
|
323
|
+
return junitFailures(xml);
|
|
237
324
|
}
|
|
238
325
|
catch (error) {
|
|
239
|
-
if (isNotFound(error))
|
|
326
|
+
if (isNotFound(error))
|
|
240
327
|
return null;
|
|
241
|
-
}
|
|
242
328
|
throw error;
|
|
243
329
|
}
|
|
244
330
|
}
|
|
@@ -256,6 +342,10 @@ function parseVerdict(value) {
|
|
|
256
342
|
switch (value.outcome) {
|
|
257
343
|
case 'passed':
|
|
258
344
|
return { outcome: 'passed' };
|
|
345
|
+
case 'queued':
|
|
346
|
+
if (isQueuedVerdict(value))
|
|
347
|
+
return value;
|
|
348
|
+
break;
|
|
259
349
|
case 'bound':
|
|
260
350
|
if ((value.bound === 'total' || value.bound === 'fixture') &&
|
|
261
351
|
typeof value.limitMs === 'number' &&
|
|
@@ -391,10 +481,18 @@ export async function failedTasksOfRun(runJson, workspaceData) {
|
|
|
391
481
|
}
|
|
392
482
|
return failed;
|
|
393
483
|
}
|
|
484
|
+
/** The same honest admission diagnostic in live output and a terminal verdict. */
|
|
485
|
+
export function describeAdmissionQueue(wait) {
|
|
486
|
+
return `queued for admission ${(wait.waitedMs / 1_000).toFixed(1)} s; mbx ${wait.requests
|
|
487
|
+
.map((request) => `pid=${request.pid} ticket=${request.ticket} queue position=${request.queuePosition}`)
|
|
488
|
+
.join(', ')}`;
|
|
489
|
+
}
|
|
394
490
|
export function describeVerdict(verdict) {
|
|
395
491
|
switch (verdict.outcome) {
|
|
396
492
|
case 'passed':
|
|
397
493
|
return 'passed';
|
|
494
|
+
case 'queued':
|
|
495
|
+
return `${describeAdmissionQueue(verdict)}; exited ${verdict.exitCode} before first admission`;
|
|
398
496
|
case 'bound':
|
|
399
497
|
return verdict.bound === 'test'
|
|
400
498
|
? `per-test timeout only: ${verdict.tests.join(', ')}`
|
package/dist/index.d.ts
CHANGED
|
@@ -30,8 +30,9 @@ export declare const createNodesV2: CreateNodesV2;
|
|
|
30
30
|
* hint and the opt-in producer completion receipts. Each sees the same options and run context; neither reads the
|
|
31
31
|
* other's output. The hint is recorded first so a producer-receipt bug cannot cost the controller its evidence. The
|
|
32
32
|
* pair also serves a run that inherits no CPU pool its own, which every task inherits (`run-cpu-pool.ts`), and closes
|
|
33
|
-
* it when the run ends. Last, once every task has finished, the post hook
|
|
34
|
-
* superseded Cargo unit generations of each Cargo workspace the run built into
|
|
33
|
+
* it when the run ends. Last, once every task has finished, the post hook starts the reclaim of the
|
|
34
|
+
* superseded Cargo unit generations of each Cargo workspace the run built into, in a process of its own, never on
|
|
35
|
+
* Nx's thread (`@smoothbricks/cargo-retain`).
|
|
35
36
|
*/
|
|
36
37
|
export declare const preTasksExecution: PreTasksExecution<ProducerReceiptsOptions>;
|
|
37
38
|
export declare const postTasksExecution: PostTasksExecution<ProducerReceiptsOptions>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EAGnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAGtB,KAAK,mBAAm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,EAChB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmCxB"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,6 @@ import { EXTRACTED_BINARIES_METADATA, EXTRACTED_CARGO_METADATA, EXTRACTED_TARGET
|
|
|
7
7
|
import { readJsonFile, } from 'nx/src/devkit-exports.js';
|
|
8
8
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
9
9
|
import { parse as parseToml } from 'smol-toml';
|
|
10
|
-
import { parseJsonConfigFileContent, readConfigFile, sys as typescriptSys } from 'typescript';
|
|
11
10
|
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
|
|
12
11
|
import { refuseOverlappingOutputs } from './build-state-output-policy.js';
|
|
13
12
|
import { bunLockDependencies, bunLockInput, bunLockNode } from './bun-lock-scope.js';
|
|
@@ -17,14 +16,14 @@ import { CARGO_TOOLCHAIN_NAMED_INPUT, cargoRuntimeInput, cargoToolchainInputs }
|
|
|
17
16
|
import { attributeCargoWorkspacePackages, CARGO_TEST_ARCHIVE_FILE, CARGO_TEST_ARCHIVE_TARGET, CARGO_TEST_EXCEPTIONS_SUFFIX, CARGO_TEST_TARGET, cargoPackageTestInputs, cargoTestGroupTargetName, cargoTestPackageTargetName, createCargoInputsCache, EXTERNAL_RUST_CRATES_INPUT, exceptionalTestFilter, listCargoCrossTestTargets, listCargoWorkspacePackages, NEXTEST_REPO_CONFIG_PATH, nextestToolConfigArg, PLUGIN_NEXTEST_CONFIG_PATH, requireExternalRustCratesInput, serialTestGroups, } from './cargo-workspace.js';
|
|
18
17
|
import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_FETCH_COMMAND, CARGO_FETCH_TARGET, CARGO_LINT_CLIPPY_COMMAND, cargoCrossTestArchiveFile, cargoCrossTestArchiveTargetName, cargoCrossTestTargetName, cargoFrozen, runsFrozenCargo, } from './cross-check-policy.js';
|
|
19
18
|
import { eslintConfigClosure } from './eslint-config-closure.js';
|
|
20
|
-
import {
|
|
19
|
+
import { ESLINT_SOURCES_GLOB, eslintSources } from './eslint-sources.js';
|
|
20
|
+
import { ALL_VERDICTS_EXECUTOR, ESLINT_SOURCES_TOKEN, } from './executors/all-verdicts/schema.js';
|
|
21
21
|
import { closeRunCpuPool, serveRunCpuPool } from './executors/bounded-exec/run-cpu-pool.js';
|
|
22
22
|
import { ffiPathProblem } from './executors/scriptc-native/ffi-paths.js';
|
|
23
23
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
24
24
|
import { NEXTEST_TIMINGS_PATH, namedTestsFilter, readNextestTimings, timedShardMembers } from './nextest-timings.js';
|
|
25
25
|
import { postTasksExecution as postProducerReceipts, preTasksExecution as preProducerReceipts, } from './producer-receipts.js';
|
|
26
26
|
import { runtimeInput, shellWord } from './runtime-input.js';
|
|
27
|
-
import { isNonSourceDirectory } from './source-directories.js';
|
|
28
27
|
import { inferredTaskKind, refuseBuildTestDependencies } from './task-graph-policy.js';
|
|
29
28
|
import { postTasksExecution as postTaskResults, preTasksExecution as preTaskResults } from './task-results.js';
|
|
30
29
|
import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite } from './test-timings.js';
|
|
@@ -268,20 +267,19 @@ const ESLINT_CONFIG_FILES = [
|
|
|
268
267
|
'eslint.config.mts',
|
|
269
268
|
'eslint.config.cts',
|
|
270
269
|
];
|
|
271
|
-
/** Every JavaScript and TypeScript module kind ESLint is handed. */
|
|
272
|
-
const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
|
|
273
270
|
/**
|
|
274
271
|
* The ESLint sources and config closure of Nx's workspace file index, listed
|
|
275
272
|
* once per graph computation; `null` when no workspace ESLint config enables ESLint.
|
|
276
273
|
*
|
|
277
|
-
* The
|
|
278
|
-
* inputs
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
274
|
+
* The lists the graph records for a project (its lint target's metadata, and
|
|
275
|
+
* the inputs that name its program files) are drawn from the index, not from a
|
|
276
|
+
* walk of the tree. A walk also listed gitignored generated modules a build had
|
|
277
|
+
* left on disk, so every such task's key depended on whether a build had run in
|
|
278
|
+
* that checkout: one workspace's graph listed them and a fresh fork's did not,
|
|
279
|
+
* which alone re-keyed 197 of 510 gate tasks. Drawing them from the index makes
|
|
280
|
+
* the plugin and the hasher agree on one file set. What the lint command runs
|
|
281
|
+
* on is in no graph: the executor reads it when the command runs
|
|
282
|
+
* (eslint-sources.ts).
|
|
285
283
|
*
|
|
286
284
|
* The configs key every lint target with exactly the workspace files they
|
|
287
285
|
* load (eslint-config-closure.ts): a glob over the directory holding a
|
|
@@ -298,66 +296,26 @@ async function eslintWorkspace(workspaceRoot) {
|
|
|
298
296
|
configImports: eslintConfigClosure(workspaceRoot, configs, indexed),
|
|
299
297
|
};
|
|
300
298
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Read a tsconfig with this plugin's own TypeScript. `@nx/js`'s readTsConfig does an
|
|
303
|
-
* undeclared `require('typescript')` resolved from its own location: where that lands on the
|
|
304
|
-
* TypeScript 7 native package (whose entry exports only its version), `sys` is undefined and
|
|
305
|
-
* graph construction dies reading `sys.readFile`. The plugin declares TypeScript 6, whose
|
|
306
|
-
* `sys` this uses, so the resolution is the one this package's manifest promises.
|
|
307
|
-
*/
|
|
308
|
-
function readTestTsConfig(testConfig) {
|
|
309
|
-
const readResult = readConfigFile(testConfig, typescriptSys.readFile);
|
|
310
|
-
return parseJsonConfigFileContent(readResult.config, typescriptSys, dirname(testConfig));
|
|
311
|
-
}
|
|
312
299
|
function projectLintCommands(projectRoot, workspaceRoot, eslint) {
|
|
313
300
|
const commands = [];
|
|
314
301
|
const inputs = [];
|
|
315
302
|
let eslintFileSet = null;
|
|
316
|
-
const absoluteProjectRoot = join(workspaceRoot, projectRoot);
|
|
317
303
|
const quote = (path) => `'${path.replaceAll("'", "'\"'\"'")}'`;
|
|
318
304
|
if (BIOME_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) {
|
|
319
305
|
commands.push(`biome check --files-ignore-unknown=true ${quote(projectRoot)}`);
|
|
320
306
|
}
|
|
321
307
|
if (eslint !== null) {
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
const testConfig = join(absoluteProjectRoot, 'tsconfig.test.json');
|
|
331
|
-
if (existsSync(testConfig)) {
|
|
332
|
-
// A test program can live anywhere the declaration selects, not just src.
|
|
333
|
-
// Use the compiler's file set and the existing declaration-chain hasher,
|
|
334
|
-
// so inherited includes and files outside this project keep their keys.
|
|
335
|
-
const program = readTestTsConfig(testConfig);
|
|
336
|
-
const errors = program.errors.filter(({ code }) => code !== 18003);
|
|
337
|
-
if (errors.length > 0) {
|
|
338
|
-
throw new Error(`${testConfig}: ${errors.map(({ code, messageText }) => `TS${code}: ${JSON.stringify(messageText)}`).join('; ')}`);
|
|
339
|
-
}
|
|
340
|
-
inputs.push('{projectRoot}/tsconfig.test.json');
|
|
341
|
-
for (const file of program.fileNames) {
|
|
342
|
-
const path = relative(workspaceRoot, file).split(sep).join('/');
|
|
343
|
-
if (path === '..' || path.startsWith('../') || isAbsolute(path)) {
|
|
344
|
-
throw new Error(`${testConfig}: test source ${file} is outside the workspace and cannot be hashed`);
|
|
345
|
-
}
|
|
346
|
-
// Only a module Nx indexes is linted and keyed. An ignored one is build
|
|
347
|
-
// output that a fresh checkout lacks; a JSON file is not ESLint's.
|
|
348
|
-
if (!eslint.sources.has(path) || path.split('/').some(isNonSourceDirectory))
|
|
349
|
-
continue;
|
|
350
|
-
sourceFiles.add(path);
|
|
351
|
-
inputs.push(`{workspaceRoot}/${path}`);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
if (sourceFiles.size > 0) {
|
|
355
|
-
const files = [...sourceFiles].sort();
|
|
356
|
-
eslintFileSet = { command: `eslint ${files.map(quote).join(' ')}`, files };
|
|
308
|
+
const sources = eslintSources(workspaceRoot, projectRoot, eslint.sources);
|
|
309
|
+
inputs.push(...sources.inputs);
|
|
310
|
+
// The command names no file: a graph the daemon serves past a deletion or an addition would hand ESLint a pattern
|
|
311
|
+
// no file matches, or leave a new file unlinted. The all-verdicts executor resolves the token when it runs, and the
|
|
312
|
+
// list beside the command is the file set this graph resolved, for the inspectors that read it.
|
|
313
|
+
if (sources.files.length > 0) {
|
|
314
|
+
eslintFileSet = { command: `eslint ${ESLINT_SOURCES_TOKEN}`, files: sources.files };
|
|
357
315
|
commands.push(eslintFileSet.command);
|
|
358
316
|
}
|
|
359
317
|
}
|
|
360
|
-
return { commands, inputs
|
|
318
|
+
return { commands, inputs, eslintFileSet };
|
|
361
319
|
}
|
|
362
320
|
/** A host's directory under a package's `dist/bin`, as `@smoothbricks/cowshed`'s launcher names it. */
|
|
363
321
|
const EXECUTABLE_PLATFORM_DIRECTORY = {
|
|
@@ -930,8 +888,9 @@ function isBuildOutputPackageJson(packageJsonPath) {
|
|
|
930
888
|
* hint and the opt-in producer completion receipts. Each sees the same options and run context; neither reads the
|
|
931
889
|
* other's output. The hint is recorded first so a producer-receipt bug cannot cost the controller its evidence. The
|
|
932
890
|
* pair also serves a run that inherits no CPU pool its own, which every task inherits (`run-cpu-pool.ts`), and closes
|
|
933
|
-
* it when the run ends. Last, once every task has finished, the post hook
|
|
934
|
-
* superseded Cargo unit generations of each Cargo workspace the run built into
|
|
891
|
+
* it when the run ends. Last, once every task has finished, the post hook starts the reclaim of the
|
|
892
|
+
* superseded Cargo unit generations of each Cargo workspace the run built into, in a process of its own, never on
|
|
893
|
+
* Nx's thread (`@smoothbricks/cargo-retain`).
|
|
935
894
|
*/
|
|
936
895
|
export const preTasksExecution = async (options, context) => {
|
|
937
896
|
// Before any task is hashed: a workspace that declares the test-walk check
|
|
@@ -1933,11 +1892,54 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1933
1892
|
],
|
|
1934
1893
|
...(lintCommands.length > 0
|
|
1935
1894
|
? {
|
|
1936
|
-
options: {
|
|
1895
|
+
options: {
|
|
1896
|
+
commands: lintCommands,
|
|
1897
|
+
cwd: '.',
|
|
1898
|
+
...(eslintFileSet === null ? {} : { eslintProjectRoot: projectRoot }),
|
|
1899
|
+
},
|
|
1937
1900
|
}
|
|
1938
1901
|
: {}),
|
|
1939
1902
|
};
|
|
1940
1903
|
}
|
|
1904
|
+
// The process-lineage entry has no full API-generator dependency: the generator check itself is bounded work.
|
|
1905
|
+
const lineageProducer = nativeToolDependsOn(nativeTools, 'cowshed', 'lineage-js');
|
|
1906
|
+
if (lineageProducer.length > 0 && packageJson.name === '@smoothbricks/nx-plugin') {
|
|
1907
|
+
for (const name of ['tsc-js', 'typecheck', 'typecheck-tests']) {
|
|
1908
|
+
const target = targets[name];
|
|
1909
|
+
if (target === undefined)
|
|
1910
|
+
continue;
|
|
1911
|
+
target.dependsOn = [...(target.dependsOn ?? []), ...lineageProducer];
|
|
1912
|
+
target.inputs = [
|
|
1913
|
+
...(target.inputs ?? ['production']),
|
|
1914
|
+
{ dependentTasksOutputFiles: '**/dist/lineage/**/*', transitive: false },
|
|
1915
|
+
];
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
// Runtime observers need the local addon, not the package aggregate (which can deliberately build only JS).
|
|
1919
|
+
// Declarations retain these prerequisites and output inputs with Nx's ordinary "..." merge token.
|
|
1920
|
+
// The canonical release-check instead judges prebuilt shipping artifacts and must remain dependency-free.
|
|
1921
|
+
const observerProducers = [...nativeToolDependsOn(nativeTools, 'cowshed'), ...lineageProducer];
|
|
1922
|
+
if (observerProducers.length > 0) {
|
|
1923
|
+
for (const name of new Set([...Object.keys(targets), ...Object.keys(declaredTargets)])) {
|
|
1924
|
+
const declared = declaredTargets[name];
|
|
1925
|
+
const executor = isRecord(declared) && declared.executor !== undefined ? declared.executor : targets[name]?.executor;
|
|
1926
|
+
if (executor !== '@smoothbricks/nx-plugin:bounded-exec' || name === 'release-check')
|
|
1927
|
+
continue;
|
|
1928
|
+
// Nx discards an incompatible executor's inferred configuration; only the observer prerequisites belong below it.
|
|
1929
|
+
if (targets[name]?.executor !== undefined && targets[name]?.executor !== executor) {
|
|
1930
|
+
targets[name] = {};
|
|
1931
|
+
}
|
|
1932
|
+
targets[name] ??= {};
|
|
1933
|
+
const target = targets[name];
|
|
1934
|
+
target.dependsOn = [...(target.dependsOn ?? []), ...observerProducers];
|
|
1935
|
+
const inputs = target.inputs ?? (isRecord(declared) && Array.isArray(declared.inputs) ? [] : ['default', '^production']);
|
|
1936
|
+
target.inputs = [
|
|
1937
|
+
...inputs,
|
|
1938
|
+
{ dependentTasksOutputFiles: '**/*.node', transitive: true },
|
|
1939
|
+
{ dependentTasksOutputFiles: '**/dist/lineage/**/*.js', transitive: true },
|
|
1940
|
+
];
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1941
1943
|
// Publish each inferred target's semantic kind (`inferredTaskKind`) as metadata. Nx merges metadata beneath a
|
|
1942
1944
|
// declaration, so the final graph still says which tasks are build and which are test work after a package rewrites
|
|
1943
1945
|
// one. Fresh objects: `CARGO_PRODUCER_METADATA` is shared by every producer.
|
|
@@ -1963,7 +1965,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1963
1965
|
[VERSIONLESS_PRODUCTION_INPUT]: ['production', ...versionlessProjectInputs],
|
|
1964
1966
|
[VERSIONLESS_DEFAULT_INPUT]: ['default', ...versionlessProjectInputs],
|
|
1965
1967
|
}),
|
|
1966
|
-
...(Object.keys(targets).some((name) => name.startsWith('cargo-') || name.startsWith('napi-'))
|
|
1968
|
+
...([...Object.keys(targets), ...Object.keys(declaredTargets)].some((name) => name.startsWith('cargo-') || name.startsWith('napi-'))
|
|
1967
1969
|
? { [CARGO_TOOLCHAIN_NAMED_INPUT]: cargoToolchainInputs() }
|
|
1968
1970
|
: {}),
|
|
1969
1971
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/managed-files/files.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,kBAAkB,EAAmD,MAAM,kBAAkB,CAAC;AAI5G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAa7C,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,uBAAuB,EAAE,OAAO,CAAC;IACjC,0BAA0B,EAAE,OAAO,CAAC;IACpC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,uBAAuB,EAAE,OAAO,CAAC;IACjC,8BAA8B,EAAE,OAAO,CAAC;IACxC,qBAAqB,CAAC,EAAE,YAAY,CAAC;IACrC,wBAAwB,CAAC,EAAE,YAAY,CAAC;IACxC,cAAc,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,yFAAyF;IACzF,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,gBAAgB,CAAC,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;IACzD,eAAe,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACvD,cAAc,CAAC,EAAE,6BAA6B,CAAC;IAC/C,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,mBAAmB,EAAE,M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AQ;aACjB,GAAG,EAAE,WAAW;aAChB,IAAI,EAAE,yBAAyB;CACvB,CAAC;AA+OX,eAAO,MAAM,yBAAyB;;;GAAyE,CAAC;AAchH,qFAAqF;AACrF,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAElF;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,EAAE,CAM7E;AAED,+GAA+G;AAC/G,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,aAAa,GAAG,kBAAkB,GAAG,6BAA6B,GAAG,yBAAyB,EACtG,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CAMR"}
|
|
@@ -147,6 +147,12 @@ const managedFiles = [
|
|
|
147
147
|
target: 'tooling/git-hooks/pre-push.sh',
|
|
148
148
|
executable: true,
|
|
149
149
|
},
|
|
150
|
+
{
|
|
151
|
+
kind: 'raw',
|
|
152
|
+
source: 'tooling/git-reword-commit',
|
|
153
|
+
target: 'tooling/git-reword-commit',
|
|
154
|
+
executable: true,
|
|
155
|
+
},
|
|
150
156
|
{
|
|
151
157
|
kind: 'raw',
|
|
152
158
|
source: 'git-format-staged.yml',
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A refusal says why: a malformed summary or hash list is never guessed at. */
|
|
2
|
+
export type HashList = {
|
|
3
|
+
readonly kind: 'hashes';
|
|
4
|
+
readonly hashes: readonly string[];
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: 'refused';
|
|
7
|
+
readonly why: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Why a run summary's `run` is not of the invocation that began at `since` (epoch milliseconds), or undefined when it
|
|
12
|
+
* is. A summary Nx began before the gate is an earlier invocation's: its tasks are not the gate's.
|
|
13
|
+
*/
|
|
14
|
+
export declare function staleSummary(run: Record<string, unknown>, since: number): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The distinct hashes of the run's succeeded tasks (status 0), in run order, from a summary Nx began at or after
|
|
17
|
+
* `since` (epoch milliseconds). Every task must be well formed, failed or not.
|
|
18
|
+
*/
|
|
19
|
+
export declare function succeededHashes(since: number, summaryJson: string): HashList;
|
|
20
|
+
/** The hash list 'hashes' printed: a JSON array of distinct, well-formed task hashes. 'publish' checks it before spawning. */
|
|
21
|
+
export declare function hashList(text: string): HashList;
|
|
22
|
+
/** Run the packaged publisher, returning a failure status and diagnostic for operational refusals. */
|
|
23
|
+
export declare function runNxPublish(argv: readonly string[]): Promise<number>;
|
|
24
|
+
//# sourceMappingURL=nx-publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-publish.d.ts","sourceRoot":"","sources":["../src/nx-publish.ts"],"names":[],"mappings":"AAiBA,gFAAgF;AAChF,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC/D;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAQvD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAMD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM5F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,QAAQ,CAwB5E;AAED,8HAA8H;AAC9H,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAY/C;AA0DD,sGAAsG;AACtG,wBAAsB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAM3E"}
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { isAbsolute, join } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
const USAGE = 'usage: smoo-nx-publish hashes RUN_JSON SINCE_EPOCH | publish CHECKOUT HASHES_JSON\n';
|
|
9
|
+
/** A task hash as the gateway's cache route takes it (05_gateway.md). */
|
|
10
|
+
const TASK_HASH = /^[A-Za-z0-9_-]{1,128}$/;
|
|
11
|
+
// One cached producer copies the unchanged canonical cowshed scripts outside the TypeScript output tree.
|
|
12
|
+
const PUBLISH_ASSETS = fileURLToPath(new URL('../runtime/nx-publish/', import.meta.url));
|
|
13
|
+
const refusal = (why) => ({ kind: 'refused', why });
|
|
14
|
+
function errorMessage(error) {
|
|
15
|
+
return error instanceof Error ? error.message : String(error);
|
|
16
|
+
}
|
|
17
|
+
export function isRecord(value) {
|
|
18
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
function isTaskHash(value) {
|
|
21
|
+
return typeof value === 'string' && TASK_HASH.test(value);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Why a run summary's `run` is not of the invocation that began at `since` (epoch milliseconds), or undefined when it
|
|
25
|
+
* is. A summary Nx began before the gate is an earlier invocation's: its tasks are not the gate's.
|
|
26
|
+
*/
|
|
27
|
+
export function staleSummary(run, since) {
|
|
28
|
+
const started = run.startTime;
|
|
29
|
+
const startedAt = typeof started === 'string' ? Date.parse(started) : Number.NaN;
|
|
30
|
+
if (Number.isNaN(startedAt))
|
|
31
|
+
return `the run summary has no start time: ${JSON.stringify(started)}`;
|
|
32
|
+
if (startedAt >= since)
|
|
33
|
+
return undefined;
|
|
34
|
+
return `the run summary is of an invocation that began at ${started}, before this gate began at ${new Date(since).toISOString()}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The distinct hashes of the run's succeeded tasks (status 0), in run order, from a summary Nx began at or after
|
|
38
|
+
* `since` (epoch milliseconds). Every task must be well formed, failed or not.
|
|
39
|
+
*/
|
|
40
|
+
export function succeededHashes(since, summaryJson) {
|
|
41
|
+
let summary;
|
|
42
|
+
try {
|
|
43
|
+
summary = JSON.parse(summaryJson);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return refusal(`the run summary is not JSON: ${errorMessage(error)}`);
|
|
47
|
+
}
|
|
48
|
+
if (!isRecord(summary) || !isRecord(summary.run) || !Array.isArray(summary.tasks)) {
|
|
49
|
+
return refusal('the run summary has no run object or no tasks array');
|
|
50
|
+
}
|
|
51
|
+
const stale = staleSummary(summary.run, since);
|
|
52
|
+
if (stale !== undefined)
|
|
53
|
+
return refusal(stale);
|
|
54
|
+
const tasks = summary.tasks;
|
|
55
|
+
const hashes = new Set();
|
|
56
|
+
for (const task of tasks) {
|
|
57
|
+
if (!isRecord(task) || typeof task.status !== 'number') {
|
|
58
|
+
return refusal(`the run summary has a task without a numeric status: ${JSON.stringify(task)}`);
|
|
59
|
+
}
|
|
60
|
+
if (!isTaskHash(task.hash)) {
|
|
61
|
+
return refusal(`the run summary has an invalid task hash: ${JSON.stringify(task.hash)}`);
|
|
62
|
+
}
|
|
63
|
+
if (task.status === 0)
|
|
64
|
+
hashes.add(task.hash);
|
|
65
|
+
}
|
|
66
|
+
return { kind: 'hashes', hashes: [...hashes] };
|
|
67
|
+
}
|
|
68
|
+
/** The hash list 'hashes' printed: a JSON array of distinct, well-formed task hashes. 'publish' checks it before spawning. */
|
|
69
|
+
export function hashList(text) {
|
|
70
|
+
let value;
|
|
71
|
+
try {
|
|
72
|
+
value = JSON.parse(text);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
return refusal(`the hash list is not JSON: ${errorMessage(error)}`);
|
|
76
|
+
}
|
|
77
|
+
if (!Array.isArray(value) || !value.every(isTaskHash)) {
|
|
78
|
+
return refusal('the hash list is not a JSON array of valid task hashes');
|
|
79
|
+
}
|
|
80
|
+
if (new Set(value).size !== value.length)
|
|
81
|
+
return refusal('the hash list repeats a task hash');
|
|
82
|
+
return { kind: 'hashes', hashes: value };
|
|
83
|
+
}
|
|
84
|
+
/** cache_adapter.js first: it defines the cache nx_publish.js calls. Both go to 'node -' as one program. */
|
|
85
|
+
function bridgeProgram() {
|
|
86
|
+
const adapter = readFileSync(join(PUBLISH_ASSETS, 'cache_adapter.js'), 'utf8');
|
|
87
|
+
const publisher = readFileSync(join(PUBLISH_ASSETS, 'nx_publish.js'), 'utf8');
|
|
88
|
+
return `${adapter}\n${publisher}`;
|
|
89
|
+
}
|
|
90
|
+
/** Runs the bridge as 'node - ARGS' with the program on stdin. Its stderr is ours; its stdout comes back. */
|
|
91
|
+
function runBridge(args) {
|
|
92
|
+
// Read before spawning: a read that threw after the spawn would leave node waiting on a stdin that never closes.
|
|
93
|
+
const program = bridgeProgram();
|
|
94
|
+
// 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")
|
|
95
|
+
return new Promise((resolve, reject) => {
|
|
96
|
+
const child = spawn('node', ['-', ...args], { stdio: ['pipe', 'pipe', 'inherit'] });
|
|
97
|
+
let stdout = '';
|
|
98
|
+
child.stdout.setEncoding('utf8');
|
|
99
|
+
child.stdout.on('data', (chunk) => {
|
|
100
|
+
stdout += chunk;
|
|
101
|
+
});
|
|
102
|
+
child.on('error', reject);
|
|
103
|
+
child.on('close', (status, signal) => {
|
|
104
|
+
if (status === null)
|
|
105
|
+
reject(new Error(`node ended by signal ${String(signal)}`));
|
|
106
|
+
else
|
|
107
|
+
resolve({ status, stdout });
|
|
108
|
+
});
|
|
109
|
+
child.stdin.on('error', reject);
|
|
110
|
+
child.stdin.end(program);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function fail(why) {
|
|
114
|
+
process.stderr.write(`smoo-nx-publish: ${why}\n`);
|
|
115
|
+
return 1;
|
|
116
|
+
}
|
|
117
|
+
async function main(argv) {
|
|
118
|
+
const [verb, first, second] = argv;
|
|
119
|
+
if (verb === 'hashes' && argv.length === 3 && first !== undefined && second !== undefined) {
|
|
120
|
+
const since = Number(second);
|
|
121
|
+
if (!Number.isInteger(since))
|
|
122
|
+
return fail(`SINCE must be whole epoch seconds, not ${second}`);
|
|
123
|
+
const result = succeededHashes(since * 1000, readFileSync(first, 'utf8'));
|
|
124
|
+
if (result.kind === 'refused')
|
|
125
|
+
return fail(result.why);
|
|
126
|
+
process.stdout.write(`${JSON.stringify(result.hashes)}\n`);
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
if (verb === 'publish' && argv.length === 3 && first !== undefined && second !== undefined) {
|
|
130
|
+
if (!isAbsolute(first))
|
|
131
|
+
return fail(`the checkout must be an absolute path, not ${first}`);
|
|
132
|
+
const list = hashList(readFileSync(second, 'utf8'));
|
|
133
|
+
if (list.kind === 'refused')
|
|
134
|
+
return fail(list.why);
|
|
135
|
+
const bridge = await runBridge([first, JSON.stringify(list.hashes)]);
|
|
136
|
+
process.stdout.write(bridge.stdout);
|
|
137
|
+
return bridge.status;
|
|
138
|
+
}
|
|
139
|
+
process.stderr.write(USAGE);
|
|
140
|
+
return 64;
|
|
141
|
+
}
|
|
142
|
+
/** Run the packaged publisher, returning a failure status and diagnostic for operational refusals. */
|
|
143
|
+
export async function runNxPublish(argv) {
|
|
144
|
+
try {
|
|
145
|
+
return await main(argv);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return fail(errorMessage(error));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
type Token = {
|
|
2
|
+
readonly kind: 'word';
|
|
3
|
+
readonly text: string;
|
|
4
|
+
} | {
|
|
5
|
+
readonly kind: 'separator';
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'redirect';
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The shell tokens of `script`. A command substitution is part of its word, and the programs it runs are appended to
|
|
11
|
+
* `nested`; quoting is removed from the words, which are only inspected, never run.
|
|
12
|
+
*/
|
|
13
|
+
export declare function shellTokens(script: string, nested: string[]): Token[];
|
|
1
14
|
/**
|
|
2
15
|
* The programs `script` runs by name or path: the program of each simple command, through `env`, `exec`,
|
|
3
16
|
* `command`, `sh -c` and command substitutions, and the command a `runtime-input.sh` input runs. Shell builtins are
|
|
@@ -57,4 +70,5 @@ export declare const RUNTIME_INPUT_FAILURES = ".runtime-input-failures";
|
|
|
57
70
|
* its stderr. A record without a report (its evidence could not be written) is named as such.
|
|
58
71
|
*/
|
|
59
72
|
export declare function runtimeInputFailureReports(root: string, sinceMs: number): string[];
|
|
73
|
+
export {};
|
|
60
74
|
//# sourceMappingURL=runtime-input-policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-input-policy.d.ts","sourceRoot":"","sources":["../src/runtime-input-policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-input-policy.d.ts","sourceRoot":"","sources":["../src/runtime-input-policy.ts"],"names":[],"mappings":"AA2EA,KAAK,KAAK,GACN;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GAC9B;IAAE,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;AAWhE;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAYlF"}
|
|
@@ -99,7 +99,7 @@ function closingBracket(text, from, open, close) {
|
|
|
99
99
|
* The shell tokens of `script`. A command substitution is part of its word, and the programs it runs are appended to
|
|
100
100
|
* `nested`; quoting is removed from the words, which are only inspected, never run.
|
|
101
101
|
*/
|
|
102
|
-
function shellTokens(script, nested) {
|
|
102
|
+
export function shellTokens(script, nested) {
|
|
103
103
|
const tokens = [];
|
|
104
104
|
let word;
|
|
105
105
|
const flush = () => {
|