@smoothbricks/nx-plugin 0.3.10 → 0.3.12

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.
Files changed (43) hide show
  1. package/README.md +23 -2
  2. package/dist/bounded-test-policy.d.ts +26 -0
  3. package/dist/bounded-test-policy.d.ts.map +1 -1
  4. package/dist/bounded-test-policy.js +194 -0
  5. package/dist/cargo-workspace.d.ts +67 -0
  6. package/dist/cargo-workspace.d.ts.map +1 -0
  7. package/dist/cargo-workspace.js +215 -0
  8. package/dist/cross-check-policy.d.ts +60 -1
  9. package/dist/cross-check-policy.d.ts.map +1 -1
  10. package/dist/cross-check-policy.js +65 -1
  11. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  12. package/dist/executors/bounded-exec/executor.js +86 -51
  13. package/dist/executors/bounded-exec/schema.d.ts +13 -0
  14. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  15. package/dist/executors/clean-outputs/executor.js +17 -3
  16. package/dist/executors/napi-cross-toolchain/executor.d.ts.map +1 -1
  17. package/dist/executors/napi-cross-toolchain/executor.js +8 -0
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +344 -57
  21. package/dist/package-target-policy.d.ts +2 -1
  22. package/dist/package-target-policy.d.ts.map +1 -1
  23. package/dist/package-target-policy.js +54 -13
  24. package/dist/workspace-config-policy.js +32 -35
  25. package/nextest.toml +42 -0
  26. package/package.json +2 -1
  27. package/src/bounded-test-policy.test.ts +304 -0
  28. package/src/bounded-test-policy.ts +218 -0
  29. package/src/cargo-workspace.ts +243 -0
  30. package/src/cross-check-policy.test.ts +24 -0
  31. package/src/cross-check-policy.ts +80 -1
  32. package/src/executors/bounded-exec/executor.test.ts +147 -3
  33. package/src/executors/bounded-exec/executor.ts +103 -53
  34. package/src/executors/bounded-exec/schema.json +7 -2
  35. package/src/executors/bounded-exec/schema.ts +13 -0
  36. package/src/executors/clean-outputs/executor.ts +17 -3
  37. package/src/executors/napi-cross-toolchain/executor.ts +8 -0
  38. package/src/index.test.ts +373 -25
  39. package/src/index.ts +390 -65
  40. package/src/package-target-policy.test.ts +50 -0
  41. package/src/package-target-policy.ts +58 -9
  42. package/src/workspace-config-policy.test.ts +15 -30
  43. package/src/workspace-config-policy.ts +32 -39
@@ -1 +1 @@
1
- {"version":3,"file":"cross-check-policy.d.ts","sourceRoot":"","sources":["../src/cross-check-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,4FAAyF,CAAC;AAE/H,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,mFAAyG,CAAC"}
1
+ {"version":3,"file":"cross-check-policy.d.ts","sourceRoot":"","sources":["../src/cross-check-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAI1D;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,wBAAwB,QAKlC,CAAC;AAEJ,eAAO,MAAM,yBAAyB,QAGrC,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,mFAAyG,CAAC"}
@@ -34,6 +34,63 @@ export const DEVENV_CROSS_PROFILE = 'linux-cross';
34
34
  * build-output families, so no aggregate `build` picks it up either.
35
35
  */
36
36
  export const CARGO_CROSS_LINT_TARGET = 'cargo-lint-cross';
37
+ const CARGO_CROSS_LINT_GUARD = `[ -n "\${CC_x86_64_unknown_linux_gnu:-}" ] || [ "$(uname -s)" = Linux ] || { echo 'cargo-lint-cross needs the linux-cross C toolchain; run: bun run check:linux' >&2; exit 2; }`;
38
+ /**
39
+ * Point this cargo at a project-local home so parallel Nx cargos do not
40
+ * exclusive-lock `~/.cargo/.package-cache`. Downloaded crates stay shared.
41
+ */
42
+ export function withProjectCargoHome(homeRel, command) {
43
+ return `host_cargo_home="\${CARGO_HOME:-$HOME/.cargo}"; mkdir -p ${homeRel}; if [ -d "$host_cargo_home/registry" ]; then ln -sfn "$host_cargo_home/registry" ${homeRel}/registry; fi; if [ -d "$host_cargo_home/git" ]; then ln -sfn "$host_cargo_home/git" ${homeRel}/git; fi; CARGO_HOME="$PWD/${homeRel}" ${command}`;
44
+ }
45
+ /**
46
+ * The prefix `cargoFrozen` writes. Exported so target inference can recognize
47
+ * the commands whose precondition `CARGO_FETCH_TARGET` supplies without
48
+ * re-spelling the flag; a second copy would silently stop matching.
49
+ */
50
+ export const CARGO_FROZEN_PREFIX = 'cargo --frozen ';
51
+ /**
52
+ * `--frozen` is cargo's `--locked` + `--offline`. Cargo.lock and the registry
53
+ * cache are inputs: inferred cargo must not rewrite the lockfile or fetch.
54
+ * The flag sits on `cargo` so nextest sees a cargo-level option, not its own.
55
+ *
56
+ * The registry cache being an INPUT is a precondition, and offline cargo
57
+ * enforces it at RESOLUTION, before it selects a single target: an offline
58
+ * registry source only reports packages already downloaded, so one absent
59
+ * member of the lockfile's graph makes the whole workspace unresolvable with
60
+ * `no matching package named <dep> found`. The failure therefore has nothing to
61
+ * do with which targets a command builds — `build`, `check`, `test --lib` and
62
+ * `test --no-run` all fail identically on a dependency only a bench needs — and
63
+ * narrowing a command's target selection cannot cure it.
64
+ *
65
+ * Dev- and bench-only dependencies are the exposed class. A build downloads the
66
+ * normal dependency graph, so on a runner that builds before it tests those are
67
+ * warm by accident; nothing downloads a dev-dependency until something compiles
68
+ * a test target, and by then `--frozen` refuses to. `CARGO_FETCH_TARGET` below
69
+ * turns that accident into a stated dependency.
70
+ */
71
+ export function cargoFrozen(args) {
72
+ return `${CARGO_FROZEN_PREFIX}${args}`;
73
+ }
74
+ /**
75
+ * Nx target name. Downloads one Cargo workspace's locked dependency graph so
76
+ * every `cargoFrozen` command in that workspace can resolve offline. No colons,
77
+ * per the repo's target-naming rule, and outside the `-js`/`-napi`/`-wasm` and
78
+ * platform-suffix families so no aggregate sweeps it up.
79
+ */
80
+ export const CARGO_FETCH_TARGET = 'cargo-fetch';
81
+ /**
82
+ * `--locked` rather than bare `cargo fetch`: this downloads exactly the graph
83
+ * Cargo.lock pins and fails loudly on a stale lockfile. Without it a fetch could
84
+ * re-resolve and hand `--frozen` a cache built from a different graph than the
85
+ * lockfile names, which is the guarantee `--frozen` exists to give.
86
+ *
87
+ * `fetch` and nothing else, because fetching is the only act that needs the
88
+ * network; every compile downstream stays frozen.
89
+ *
90
+ * No `--target`: with no triple named cargo fetches every target's
91
+ * dependencies, so one run also covers `CARGO_CROSS_LINT_TARGET`'s Linux triple.
92
+ */
93
+ export const CARGO_FETCH_COMMAND = 'cargo fetch --locked';
37
94
  /**
38
95
  * Clippy rather than `cargo check`, and `-D warnings`, because that is exactly
39
96
  * what CI's `lint` runs; a weaker local command would pass where CI fails.
@@ -51,8 +108,15 @@ export const CARGO_CROSS_LINT_TARGET = 'cargo-lint-cross';
51
108
  *
52
109
  * `cargo fmt` is absent on purpose: formatting is target-independent and already
53
110
  * covered by `cargo-lint`, so repeating it here would only cost time.
111
+ *
112
+ * `CARGO_HOME` is per-project (`$PWD/target/cargo-lint-cross-home`). Cargo's
113
+ * package-cache flock lives in CARGO_HOME; three workspaces otherwise serialize
114
+ * on `~/.cargo/.package-cache` even with distinct `--target-dir`. Registry and
115
+ * git are linked to the host home so crates are not re-fetched. `--frozen`
116
+ * keeps that shared registry read-only: lockfile and cache are inputs.
54
117
  */
55
- export const CARGO_CROSS_LINT_COMMAND = `cargo clippy --workspace --all-targets --target ${CARGO_LINUX_TRIPLE} -- -D warnings`;
118
+ export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${withProjectCargoHome('target/cargo-lint-cross-home', cargoFrozen(`clippy --workspace --all-targets --target ${CARGO_LINUX_TRIPLE} --target-dir target/cargo-lint-cross -- -D warnings`))}`;
119
+ export const CARGO_LINT_CLIPPY_COMMAND = withProjectCargoHome('target/cargo-lint-home', cargoFrozen('clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings'));
56
120
  /** Root `package.json` script name, in the repo's `verb:qualifier` style. */
57
121
  export const CROSS_CHECK_SCRIPT_NAME = 'check:linux';
58
122
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/executor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAStD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAQD,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAsH5B;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,CAM3D"}
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/executor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAUtD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAqBD,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAuJ5B;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,CAM3D"}
@@ -1,6 +1,7 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { isAbsolute, join } from 'node:path';
3
3
  const DEFAULT_KILL_AFTER_MS = 10_000;
4
+ const REAP_AFTER_FORCE_KILL_MS = 2_000;
4
5
  const EXIT_CODE_BY_SIGNAL = {
5
6
  SIGHUP: 129,
6
7
  SIGINT: 130,
@@ -13,10 +14,11 @@ export async function runBoundedExec(options, context, killer) {
13
14
  const cwd = resolveCwd(options.cwd, context.root);
14
15
  const command = buildCommand(options);
15
16
  const timeoutMs = options.timeoutMs;
17
+ const idleTimeoutMs = options.idleTimeoutMs;
16
18
  const killAfterMs = options.killAfterMs ?? DEFAULT_KILL_AFTER_MS;
17
19
  const startedAt = Date.now();
18
20
  const outputChunks = [];
19
- const state = { settled: false, timedOut: false, forceKillNeeded: false };
21
+ const state = { settled: false, expiry: null, forceKillNeeded: false };
20
22
  const child = spawn(command, [], {
21
23
  cwd,
22
24
  env: mergeEnv(options.env),
@@ -34,8 +36,25 @@ export async function runBoundedExec(options, context, killer) {
34
36
  outputChunks.push(text);
35
37
  process.stderr.write(text);
36
38
  };
37
- child.stdout?.on('data', appendStdout);
38
- child.stderr?.on('data', appendStderr);
39
+ let idleTimer;
40
+ const armIdleTimer = () => {
41
+ if (idleTimeoutMs === undefined || state.settled || state.expiry !== null) {
42
+ return;
43
+ }
44
+ clearTimeout(idleTimer);
45
+ idleTimer = setTimeout(() => expire({ kind: 'idle', limitMs: idleTimeoutMs }), idleTimeoutMs);
46
+ };
47
+ // Only the CHILD's own output counts as progress. The diagnostics below go
48
+ // through appendStderr as well, and re-arming on those would let a teardown
49
+ // message extend the very bound that just fired.
50
+ child.stdout?.on('data', (chunk) => {
51
+ armIdleTimer();
52
+ appendStdout(chunk);
53
+ });
54
+ child.stderr?.on('data', (chunk) => {
55
+ armIdleTimer();
56
+ appendStderr(chunk);
57
+ });
39
58
  const killChildTree = async (force) => {
40
59
  const pid = child.pid;
41
60
  if (!pid) {
@@ -63,55 +82,67 @@ export async function runBoundedExec(options, context, killer) {
63
82
  process.on('SIGINT', onSigint);
64
83
  process.on('SIGTERM', onSigterm);
65
84
  process.on('SIGHUP', onSighup);
66
- let timeout;
67
- const timeoutPromise = new Promise((resolve) => {
68
- timeout = setTimeout(() => {
69
- state.timedOut = true;
70
- const elapsedMs = Date.now() - startedAt;
71
- appendStderr(`\nCommand timed out after ${elapsedMs}ms (timeoutMs=${timeoutMs}, cwd=${cwd}): ${command}\n`);
72
- void (async () => {
73
- await ignoreKillError(killChildTree(false));
74
- if (!state.settled && killAfterMs > 0) {
75
- await delay(killAfterMs);
76
- }
77
- if (!state.settled) {
78
- state.forceKillNeeded = true;
79
- appendStderr(`Force-killing timed out command after killAfterMs=${killAfterMs}: ${command}\n`);
80
- await ignoreKillError(killChildTree(true));
81
- }
82
- resolve();
83
- })();
84
- }, timeoutMs);
85
- });
85
+ // `Promise.withResolvers` would read better here but needs lib es2024; this
86
+ // package inherits lib es2022 from tsconfig.base.json.
87
+ let resolveExit;
86
88
  const exitPromise = new Promise((resolve) => {
89
+ resolveExit = resolve;
87
90
  child.once('error', (error) => {
88
91
  appendStderr(`${error.message}\n`);
92
+ state.settled = true;
89
93
  resolve({ code: 1, signal: null });
90
94
  });
91
95
  child.once('exit', (code, signal) => {
96
+ state.settled = true;
92
97
  resolve({ code, signal });
93
98
  });
94
99
  });
95
- const exit = await exitPromise;
96
- const exitedGracefullyAfterTimeout = state.timedOut && exit.code === 0 && exit.signal === null;
97
- state.settled = !state.timedOut || exitedGracefullyAfterTimeout;
98
- if (timeout) {
99
- clearTimeout(timeout);
100
- }
100
+ // Both bounds escalate through one path, so a run expires at most once and
101
+ // the report always names which bound did it. A bare "timed out" would leave
102
+ // the reader unable to tell a wedged toolchain from a loaded machine — the
103
+ // two have opposite fixes.
104
+ const expire = (bound) => {
105
+ if (state.settled || state.expiry !== null) {
106
+ return;
107
+ }
108
+ state.expiry = bound;
109
+ clearTimeout(totalTimer);
110
+ clearTimeout(idleTimer);
111
+ const elapsedMs = Date.now() - startedAt;
112
+ appendStderr(bound.kind === 'idle'
113
+ ? `\nCommand made no progress: no output for ${bound.limitMs}ms (idleTimeoutMs=${bound.limitMs}) after ${elapsedMs}ms of runtime (cwd=${cwd}): ${command}\n`
114
+ : `\nCommand timed out after ${elapsedMs}ms (timeoutMs=${bound.limitMs}, cwd=${cwd}): ${command}\n`);
115
+ void (async () => {
116
+ await ignoreKillError(killChildTree(false));
117
+ if (!state.settled && killAfterMs > 0) {
118
+ await delay(killAfterMs);
119
+ }
120
+ if (!state.settled) {
121
+ state.forceKillNeeded = true;
122
+ appendStderr(`Force-killing timed out command after killAfterMs=${killAfterMs}: ${command}\n`);
123
+ await ignoreKillError(killChildTree(true));
124
+ await delay(REAP_AFTER_FORCE_KILL_MS);
125
+ }
126
+ if (!state.settled) {
127
+ resolveExit({ code: 1, signal: 'SIGKILL' });
128
+ }
129
+ })();
130
+ };
131
+ const totalTimer = setTimeout(() => expire({ kind: 'total', limitMs: timeoutMs }), timeoutMs);
132
+ armIdleTimer();
133
+ const { code: exitCode, signal: exitSignal } = await exitPromise;
134
+ clearTimeout(totalTimer);
135
+ clearTimeout(idleTimer);
101
136
  removeSignalHandlers();
102
- if (state.timedOut) {
103
- await timeoutPromise;
104
- state.settled = true;
105
- }
106
- const code = exit.code ?? signalToExitCode(exit.signal);
107
- if (code !== 0 && !state.timedOut) {
137
+ const code = exitCode ?? signalToExitCode(exitSignal);
138
+ if (code !== 0 && state.expiry === null) {
108
139
  appendStderr(`Command exited with status ${code}: ${command}\n`);
109
140
  }
110
- if (state.timedOut && !state.forceKillNeeded) {
141
+ if (state.expiry !== null && !state.forceKillNeeded) {
111
142
  appendStderr(`Timed out command exited after graceful termination: ${command}\n`);
112
143
  }
113
144
  return {
114
- success: !state.timedOut && code === 0,
145
+ success: state.expiry === null && code === 0,
115
146
  terminalOutput: outputChunks.join(''),
116
147
  };
117
148
  }
@@ -123,20 +154,24 @@ export function createProcessTreeKiller() {
123
154
  };
124
155
  }
125
156
  function killProcessGroup(pid, signal) {
126
- return new Promise((resolve) => {
127
- try {
128
- // Send signal to the entire process group (negative PID).
129
- // The executor spawns with detached: true on POSIX, which creates a
130
- // dedicated process group. Signaling -pid is atomic and catches all
131
- // descendants, including grandchildren that tree-walk libraries miss
132
- // when parents die and children get reparented to init.
133
- process.kill(-pid, signal);
134
- }
135
- catch {
136
- // ESRCH: process group already exited between timeout and kill.
137
- }
138
- resolve();
139
- });
157
+ try {
158
+ // Send signal to the entire process group (negative PID).
159
+ // The executor spawns with detached: true on POSIX, which creates a
160
+ // dedicated process group. Signaling -pid is atomic and catches all
161
+ // descendants, including grandchildren that tree-walk libraries miss
162
+ // when parents die and children get reparented to init.
163
+ process.kill(-pid, signal);
164
+ }
165
+ catch {
166
+ // ESRCH: process group already exited, or this pid is not a group leader.
167
+ }
168
+ try {
169
+ process.kill(pid, signal);
170
+ }
171
+ catch {
172
+ // Already reaped.
173
+ }
174
+ return Promise.resolve();
140
175
  }
141
176
  function resolveCwd(cwd, root) {
142
177
  if (!cwd) {
@@ -3,6 +3,19 @@ export interface BoundedExecOptions {
3
3
  cwd?: string;
4
4
  env?: Record<string, string>;
5
5
  timeoutMs: number;
6
+ /**
7
+ * Kill the process tree when it has produced no stdout or stderr for this
8
+ * long. Absent means no progress bound.
9
+ *
10
+ * This is the bound that catches a hang. A wedged process — a flock deadlock
11
+ * between two cargo writers, a transformer waiting on a lock nobody will
12
+ * release, a runner that ignores its own per-test timeout — emits nothing at
13
+ * all, so silence is the signal. Unlike `timeoutMs` it does not scale with
14
+ * machine speed or load: a machine ten times slower still prints progress,
15
+ * just further apart, and each gap is bounded by the slowest single unit of
16
+ * work rather than by the total.
17
+ */
18
+ idleTimeoutMs?: number;
6
19
  killAfterMs?: number;
7
20
  forwardAllArgs?: boolean;
8
21
  args?: string | string[];
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB"}
@@ -1,4 +1,4 @@
1
- import { execFileSync } from 'node:child_process';
1
+ import { spawnSync } from 'node:child_process';
2
2
  import { rm } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  export default async function cleanOutputsExecutor(options, context) {
@@ -60,9 +60,23 @@ function isWithin(candidate, parent) {
60
60
  }
61
61
  function containsTrackedFiles(outputDir, workspaceRoot) {
62
62
  const relativeOutputDir = path.relative(workspaceRoot, outputDir);
63
- const trackedFiles = execFileSync('git', ['ls-files', '--', relativeOutputDir], {
63
+ const result = spawnSync('git', ['ls-files', '--', relativeOutputDir], {
64
64
  cwd: workspaceRoot,
65
65
  encoding: 'utf8',
66
66
  });
67
- return trackedFiles.trim().length > 0;
67
+ const command = `git ls-files -- ${relativeOutputDir}`;
68
+ if (typeof result.stdout === 'string' && result.stdout.length > 0) {
69
+ process.stdout.write(result.stdout);
70
+ }
71
+ if (typeof result.stderr === 'string' && result.stderr.length > 0) {
72
+ process.stderr.write(result.stderr);
73
+ }
74
+ if (result.error) {
75
+ console.error(result.error.message);
76
+ throw new Error(`${command} failed with exit code ${result.status ?? 1}`, { cause: result.error });
77
+ }
78
+ if (result.status !== 0) {
79
+ throw new Error(`${command} failed with exit code ${result.status ?? 1}`);
80
+ }
81
+ return result.stdout.trim().length > 0;
68
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/napi-cross-toolchain/executor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE;QACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC7C,CAAC;CACH;AAaD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAExE,wBAA8B,0BAA0B,CACtD,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAe/B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,cAAc,CAiEjB"}
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/napi-cross-toolchain/executor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE;QACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC7C,CAAC;CACH;AAaD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAExE,wBAA8B,0BAA0B,CACtD,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAe/B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,cAAc,CAyEjB"}
@@ -84,6 +84,7 @@ export function prewarmCrossToolchain(options) {
84
84
  }
85
85
  mkdirSync(path.dirname(destination), { recursive: true });
86
86
  const staging = mkdtempSync(`${destination}.staging-`);
87
+ const command = `tar -xJf ${tarball} -C ${staging}`;
87
88
  try {
88
89
  execFileSync('tar', ['-xJf', tarball, '-C', staging], { stdio: 'inherit' });
89
90
  if (!existsSync(path.join(staging, 'package.json'))) {
@@ -97,6 +98,13 @@ export function prewarmCrossToolchain(options) {
97
98
  if ((code === 'ENOTEMPTY' || code === 'EEXIST') && existsSync(marker)) {
98
99
  return 'ready';
99
100
  }
101
+ const status = error instanceof Error && 'status' in error ? error.status : undefined;
102
+ if (status !== undefined) {
103
+ if (error instanceof Error) {
104
+ console.error(error.message);
105
+ }
106
+ throw new Error(`${command} failed with exit code ${typeof status === 'number' ? status : 1}`, { cause: error });
107
+ }
100
108
  throw error;
101
109
  }
102
110
  return 'extracted';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { type CreateNodesV2 } from 'nx/src/devkit-exports.js';
2
+ import { CARGO_TEST_COMPILE_TARGET } from './cargo-workspace.js';
3
+ export { CARGO_TEST_COMPILE_TARGET };
2
4
  export declare function hostPlatformTargetNames(targetNames: Iterable<string>): string[];
3
5
  interface NapiTargetConvention {
4
6
  architecture: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AA2BlC,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAU/E;AAyBD,UAAU,oBAAoB;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC;IAChC,YAAY,EAAE,OAAO,CAAC;CACvB;AA+BD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AA2CD,eAAO,MAAM,aAAa,EAAE,aA4B3B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EACL,yBAAyB,EAQ1B,MAAM,sBAAsB,CAAC;AAY9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAsBrC,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAU/E;AAyBD,UAAU,oBAAoB;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC;IAChC,YAAY,EAAE,OAAO,CAAC;CACvB;AA+BD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AAkKD,eAAO,MAAM,aAAa,EAAE,aA4B3B,CAAC"}