@smoothbricks/nx-plugin 0.4.22 → 0.4.23
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 +77 -21
- package/dist/bin/smoo-nx-exec.js +35 -11
- 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 +112 -76
- 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/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 +2 -2
- 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/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 +94 -53
- package/src/index.ts +164 -84
- 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/package-target-policy.ts +1 -1
- package/src/platform-targets.ts +8 -0
- package/src/workspace-config-policy.ts +6 -1
package/src/ensure-built.test.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { chmod, mkdir, mkdtemp, readFile, realpath, rm, symlink, writeFile } fro
|
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
7
8
|
|
|
8
9
|
import type { Task } from 'nx/src/config/task-graph';
|
|
9
10
|
|
|
@@ -446,6 +447,26 @@ describe('smoo-nx-exec', () => {
|
|
|
446
447
|
expect(run.stdout.split('\n')[0]).toBe(MARKER);
|
|
447
448
|
});
|
|
448
449
|
|
|
450
|
+
it("hands the exec'd binary blocking stdio, so a pipe its output fills is never cut", async () => {
|
|
451
|
+
// Node leaves a pipe O_NONBLOCK on macOS, and the flag belongs to the open file description, so
|
|
452
|
+
// it survives execve: the binary's writes then fail with EAGAIN once the pipe holds 64 KiB and
|
|
453
|
+
// nobody is reading. A reader that starts late is what makes the pipe fill.
|
|
454
|
+
const flood = join(workspace, 'flood');
|
|
455
|
+
await writeFile(flood, '#!/bin/sh\nhead -c 300000 /dev/zero\n');
|
|
456
|
+
await chmod(flood, 0o755);
|
|
457
|
+
try {
|
|
458
|
+
const piped = Bun.spawn(
|
|
459
|
+
['sh', '-c', `"$0" "$1" app:build -- ./flood | { sleep 1; tr -cd '\\000' | wc -c; }`, 'node', builtBinEntry],
|
|
460
|
+
{ cwd: workspace, env: fixtureNxEnvironment(), stdout: 'pipe', stderr: 'pipe' },
|
|
461
|
+
);
|
|
462
|
+
const received = (await new Response(piped.stdout).text()).trim();
|
|
463
|
+
expect(await piped.exited).toBe(0);
|
|
464
|
+
expect(received).toBe('300000');
|
|
465
|
+
} finally {
|
|
466
|
+
await rm(flood, { force: true });
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
|
|
449
470
|
it('leaves the exec\u0027d binary the caller\u0027s cwd and none of Nx\u0027s environment', async () => {
|
|
450
471
|
// Invoked from a subdirectory, with the binary named relative to it: the
|
|
451
472
|
// resolution the wrapper's users actually perform.
|
|
@@ -508,7 +529,7 @@ describe('smoo-nx-exec', () => {
|
|
|
508
529
|
expect(await readFile(builds(), 'utf-8')).toBe(before);
|
|
509
530
|
});
|
|
510
531
|
|
|
511
|
-
it('runs again when a dependency\u0027s own inputs change', async () => {
|
|
532
|
+
it('runs again when a dependency\u0027s own inputs change, keeping stdout for the binary alone', async () => {
|
|
512
533
|
const before = await readFile(builds(), 'utf-8');
|
|
513
534
|
await writeFile(join(workspace, 'packages', 'lib', 'source1.txt'), 'lib changed\n');
|
|
514
535
|
const changed = await runBin(workspace, ['app:build', '--', './report']);
|
|
@@ -516,6 +537,13 @@ describe('smoo-nx-exec', () => {
|
|
|
516
537
|
expect(await readFile(join(workspace, 'packages', 'lib', 'dist', 'lib.txt'), 'utf-8')).toBe('lib changed\n');
|
|
517
538
|
expect(await readFile(marker(), 'utf-8')).toBe('built\nlib changed\n');
|
|
518
539
|
expect(await readFile(builds(), 'utf-8')).toBe(`${before}lib changed\n`);
|
|
540
|
+
// The run's log is on stderr. Stdout is the exec'd binary's and holds
|
|
541
|
+
// nothing else, or `wrapper | jq` reads Nx's banner as data.
|
|
542
|
+
expect(stripVTControlCharacters(changed.stderr)).toContain('nx run lib:build');
|
|
543
|
+
expect(changed.stdout.split('\n')[0], changed.stdout).toBe(MARKER);
|
|
544
|
+
for (const line of changed.stdout.split('\n').filter((line) => line !== '')) {
|
|
545
|
+
expect(line === MARKER || line.startsWith('cwd=') || /^NX_[A-Z_]+=/.test(line), line).toBe(true);
|
|
546
|
+
}
|
|
519
547
|
|
|
520
548
|
// And the graph settles back to silence, which is only reachable if the
|
|
521
549
|
// dependent-outputs task was hashed too.
|
|
@@ -544,6 +572,38 @@ describe('smoo-nx-exec', () => {
|
|
|
544
572
|
expect(settled.stdout.split('\n')[0]).toBe(MARKER);
|
|
545
573
|
});
|
|
546
574
|
|
|
575
|
+
it('without a binary, stays silent and exits 0 when nothing is stale', async () => {
|
|
576
|
+
const run = await runBin(workspace, ['app:build']);
|
|
577
|
+
expect(run.code, run.stdout + run.stderr).toBe(0);
|
|
578
|
+
expect(run.stdout).toBe('');
|
|
579
|
+
expect(run.stderr).toBe('');
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
it('without a binary, runs what is stale, shows that run and exits 0', async () => {
|
|
583
|
+
const before = await readFile(builds(), 'utf-8');
|
|
584
|
+
await writeFile(join(workspace, 'packages', 'lib', 'source1.txt'), 'lib checked\n');
|
|
585
|
+
const run = await runBin(workspace, ['app:build']);
|
|
586
|
+
expect(run.code, run.stdout + run.stderr).toBe(0);
|
|
587
|
+
// An outer `nx run nx-plugin:test` exports FORCE_COLOR, so the fixture's
|
|
588
|
+
// Nx styles its task lines; what the test pins is the line, not its colour.
|
|
589
|
+
expect(stripVTControlCharacters(run.stderr)).toContain('nx run lib:build');
|
|
590
|
+
expect(run.stdout).toBe('');
|
|
591
|
+
expect(await readFile(marker(), 'utf-8')).toBe('built\nlib checked\n');
|
|
592
|
+
expect(await readFile(builds(), 'utf-8')).toBe(`${before}lib checked\n`);
|
|
593
|
+
|
|
594
|
+
const settled = await runBin(workspace, ['app:build']);
|
|
595
|
+
expect(settled.code, settled.stdout + settled.stderr).toBe(0);
|
|
596
|
+
expect(settled.stdout).toBe('');
|
|
597
|
+
expect(settled.stderr).toBe('');
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
it('without a binary, exits with a failing target\u0027s code', async () => {
|
|
601
|
+
const run = await runBin(workspace, ['app:broken']);
|
|
602
|
+
expect(run.code).toBe(1);
|
|
603
|
+
expect(stripVTControlCharacters(run.stderr)).toContain('nx run app:broken');
|
|
604
|
+
expect(run.stdout).toBe('');
|
|
605
|
+
});
|
|
606
|
+
|
|
547
607
|
it('forwards a failing target\u0027s exit code and never execs', async () => {
|
|
548
608
|
const run = await runBin(workspace, ['app:broken', '--', './report']);
|
|
549
609
|
expect(run.code).toBe(1);
|
|
@@ -557,7 +617,7 @@ describe('smoo-nx-exec', () => {
|
|
|
557
617
|
});
|
|
558
618
|
expect(run.code).toBe(0);
|
|
559
619
|
expect(run.stderr).toContain('daemon is disabled');
|
|
560
|
-
expect(run.stdout).
|
|
620
|
+
expect(run.stdout.split('\n')[0], run.stdout).toBe(MARKER);
|
|
561
621
|
});
|
|
562
622
|
|
|
563
623
|
it('prints the message from a plain-object Nx rejection', async () => {
|
|
@@ -597,9 +657,9 @@ describe('smoo-nx-exec', () => {
|
|
|
597
657
|
});
|
|
598
658
|
|
|
599
659
|
it('rejects a malformed invocation with a usage error', async () => {
|
|
600
|
-
const
|
|
601
|
-
expect(
|
|
602
|
-
expect(
|
|
660
|
+
const emptyCommand = await runBin(workspace, ['app:build', '--']);
|
|
661
|
+
expect(emptyCommand.code).toBe(2);
|
|
662
|
+
expect(emptyCommand.stderr).toContain('no binary given');
|
|
603
663
|
|
|
604
664
|
const badTarget = await runBin(workspace, ['build', '--', './report']);
|
|
605
665
|
expect(badTarget.code).toBe(2);
|
package/src/ensure-built.ts
CHANGED
|
@@ -14,7 +14,6 @@ import type * as NxHashTask from 'nx/src/hasher/hash-task';
|
|
|
14
14
|
import type * as NxTaskHasher from 'nx/src/hasher/task-hasher';
|
|
15
15
|
import type * as NxNative from 'nx/src/native';
|
|
16
16
|
import type * as NxExecutionHooks from 'nx/src/project-graph/plugins/tasks-execution-hooks';
|
|
17
|
-
import type * as NxProjectGraph from 'nx/src/project-graph/project-graph';
|
|
18
17
|
import type * as NxCache from 'nx/src/tasks-runner/cache';
|
|
19
18
|
import type * as NxCreateTaskGraph from 'nx/src/tasks-runner/create-task-graph';
|
|
20
19
|
import type { TaskResults } from 'nx/src/tasks-runner/life-cycle';
|
|
@@ -24,7 +23,6 @@ import type * as NxTasksRunnerUtils from 'nx/src/tasks-runner/utils';
|
|
|
24
23
|
import type * as NxCacheDirectory from 'nx/src/utils/cache-directory';
|
|
25
24
|
import type * as NxCommandLineUtils from 'nx/src/utils/command-line-utils';
|
|
26
25
|
import type { NxArgs } from 'nx/src/utils/command-line-utils';
|
|
27
|
-
import type * as NxExitCodes from 'nx/src/utils/exit-codes';
|
|
28
26
|
import type * as NxPerfLogging from 'nx/src/utils/perf-logging';
|
|
29
27
|
import type * as NxWorkspaceRoot from 'nx/src/utils/workspace-root';
|
|
30
28
|
|
|
@@ -35,7 +33,6 @@ interface NxRuntimeModules {
|
|
|
35
33
|
readonly 'nx/src/hasher/task-hasher': typeof NxTaskHasher;
|
|
36
34
|
readonly 'nx/src/native': typeof NxNative;
|
|
37
35
|
readonly 'nx/src/project-graph/plugins/tasks-execution-hooks': typeof NxExecutionHooks;
|
|
38
|
-
readonly 'nx/src/project-graph/project-graph': typeof NxProjectGraph;
|
|
39
36
|
readonly 'nx/src/tasks-runner/cache': typeof NxCache;
|
|
40
37
|
readonly 'nx/src/tasks-runner/create-task-graph': typeof NxCreateTaskGraph;
|
|
41
38
|
readonly 'nx/src/tasks-runner/run-command': typeof NxRunCommand;
|
|
@@ -43,7 +40,6 @@ interface NxRuntimeModules {
|
|
|
43
40
|
readonly 'nx/src/tasks-runner/utils': typeof NxTasksRunnerUtils;
|
|
44
41
|
readonly 'nx/src/utils/cache-directory': typeof NxCacheDirectory;
|
|
45
42
|
readonly 'nx/src/utils/command-line-utils': typeof NxCommandLineUtils;
|
|
46
|
-
readonly 'nx/src/utils/exit-codes': typeof NxExitCodes;
|
|
47
43
|
readonly 'nx/src/utils/perf-logging': typeof NxPerfLogging;
|
|
48
44
|
readonly 'nx/src/utils/workspace-root': typeof NxWorkspaceRoot;
|
|
49
45
|
}
|
|
@@ -99,7 +95,8 @@ export type MissReason =
|
|
|
99
95
|
* `built` means the work was handed to Nx — which may have restored outputs
|
|
100
96
|
* from the local cache rather than recompiled anything. The line `hit` draws is
|
|
101
97
|
* "did this process have to do work", which is what a CLI wrapper needs in
|
|
102
|
-
* order to decide whether to stay quiet.
|
|
98
|
+
* order to decide whether to stay quiet. A run writes only to stderr: stdout
|
|
99
|
+
* belongs to whatever the caller goes on to run.
|
|
103
100
|
*
|
|
104
101
|
* `failed` is an operational outcome, not an exception: the target ran and did
|
|
105
102
|
* not succeed. A caller re-raises `signal` when there is one and exits with
|
|
@@ -225,7 +222,7 @@ export function unvouched<Entry>(entries: readonly Entry[], verdicts: readonly b
|
|
|
225
222
|
* on every invocation. So it never spawns the `nx` CLI: a native filesystem
|
|
226
223
|
* snapshot refreshes the daemon's inputs, the task hashes and on-disk output
|
|
227
224
|
* verification are daemon round-trips, and the cache lookup is a local SQLite
|
|
228
|
-
* read.
|
|
225
|
+
* read. Only a miss starts the workspace's `nx` CLI, to run the target.
|
|
229
226
|
*
|
|
230
227
|
* With the daemon disabled there is no probe to make — hashing would have to
|
|
231
228
|
* build the project graph in this process, and no service holds the recorded
|
|
@@ -278,7 +275,7 @@ async function ensureBuiltInWorkspace(
|
|
|
278
275
|
// this explicit fallback path, which also lets a deliberately minimal
|
|
279
276
|
// checkout-local CLI stand in for Nx.
|
|
280
277
|
if (process.env.NX_DAEMON === 'false') {
|
|
281
|
-
return runViaCli(workspaceRoot, selector);
|
|
278
|
+
return runViaCli(workspaceRoot, selector, { kind: 'no-daemon', taskId: selectorTaskId(selector) });
|
|
282
279
|
}
|
|
283
280
|
// Nx rejects daemon access when the client package's version differs from
|
|
284
281
|
// the workspace's running daemon. Resolve every runtime module from the
|
|
@@ -288,7 +285,7 @@ async function ensureBuiltInWorkspace(
|
|
|
288
285
|
bindWorkspaceRoot(workspaceRoot, requireNx);
|
|
289
286
|
const { daemonClient } = requireNx('nx/src/daemon/client/client');
|
|
290
287
|
if (!daemonClient.enabled()) {
|
|
291
|
-
return runViaCli(workspaceRoot, selector);
|
|
288
|
+
return runViaCli(workspaceRoot, selector, { kind: 'no-daemon', taskId: selectorTaskId(selector) });
|
|
292
289
|
}
|
|
293
290
|
|
|
294
291
|
// An outer Nx task exports its own cache-bypass setting to the process it
|
|
@@ -356,32 +353,33 @@ async function ensureBuiltInWorkspace(
|
|
|
356
353
|
|
|
357
354
|
performance.mark('ensureBuilt:probe:start');
|
|
358
355
|
let reason: MissReason | null;
|
|
359
|
-
const selectorTaskId =
|
|
360
|
-
selector.configuration === undefined
|
|
361
|
-
? `${selector.project}:${selector.target}`
|
|
362
|
-
: `${selector.project}:${selector.target}:${selector.configuration}`;
|
|
363
356
|
if (process.env.NX_SKIP_NX_CACHE === 'true' || process.env.NX_DISABLE_NX_CACHE === 'true') {
|
|
364
|
-
reason = { kind: 'cache-disabled', taskId: selectorTaskId };
|
|
357
|
+
reason = { kind: 'cache-disabled', taskId: selectorTaskId(selector) };
|
|
365
358
|
} else if (inputsChanged) {
|
|
366
|
-
reason = { kind: 'stale-inputs', taskId: selectorTaskId };
|
|
359
|
+
reason = { kind: 'stale-inputs', taskId: selectorTaskId(selector) };
|
|
367
360
|
} else {
|
|
368
361
|
reason = await probe(workspaceRoot, nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx);
|
|
369
362
|
}
|
|
370
363
|
performance.measure('ensureBuilt:probe', 'ensureBuilt:probe:start');
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
: await runTarget(nxJson, nxArgs, overrides, selector, reason, requireNx);
|
|
364
|
+
// The CLI runs the hooks around its own run, under its own id. This process
|
|
365
|
+
// ran none of the tasks, so it reports none for the id it opened.
|
|
366
|
+
const result = reason === null ? HIT : await runViaCli(workspaceRoot, selector, reason);
|
|
375
367
|
await hooks.runPostTasksExecution({
|
|
376
368
|
id: runId,
|
|
377
|
-
taskResults:
|
|
369
|
+
taskResults: NO_TASK_RESULTS,
|
|
378
370
|
workspaceRoot,
|
|
379
371
|
nxJsonConfiguration: nxJson,
|
|
380
372
|
argv: process.argv,
|
|
381
373
|
startTime,
|
|
382
374
|
endTime: Date.now(),
|
|
383
375
|
});
|
|
384
|
-
return
|
|
376
|
+
return result;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function selectorTaskId(selector: TargetSelector): string {
|
|
380
|
+
return selector.configuration === undefined
|
|
381
|
+
? `${selector.project}:${selector.target}`
|
|
382
|
+
: `${selector.project}:${selector.target}:${selector.configuration}`;
|
|
385
383
|
}
|
|
386
384
|
|
|
387
385
|
/**
|
|
@@ -797,78 +795,35 @@ function isSystemError(error: unknown): boolean {
|
|
|
797
795
|
return error instanceof Error && 'code' in error && typeof error.code === 'string';
|
|
798
796
|
}
|
|
799
797
|
|
|
800
|
-
interface CompletedRun {
|
|
801
|
-
readonly result: EnsureBuiltResult;
|
|
802
|
-
readonly taskResults: TaskResults;
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
async function runTarget(
|
|
806
|
-
nxJson: NxJsonConfiguration,
|
|
807
|
-
nxArgs: NxArgs,
|
|
808
|
-
overrides: Record<string, unknown>,
|
|
809
|
-
selector: TargetSelector,
|
|
810
|
-
reason: MissReason,
|
|
811
|
-
requireNx: WorkspaceNxRequire,
|
|
812
|
-
): Promise<CompletedRun> {
|
|
813
|
-
const { runCommandForTasks } = requireNx('nx/src/tasks-runner/run-command');
|
|
814
|
-
const { createProjectGraphAsync } = requireNx('nx/src/project-graph/project-graph');
|
|
815
|
-
const { signalToCode } = requireNx('nx/src/utils/exit-codes');
|
|
816
|
-
// `runCommandForTasks` derives its own task graph and hashes, so the probe's
|
|
817
|
-
// work is not reusable. That duplication is one daemon round-trip on a path
|
|
818
|
-
// that is about to run a build.
|
|
819
|
-
const projectGraph = await createProjectGraphAsync();
|
|
820
|
-
const { taskResults, completed } = await runCommandForTasks(
|
|
821
|
-
[requireProject(projectGraph, selector.project)],
|
|
822
|
-
projectGraph,
|
|
823
|
-
{ nxJson },
|
|
824
|
-
nxArgs,
|
|
825
|
-
overrides,
|
|
826
|
-
selector.project,
|
|
827
|
-
{},
|
|
828
|
-
{ excludeTaskDependencies: false, loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false' },
|
|
829
|
-
);
|
|
830
|
-
if (!completed) {
|
|
831
|
-
// Nx's own encoding of an interrupted run: `runCommand` reports
|
|
832
|
-
// `signalToCode('SIGINT')` here. The runner does not surface which signal
|
|
833
|
-
// actually arrived, so there is none to forward — only the code Nx's CLI
|
|
834
|
-
// would have exited with.
|
|
835
|
-
return {
|
|
836
|
-
result: { disposition: 'failed', reason, exitCode: signalToCode('SIGINT'), signal: null },
|
|
837
|
-
taskResults,
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
for (const taskResult of Object.values(taskResults)) {
|
|
841
|
-
if (taskResult.status === 'failure' || taskResult.status === 'skipped') {
|
|
842
|
-
return { result: { disposition: 'failed', reason, exitCode: 1, signal: null }, taskResults };
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
return { result: { disposition: 'built', reason }, taskResults };
|
|
846
|
-
}
|
|
847
|
-
|
|
848
798
|
/**
|
|
849
|
-
*
|
|
850
|
-
*
|
|
799
|
+
* Run the target through the workspace's own `nx`, the invocation whose hashes
|
|
800
|
+
* the probe reproduces, with the child's stdout on this process's stderr.
|
|
851
801
|
*
|
|
852
|
-
*
|
|
802
|
+
* A child, because Nx does not only write through `process.stdout`: its Rust
|
|
803
|
+
* pseudo-terminal and the forked executors it starts with inherited stdio
|
|
804
|
+
* write task output straight to file descriptor 1, and Node cannot point that
|
|
805
|
+
* descriptor elsewhere in its own process. In a child it is simply stderr, so
|
|
806
|
+
* the stdout of a wrapper that goes on to exec a binary carries nothing but
|
|
807
|
+
* that binary's output (`<cli> list | jq` reads only data).
|
|
808
|
+
*
|
|
809
|
+
* Inheriting rather than piping is the other half. The wrapper this facility
|
|
853
810
|
* replaces piped Nx's output so it could read a cache marker out of the log and
|
|
854
811
|
* stay silent on a hit — a text heuristic over ANSI-coloured, format-unstable
|
|
855
|
-
* output.
|
|
856
|
-
*
|
|
857
|
-
* child's exit status is forwarded verbatim.
|
|
812
|
+
* output. The probe already decided this is no hit, so the output is the run's
|
|
813
|
+
* own, and the child's exit status is forwarded verbatim.
|
|
858
814
|
*/
|
|
859
|
-
async function runViaCli(
|
|
815
|
+
async function runViaCli(
|
|
816
|
+
workspaceRoot: string,
|
|
817
|
+
selector: TargetSelector,
|
|
818
|
+
reason: MissReason,
|
|
819
|
+
): Promise<EnsureBuiltResult> {
|
|
860
820
|
const nxCli = join(workspaceRoot, 'node_modules', '.bin', 'nx');
|
|
861
821
|
if (!existsSync(nxCli)) {
|
|
862
|
-
throw new Error(`ensureBuilt:
|
|
863
|
-
}
|
|
864
|
-
const
|
|
865
|
-
const targetSpec = selector.configuration
|
|
866
|
-
? `${selector.project}:${selector.target}:${selector.configuration}`
|
|
867
|
-
: `${selector.project}:${selector.target}`;
|
|
868
|
-
const signalToCode = nxSignalToCode;
|
|
869
|
-
const child = spawn(nxCli, ['run', targetSpec, '--outputStyle=stream'], {
|
|
822
|
+
throw new Error(`ensureBuilt: ${describeMiss(reason)}, and ${nxCli} does not exist`);
|
|
823
|
+
}
|
|
824
|
+
const child = spawn(nxCli, ['run', selectorTaskId(selector), '--outputStyle=stream'], {
|
|
870
825
|
cwd: workspaceRoot,
|
|
871
|
-
stdio: 'inherit',
|
|
826
|
+
stdio: ['inherit', 2, 'inherit'],
|
|
872
827
|
});
|
|
873
828
|
// `Promise.withResolvers` would read better but needs lib es2024; this
|
|
874
829
|
// package inherits lib es2022 from tsconfig.base.json.
|
|
@@ -876,7 +831,7 @@ async function runViaCli(workspaceRoot: string, selector: TargetSelector): Promi
|
|
|
876
831
|
child.once('error', reject);
|
|
877
832
|
child.once('exit', (code, signal) => settle({ code, signal }));
|
|
878
833
|
});
|
|
879
|
-
return cliExitOutcome(reason, exit,
|
|
834
|
+
return cliExitOutcome(reason, exit, nxSignalToCode);
|
|
880
835
|
}
|
|
881
836
|
|
|
882
837
|
function nxSignalToCode(signal: NodeJS.Signals | null): number {
|
package/src/index.test.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { BOUNDED_TEST_TIMEOUT_MS } from './bounded-test-policy.js';
|
|
|
12
12
|
import { exceptionalTestFilter, packageNameFromCargoTestTarget } from './cargo-workspace.js';
|
|
13
13
|
import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_LINT_CLIPPY_COMMAND } from './cross-check-policy.js';
|
|
14
14
|
import { createNodesV2, createNodesV2ForPlatform } from './index.js';
|
|
15
|
-
import { applyWorkspaceConfig } from './workspace-config-policy.js';
|
|
15
|
+
import { applyWorkspaceConfig, RELEASE_CONFIGURATION } from './workspace-config-policy.js';
|
|
16
16
|
|
|
17
17
|
const [, inferTargets] = createNodesV2;
|
|
18
18
|
|
|
@@ -895,9 +895,13 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
895
895
|
/^cargo --frozen nextest archive --workspace --archive-file target\/nextest\/archive\.tar\.zst --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
|
|
896
896
|
);
|
|
897
897
|
expect(targets['cargo-test-archive']?.inputs).toContain('{projectRoot}/.config/nextest.toml');
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
898
|
+
// Tests compile the dev profile only. Nx forwards a run's configuration
|
|
899
|
+
// down every edge to each target that has it, so a release configuration
|
|
900
|
+
// here would make a release `build` compile test binaries nobody runs.
|
|
901
|
+
for (const name of ['cargo-test-compile', 'cargo-test-archive', 'cargo-test', 'cargo-test-ferris-core', 'test']) {
|
|
902
|
+
expect(targets[name]).toBeDefined();
|
|
903
|
+
expect(targets[name]?.configurations?.[RELEASE_CONFIGURATION]).toBeUndefined();
|
|
904
|
+
}
|
|
901
905
|
expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
902
906
|
expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
903
907
|
// The runner executes the archive's binaries and remaps the workspace
|
|
@@ -911,7 +915,6 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
911
915
|
expect(targets['cargo-test-ferris-core']?.inputs).toContain(
|
|
912
916
|
'{workspaceRoot}/packages/ferris/.config/nextest.toml',
|
|
913
917
|
);
|
|
914
|
-
expect(targets['cargo-test-ferris-core']?.configurations?.production).toEqual({});
|
|
915
918
|
expect(targets['cargo-test-ferris-core']?.inputs).toEqual(
|
|
916
919
|
expect.arrayContaining([
|
|
917
920
|
'{workspaceRoot}/packages/ferris/Cargo.toml',
|
|
@@ -922,15 +925,15 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
922
925
|
expect(targets['cargo-test-ferris-core']?.inputs).not.toContain(
|
|
923
926
|
'{workspaceRoot}/packages/ferris/crates/ferris-wasm/**/*',
|
|
924
927
|
);
|
|
925
|
-
// One clippy for the workspace
|
|
926
|
-
// compiled every
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
928
|
+
// One clippy for the workspace, writing the same `target/` as the dev
|
|
929
|
+
// test compile: a directory of its own compiled every host unit twice.
|
|
930
|
+
const [fmt, clippy] = targets['cargo-lint']?.options?.commands ?? [];
|
|
931
|
+
expect(fmt).toBe('cargo fmt --all --check');
|
|
932
|
+
expect(clippy).toMatch(/^cargo --frozen clippy --workspace --all-targets .*-- -D warnings$/);
|
|
933
|
+
for (const command of [clippy, targets['cargo-test-compile']?.options?.command]) {
|
|
934
|
+
expect(command).not.toContain('--target-dir');
|
|
935
|
+
}
|
|
936
|
+
expect(targets['cargo-lint']?.options?.cwd).toBe(targets['cargo-test-compile']?.options?.cwd);
|
|
934
937
|
expect(targets['cargo-lint']?.cache).toBe(true);
|
|
935
938
|
expect(targets['cargo-lint']?.outputs).toEqual([]);
|
|
936
939
|
expect(targets['cargo-lint']?.inputs).toEqual(
|
|
@@ -965,15 +968,15 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
965
968
|
|
|
966
969
|
const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
|
|
967
970
|
|
|
968
|
-
// A clippy target dir is not an Nx output — restoring
|
|
971
|
+
// A clippy target dir is not an Nx output — restoring a multi-GiB build
|
|
969
972
|
// tree from a cache is worse than rebuilding it — so `clean` cannot find
|
|
970
973
|
// these through `outputs`. They are read back off the commands that
|
|
971
974
|
// write them, which is why a new `--target-dir` cannot be forgotten here.
|
|
975
|
+
// The workspace `target/` every dev build shares is not one of them.
|
|
972
976
|
expect(targets.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
|
|
973
977
|
expect(targets.clean?.cache).toBe(false);
|
|
974
978
|
expect(targets.clean?.options?.outputs).toEqual([
|
|
975
979
|
'{projectRoot}/dist',
|
|
976
|
-
'{workspaceRoot}/packages/ferris/target/cargo-lint',
|
|
977
980
|
'{workspaceRoot}/packages/ferris/target/cargo-lint-cross',
|
|
978
981
|
'{workspaceRoot}/packages/ferris/target/nextest',
|
|
979
982
|
]);
|
|
@@ -1118,10 +1121,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1118
1121
|
command: 'cargo --frozen test --workspace --no-run',
|
|
1119
1122
|
cwd: '.',
|
|
1120
1123
|
});
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
]);
|
|
1124
|
+
// The root owns the one workspace clippy, run where the dev build runs.
|
|
1125
|
+
expect(String(root['cargo-lint']?.options?.commands?.[1])).toContain('clippy --workspace');
|
|
1126
|
+
expect(root['cargo-lint']?.options?.cwd).toBe(root['cargo-test-compile']?.options?.cwd);
|
|
1125
1127
|
expect(root['cargo-lint']?.dependsOn).toContain('cargo-fetch');
|
|
1126
1128
|
expect(root['cargo-test']?.dependsOn).toHaveLength(5);
|
|
1127
1129
|
|
|
@@ -1149,9 +1151,16 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1149
1151
|
|
|
1150
1152
|
expect(wasm['cargo-test-runtime-wasm']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
1151
1153
|
expect(wasm['cargo-wasm']?.options).toMatchObject({ cwd: '.' });
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
)
|
|
1154
|
+
// Dev by default, in the workspace's own `target/`; only the release
|
|
1155
|
+
// configuration compiles, and binds, the release artifact.
|
|
1156
|
+
expect(wasm['cargo-wasm']?.options?.commands).toEqual([
|
|
1157
|
+
'cargo --frozen build --target wasm32-unknown-unknown -p runtime-wasm',
|
|
1158
|
+
'wasm-bindgen --target web --out-dir packages/wasm/dist-wasm/web target/wasm32-unknown-unknown/debug/runtime_wasm.wasm',
|
|
1159
|
+
]);
|
|
1160
|
+
expect(wasm['cargo-wasm']?.configurations?.[RELEASE_CONFIGURATION]?.commands).toEqual([
|
|
1161
|
+
'cargo --frozen build --release --target wasm32-unknown-unknown -p runtime-wasm',
|
|
1162
|
+
'wasm-bindgen --target web --out-dir packages/wasm/dist-wasm/web target/wasm32-unknown-unknown/release/runtime_wasm.wasm',
|
|
1163
|
+
]);
|
|
1155
1164
|
expect(wasm['cargo-wasm']?.outputs).toEqual(['{projectRoot}/dist-wasm']);
|
|
1156
1165
|
expect(wasm['cargo-wasm']?.dependsOn).toEqual([rootFetch, '^build']);
|
|
1157
1166
|
expect(wasm.build?.dependsOn).toContainEqual(rootCompile);
|
|
@@ -1181,10 +1190,11 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1181
1190
|
command:
|
|
1182
1191
|
'packages/native/node_modules/.bin/napi build --platform --no-js --dts native.napi.d.ts --manifest-path packages/native/crates/native-napi/Cargo.toml --package native-napi --package-json-path packages/native/package.json --output-dir packages/native/.cache/native-debug',
|
|
1183
1192
|
});
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1193
|
+
const platformBuild = (release: string): string =>
|
|
1194
|
+
`packages/native/node_modules/.bin/napi build${release} --platform --no-js --dts native.darwin-arm64.d.ts --target aarch64-apple-darwin --manifest-path packages/native/crates/native-napi/Cargo.toml --package native-napi --package-json-path packages/native/package.json --output-dir packages/native/dist/native/darwin-arm64`;
|
|
1195
|
+
expect(native['napi-arm64-macos']?.options).toMatchObject({ cwd: '.', command: platformBuild('') });
|
|
1196
|
+
expect(native['napi-arm64-macos']?.configurations?.[RELEASE_CONFIGURATION]).toEqual({
|
|
1197
|
+
command: platformBuild(' --release'),
|
|
1188
1198
|
});
|
|
1189
1199
|
expect(native.build?.dependsOn).toContainEqual(rootCompile);
|
|
1190
1200
|
expect(native.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
|
|
@@ -1231,13 +1241,8 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1231
1241
|
const leaf = projects.get('nested/modules/leaf')?.targets ?? {};
|
|
1232
1242
|
// Each cargo workspace root runs one clippy over all its members; the
|
|
1233
1243
|
// packages owning crates validate through that verdict.
|
|
1234
|
-
expect(outer['cargo-lint']?.options).
|
|
1235
|
-
|
|
1236
|
-
commands: [
|
|
1237
|
-
'cargo fmt --all --check',
|
|
1238
|
-
'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
|
|
1239
|
-
],
|
|
1240
|
-
});
|
|
1244
|
+
expect(outer['cargo-lint']?.options?.cwd).toBe('.');
|
|
1245
|
+
expect(String(outer['cargo-lint']?.options?.commands?.[1])).toContain('clippy --workspace');
|
|
1241
1246
|
// Workspace-anchored, because Nx hashes a `{projectRoot}` glob against
|
|
1242
1247
|
// only the files its project owns, and the group project owns alpha and
|
|
1243
1248
|
// beta: spelled from the root project, those globs hash nothing and the
|
|
@@ -1274,9 +1279,6 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1274
1279
|
{ projects: ['inner-root'], target: 'cargo-fetch' },
|
|
1275
1280
|
{ projects: ['inner-root'], target: 'cargo-test-archive' },
|
|
1276
1281
|
]);
|
|
1277
|
-
// The profile lives in the archive, so the runner's production
|
|
1278
|
-
// configuration has nothing left to say.
|
|
1279
|
-
expect(leaf['cargo-test-inner-leaf']?.configurations?.production).toEqual({});
|
|
1280
1282
|
expect(inner['cargo-test-archive']?.options?.cwd).toBe('nested');
|
|
1281
1283
|
expect(resolveDeclaredOverInferred(group, declared, 'cargo-lint')).toMatchObject({
|
|
1282
1284
|
executor: 'nx:noop',
|
|
@@ -1428,14 +1430,22 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1428
1430
|
outputs: ['{projectRoot}/generated/wasm'],
|
|
1429
1431
|
options: {
|
|
1430
1432
|
commands: [
|
|
1431
|
-
'cargo --frozen build --
|
|
1432
|
-
'wasm-bindgen --target nodejs --out-dir generated/wasm/node crates/git-do/target/
|
|
1433
|
-
'wasm-bindgen --target web --out-dir generated/wasm/web crates/git-do/target/
|
|
1433
|
+
'cargo --frozen build --target wasm32-unknown-unknown --manifest-path crates/git-do/Cargo.toml',
|
|
1434
|
+
'wasm-bindgen --target nodejs --out-dir generated/wasm/node crates/git-do/target/wasm32-unknown-unknown/debug/gitoxide_engine.wasm',
|
|
1435
|
+
'wasm-bindgen --target web --out-dir generated/wasm/web crates/git-do/target/wasm32-unknown-unknown/debug/gitoxide_engine.wasm',
|
|
1434
1436
|
],
|
|
1435
1437
|
cwd: 'packages/git-do',
|
|
1436
1438
|
parallel: false,
|
|
1437
1439
|
},
|
|
1438
1440
|
});
|
|
1441
|
+
// No workspace claims the crate, so cargo's default target dir is the one
|
|
1442
|
+
// beside its own manifest, and the release configuration reads the
|
|
1443
|
+
// release artifact from it.
|
|
1444
|
+
expect(targets['cargo-wasm']?.configurations?.[RELEASE_CONFIGURATION]?.commands).toEqual([
|
|
1445
|
+
'cargo --frozen build --release --target wasm32-unknown-unknown --manifest-path crates/git-do/Cargo.toml',
|
|
1446
|
+
'wasm-bindgen --target nodejs --out-dir generated/wasm/node crates/git-do/target/wasm32-unknown-unknown/release/gitoxide_engine.wasm',
|
|
1447
|
+
'wasm-bindgen --target web --out-dir generated/wasm/web crates/git-do/target/wasm32-unknown-unknown/release/gitoxide_engine.wasm',
|
|
1448
|
+
]);
|
|
1439
1449
|
// A wasm-bindgen crate in a nested Cargo workspace still needs its locked
|
|
1440
1450
|
// graph downloaded, and the project root is not a member of it, so the
|
|
1441
1451
|
// fetch names the crate manifest instead of relying on cwd.
|
|
@@ -1528,14 +1538,23 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1528
1538
|
options: {
|
|
1529
1539
|
cwd: 'packages/cowshed',
|
|
1530
1540
|
command:
|
|
1531
|
-
'napi build --
|
|
1541
|
+
'napi build --platform --no-js --dts cowshed.napi.d.ts --manifest-path crates/cowshed-napi/Cargo.toml --package cowshed-napi --package-json-path package.json --output-dir dist/native/host',
|
|
1542
|
+
},
|
|
1543
|
+
configurations: {
|
|
1544
|
+
[RELEASE_CONFIGURATION]: {
|
|
1545
|
+
command:
|
|
1546
|
+
'napi build --release --platform --no-js --dts cowshed.napi.d.ts --manifest-path crates/cowshed-napi/Cargo.toml --package cowshed-napi --package-json-path package.json --output-dir dist/native/host',
|
|
1547
|
+
},
|
|
1532
1548
|
},
|
|
1533
1549
|
});
|
|
1534
1550
|
expect(unservedHostTargets.build?.dependsOn).toEqual(['^build', 'cargo-test-compile', 'cargo-napi', 'tsc-js']);
|
|
1535
1551
|
expect(targets['napi-arm64-macos']?.outputs).toEqual(['{projectRoot}/dist/native/darwin-arm64']);
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1552
|
+
// Every local build compiles dev; only the release configuration ships.
|
|
1553
|
+
const darwinArm64Build = (release: string): string =>
|
|
1554
|
+
`napi build${release} --platform --no-js --dts cowshed.darwin-arm64.d.ts --target aarch64-apple-darwin --manifest-path crates/cowshed-napi/Cargo.toml --package cowshed-napi --package-json-path package.json --output-dir dist/native/darwin-arm64`;
|
|
1555
|
+
expect(targets['napi-arm64-macos']?.options).toMatchObject({ command: darwinArm64Build('') });
|
|
1556
|
+
expect(targets['napi-arm64-macos']?.configurations?.[RELEASE_CONFIGURATION]).toEqual({
|
|
1557
|
+
command: darwinArm64Build(' --release'),
|
|
1539
1558
|
});
|
|
1540
1559
|
expect(targets['napi-arm64-macos']?.options?.env).toBeUndefined();
|
|
1541
1560
|
// No cargo-test-compile edge here, on ANY host: a platform target's
|
|
@@ -1596,7 +1615,10 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1596
1615
|
expect(darwinArm64Targets['napi-arm64-linux']?.dependsOn).toEqual(['napi-toolchain-arm64-linux']);
|
|
1597
1616
|
expect(darwinArm64Targets['napi-x64-linux']?.outputs).toEqual(['{projectRoot}/dist/native/linux-x64-gnu']);
|
|
1598
1617
|
expect(darwinArm64Targets['napi-x64-linux']?.options?.command).toBe(
|
|
1599
|
-
'napi build --
|
|
1618
|
+
'napi build --platform --no-js --dts cowshed.linux-x64-gnu.d.ts --target x86_64-unknown-linux-gnu --use-napi-cross --manifest-path crates/cowshed-napi/Cargo.toml --package cowshed-napi --package-json-path package.json --output-dir dist/native/linux-x64-gnu',
|
|
1619
|
+
);
|
|
1620
|
+
expect(darwinArm64Targets['napi-x64-linux']?.configurations?.[RELEASE_CONFIGURATION]?.command).toContain(
|
|
1621
|
+
'napi build --release --platform',
|
|
1600
1622
|
);
|
|
1601
1623
|
|
|
1602
1624
|
// The whole rule, stated once per forced host: a triple gets a cross
|
|
@@ -1743,6 +1765,29 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1743
1765
|
}
|
|
1744
1766
|
});
|
|
1745
1767
|
|
|
1768
|
+
it('binds the wasm a package workspace member writes into that workspace target dir', async () => {
|
|
1769
|
+
const workspace = await createWorkspace();
|
|
1770
|
+
try {
|
|
1771
|
+
await workspace.write('packages/columine/package.json', '{"name":"columine"}\n');
|
|
1772
|
+
await workspace.write('packages/columine/Cargo.toml', '[workspace]\nmembers = ["crates/columine-wasm"]\n');
|
|
1773
|
+
await workspace.write(
|
|
1774
|
+
'packages/columine/crates/columine-wasm/Cargo.toml',
|
|
1775
|
+
'[package]\nname = "columine-wasm"\n\n[lib]\ncrate-type = ["cdylib", "rlib"]\n\n[package.metadata.smoothbricks.wasm-bindgen]\ntargets = ["web"]\n',
|
|
1776
|
+
);
|
|
1777
|
+
|
|
1778
|
+
const targets = await inferProjectTargets(workspace, 'packages/columine/package.json');
|
|
1779
|
+
|
|
1780
|
+
// Cargo writes a member's artifacts under its workspace root, not beside
|
|
1781
|
+
// the member's manifest, so the bindgen input is read from there.
|
|
1782
|
+
expect(targets['cargo-wasm']?.options?.commands).toEqual([
|
|
1783
|
+
'cargo --frozen build --target wasm32-unknown-unknown --manifest-path crates/columine-wasm/Cargo.toml',
|
|
1784
|
+
'wasm-bindgen --target web --out-dir dist-wasm/web target/wasm32-unknown-unknown/debug/columine_wasm.wasm',
|
|
1785
|
+
]);
|
|
1786
|
+
} finally {
|
|
1787
|
+
await workspace.cleanup();
|
|
1788
|
+
}
|
|
1789
|
+
});
|
|
1790
|
+
|
|
1746
1791
|
it('shards a crate around the tests nextest.toml singles out, not through them', async () => {
|
|
1747
1792
|
const workspace = await createWorkspace();
|
|
1748
1793
|
try {
|
|
@@ -1897,8 +1942,8 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1897
1942
|
const workspace = await createWorkspace();
|
|
1898
1943
|
const declared: Record<string, TargetConfiguration> = {
|
|
1899
1944
|
// One added edge per target. Everything that makes each target do its job
|
|
1900
|
-
// — executor, options, inputs, cache
|
|
1901
|
-
//
|
|
1945
|
+
// — executor, options, inputs, cache — must survive the declaration
|
|
1946
|
+
// instead of being replaced wholesale by it.
|
|
1902
1947
|
'cargo-test': { dependsOn: ['cargo-test-compile', 'cargo-wasm'] },
|
|
1903
1948
|
'cargo-test-compile': { dependsOn: ['cargo-wasm'] },
|
|
1904
1949
|
'cargo-lint': { inputs: ['{projectRoot}/clippy.toml'] },
|
|
@@ -1933,9 +1978,6 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1933
1978
|
timeoutMs: 120000,
|
|
1934
1979
|
killAfterMs: 10000,
|
|
1935
1980
|
});
|
|
1936
|
-
expect(cargoTest?.configurations).toEqual({
|
|
1937
|
-
production: { command: 'cargo --frozen test --workspace --release' },
|
|
1938
|
-
});
|
|
1939
1981
|
expect(cargoTest?.inputs).toContain('{projectRoot}/**/*.rs');
|
|
1940
1982
|
|
|
1941
1983
|
const cargoTestCompile = resolveDeclaredOverInferred(targets, declared, 'cargo-test-compile');
|
|
@@ -2244,9 +2286,8 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2244
2286
|
expect(String(archive?.options?.commands?.[1])).toMatch(
|
|
2245
2287
|
/^cargo-nextest nextest archive --workspace --target aarch64-apple-darwin --frozen --archive-file target\/nextest\/archive-aarch64-apple-darwin\.tar\.zst --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
|
|
2246
2288
|
);
|
|
2247
|
-
expect(
|
|
2248
|
-
|
|
2249
|
-
);
|
|
2289
|
+
expect(archive?.configurations?.[RELEASE_CONFIGURATION]).toBeUndefined();
|
|
2290
|
+
expect(run?.configurations?.[RELEASE_CONFIGURATION]).toBeUndefined();
|
|
2250
2291
|
// The archive BUILDS, so it needs the locked registry graph; the runner
|
|
2251
2292
|
// never touches cargo, so it needs nothing and depends on nothing.
|
|
2252
2293
|
expect(archive?.dependsOn).toEqual(['cargo-fetch']);
|