@smoothbricks/nx-plugin 0.4.22 → 0.4.24
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 +93 -33
- package/dist/bin/smoo-nx-exec.js +35 -11
- package/dist/bin/smoo-nx-nextest-extract.d.ts +3 -0
- package/dist/bin/smoo-nx-nextest-extract.d.ts.map +1 -0
- package/dist/bin/smoo-nx-nextest-extract.js +41 -0
- package/dist/cargo-closure-input.d.ts +63 -0
- package/dist/cargo-closure-input.d.ts.map +1 -0
- package/dist/cargo-closure-input.js +197 -0
- package/dist/cargo-source-hash.d.ts +37 -0
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +108 -190
- package/dist/cross-check-policy.d.ts +14 -0
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +15 -1
- package/dist/ensure-built.d.ts +3 -2
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +33 -56
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +152 -91
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +12 -15
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +10 -0
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/managed-files/publish-workflow.js +12 -6
- package/dist/manifest-hash.d.ts.map +1 -1
- package/dist/manifest-hash.js +24 -30
- package/dist/nextest-extraction.d.ts +101 -0
- package/dist/nextest-extraction.d.ts.map +1 -0
- package/dist/nextest-extraction.js +268 -0
- package/dist/package-target-policy.js +1 -1
- package/dist/platform-targets.d.ts +7 -0
- package/dist/platform-targets.d.ts.map +1 -1
- package/dist/platform-targets.js +7 -0
- package/dist/workspace-config-policy.d.ts +1 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +1 -1
- package/managed/raw/envrc +38 -1
- package/managed/raw/tooling/direnv/developer-links.ts +201 -0
- package/managed/raw/tooling/direnv/devenv.smoo.nix +75 -51
- package/managed/raw/tooling/direnv/secret-references.ts +3 -1
- package/managed/raw/tooling/direnv/setup-environment.ts +562 -78
- package/managed/raw/tooling/direnv/shared-caches.sh +53 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +22 -1
- package/managed/templates/github/workflows/managed-files.yml +4 -3
- package/nextest.toml +5 -5
- package/package.json +4 -3
- package/src/__tests__/fixture-nx-env.ts +31 -0
- package/src/__tests__/in-process-nx-index.ts +9 -0
- package/src/bin/smoo-nx-exec.ts +40 -11
- package/src/bin/smoo-nx-nextest-extract.ts +43 -0
- package/src/bounded-test-policy.test.ts +4 -1
- package/src/cargo-closure-input.test.ts +184 -0
- package/src/cargo-closure-input.ts +247 -0
- package/src/cargo-source-hash.test.ts +8 -9
- package/src/cargo-source-hash.ts +146 -47
- package/src/cross-check-policy.ts +15 -3
- package/src/ensure-built.test.ts +65 -5
- package/src/ensure-built.ts +40 -85
- package/src/index.test.ts +222 -75
- package/src/index.ts +213 -101
- package/src/managed-files/ci-workflow.ts +12 -15
- package/src/managed-files/files.ts +10 -0
- package/src/managed-files/generator.test.ts +29 -0
- package/src/managed-files/publish-workflow.ts +17 -6
- package/src/manifest-hash.test.ts +21 -1
- package/src/manifest-hash.ts +26 -29
- package/src/nextest-extraction.test.ts +74 -0
- package/src/nextest-extraction.ts +329 -0
- package/src/package-target-policy.ts +1 -1
- package/src/platform-targets.ts +8 -0
- package/src/workspace-config-policy.ts +6 -1
package/dist/ensure-built.js
CHANGED
|
@@ -92,7 +92,7 @@ export function unvouched(entries, verdicts) {
|
|
|
92
92
|
* on every invocation. So it never spawns the `nx` CLI: a native filesystem
|
|
93
93
|
* snapshot refreshes the daemon's inputs, the task hashes and on-disk output
|
|
94
94
|
* verification are daemon round-trips, and the cache lookup is a local SQLite
|
|
95
|
-
* read.
|
|
95
|
+
* read. Only a miss starts the workspace's `nx` CLI, to run the target.
|
|
96
96
|
*
|
|
97
97
|
* With the daemon disabled there is no probe to make — hashing would have to
|
|
98
98
|
* build the project graph in this process, and no service holds the recorded
|
|
@@ -141,7 +141,7 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
|
|
|
141
141
|
// this explicit fallback path, which also lets a deliberately minimal
|
|
142
142
|
// checkout-local CLI stand in for Nx.
|
|
143
143
|
if (process.env.NX_DAEMON === 'false') {
|
|
144
|
-
return runViaCli(workspaceRoot, selector);
|
|
144
|
+
return runViaCli(workspaceRoot, selector, { kind: 'no-daemon', taskId: selectorTaskId(selector) });
|
|
145
145
|
}
|
|
146
146
|
// Nx rejects daemon access when the client package's version differs from
|
|
147
147
|
// the workspace's running daemon. Resolve every runtime module from the
|
|
@@ -151,7 +151,7 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
|
|
|
151
151
|
bindWorkspaceRoot(workspaceRoot, requireNx);
|
|
152
152
|
const { daemonClient } = requireNx('nx/src/daemon/client/client');
|
|
153
153
|
if (!daemonClient.enabled()) {
|
|
154
|
-
return runViaCli(workspaceRoot, selector);
|
|
154
|
+
return runViaCli(workspaceRoot, selector, { kind: 'no-daemon', taskId: selectorTaskId(selector) });
|
|
155
155
|
}
|
|
156
156
|
// An outer Nx task exports its own cache-bypass setting to the process it
|
|
157
157
|
// launches. That setting describes the outer task, not the nested target:
|
|
@@ -199,32 +199,34 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
|
|
|
199
199
|
});
|
|
200
200
|
performance.mark('ensureBuilt:probe:start');
|
|
201
201
|
let reason;
|
|
202
|
-
const selectorTaskId = selector.configuration === undefined
|
|
203
|
-
? `${selector.project}:${selector.target}`
|
|
204
|
-
: `${selector.project}:${selector.target}:${selector.configuration}`;
|
|
205
202
|
if (process.env.NX_SKIP_NX_CACHE === 'true' || process.env.NX_DISABLE_NX_CACHE === 'true') {
|
|
206
|
-
reason = { kind: 'cache-disabled', taskId: selectorTaskId };
|
|
203
|
+
reason = { kind: 'cache-disabled', taskId: selectorTaskId(selector) };
|
|
207
204
|
}
|
|
208
205
|
else if (inputsChanged) {
|
|
209
|
-
reason = { kind: 'stale-inputs', taskId: selectorTaskId };
|
|
206
|
+
reason = { kind: 'stale-inputs', taskId: selectorTaskId(selector) };
|
|
210
207
|
}
|
|
211
208
|
else {
|
|
212
209
|
reason = await probe(workspaceRoot, nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx);
|
|
213
210
|
}
|
|
214
211
|
performance.measure('ensureBuilt:probe', 'ensureBuilt:probe:start');
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
// The CLI runs the hooks around its own run, under its own id. This process
|
|
213
|
+
// ran none of the tasks, so it reports none for the id it opened.
|
|
214
|
+
const result = reason === null ? HIT : await runViaCli(workspaceRoot, selector, reason);
|
|
218
215
|
await hooks.runPostTasksExecution({
|
|
219
216
|
id: runId,
|
|
220
|
-
taskResults:
|
|
217
|
+
taskResults: NO_TASK_RESULTS,
|
|
221
218
|
workspaceRoot,
|
|
222
219
|
nxJsonConfiguration: nxJson,
|
|
223
220
|
argv: process.argv,
|
|
224
221
|
startTime,
|
|
225
222
|
endTime: Date.now(),
|
|
226
223
|
});
|
|
227
|
-
return
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
function selectorTaskId(selector) {
|
|
227
|
+
return selector.configuration === undefined
|
|
228
|
+
? `${selector.project}:${selector.target}`
|
|
229
|
+
: `${selector.project}:${selector.target}:${selector.configuration}`;
|
|
228
230
|
}
|
|
229
231
|
/**
|
|
230
232
|
* Nx computes `workspaceRoot` once, at module load, from
|
|
@@ -576,56 +578,31 @@ function firstMovedClaim(observed) {
|
|
|
576
578
|
function isSystemError(error) {
|
|
577
579
|
return error instanceof Error && 'code' in error && typeof error.code === 'string';
|
|
578
580
|
}
|
|
579
|
-
async function runTarget(nxJson, nxArgs, overrides, selector, reason, requireNx) {
|
|
580
|
-
const { runCommandForTasks } = requireNx('nx/src/tasks-runner/run-command');
|
|
581
|
-
const { createProjectGraphAsync } = requireNx('nx/src/project-graph/project-graph');
|
|
582
|
-
const { signalToCode } = requireNx('nx/src/utils/exit-codes');
|
|
583
|
-
// `runCommandForTasks` derives its own task graph and hashes, so the probe's
|
|
584
|
-
// work is not reusable. That duplication is one daemon round-trip on a path
|
|
585
|
-
// that is about to run a build.
|
|
586
|
-
const projectGraph = await createProjectGraphAsync();
|
|
587
|
-
const { taskResults, completed } = await runCommandForTasks([requireProject(projectGraph, selector.project)], projectGraph, { nxJson }, nxArgs, overrides, selector.project, {}, { excludeTaskDependencies: false, loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false' });
|
|
588
|
-
if (!completed) {
|
|
589
|
-
// Nx's own encoding of an interrupted run: `runCommand` reports
|
|
590
|
-
// `signalToCode('SIGINT')` here. The runner does not surface which signal
|
|
591
|
-
// actually arrived, so there is none to forward — only the code Nx's CLI
|
|
592
|
-
// would have exited with.
|
|
593
|
-
return {
|
|
594
|
-
result: { disposition: 'failed', reason, exitCode: signalToCode('SIGINT'), signal: null },
|
|
595
|
-
taskResults,
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
for (const taskResult of Object.values(taskResults)) {
|
|
599
|
-
if (taskResult.status === 'failure' || taskResult.status === 'skipped') {
|
|
600
|
-
return { result: { disposition: 'failed', reason, exitCode: 1, signal: null }, taskResults };
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
return { result: { disposition: 'built', reason }, taskResults };
|
|
604
|
-
}
|
|
605
581
|
/**
|
|
606
|
-
*
|
|
607
|
-
*
|
|
582
|
+
* Run the target through the workspace's own `nx`, the invocation whose hashes
|
|
583
|
+
* the probe reproduces, with the child's stdout on this process's stderr.
|
|
608
584
|
*
|
|
609
|
-
*
|
|
585
|
+
* A child, because Nx does not only write through `process.stdout`: its Rust
|
|
586
|
+
* pseudo-terminal and the forked executors it starts with inherited stdio
|
|
587
|
+
* write task output straight to file descriptor 1, and Node cannot point that
|
|
588
|
+
* descriptor elsewhere in its own process. In a child it is simply stderr, so
|
|
589
|
+
* the stdout of a wrapper that goes on to exec a binary carries nothing but
|
|
590
|
+
* that binary's output (`<cli> list | jq` reads only data).
|
|
591
|
+
*
|
|
592
|
+
* Inheriting rather than piping is the other half. The wrapper this facility
|
|
610
593
|
* replaces piped Nx's output so it could read a cache marker out of the log and
|
|
611
594
|
* stay silent on a hit — a text heuristic over ANSI-coloured, format-unstable
|
|
612
|
-
* output.
|
|
613
|
-
*
|
|
614
|
-
* child's exit status is forwarded verbatim.
|
|
595
|
+
* output. The probe already decided this is no hit, so the output is the run's
|
|
596
|
+
* own, and the child's exit status is forwarded verbatim.
|
|
615
597
|
*/
|
|
616
|
-
async function runViaCli(workspaceRoot, selector) {
|
|
598
|
+
async function runViaCli(workspaceRoot, selector, reason) {
|
|
617
599
|
const nxCli = join(workspaceRoot, 'node_modules', '.bin', 'nx');
|
|
618
600
|
if (!existsSync(nxCli)) {
|
|
619
|
-
throw new Error(`ensureBuilt:
|
|
620
|
-
}
|
|
621
|
-
const
|
|
622
|
-
const targetSpec = selector.configuration
|
|
623
|
-
? `${selector.project}:${selector.target}:${selector.configuration}`
|
|
624
|
-
: `${selector.project}:${selector.target}`;
|
|
625
|
-
const signalToCode = nxSignalToCode;
|
|
626
|
-
const child = spawn(nxCli, ['run', targetSpec, '--outputStyle=stream'], {
|
|
601
|
+
throw new Error(`ensureBuilt: ${describeMiss(reason)}, and ${nxCli} does not exist`);
|
|
602
|
+
}
|
|
603
|
+
const child = spawn(nxCli, ['run', selectorTaskId(selector), '--outputStyle=stream'], {
|
|
627
604
|
cwd: workspaceRoot,
|
|
628
|
-
stdio: 'inherit',
|
|
605
|
+
stdio: ['inherit', 2, 'inherit'],
|
|
629
606
|
});
|
|
630
607
|
// `Promise.withResolvers` would read better but needs lib es2024; this
|
|
631
608
|
// package inherits lib es2022 from tsconfig.base.json.
|
|
@@ -633,7 +610,7 @@ async function runViaCli(workspaceRoot, selector) {
|
|
|
633
610
|
child.once('error', reject);
|
|
634
611
|
child.once('exit', (code, signal) => settle({ code, signal }));
|
|
635
612
|
});
|
|
636
|
-
return cliExitOutcome(reason, exit,
|
|
613
|
+
return cliExitOutcome(reason, exit, nxSignalToCode);
|
|
637
614
|
}
|
|
638
615
|
function nxSignalToCode(signal) {
|
|
639
616
|
switch (signal) {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAalC,OAAO,EAKL,yBAAyB,EAa1B,MAAM,sBAAsB,CAAC;AA4B9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,gEAAgE;AAChE,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAqQlD,KAAK,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;AACxC,KAAK,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,UAAU,YAAY;IACpB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,gBAAgB,CAAC;CAChC;AAmID,UAAU,oBAAqB,SAAQ,YAAY;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AA0CD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AA+XD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
|