@smoothbricks/nx-plugin 0.5.5 → 0.5.7
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 +59 -11
- package/dist/ensure-built-receipt.d.ts +2 -2
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +7 -2
- package/dist/ensure-built-witness.d.ts +12 -1
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +32 -0
- package/dist/ensure-built.d.ts +2 -2
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +27 -5
- package/dist/executors/all-verdicts/executor.d.ts +35 -0
- package/dist/executors/all-verdicts/executor.d.ts.map +1 -0
- package/dist/executors/all-verdicts/executor.js +133 -0
- package/dist/executors/all-verdicts/schema.d.ts +10 -0
- package/dist/executors/all-verdicts/schema.d.ts.map +1 -0
- package/dist/executors/all-verdicts/schema.js +2 -0
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +48 -11
- package/dist/executors/bounded-exec/progress.d.ts +1 -3
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +1 -2
- package/dist/executors/bounded-exec/runner-hook.d.ts +2 -0
- package/dist/executors/bounded-exec/runner-hook.d.ts.map +1 -0
- package/dist/executors/bounded-exec/runner-hook.js +301 -0
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts +18 -0
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -0
- package/dist/executors/bounded-exec/runner-lifecycle.js +92 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/producer-receipts.d.ts +24 -1
- package/dist/producer-receipts.d.ts.map +1 -1
- package/dist/producer-receipts.js +91 -60
- package/executors.json +5 -0
- package/managed/raw/git-format-staged.yml +16 -3
- package/managed/raw/patches/nx@23.2.1.patch +397 -33
- package/package.json +2 -2
- package/src/ensure-built-receipt.ts +8 -2
- package/src/ensure-built-witness.ts +29 -1
- package/src/ensure-built.ts +39 -7
- package/src/executors/all-verdicts/executor.test.ts +135 -0
- package/src/executors/all-verdicts/executor.ts +164 -0
- package/src/executors/all-verdicts/schema.json +22 -0
- package/src/executors/all-verdicts/schema.ts +10 -0
- package/src/executors/bounded-exec/cargo-progress-host.test.ts +332 -0
- package/src/executors/bounded-exec/executor.test.ts +89 -42
- package/src/executors/bounded-exec/executor.ts +45 -11
- package/src/executors/bounded-exec/progress.test.ts +1 -14
- package/src/executors/bounded-exec/progress.ts +2 -5
- package/src/executors/bounded-exec/runner-hook.test.ts +193 -0
- package/src/executors/bounded-exec/runner-hook.ts +292 -0
- package/src/executors/bounded-exec/runner-lifecycle.test.ts +82 -0
- package/src/executors/bounded-exec/runner-lifecycle.ts +102 -0
- package/src/index.test.ts +7 -5
- package/src/index.ts +4 -1
- package/src/nx-daemon-start-never.test.ts +137 -0
- package/src/producer-receipts.test.ts +99 -0
- package/src/producer-receipts.ts +111 -58
- package/test-timings.json +101 -96
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"producer-receipts.d.ts","sourceRoot":"","sources":["../src/producer-receipts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"producer-receipts.d.ts","sourceRoot":"","sources":["../src/producer-receipts.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnH,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,2BAA2B,CAAC;AAEvF,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK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yBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,CAoIf;AACD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAOrG"}
|
|
@@ -5,7 +5,7 @@ import { delimiter, dirname, join, resolve } from 'node:path';
|
|
|
5
5
|
import typia from 'typia';
|
|
6
6
|
import { createWorkspaceNxRequire, parseTargetSelector, providerInputProof, selectorTaskId, } from './ensure-built.js';
|
|
7
7
|
import { captureProducerSource, producerOutputPaths, providerReceipt, receiptNode, } from './ensure-built-receipt.js';
|
|
8
|
-
import { censusStart,
|
|
8
|
+
import { censusFileHashes, censusStart, graphInstallationCensus, movedNodes, readInstallationCensus, workspaceSnapshot, writeWitness, } from './ensure-built-witness.js';
|
|
9
9
|
import { graphInputContractIdentity } from './graph-input-contract.js';
|
|
10
10
|
/**
|
|
11
11
|
* Where a checkout keeps its producer records, relative to its root: in its own source tree, never in Nx's
|
|
@@ -17,6 +17,11 @@ import { graphInputContractIdentity } from './graph-input-contract.js';
|
|
|
17
17
|
* is no source or input of the run that publishes it.
|
|
18
18
|
*/
|
|
19
19
|
export const PRODUCER_RECORDS = join('.cache', 'producer-receipts');
|
|
20
|
+
/**
|
|
21
|
+
* The installation census the pre-task hook took last, in Nx's workspace-data beside the graph witness: a hash source
|
|
22
|
+
* for the next census ({@link installedClosureTool}), never a proof and never part of a receipt.
|
|
23
|
+
*/
|
|
24
|
+
const PRODUCER_INSTALLATION_CENSUS = 'producer-installation-census.json';
|
|
20
25
|
const runs = new Map();
|
|
21
26
|
function sha(value) {
|
|
22
27
|
return createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
@@ -96,6 +101,80 @@ function targetGraph(root, target, projectGraph) {
|
|
|
96
101
|
throw new Error(`Invalid declared producer target ${target}`);
|
|
97
102
|
return createWorkspaceNxRequire(root)('nx/src/tasks-runner/create-task-graph').createTaskGraph(projectGraph, {}, [selector.project], [selector.target], selector.configuration, {}, false);
|
|
98
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* The installed closure of Nx, this plugin, TypeScript and the local graph plugins as one producer tool: every node of
|
|
106
|
+
* the installation census, and the module namespace each of its resolutions searched. The census is not proved by a
|
|
107
|
+
* stat pass of its own: each of its nodes is stat-ed again as a tool node, a file whose stamp moved since the census
|
|
108
|
+
* read it is read again, and the capture's stability check refuses a tool node that moves before publication.
|
|
109
|
+
*
|
|
110
|
+
* Its value is a function of the closure's node stamps (device, inode, mode, size, mtime and ctime), not of the moment
|
|
111
|
+
* it is taken. So every node is stat-ed on every call, and that is what makes reuse safe: a file whose stamp is the one
|
|
112
|
+
* the census recorded at `record` read it at keeps that census's hash, so an unchanged closure reads no file bytes,
|
|
113
|
+
* while a file rewritten in place, as a developer-linked package's rebuilt `dist` is with no lockfile or
|
|
114
|
+
* `node_modules` change, moves its ctime and is read again. The tool's nodes take the hash this census read
|
|
115
|
+
* ({@link censusFileHashes}) instead of reading each file a second time: a write landing between two reads could make
|
|
116
|
+
* them disagree.
|
|
117
|
+
*/
|
|
118
|
+
export function installedClosureTool(root, nxJson, localInputs, record, resolvePackage, expand, census) {
|
|
119
|
+
let installationMiss = 'unproved installed module/resolution closure';
|
|
120
|
+
performance.mark('producerReceipts:census:start');
|
|
121
|
+
const installation = graphInstallationCensus(root, nxJson, resolvePackage, expand, localInputs ?? { plugins: [], packages: [], identity: '[]' }, (detail) => {
|
|
122
|
+
installationMiss = detail;
|
|
123
|
+
}, readInstallationCensus(record));
|
|
124
|
+
performance.measure('producerReceipts:census', 'producerReceipts:census:start');
|
|
125
|
+
if (installation === null)
|
|
126
|
+
return { ok: false, detail: `Producer installed module/resolution closure is unproved: ${installationMiss}` };
|
|
127
|
+
writeWitness(record, installation);
|
|
128
|
+
const paths = new Set(installation.nodes.map(({ path }) => path));
|
|
129
|
+
const absent = new Set();
|
|
130
|
+
function namespace(path) {
|
|
131
|
+
let stats;
|
|
132
|
+
try {
|
|
133
|
+
stats = lstatSync(path);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (error instanceof Error && 'code' in error && ['ENOENT', 'ENOTDIR'].includes(String(error.code))) {
|
|
137
|
+
absent.add(path);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
paths.add(path);
|
|
143
|
+
if (stats.isSymbolicLink())
|
|
144
|
+
paths.add(realpathSync(path));
|
|
145
|
+
if (stats.isDirectory())
|
|
146
|
+
for (const name of readdirSync(path))
|
|
147
|
+
paths.add(join(path, name));
|
|
148
|
+
}
|
|
149
|
+
const resolutions = [];
|
|
150
|
+
for (const [from, name, target] of installation.resolutions) {
|
|
151
|
+
resolutions.push({ from, name, target });
|
|
152
|
+
for (const directory of createRequire(join(from, 'package.json')).resolve.paths(name) ?? []) {
|
|
153
|
+
namespace(directory);
|
|
154
|
+
const candidate = join(directory, name);
|
|
155
|
+
if (existsSync(candidate))
|
|
156
|
+
namespace(candidate);
|
|
157
|
+
else
|
|
158
|
+
absent.add(candidate);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const recorded = censusFileHashes(installation);
|
|
162
|
+
const nodes = [...paths].sort().map((path) => receiptNode(path, path, census, recorded));
|
|
163
|
+
return {
|
|
164
|
+
ok: true,
|
|
165
|
+
value: {
|
|
166
|
+
kind: 'module',
|
|
167
|
+
name: 'installed-nx-plugin-closure',
|
|
168
|
+
from: root,
|
|
169
|
+
path: root,
|
|
170
|
+
physicalPath: realpathSync(root),
|
|
171
|
+
nodes,
|
|
172
|
+
missing: [...absent].sort(),
|
|
173
|
+
resolutions,
|
|
174
|
+
sha256: sha(nodes),
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
99
178
|
/** Tool resolution is captured in producer scope; readers inspect its recorded filesystem, not their own environment. */
|
|
100
179
|
function toolsFor(root, nxJson, projectGraph, bases) {
|
|
101
180
|
try {
|
|
@@ -115,67 +194,12 @@ function toolsFor(root, nxJson, projectGraph, bases) {
|
|
|
115
194
|
return { ok: false, detail: proof.runtimeSource.detail };
|
|
116
195
|
needsCargo ||= Object.values(proof.inputs).some((input) => input.runtime.length > 0);
|
|
117
196
|
}
|
|
118
|
-
let installationMiss = 'unproved installed module/resolution closure';
|
|
119
|
-
const identity = graphInstallationIdentity(root, nxJson, load('nx/src/utils/package-json').readModulePackageJson, load('nx/src/native').expandOutputs, local ?? { plugins: [], packages: [], identity: '[]' }, (detail) => {
|
|
120
|
-
installationMiss = detail;
|
|
121
|
-
});
|
|
122
|
-
if (identity === null)
|
|
123
|
-
return { ok: false, detail: `Producer installed module/resolution closure is unproved: ${installationMiss}` };
|
|
124
|
-
const installation = (() => {
|
|
125
|
-
const _io0 = input => Array.isArray(input.nodes) && input.nodes.every(elem => "object" === typeof elem && null !== elem && _io1(elem)) && (Array.isArray(input.resolutions) && input.resolutions.every(elem => Array.isArray(elem) && (elem.length === 3 && "string" === typeof elem[0] && "string" === typeof elem[1] && (null === elem[2] || "string" === typeof elem[2])))) && (null === input.localInputs || "string" === typeof input.localInputs);
|
|
126
|
-
const _io1 = input => "string" === typeof input.path && "string" === typeof input.stamp;
|
|
127
|
-
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
128
|
-
return input => { input = JSON.parse(input); return __is(input) ? input : null; };
|
|
129
|
-
})()(identity);
|
|
130
|
-
if (installation === null)
|
|
131
|
-
return { ok: false, detail: 'Invalid installed module closure evidence' };
|
|
132
197
|
const observed = [];
|
|
133
198
|
const census = { start: censusStart(), observed };
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
stats = lstatSync(path);
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
if (error instanceof Error && 'code' in error && ['ENOENT', 'ENOTDIR'].includes(String(error.code))) {
|
|
143
|
-
absent.add(path);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
throw error;
|
|
147
|
-
}
|
|
148
|
-
paths.add(path);
|
|
149
|
-
if (stats.isSymbolicLink())
|
|
150
|
-
paths.add(realpathSync(path));
|
|
151
|
-
if (stats.isDirectory())
|
|
152
|
-
for (const name of readdirSync(path))
|
|
153
|
-
paths.add(join(path, name));
|
|
154
|
-
}
|
|
155
|
-
const resolutions = [];
|
|
156
|
-
for (const [from, name, target] of installation.resolutions) {
|
|
157
|
-
resolutions.push({ from, name, target });
|
|
158
|
-
for (const directory of createRequire(join(from, 'package.json')).resolve.paths(name) ?? []) {
|
|
159
|
-
namespace(directory);
|
|
160
|
-
const candidate = join(directory, name);
|
|
161
|
-
if (existsSync(candidate))
|
|
162
|
-
namespace(candidate);
|
|
163
|
-
else
|
|
164
|
-
absent.add(candidate);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const nodes = [...paths].sort().map((path) => receiptNode(path, path, census));
|
|
168
|
-
const module = {
|
|
169
|
-
kind: 'module',
|
|
170
|
-
name: 'installed-nx-plugin-closure',
|
|
171
|
-
from: root,
|
|
172
|
-
path: root,
|
|
173
|
-
physicalPath: realpathSync(root),
|
|
174
|
-
nodes,
|
|
175
|
-
missing: [...absent].sort(),
|
|
176
|
-
resolutions,
|
|
177
|
-
sha256: sha(nodes),
|
|
178
|
-
};
|
|
199
|
+
const closure = installedClosureTool(root, nxJson, local, join(data, PRODUCER_INSTALLATION_CENSUS), load('nx/src/utils/package-json').readModulePackageJson, load('nx/src/native').expandOutputs, census);
|
|
200
|
+
if (!closure.ok)
|
|
201
|
+
return closure;
|
|
202
|
+
const module = closure.value;
|
|
179
203
|
const tools = [module];
|
|
180
204
|
for (const name of ['nx-runtime', 'bun', 'sh', 'git', ...(needsCargo ? ['rustc', 'cargo'] : [])]) {
|
|
181
205
|
const candidates = name === 'nx-runtime'
|
|
@@ -274,19 +298,26 @@ export async function preTasksExecution(options, context) {
|
|
|
274
298
|
return;
|
|
275
299
|
try {
|
|
276
300
|
const load = createWorkspaceNxRequire(context.workspaceRoot);
|
|
301
|
+
// A hook that can hold a run for minutes names its phases: Nx reports each measure under NX_PERF_LOGGING.
|
|
302
|
+
performance.mark('producerReceipts:graph:start');
|
|
277
303
|
const projectGraph = await load('nx/src/project-graph/project-graph').createProjectGraphAsync();
|
|
304
|
+
performance.measure('producerReceipts:graph', 'producerReceipts:graph:start');
|
|
278
305
|
const bases = new Map();
|
|
279
306
|
for (const target of targets) {
|
|
307
|
+
performance.mark('producerReceipts:source:start');
|
|
280
308
|
const graph = targetGraph(context.workspaceRoot, target, projectGraph);
|
|
281
309
|
const outputs = producerOutputPaths(context.workspaceRoot, Object.values(graph.tasks), load('nx/src/native').expandOutputs);
|
|
282
310
|
const source = captureProducerSource(context.workspaceRoot, outputs);
|
|
311
|
+
performance.measure('producerReceipts:source', 'producerReceipts:source:start');
|
|
283
312
|
if (!source.ok) {
|
|
284
313
|
runs.set(context.id, source);
|
|
285
314
|
return;
|
|
286
315
|
}
|
|
287
316
|
bases.set(target, { graph, source: source.value });
|
|
288
317
|
}
|
|
318
|
+
performance.mark('producerReceipts:tools:start');
|
|
289
319
|
const tools = toolsFor(context.workspaceRoot, context.nxJsonConfiguration, projectGraph, [...bases.values()]);
|
|
320
|
+
performance.measure('producerReceipts:tools', 'producerReceipts:tools:start');
|
|
290
321
|
runs.set(context.id, tools.ok
|
|
291
322
|
? {
|
|
292
323
|
ok: true,
|
package/executors.json
CHANGED
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"implementation": "./dist/executors/shard-timings/executor.js",
|
|
25
25
|
"schema": "./src/executors/shard-timings/schema.json",
|
|
26
26
|
"description": "Fail when a timings-sharded bun test suite runs a file its --timings manifest does not name"
|
|
27
|
+
},
|
|
28
|
+
"all-verdicts": {
|
|
29
|
+
"implementation": "./dist/executors/all-verdicts/executor.js",
|
|
30
|
+
"schema": "./src/executors/all-verdicts/schema.json",
|
|
31
|
+
"description": "Run every command at once to its own verdict and report each one a signal ended or that never ran as UNJUDGED"
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
}
|
|
@@ -9,9 +9,16 @@ formatters:
|
|
|
9
9
|
- '!.*' # Exclude hidden files
|
|
10
10
|
|
|
11
11
|
# Biome for JS/TS family (including CommonJS/CTS and ESM .mjs/.mts)
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
# At commit it may rewrite exactly: formatting, import order (assist/source/organizeImports) and string
|
|
13
|
+
# concatenation to template literals (lint/style/useTemplate, an unsafe fix, so --unsafe with --only).
|
|
14
|
+
# Those two are the land gate's autofixable refusals; every other rule stays a lint finding.
|
|
15
|
+
# Biome check --write silently passes unparsable stdin through; the final biome format refuses it,
|
|
16
|
+
# and the pipeline's status is that format's.
|
|
17
|
+
biome-scripts:
|
|
18
|
+
command:
|
|
19
|
+
"biome check --write --unsafe --files-ignore-unknown=true --use-editorconfig=true
|
|
20
|
+
--only=assist/source/organizeImports --only=lint/style/useTemplate '--stdin-file-path={}' | biome format
|
|
21
|
+
--files-ignore-unknown=true --use-editorconfig=true '--stdin-file-path={}'"
|
|
15
22
|
patterns:
|
|
16
23
|
- '*.js'
|
|
17
24
|
- '*.cjs'
|
|
@@ -21,6 +28,12 @@ formatters:
|
|
|
21
28
|
- '*.mts'
|
|
22
29
|
- '*.jsx'
|
|
23
30
|
- '*.tsx'
|
|
31
|
+
|
|
32
|
+
# Biome for data and markup. smoo's JSON writer runs this exact command (biomeHookArguments), so a
|
|
33
|
+
# file it writes is a fixed point of the hook; a test pins the two together.
|
|
34
|
+
biome:
|
|
35
|
+
command: "biome format --files-ignore-unknown=true --use-editorconfig=true '--stdin-file-path={}'"
|
|
36
|
+
patterns:
|
|
24
37
|
- '*.json'
|
|
25
38
|
- '*.jsonc'
|
|
26
39
|
- '*.html'
|