@smoothbricks/nx-plugin 0.7.17 → 0.7.19
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 +315 -114
- package/dist/.build-inputs.json +47 -38
- package/dist/built-output-packages.js +1 -1
- package/dist/bun-lock-scope.d.ts +128 -20
- package/dist/bun-lock-scope.d.ts.map +1 -1
- package/dist/bun-lock-scope.js +267 -44
- package/dist/cargo-closure-input.d.ts +8 -6
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +15 -12
- package/dist/cargo-source-hash.d.ts +26 -25
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +84 -105
- package/dist/cargo-toolchain-paths.d.ts +2 -2
- package/dist/cargo-toolchain-paths.js +2 -2
- package/dist/cargo-workspace.d.ts +20 -2
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +43 -22
- package/dist/ensure-built-receipt.d.ts +3 -2
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +3 -2
- package/dist/eslint-config-closure.d.ts +8 -3
- package/dist/eslint-config-closure.d.ts.map +1 -1
- package/dist/eslint-config-closure.js +24 -5
- package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
- package/dist/executors/bounded-exec/admission-queue.js +9 -10
- package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
- package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
- package/dist/executors/bounded-exec/awake-clock.js +22 -0
- package/dist/executors/bounded-exec/bounds.d.ts +19 -6
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +22 -15
- package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
- package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
- package/dist/executors/bounded-exec/case-gate.js +342 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
- package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +102 -16
- package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
- package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-rise.js +111 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
- package/dist/executors/bounded-exec/endpoint-life.js +228 -0
- package/dist/executors/bounded-exec/executor.d.ts +1 -1
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +256 -86
- package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +8 -1
- package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
- package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
- package/dist/executors/bounded-exec/go-run-summary.js +98 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
- package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
- package/dist/executors/bounded-exec/lease-wait.js +1 -0
- package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +45 -8
- package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
- package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
- package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
- package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
- package/dist/executors/bounded-exec/parent-grant.js +1 -0
- package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
- package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
- package/dist/executors/bounded-exec/pool-admission.js +47 -1
- package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
- package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress-channel.js +113 -0
- package/dist/executors/bounded-exec/progress.d.ts +5 -1
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +31 -1
- package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +123 -16
- package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
- package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
- package/dist/executors/bounded-exec/reservation-connection.js +248 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
- package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +13 -9
- package/dist/executors/bounded-exec/schema.d.ts +7 -2
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/schema.js +17 -1
- package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
- package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
- package/dist/executors/bounded-exec/suite-minimum.js +85 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-result-writer.js +1 -0
- package/dist/executors/bounded-exec/test-results.d.ts +5 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-results.js +2 -2
- package/dist/executors/bounded-exec/verdict.d.ts +39 -10
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +60 -14
- package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +32 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +294 -152
- package/dist/managed-files/ci-workflow.d.ts +4 -1
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +9 -14
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.js +3 -3
- package/dist/managed-files/generator.d.ts +5 -1
- package/dist/managed-files/generator.d.ts.map +1 -1
- package/dist/managed-files/generator.js +22 -7
- package/dist/managed-files/render-memo.d.ts +13 -0
- package/dist/managed-files/render-memo.d.ts.map +1 -0
- package/dist/managed-files/render-memo.js +94 -0
- package/dist/task-results.js +2 -1
- package/dist/test-program.d.ts +11 -6
- package/dist/test-program.d.ts.map +1 -1
- package/dist/test-program.js +39 -35
- package/dist/tool-bins.d.ts +12 -0
- package/dist/tool-bins.d.ts.map +1 -1
- package/dist/tool-bins.js +31 -6
- package/dist/typecheck-test-policy.d.ts +10 -1
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +40 -24
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +135 -42
- package/dist/workspace-index.d.ts +14 -1
- package/dist/workspace-index.d.ts.map +1 -1
- package/dist/workspace-index.js +36 -4
- package/executors.json +2 -0
- package/managed/raw/envrc +24 -0
- package/managed/raw/patches/nx@24.0.3.patch +1851 -221
- package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
- package/managed/raw/tooling/direnv/developer-links.ts +122 -14
- package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
- package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
- package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
- package/package.json +68 -11
- package/runtime/nx-publish/.build-inputs.json +2 -2
- package/runtime/nx-publish/cache_adapter.js +293 -3
- package/runtime/nx-publish/nx_publish.js +36 -14
- package/src/built-output-packages.ts +1 -1
- package/src/bun-lock-scope.ts +293 -40
- package/src/cargo-closure-input.ts +20 -12
- package/src/cargo-source-hash.ts +119 -145
- package/src/cargo-toolchain-paths.ts +2 -2
- package/src/cargo-workspace.ts +59 -21
- package/src/ensure-built-receipt.ts +3 -2
- package/src/eslint-config-closure.ts +27 -6
- package/src/executors/bounded-exec/admission-queue.ts +11 -10
- package/src/executors/bounded-exec/awake-clock.ts +20 -0
- package/src/executors/bounded-exec/bounds.ts +41 -19
- package/src/executors/bounded-exec/case-gate.ts +365 -0
- package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
- package/src/executors/bounded-exec/cpu-pool.ts +139 -12
- package/src/executors/bounded-exec/cpu-rise.ts +156 -0
- package/src/executors/bounded-exec/endpoint-life.ts +279 -0
- package/src/executors/bounded-exec/executor.ts +341 -123
- package/src/executors/bounded-exec/gateway-lease.ts +6 -0
- package/src/executors/bounded-exec/go-run-summary.ts +137 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
- package/src/executors/bounded-exec/lease-wait.ts +1 -0
- package/src/executors/bounded-exec/mbx-pool.ts +57 -9
- package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
- package/src/executors/bounded-exec/parent-grant.ts +3 -0
- package/src/executors/bounded-exec/pool-admission.ts +59 -2
- package/src/executors/bounded-exec/progress-channel.ts +129 -0
- package/src/executors/bounded-exec/progress.ts +39 -3
- package/src/executors/bounded-exec/ram-temp.ts +137 -17
- package/src/executors/bounded-exec/reservation-connection.ts +221 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
- package/src/executors/bounded-exec/runner-sizing.ts +13 -8
- package/src/executors/bounded-exec/schema.json +1 -1
- package/src/executors/bounded-exec/schema.ts +21 -2
- package/src/executors/bounded-exec/suite-minimum.ts +81 -0
- package/src/executors/bounded-exec/test-result-writer.ts +3 -0
- package/src/executors/bounded-exec/test-results.ts +5 -0
- package/src/executors/bounded-exec/verdict.ts +83 -22
- package/src/executors/cargo-zigbuild/executor.ts +30 -19
- package/src/index.ts +357 -166
- package/src/managed-files/ci-workflow.ts +13 -17
- package/src/managed-files/files.ts +3 -3
- package/src/managed-files/generator.ts +21 -6
- package/src/managed-files/render-memo.ts +135 -0
- package/src/test-program.ts +36 -41
- package/src/tool-bins.ts +35 -6
- package/src/typecheck-test-policy.ts +49 -24
- package/src/workspace-config-policy.ts +161 -43
- package/src/workspace-index.ts +40 -5
- package/test-timings.json +157 -141
- package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
package/src/index.ts
CHANGED
|
@@ -26,7 +26,22 @@ import { parse as parseToml } from 'smol-toml';
|
|
|
26
26
|
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
|
|
27
27
|
import { refuseOverlappingOutputs } from './build-state-output-policy.js';
|
|
28
28
|
import { builtOutputLockfileDependencies, builtOutputLockfileNodes } from './built-output-packages.js';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
BUN_LOCK_SCOPE_NAMED_INPUT,
|
|
31
|
+
bunLoadInput,
|
|
32
|
+
bunLoadScopes,
|
|
33
|
+
bunLockDependencies,
|
|
34
|
+
bunLockInput,
|
|
35
|
+
bunLockNode,
|
|
36
|
+
bunLockRuntimeNode,
|
|
37
|
+
bunScopeInput,
|
|
38
|
+
bunVersionAliasDependencies,
|
|
39
|
+
manifestsAbove,
|
|
40
|
+
type PackageLoad,
|
|
41
|
+
refuseUndeclaredImports,
|
|
42
|
+
specifierPackage,
|
|
43
|
+
typescriptLoads,
|
|
44
|
+
} from './bun-lock-scope.js';
|
|
30
45
|
import {
|
|
31
46
|
CARGO_CLOSURE_INPUT,
|
|
32
47
|
CARGO_LOCK_NODE_PREFIX,
|
|
@@ -34,7 +49,7 @@ import {
|
|
|
34
49
|
cargoClosureInputs,
|
|
35
50
|
cargoLockNode,
|
|
36
51
|
cargoLockNodeName,
|
|
37
|
-
|
|
52
|
+
indexedCargoSources,
|
|
38
53
|
isCargoLockInput,
|
|
39
54
|
resolveCargoClosureSource,
|
|
40
55
|
} from './cargo-closure-input.js';
|
|
@@ -49,6 +64,7 @@ import {
|
|
|
49
64
|
type CargoCrossTestTarget,
|
|
50
65
|
type CargoInputsCache,
|
|
51
66
|
cargoPackageTestInputs,
|
|
67
|
+
cargoProducerOutputInputs,
|
|
52
68
|
cargoTestGroupTargetName,
|
|
53
69
|
cargoTestPackageTargetName,
|
|
54
70
|
createCargoInputsCache,
|
|
@@ -85,8 +101,10 @@ import {
|
|
|
85
101
|
type AllVerdictsOptions,
|
|
86
102
|
ESLINT_SOURCES_TOKEN,
|
|
87
103
|
} from './executors/all-verdicts/schema.js';
|
|
104
|
+
import { runsAsCargoLeaf } from './executors/bounded-exec/mbx-pool.js';
|
|
88
105
|
import { closeRunReservations, serveRunReservations } from './executors/bounded-exec/mbx-reservations.js';
|
|
89
106
|
import { closeRunCpuPool, serveRunCpuPool } from './executors/bounded-exec/run-cpu-pool.js';
|
|
107
|
+
import { boundedCommand } from './executors/bounded-exec/schema.js';
|
|
90
108
|
import { ffiPathProblem } from './executors/scriptc-native/ffi-paths.js';
|
|
91
109
|
import type { ScriptcNativeFfi } from './executors/scriptc-native/schema.js';
|
|
92
110
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
@@ -106,7 +124,13 @@ import {
|
|
|
106
124
|
timingsSuiteInputs,
|
|
107
125
|
} from './test-timings.js';
|
|
108
126
|
import { assertUpstreamBasePrecondition } from './test-walk-policy.js';
|
|
109
|
-
import {
|
|
127
|
+
import {
|
|
128
|
+
type NativeTools,
|
|
129
|
+
nativeToolCommand,
|
|
130
|
+
nativeToolDependsOn,
|
|
131
|
+
pluginBuildDependsOn,
|
|
132
|
+
resolveNativeTools,
|
|
133
|
+
} from './tool-bins.js';
|
|
110
134
|
import { typecheckRoute } from './typecheck-route.js';
|
|
111
135
|
import {
|
|
112
136
|
isBuildOutputTargetName,
|
|
@@ -145,6 +169,13 @@ const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
|
|
|
145
169
|
*/
|
|
146
170
|
const TYPECHECK_COMPILER_ENV = 'SMOO_TYPECHECK_TSC';
|
|
147
171
|
const TYPECHECK_COMPILER_INPUT = { env: TYPECHECK_COMPILER_ENV };
|
|
172
|
+
/**
|
|
173
|
+
* The named input a project defines as the compiler identity of its inferred `typecheck`: {@link TYPECHECK_COMPILER_INPUT}
|
|
174
|
+
* where that target runs the native compiler, undefined where it runs ttsc, whose compiler the workspace keys, or where
|
|
175
|
+
* a declared `typecheck` replaces the inferred command. A workspace `typecheck` default that replaces the inferred
|
|
176
|
+
* inputs names it to key exactly the compiler its command runs, and defines it empty in `nx.json` for the rest.
|
|
177
|
+
*/
|
|
178
|
+
const TYPECHECK_COMPILER_NAMED_INPUT = 'typecheckCompiler';
|
|
148
179
|
function typecheckCommand(args: string): string {
|
|
149
180
|
return `"\${${TYPECHECK_COMPILER_ENV}:?is unset, enter the devenv shell (devenv.smoo.nix builds the typecheck compiler)}" ${args}`;
|
|
150
181
|
}
|
|
@@ -231,13 +262,46 @@ const NODE_MODULES_SEGMENT = /(?:^|\/)node_modules(?:\/|$)/;
|
|
|
231
262
|
* which is the silence above. The ancestors this cannot name as a fileset are
|
|
232
263
|
* the two kinds Nx has no fileset for; see {@link configChainInput}.
|
|
233
264
|
*/
|
|
234
|
-
function typescriptConfigChainInputs(configPaths: readonly string[], workspaceRoot: string):
|
|
235
|
-
const
|
|
265
|
+
function typescriptConfigChainInputs(configPaths: readonly string[], workspaceRoot: string): TypescriptConfigChain {
|
|
266
|
+
const chain: TypescriptConfigChainParts = {
|
|
267
|
+
inputs: new Set([WORKSPACE_TSCONFIG_BASE_INPUT]),
|
|
268
|
+
extendsLoads: [],
|
|
269
|
+
transformLoads: [],
|
|
270
|
+
};
|
|
236
271
|
const walked = new Set<string>();
|
|
237
272
|
for (const configPath of configPaths) {
|
|
238
|
-
addTypescriptConfigAncestors(configPath, workspaceRoot,
|
|
273
|
+
addTypescriptConfigAncestors(configPath, workspaceRoot, chain, walked);
|
|
274
|
+
}
|
|
275
|
+
return { inputs: [...chain.inputs], extendsLoads: chain.extendsLoads, transformLoads: chain.transformLoads };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** What a project's TypeScript configs make its tasks read: the config files, and the packages they load by name. */
|
|
279
|
+
interface TypescriptConfigChain {
|
|
280
|
+
/** Every workspace config of the chains, as an input. */
|
|
281
|
+
readonly inputs: string[];
|
|
282
|
+
/** Each installed config the chains extend, by the package holding it and the directory of the config naming it. */
|
|
283
|
+
readonly extendsLoads: readonly PackageLoad[];
|
|
284
|
+
/** Each transform plugin a workspace config of the chains names (`compilerOptions.plugins[].transform`), which ttsc loads. */
|
|
285
|
+
readonly transformLoads: readonly PackageLoad[];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
interface TypescriptConfigChainParts {
|
|
289
|
+
readonly inputs: Set<string>;
|
|
290
|
+
readonly extendsLoads: PackageLoad[];
|
|
291
|
+
readonly transformLoads: PackageLoad[];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** The bare transform plugin specifiers one config names (`compilerOptions.plugins[].transform`). */
|
|
295
|
+
function typescriptTransforms(configPath: string): string[] {
|
|
296
|
+
const config: unknown = readJsonFile(configPath, { expectComments: true });
|
|
297
|
+
if (!isRecord(config) || !isRecord(config.compilerOptions) || !Array.isArray(config.compilerOptions.plugins)) {
|
|
298
|
+
return [];
|
|
239
299
|
}
|
|
240
|
-
return
|
|
300
|
+
return config.compilerOptions.plugins.flatMap((plugin: unknown) =>
|
|
301
|
+
isRecord(plugin) && typeof plugin.transform === 'string' && /^[@\w]/u.test(plugin.transform)
|
|
302
|
+
? [plugin.transform]
|
|
303
|
+
: [],
|
|
304
|
+
);
|
|
241
305
|
}
|
|
242
306
|
|
|
243
307
|
/**
|
|
@@ -245,24 +309,32 @@ function typescriptConfigChainInputs(configPaths: readonly string[], workspaceRo
|
|
|
245
309
|
* `extends` cycle.
|
|
246
310
|
*
|
|
247
311
|
* The walk stops at an ancestor Nx cannot hash, because everything reachable
|
|
248
|
-
* from an installed config is installed too: the
|
|
249
|
-
*
|
|
250
|
-
*
|
|
312
|
+
* from an installed config is installed too: the package holding it is
|
|
313
|
+
* recorded as a load of the extending config's directory, and the lock scope
|
|
314
|
+
* that declares it there keys that whole subtree. Parsing it could only
|
|
315
|
+
* invent failures for a dependency's own chain.
|
|
251
316
|
*/
|
|
252
317
|
function addTypescriptConfigAncestors(
|
|
253
318
|
configPath: string,
|
|
254
319
|
workspaceRoot: string,
|
|
255
|
-
|
|
320
|
+
chain: TypescriptConfigChainParts,
|
|
256
321
|
walked: Set<string>,
|
|
257
322
|
): void {
|
|
258
323
|
if (walked.has(configPath)) return;
|
|
259
324
|
walked.add(configPath);
|
|
325
|
+
const directory = relative(workspaceRoot, dirname(configPath)).replaceAll('\\', '/') || '.';
|
|
326
|
+
for (const transform of typescriptTransforms(configPath)) {
|
|
327
|
+
chain.transformLoads.push({ directory, name: specifierPackage(transform) });
|
|
328
|
+
}
|
|
260
329
|
for (const specifier of typescriptConfigExtends(configPath)) {
|
|
261
330
|
const ancestor = resolveTypescriptConfigExtends(specifier, configPath);
|
|
262
331
|
const input = configChainInput(ancestor, configPath, workspaceRoot);
|
|
263
|
-
if (input === null)
|
|
264
|
-
|
|
265
|
-
|
|
332
|
+
if (input === null) {
|
|
333
|
+
if (ancestor.installed) chain.extendsLoads.push({ directory, name: specifierPackage(specifier) });
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
chain.inputs.add(input);
|
|
337
|
+
addTypescriptConfigAncestors(ancestor.path, workspaceRoot, chain, walked);
|
|
266
338
|
}
|
|
267
339
|
}
|
|
268
340
|
|
|
@@ -426,6 +498,8 @@ interface EslintWorkspace {
|
|
|
426
498
|
readonly sources: ReadonlySet<string>;
|
|
427
499
|
/** The workspace modules the root configs load, transitively, workspace-relative and sorted; the configs excluded. */
|
|
428
500
|
readonly configImports: readonly string[];
|
|
501
|
+
/** The lock scopes of the installed packages those modules load by name, each where its module loads it; sorted. */
|
|
502
|
+
readonly configScopes: readonly string[];
|
|
429
503
|
}
|
|
430
504
|
|
|
431
505
|
/**
|
|
@@ -445,15 +519,18 @@ interface EslintWorkspace {
|
|
|
445
519
|
* The configs key every lint target with exactly the workspace files they
|
|
446
520
|
* load (eslint-config-closure.ts): a glob over the directory holding a
|
|
447
521
|
* config's rule modules keyed every file beside them, and one test fixture
|
|
448
|
-
* there re-keyed 44 lint targets in one land.
|
|
522
|
+
* there re-keyed 44 lint targets in one land. The packages they load by name
|
|
523
|
+
* key it by the lock scope declaring each where it loads (bun-lock-scope.ts).
|
|
449
524
|
*/
|
|
450
525
|
async function eslintWorkspace(workspaceRoot: string): Promise<EslintWorkspace | null> {
|
|
451
526
|
const configs = ESLINT_CONFIG_FILES.filter((name) => existsSync(join(workspaceRoot, name)));
|
|
452
527
|
if (configs.length === 0) return null;
|
|
453
528
|
const indexed = new Set(await globIndexedFiles(workspaceRoot, [ESLINT_SOURCES_GLOB, '**/*.json']));
|
|
529
|
+
const closure = eslintConfigClosure(workspaceRoot, configs, indexed);
|
|
454
530
|
return {
|
|
455
531
|
sources: new Set([...indexed].filter((path) => !path.endsWith('.json'))),
|
|
456
|
-
configImports:
|
|
532
|
+
configImports: closure.files,
|
|
533
|
+
configScopes: bunLoadScopes(workspaceRoot, closure.packageLoads),
|
|
457
534
|
};
|
|
458
535
|
}
|
|
459
536
|
|
|
@@ -851,18 +928,21 @@ function createCargoWasmTarget(
|
|
|
851
928
|
* create its parent, so the build consumes what the `mkdir` produced. Outside
|
|
852
929
|
* Nx there is no task hash, and a build no task names is refused here rather
|
|
853
930
|
* than by every runner.
|
|
931
|
+
*
|
|
932
|
+
* `inputs` is the workspace's Cargo union; the build also runs the nextest helper (`record`).
|
|
854
933
|
*/
|
|
855
934
|
function createCargoTestBuildTarget(
|
|
856
935
|
projectRoot: string,
|
|
857
936
|
toolConfig: string,
|
|
858
937
|
nativeTools: NativeTools | null,
|
|
938
|
+
inputs: NonNullable<TargetConfiguration['inputs']>,
|
|
859
939
|
): TargetConfiguration {
|
|
860
|
-
const helper = nativeToolCommand(nativeTools, projectRoot, 'nextest-extract',
|
|
940
|
+
const helper = nativeToolCommand(nativeTools, projectRoot, 'nextest-extract', NEXTEST_HELPER_BIN);
|
|
861
941
|
return {
|
|
862
942
|
executor: 'nx:run-commands',
|
|
863
943
|
metadata: CARGO_PRODUCER_METADATA,
|
|
864
944
|
cache: true,
|
|
865
|
-
inputs:
|
|
945
|
+
inputs: [...inputs, ...nextestHelperInputs(nativeTools)],
|
|
866
946
|
outputs: [
|
|
867
947
|
`{projectRoot}/${NEXTEST_BINARIES_METADATA}`,
|
|
868
948
|
`{projectRoot}/${NEXTEST_CARGO_METADATA}`,
|
|
@@ -892,6 +972,33 @@ function nextestBinariesBuild(toolConfig: string): string {
|
|
|
892
972
|
return cargoFrozen(`${NEXTEST_BINARIES_BUILD_ARGS.join(' ')} ${toolConfig}`);
|
|
893
973
|
}
|
|
894
974
|
|
|
975
|
+
/** The nextest helper the test build and every runner run (`record`, `ensure`, `target-dir`). */
|
|
976
|
+
const NEXTEST_HELPER_BIN = 'smoo-nx-nextest-binaries';
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* The helper's bytes, for a target that runs it, where this workspace builds it: the producer edge orders the build and
|
|
980
|
+
* this input keys what the target runs. An installed helper is its package's, keyed as the package.
|
|
981
|
+
*/
|
|
982
|
+
function nextestHelperInputs(
|
|
983
|
+
nativeTools: NativeTools | null,
|
|
984
|
+
): { dependentTasksOutputFiles: string; transitive: false }[] {
|
|
985
|
+
return nativeTools !== null && nativeToolDependsOn(nativeTools, 'nextest-extract').length > 0
|
|
986
|
+
? [{ dependentTasksOutputFiles: `**/dist/bin/${nativeTools.platform}/${NEXTEST_HELPER_BIN}`, transitive: false }]
|
|
987
|
+
: [];
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* The record writer's bytes, for a target that runs it after its build, where this workspace builds it: the writer
|
|
992
|
+
* decides the `.build-inputs.json` the target's outputs hold, so a change to what a record states re-keys the target
|
|
993
|
+
* and no cache hit restores a record in the old form. An installed writer is its package's, keyed as the package.
|
|
994
|
+
*/
|
|
995
|
+
function buildInputsToolInputs(
|
|
996
|
+
nativeTools: NativeTools | null,
|
|
997
|
+
): { dependentTasksOutputFiles: string; transitive: false }[] {
|
|
998
|
+
return nativeTools !== null && nativeToolDependsOn(nativeTools, 'build-inputs').length > 0
|
|
999
|
+
? [{ dependentTasksOutputFiles: `**/dist/bin/${nativeTools.platform}/smoo-nx-build-inputs`, transitive: false }]
|
|
1000
|
+
: [];
|
|
1001
|
+
}
|
|
895
1002
|
/**
|
|
896
1003
|
* One foreign triple's test archive, and the target that EXECUTES it.
|
|
897
1004
|
*
|
|
@@ -1306,12 +1413,14 @@ export const postTasksExecution: PostTasksExecution<ProducerReceiptsOptions> = a
|
|
|
1306
1413
|
export const createDependencies: CreateDependencies = (options, context) => [
|
|
1307
1414
|
...bunLockDependencies(context),
|
|
1308
1415
|
...builtOutputLockfileDependencies(options, context),
|
|
1416
|
+
...bunVersionAliasDependencies(context.externalNodes ?? {}),
|
|
1309
1417
|
];
|
|
1310
1418
|
|
|
1311
1419
|
/** Nx invokes this only after merging inferred/declarative targets and every plugin's project dependencies. */
|
|
1312
1420
|
export const createMetadata: CreateMetadata = (graph, _options, context) => {
|
|
1313
1421
|
refuseOverlappingOutputs(graph, context.workspaceRoot);
|
|
1314
1422
|
refuseBuildTestDependencies(graph, context.workspaceRoot);
|
|
1423
|
+
refuseUndeclaredImports(graph);
|
|
1315
1424
|
return {};
|
|
1316
1425
|
};
|
|
1317
1426
|
|
|
@@ -1678,20 +1787,40 @@ async function createProjectTargets(
|
|
|
1678
1787
|
[...(hasLibTsconfig ? [libTsconfigPath] : []), ...(hasTestTsconfig ? [testTsconfigPath] : [])],
|
|
1679
1788
|
workspaceRoot,
|
|
1680
1789
|
);
|
|
1790
|
+
// The packages a TypeScript task loads by name beyond its sources' imports, each keyed by the lock scope that
|
|
1791
|
+
// declares it where it loads (bun-lock-scope.ts): the project's own node keys its own declarations, and a root
|
|
1792
|
+
// declaration is named by itself, so no task is keyed on root tooling it never loads. A check reads the @types and
|
|
1793
|
+
// tslib TypeScript finds by ancestry and the installed configs its chain extends. The emit also runs ttsc from the
|
|
1794
|
+
// root's node_modules/.bin, and ttsc loads the TypeScript API from the project and each transform plugin its
|
|
1795
|
+
// configs name.
|
|
1796
|
+
const manifests = manifestsAbove(workspaceRoot, projectRoot);
|
|
1797
|
+
const rootManifests = manifests.filter((manifest) => manifest.root === '.');
|
|
1798
|
+
const checkScopes = [
|
|
1799
|
+
...bunLoadInput(manifests, typescriptLoads(manifests)).externalDependencies,
|
|
1800
|
+
...bunLoadScopes(workspaceRoot, typescriptConfigChain.extendsLoads),
|
|
1801
|
+
];
|
|
1802
|
+
const checkScopeInput = bunScopeInput(projectRoot, checkScopes);
|
|
1803
|
+
const emitScopeInput = bunScopeInput(
|
|
1804
|
+
projectRoot,
|
|
1805
|
+
checkScopes,
|
|
1806
|
+
bunLoadInput(manifests, ['typescript']).externalDependencies,
|
|
1807
|
+
bunLoadInput(rootManifests, ['ttsc', '@typescript/native']).externalDependencies,
|
|
1808
|
+
bunLoadScopes(workspaceRoot, typescriptConfigChain.transformLoads),
|
|
1809
|
+
);
|
|
1681
1810
|
const toolchainInputs = [
|
|
1682
1811
|
...RELEASE_REWRITTEN_WORKSPACE_INPUTS,
|
|
1683
|
-
|
|
1812
|
+
emitScopeInput,
|
|
1684
1813
|
...TYPESCRIPT_PATCH_INPUTS,
|
|
1685
|
-
...typescriptConfigChain,
|
|
1814
|
+
...typescriptConfigChain.inputs,
|
|
1686
1815
|
];
|
|
1687
1816
|
const checkInputs =
|
|
1688
1817
|
versionless === null
|
|
1689
1818
|
? toolchainInputs
|
|
1690
1819
|
: [
|
|
1691
1820
|
...TYPESCRIPT_PATCH_INPUTS,
|
|
1692
|
-
...typescriptConfigChain,
|
|
1821
|
+
...typescriptConfigChain.inputs,
|
|
1693
1822
|
...VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS,
|
|
1694
|
-
|
|
1823
|
+
checkScopeInput,
|
|
1695
1824
|
];
|
|
1696
1825
|
const selfProduction = versionless === null ? 'production' : VERSIONLESS_PRODUCTION_INPUT;
|
|
1697
1826
|
const selfDefault = versionless === null ? 'default' : VERSIONLESS_DEFAULT_INPUT;
|
|
@@ -1895,32 +2024,37 @@ async function createProjectTargets(
|
|
|
1895
2024
|
memberDir: plan.package.dir,
|
|
1896
2025
|
cache: cargoWorkspace.inputsCache,
|
|
1897
2026
|
cargo: cargoWorkspace.closureSource.cargo,
|
|
2027
|
+
sources: cargoWorkspace.closureSource.sources,
|
|
1898
2028
|
}),
|
|
1899
2029
|
),
|
|
1900
2030
|
)
|
|
1901
2031
|
).flat(),
|
|
1902
2032
|
),
|
|
1903
2033
|
];
|
|
1904
|
-
// Generated crate sources (wire codecs, vocabularies, fixtures)
|
|
1905
|
-
// gitignored and invisible to nx's file
|
|
1906
|
-
// as the outputs of the targets a
|
|
1907
|
-
// those outputs here means a
|
|
1908
|
-
//
|
|
1909
|
-
//
|
|
1910
|
-
//
|
|
1911
|
-
//
|
|
2034
|
+
// Generated crate sources (wire codecs, vocabularies, fixtures) and
|
|
2035
|
+
// compiled-in files are often gitignored and invisible to nx's file
|
|
2036
|
+
// hasher; they reach these targets as the outputs of the targets a
|
|
2037
|
+
// repository adds to `dependsOn`. Hashing those outputs here means a
|
|
2038
|
+
// repository never has to restate `inputs` to add them - and a restated
|
|
2039
|
+
// `inputs` REPLACES this union with the root project's `default`, which
|
|
2040
|
+
// owns no crate file, so the test build then cache-hits against edited
|
|
2041
|
+
// crates while every per-crate test reruns on the stale binary. Only the
|
|
2042
|
+
// outputs under the union's own file sets are hashed
|
|
2043
|
+
// (`cargoProducerOutputInputs`): a compile reads nothing else, and a
|
|
2044
|
+
// producer's TypeScript output outside every crate keys no Rust build.
|
|
2045
|
+
const closureInputs = workspaceInputs.length > 0 ? workspaceInputs : CARGO_INPUTS;
|
|
1912
2046
|
const workspaceCargoInputs: TargetConfiguration['inputs'] = [
|
|
1913
|
-
...
|
|
1914
|
-
|
|
2047
|
+
...closureInputs,
|
|
2048
|
+
...cargoProducerOutputInputs(closureInputs, cargoWorkspaceRoot),
|
|
1915
2049
|
];
|
|
2050
|
+
// The build's `cargo nextest list` loads the repository's nextest config and
|
|
2051
|
+
// refuses an invalid one, so that file keys the build as well as every run.
|
|
1916
2052
|
targets[CARGO_TEST_BUILD_TARGET] = createCargoTestBuildTarget(
|
|
1917
2053
|
cargoWorkspaceRoot,
|
|
1918
2054
|
nextestToolConfigArg(cargoWorkspaceRoot),
|
|
1919
2055
|
nativeTools,
|
|
2056
|
+
[...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`],
|
|
1920
2057
|
);
|
|
1921
|
-
// The build's `cargo nextest list` loads the repository's nextest config and
|
|
1922
|
-
// refuses an invalid one, so that file keys the build as well as every run.
|
|
1923
|
-
targets[CARGO_TEST_BUILD_TARGET].inputs = [...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`];
|
|
1924
2058
|
// One archive per declared foreign triple, from the same inputs and the
|
|
1925
2059
|
// same repository nextest config, whose `archive.include` decides what an
|
|
1926
2060
|
// archive CONTAINS: it is the workspace's test binaries for another
|
|
@@ -2215,38 +2349,6 @@ async function createProjectTargets(
|
|
|
2215
2349
|
];
|
|
2216
2350
|
}
|
|
2217
2351
|
|
|
2218
|
-
const napiDebug = targets['napi-debug'];
|
|
2219
|
-
if (napiDebug && cargoWorkspace) {
|
|
2220
|
-
// A crate whose project also builds the debug cdylib runs its tests after
|
|
2221
|
-
// that build: the tests dlopen what `napi-debug` writes into `target/debug`,
|
|
2222
|
-
// and a test binary run in place loads it from this tree.
|
|
2223
|
-
const runners = [
|
|
2224
|
-
...cargoPackagePlans.flatMap((plan) => plan.pieces.map((piece) => piece.targetName)),
|
|
2225
|
-
// The root owns the serial groups' runners, so they take its build as its pieces do.
|
|
2226
|
-
...(ownsCargoWorkspaceTargets
|
|
2227
|
-
? cargoWorkspace.serialGroups.map((group) => cargoTestGroupTargetName(group.group))
|
|
2228
|
-
: []),
|
|
2229
|
-
];
|
|
2230
|
-
for (const name of runners) {
|
|
2231
|
-
const target = targets[name];
|
|
2232
|
-
if (target && !hasCargoTargetDependency(target.dependsOn ?? [], 'napi-debug')) {
|
|
2233
|
-
target.dependsOn = [...(target.dependsOn ?? []), 'napi-debug'];
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
} else if (napiDebug) {
|
|
2237
|
-
const cargoTest = targets[CARGO_TEST_TARGET];
|
|
2238
|
-
if (
|
|
2239
|
-
cargoTest?.options &&
|
|
2240
|
-
typeof cargoTest.options.command === 'string' &&
|
|
2241
|
-
cargoTest.options.command.startsWith('cargo ')
|
|
2242
|
-
) {
|
|
2243
|
-
const dependsOn = cargoTest.dependsOn ?? [];
|
|
2244
|
-
if (!dependsOn.includes('napi-debug')) {
|
|
2245
|
-
cargoTest.dependsOn = [...dependsOn, 'napi-debug'];
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
2352
|
// The inferring host's own platform binaries join the aggregate `build`;
|
|
2251
2353
|
// publish still owns foreign platforms.
|
|
2252
2354
|
const hostPlatformBinaries = hostPlatformTargetNames(
|
|
@@ -2412,6 +2514,15 @@ async function createProjectTargets(
|
|
|
2412
2514
|
inputs: lintProgramInputs,
|
|
2413
2515
|
eslintFileSet,
|
|
2414
2516
|
} = projectLintCommands(projectRoot, workspaceRoot, eslint);
|
|
2517
|
+
// The lint tools run from the root's node_modules/.bin, and ESLint loads the packages its configs name.
|
|
2518
|
+
const runsEslint = eslintFileSet !== null;
|
|
2519
|
+
const lintScopes = [
|
|
2520
|
+
...bunLoadInput(rootManifests, [
|
|
2521
|
+
...(runsEslint ? ['eslint'] : []),
|
|
2522
|
+
...(lintCommands.some((command) => command.startsWith('biome ')) ? ['@biomejs/biome'] : []),
|
|
2523
|
+
]).externalDependencies,
|
|
2524
|
+
...(runsEslint ? (eslint?.configScopes ?? []) : []),
|
|
2525
|
+
];
|
|
2415
2526
|
// Every lint tool reaches its own verdict in one run: run-commands would end the
|
|
2416
2527
|
// other tools once one fails, and their findings would surface a run later.
|
|
2417
2528
|
if (validationTargets.length > 0 || lintCommands.length > 0) {
|
|
@@ -2431,6 +2542,7 @@ async function createProjectTargets(
|
|
|
2431
2542
|
`{projectRoot}/${name}`,
|
|
2432
2543
|
]),
|
|
2433
2544
|
...(eslint?.configImports ?? []).map((path) => `{workspaceRoot}/${path}`),
|
|
2545
|
+
...(lintScopes.length > 0 ? [bunScopeInput(projectRoot, lintScopes)] : []),
|
|
2434
2546
|
],
|
|
2435
2547
|
...(lintCommands.length > 0
|
|
2436
2548
|
? {
|
|
@@ -2458,29 +2570,85 @@ async function createProjectTargets(
|
|
|
2458
2570
|
}
|
|
2459
2571
|
}
|
|
2460
2572
|
|
|
2461
|
-
//
|
|
2462
|
-
//
|
|
2463
|
-
//
|
|
2464
|
-
|
|
2465
|
-
|
|
2573
|
+
// The Darwin Node idle clock and the Cargo admission observer both load the local cowshed addon. They can fail
|
|
2574
|
+
// a run but do not change a passing command, so none keys its bytes (README, "Bounded exec key"). Declarations
|
|
2575
|
+
// retain these prerequisites with Nx's ordinary "..." merge token. The wall-only release-check judges already
|
|
2576
|
+
// built shipping artifacts and remains dependency-free.
|
|
2577
|
+
const addonProducers = [...nativeToolDependsOn(nativeTools, 'cowshed'), ...lineageProducer];
|
|
2578
|
+
if (addonProducers.length > 0) {
|
|
2466
2579
|
for (const name of new Set([...Object.keys(targets), ...Object.keys(declaredTargets)])) {
|
|
2467
2580
|
const declared = declaredTargets[name];
|
|
2468
2581
|
const executor =
|
|
2469
2582
|
isRecord(declared) && declared.executor !== undefined ? declared.executor : targets[name]?.executor;
|
|
2470
2583
|
if (executor !== '@smoothbricks/nx-plugin:bounded-exec' || name === 'release-check') continue;
|
|
2471
|
-
|
|
2584
|
+
const runs = [...targetOptionSets(declared), ...targetOptionSets(targets[name])];
|
|
2585
|
+
const needsAddon = runs.some(
|
|
2586
|
+
(options) =>
|
|
2587
|
+
runsAsCargoLeaf(boundedCommandLine(options) ?? '') ||
|
|
2588
|
+
(hostPlatform?.targetFamily === 'macos' && typeof options.idleTimeoutMs === 'number'),
|
|
2589
|
+
);
|
|
2590
|
+
if (!needsAddon) continue;
|
|
2591
|
+
// Nx discards an incompatible executor's inferred configuration; only the runtime prerequisites belong below it.
|
|
2592
|
+
if (targets[name]?.executor !== undefined && targets[name]?.executor !== executor) targets[name] = {};
|
|
2593
|
+
targets[name] ??= {};
|
|
2594
|
+
const target = targets[name];
|
|
2595
|
+
target.dependsOn = [...(target.dependsOn ?? []), ...addonProducers];
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
// The package's addon loader reads napi-debug's dev-profile addon when NAPI_DEBUG_ADDON=1 (createNapiTestTarget), so
|
|
2600
|
+
// a target whose run sets it, in its declaration or its inference, runs after that build and keys the addon it writes.
|
|
2601
|
+
if (targets['napi-debug'] !== undefined) {
|
|
2602
|
+
for (const name of new Set([...Object.keys(targets), ...Object.keys(declaredTargets)])) {
|
|
2603
|
+
const declared = declaredTargets[name];
|
|
2604
|
+
const runs = [...targetOptionSets(declared), ...targetOptionSets(targets[name])];
|
|
2605
|
+
if (!runs.some((options) => isRecord(options.env) && options.env.NAPI_DEBUG_ADDON === '1')) continue;
|
|
2606
|
+
const executor =
|
|
2607
|
+
isRecord(declared) && declared.executor !== undefined ? declared.executor : targets[name]?.executor;
|
|
2608
|
+
// Nx discards an incompatible executor's inferred configuration; only the addon prerequisite belongs below it.
|
|
2472
2609
|
if (targets[name]?.executor !== undefined && targets[name]?.executor !== executor) {
|
|
2473
2610
|
targets[name] = {};
|
|
2474
2611
|
}
|
|
2475
2612
|
targets[name] ??= {};
|
|
2476
2613
|
const target = targets[name];
|
|
2477
|
-
|
|
2614
|
+
const named = [
|
|
2615
|
+
...(target.dependsOn ?? []),
|
|
2616
|
+
...(isRecord(declared) && Array.isArray(declared.dependsOn) ? declared.dependsOn : []),
|
|
2617
|
+
];
|
|
2618
|
+
if (!named.includes('napi-debug')) {
|
|
2619
|
+
target.dependsOn = [...(target.dependsOn ?? []), 'napi-debug'];
|
|
2620
|
+
}
|
|
2478
2621
|
const inputs =
|
|
2479
2622
|
target.inputs ?? (isRecord(declared) && Array.isArray(declared.inputs) ? [] : ['default', '^production']);
|
|
2480
|
-
target.inputs = [
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2623
|
+
target.inputs = [...inputs, { dependentTasksOutputFiles: '**/*.node', transitive: false }];
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
// A plugin executor is a file the workspace plugin's own build writes, so a target that starts before that build
|
|
2628
|
+
// ends loads the dist a previous build left: one without the executors the plugin gained since (a Linux CLI
|
|
2629
|
+
// target failed "Could not resolve ./dist/executors/cargo-zigbuild/executor.js" in a checkout restored from a
|
|
2630
|
+
// cache that predated it). Every such target of every project but the plugin takes the one edge, so no executor
|
|
2631
|
+
// needs its own: the executors that build the plugin (the bootstrap ones) take none, the plugin's own targets
|
|
2632
|
+
// are ordered by its own graph, and release-check stays dependency-free (specs/cowshed/06_cli.md,
|
|
2633
|
+
// `release-check`). Declarations that replace `dependsOn` keep it with Nx's "..." token.
|
|
2634
|
+
if (packageJson.name !== '@smoothbricks/nx-plugin') {
|
|
2635
|
+
for (const name of new Set([...Object.keys(targets), ...Object.keys(declaredTargets)])) {
|
|
2636
|
+
if (name === 'release-check') continue;
|
|
2637
|
+
const declared = declaredTargets[name];
|
|
2638
|
+
const executor =
|
|
2639
|
+
isRecord(declared) && declared.executor !== undefined ? declared.executor : targets[name]?.executor;
|
|
2640
|
+
const edge = pluginBuildDependsOn(nativeTools, executor);
|
|
2641
|
+
if (edge.length === 0) continue;
|
|
2642
|
+
// Nx discards an incompatible executor's inferred configuration; only the edge belongs below it.
|
|
2643
|
+
if (targets[name]?.executor !== undefined && targets[name]?.executor !== executor) {
|
|
2644
|
+
targets[name] = {};
|
|
2645
|
+
}
|
|
2646
|
+
targets[name] ??= {};
|
|
2647
|
+
const target = targets[name];
|
|
2648
|
+
const present = new Set((target.dependsOn ?? []).map((dependency) => JSON.stringify(dependency)));
|
|
2649
|
+
target.dependsOn = [
|
|
2650
|
+
...(target.dependsOn ?? []),
|
|
2651
|
+
...edge.filter((dependency) => !present.has(JSON.stringify(dependency))),
|
|
2484
2652
|
];
|
|
2485
2653
|
}
|
|
2486
2654
|
}
|
|
@@ -2494,6 +2662,21 @@ async function createProjectTargets(
|
|
|
2494
2662
|
}
|
|
2495
2663
|
}
|
|
2496
2664
|
|
|
2665
|
+
// The inferred typecheck's compiler, named only where its command is the one inferred here: a declared typecheck
|
|
2666
|
+
// that runs another command runs something this inference does not know. Nx keeps the inferred command under a
|
|
2667
|
+
// declaration that names the same executor and no command, and replaces it under any other executor, under a
|
|
2668
|
+
// top-level `command` (its run-commands shorthand) or under `options.command`/`options.commands`.
|
|
2669
|
+
const declaredTypecheck = declaredTargets.typecheck;
|
|
2670
|
+
const declaredTypecheckOptions = isRecord(declaredTypecheck) ? declaredTypecheck.options : undefined;
|
|
2671
|
+
const typecheckCompilerInputs =
|
|
2672
|
+
targets.typecheck === undefined ||
|
|
2673
|
+
(isRecord(declaredTypecheck) &&
|
|
2674
|
+
((declaredTypecheck.executor !== undefined && declaredTypecheck.executor !== targets.typecheck.executor) ||
|
|
2675
|
+
declaredTypecheck.command !== undefined)) ||
|
|
2676
|
+
(isRecord(declaredTypecheckOptions) &&
|
|
2677
|
+
(declaredTypecheckOptions.command !== undefined || declaredTypecheckOptions.commands !== undefined))
|
|
2678
|
+
? []
|
|
2679
|
+
: typecheck.inputs;
|
|
2497
2680
|
// A declared target REPLACES the inferred input list, pin included, so a
|
|
2498
2681
|
// repository that hand-writes `inputs` for a cargo target silently loses its
|
|
2499
2682
|
// toolchain identity. Name the identity once here so such a declaration can
|
|
@@ -2504,6 +2687,8 @@ async function createProjectTargets(
|
|
|
2504
2687
|
// its configuration hash, so defining it everywhere would invalidate every
|
|
2505
2688
|
// task in the repository to serve projects that can never reference it.
|
|
2506
2689
|
const namedInputs: Record<string, NonNullable<TargetConfiguration['inputs']>> = {
|
|
2690
|
+
[BUN_LOCK_SCOPE_NAMED_INPUT]: [bunLockInput(projectRoot)],
|
|
2691
|
+
...(typecheckCompilerInputs.length === 0 ? {} : { [TYPECHECK_COMPILER_NAMED_INPUT]: [...typecheckCompilerInputs] }),
|
|
2507
2692
|
...(versionless === null
|
|
2508
2693
|
? {}
|
|
2509
2694
|
: {
|
|
@@ -2590,7 +2775,8 @@ async function lockScopeNodes(
|
|
|
2590
2775
|
}
|
|
2591
2776
|
}
|
|
2592
2777
|
const own = bunLockNode(projectRoot);
|
|
2593
|
-
const
|
|
2778
|
+
const runtime = bunLockRuntimeNode(projectRoot);
|
|
2779
|
+
const nodes: Record<string, ProjectGraphExternalNode> = { [own.name]: own, [runtime.name]: runtime };
|
|
2594
2780
|
for (const node of await Promise.all(
|
|
2595
2781
|
[...directories].map((directory) => cargoLockNode(directory, cargoSourcesUnder(directory, cargoWorkspaces))),
|
|
2596
2782
|
)) {
|
|
@@ -2846,62 +3032,9 @@ function createNapiTargets(
|
|
|
2846
3032
|
};
|
|
2847
3033
|
// The task that builds the executable recordInputs runs, when this workspace builds it.
|
|
2848
3034
|
const buildInputsTool = nativeToolDependsOn(nativeTools, 'build-inputs');
|
|
2849
|
-
const
|
|
2850
|
-
const convention = NAPI_TARGET_CONVENTIONS[triple];
|
|
2851
|
-
return convention !== undefined && sameNapiPlatform(convention, hostPlatform);
|
|
2852
|
-
});
|
|
3035
|
+
const recordedInputs = [...(cargoInputs ?? []), ...buildInputsToolInputs(nativeTools)];
|
|
2853
3036
|
const targets: Record<string, TargetConfiguration> = {};
|
|
2854
|
-
|
|
2855
|
-
// The addon the test suite loads. A plain dev build shares target/debug with
|
|
2856
|
-
// cargo-test's dependency graph, so after the tests compile this is nearly
|
|
2857
|
-
// free, where a `--target <triple>` platform build compiles the graph again
|
|
2858
|
-
// under target/<triple>/. The output lives OUTSIDE dist/ because packages
|
|
2859
|
-
// publish `files: ["dist"]` wholesale: an addon the test run wrote under
|
|
2860
|
-
// dist/ would ship in place of the release build. native.ts resolves this
|
|
2861
|
-
// directory only when the napi-test target sets NAPI_DEBUG_ADDON=1, so
|
|
2862
|
-
// production loads never see it.
|
|
2863
|
-
targets['napi-debug'] = {
|
|
2864
|
-
executor: 'nx:run-commands',
|
|
2865
|
-
metadata: CARGO_PRODUCER_METADATA,
|
|
2866
|
-
cache: true,
|
|
2867
|
-
dependsOn: ['^build'],
|
|
2868
|
-
inputs: cargoInputs,
|
|
2869
|
-
outputs: ['{projectRoot}/.cache/native-debug/'],
|
|
2870
|
-
options: {
|
|
2871
|
-
cwd: cargoCwd,
|
|
2872
|
-
command: `${napiCommand} build --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${outputDir('.cache/native-debug')}`,
|
|
2873
|
-
},
|
|
2874
|
-
};
|
|
2875
|
-
|
|
2876
|
-
if (!hasHostPlatformTarget) {
|
|
2877
|
-
// The platform target for this host triple is the same compilation, so a
|
|
2878
|
-
// second cargo-napi invocation only buys a duplicate dependency graph
|
|
2879
|
-
// (a plain build and a `--target` build write different target/
|
|
2880
|
-
// subdirectories); native.ts already resolves the identical
|
|
2881
|
-
// platform-suffixed filename from <tree>/<platform-dir> after <tree>/host,
|
|
2882
|
-
// in the one tree its package's source authority selects (.cache/native-dev
|
|
2883
|
-
// in a checkout, dist/native installed).
|
|
2884
|
-
const hostBuild = (profile: CargoProfile): string =>
|
|
2885
|
-
`${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${runOutputDirectory}${recordInputs(null, profile, runOutputDirectory)}`;
|
|
2886
|
-
const hostOutputs = nativeOutputPaths('host');
|
|
2887
|
-
targets['cargo-napi'] = {
|
|
2888
|
-
executor: 'nx:run-commands',
|
|
2889
|
-
metadata: CARGO_PRODUCER_METADATA,
|
|
2890
|
-
cache: true,
|
|
2891
|
-
dependsOn: ['^build', ...buildInputsTool],
|
|
2892
|
-
inputs: cargoInputs,
|
|
2893
|
-
outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
|
|
2894
|
-
options: {
|
|
2895
|
-
cwd: cargoCwd,
|
|
2896
|
-
command: hostBuild('dev'),
|
|
2897
|
-
outputDir: hostOutputs.dev,
|
|
2898
|
-
},
|
|
2899
|
-
configurations: {
|
|
2900
|
-
[RELEASE_CONFIGURATION]: { command: hostBuild('release'), outputDir: hostOutputs.release },
|
|
2901
|
-
},
|
|
2902
|
-
};
|
|
2903
|
-
}
|
|
2904
|
-
|
|
3037
|
+
const debugDirectory = '.cache/native-debug';
|
|
2905
3038
|
for (const triple of config.targets) {
|
|
2906
3039
|
const convention = NAPI_TARGET_CONVENTIONS[triple];
|
|
2907
3040
|
if (!convention) {
|
|
@@ -2909,13 +3042,33 @@ function createNapiTargets(
|
|
|
2909
3042
|
}
|
|
2910
3043
|
const targetName = `napi-${convention.architecture}-${convention.targetFamily}`;
|
|
2911
3044
|
const outputs = nativeOutputPaths(convention.outputName);
|
|
3045
|
+
const fileName = `${config.binaryName}.${convention.outputName}.node`;
|
|
3046
|
+
if (sameNapiPlatform(convention, hostPlatform)) {
|
|
3047
|
+
const source = `${outputs.dev}/${fileName}`;
|
|
3048
|
+
const destination = `${debugDirectory}/${fileName}`;
|
|
3049
|
+
const staging = `${destination}.partial`;
|
|
3050
|
+
targets['napi-debug'] = {
|
|
3051
|
+
executor: 'nx:run-commands',
|
|
3052
|
+
cache: true,
|
|
3053
|
+
// An empty configuration selects the producer's default instead of inheriting `production` from the run.
|
|
3054
|
+
dependsOn: [{ target: targetName, configuration: '' }],
|
|
3055
|
+
inputs: [
|
|
3056
|
+
{ externalDependencies: [] },
|
|
3057
|
+
{ dependentTasksOutputFiles: posix.join(projectRoot, source), transitive: false },
|
|
3058
|
+
],
|
|
3059
|
+
outputs: [`{projectRoot}/${destination}`],
|
|
3060
|
+
options: {
|
|
3061
|
+
cwd: projectRoot,
|
|
3062
|
+
command: `mkdir -p ${debugDirectory} && cp ${source} ${staging} && mv -f ${staging} ${destination}`,
|
|
3063
|
+
},
|
|
3064
|
+
};
|
|
3065
|
+
}
|
|
2912
3066
|
if (convention.targetFamily === 'linux') {
|
|
2913
3067
|
// Every host builds a Linux addon the same way: devenv's zig through
|
|
2914
3068
|
// cargo-zigbuild, glibc pinned by the triple suffix. The napi CLI cannot
|
|
2915
3069
|
// carry that suffix (it looks for the artifact under
|
|
2916
3070
|
// target/<triple>.2.17/), so the executor names the `.node` itself.
|
|
2917
|
-
const nodeFile = (directory: string): string =>
|
|
2918
|
-
`{projectRoot}/${directory}/${config.binaryName}.${convention.outputName}.node`;
|
|
3071
|
+
const nodeFile = (directory: string): string => `{projectRoot}/${directory}/${fileName}`;
|
|
2919
3072
|
targets[targetName] = {
|
|
2920
3073
|
executor: '@smoothbricks/nx-plugin:cargo-zigbuild',
|
|
2921
3074
|
metadata: CARGO_PRODUCER_METADATA,
|
|
@@ -2944,7 +3097,7 @@ function createNapiTargets(
|
|
|
2944
3097
|
metadata: CARGO_PRODUCER_METADATA,
|
|
2945
3098
|
cache: true,
|
|
2946
3099
|
...(buildInputsTool.length > 0 ? { dependsOn: buildInputsTool } : {}),
|
|
2947
|
-
inputs:
|
|
3100
|
+
inputs: recordedInputs,
|
|
2948
3101
|
outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
|
|
2949
3102
|
options: {
|
|
2950
3103
|
cwd: cargoCwd,
|
|
@@ -2956,19 +3109,73 @@ function createNapiTargets(
|
|
|
2956
3109
|
},
|
|
2957
3110
|
};
|
|
2958
3111
|
}
|
|
3112
|
+
|
|
3113
|
+
if (!targets['napi-debug']) {
|
|
3114
|
+
// No declared platform target serves this host: retain the direct builds for both checkout consumers.
|
|
3115
|
+
targets['napi-debug'] = {
|
|
3116
|
+
executor: 'nx:run-commands',
|
|
3117
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
3118
|
+
cache: true,
|
|
3119
|
+
dependsOn: ['^build'],
|
|
3120
|
+
inputs: cargoInputs,
|
|
3121
|
+
outputs: [`{projectRoot}/${debugDirectory}/`],
|
|
3122
|
+
options: {
|
|
3123
|
+
cwd: cargoCwd,
|
|
3124
|
+
command: `${napiCommand} build --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${outputDir(debugDirectory)}`,
|
|
3125
|
+
},
|
|
3126
|
+
};
|
|
3127
|
+
const hostBuild = (profile: CargoProfile): string =>
|
|
3128
|
+
`${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${runOutputDirectory}${recordInputs(null, profile, runOutputDirectory)}`;
|
|
3129
|
+
const hostOutputs = nativeOutputPaths('host');
|
|
3130
|
+
targets['cargo-napi'] = {
|
|
3131
|
+
executor: 'nx:run-commands',
|
|
3132
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
3133
|
+
cache: true,
|
|
3134
|
+
dependsOn: ['^build', ...buildInputsTool],
|
|
3135
|
+
inputs: recordedInputs,
|
|
3136
|
+
outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
|
|
3137
|
+
options: {
|
|
3138
|
+
cwd: cargoCwd,
|
|
3139
|
+
command: hostBuild('dev'),
|
|
3140
|
+
outputDir: hostOutputs.dev,
|
|
3141
|
+
},
|
|
3142
|
+
configurations: {
|
|
3143
|
+
[RELEASE_CONFIGURATION]: { command: hostBuild('release'), outputDir: hostOutputs.release },
|
|
3144
|
+
},
|
|
3145
|
+
};
|
|
3146
|
+
}
|
|
2959
3147
|
return targets;
|
|
2960
3148
|
}
|
|
2961
3149
|
|
|
3150
|
+
/** A target's own options and each of its configurations' options, as one declaration or inference states them. */
|
|
3151
|
+
function targetOptionSets(target: unknown): Record<string, unknown>[] {
|
|
3152
|
+
if (!isRecord(target)) return [];
|
|
3153
|
+
const configurations = isRecord(target.configurations) ? Object.values(target.configurations) : [];
|
|
3154
|
+
return [target.options, ...configurations].filter(isRecord);
|
|
3155
|
+
}
|
|
3156
|
+
|
|
3157
|
+
/** The command line a bounded-exec run with `options` starts (`boundedCommand`), or null when they name no command. */
|
|
3158
|
+
function boundedCommandLine(options: Record<string, unknown>): string | null {
|
|
3159
|
+
const { command, args } = options;
|
|
3160
|
+
if (typeof command !== 'string') return null;
|
|
3161
|
+
return boundedCommand({
|
|
3162
|
+
command,
|
|
3163
|
+
args:
|
|
3164
|
+
typeof args === 'string'
|
|
3165
|
+
? args
|
|
3166
|
+
: Array.isArray(args)
|
|
3167
|
+
? args.filter((arg): arg is string => typeof arg === 'string')
|
|
3168
|
+
: undefined,
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3171
|
+
|
|
2962
3172
|
function createNapiTestTarget(projectRoot: string, hasDedicatedBunfig: boolean): TargetConfiguration {
|
|
2963
3173
|
const configFlag = hasDedicatedBunfig ? ' --config=../bunfig.napi-test.toml' : ' --config=../bunfig.toml';
|
|
2964
3174
|
return {
|
|
2965
3175
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2966
3176
|
cache: true,
|
|
2967
|
-
//
|
|
2968
|
-
//
|
|
2969
|
-
// compiles the whole graph again. tsc-js supplies dist/ts for the suite's
|
|
2970
|
-
// own imports; napi-debug supplies the addon from the graph cargo-test
|
|
2971
|
-
// already built.
|
|
3177
|
+
// Name only what the suite reads, not `build` with its unrelated host binaries.
|
|
3178
|
+
// tsc-js supplies dist/ts; napi-debug supplies the development addon.
|
|
2972
3179
|
dependsOn: ['cargo-test', 'napi-debug', 'tsc-js', '^build'],
|
|
2973
3180
|
options: {
|
|
2974
3181
|
// cwd is src/, not the package root: `bun test <arg>` treats the arg as a
|
|
@@ -3217,14 +3424,14 @@ async function resolveCargoWorkspaces(
|
|
|
3217
3424
|
if (found.length === 0) return [];
|
|
3218
3425
|
// Started only once every workspace listed cleanly, so a listing that throws
|
|
3219
3426
|
// leaves no Cargo process behind.
|
|
3220
|
-
const
|
|
3427
|
+
const indexedSources = indexedCargoSources(workspaceRoot);
|
|
3221
3428
|
return Promise.all(
|
|
3222
3429
|
found.map(async (workspace) => ({
|
|
3223
3430
|
...workspace,
|
|
3224
3431
|
closureSource: await resolveCargoClosureSource(
|
|
3225
3432
|
posix.join(workspace.projectRoot, 'Cargo.toml'),
|
|
3226
3433
|
workspaceRoot,
|
|
3227
|
-
|
|
3434
|
+
indexedSources,
|
|
3228
3435
|
workspace.inputsCache.compiledInFiles,
|
|
3229
3436
|
),
|
|
3230
3437
|
})),
|
|
@@ -3374,6 +3581,7 @@ async function cargoTestRunnerInputs(
|
|
|
3374
3581
|
memberDir,
|
|
3375
3582
|
cache: workspace.inputsCache,
|
|
3376
3583
|
cargo: workspace.closureSource.cargo,
|
|
3584
|
+
sources: workspace.closureSource.sources,
|
|
3377
3585
|
}),
|
|
3378
3586
|
),
|
|
3379
3587
|
);
|
|
@@ -3424,7 +3632,7 @@ const NEXTEST_BINARIES_FIXTURE_TIMEOUT_MS = 3_600_000;
|
|
|
3424
3632
|
* from the run's, and names the crates loudly when mbx had to compile (smoo-nx-nextest-binaries).
|
|
3425
3633
|
*/
|
|
3426
3634
|
function nextestRunnerFixture(workspace: CargoWorkspace, nativeTools: NativeTools | null): string {
|
|
3427
|
-
const helper = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract',
|
|
3635
|
+
const helper = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract', NEXTEST_HELPER_BIN);
|
|
3428
3636
|
return `${helper} ensure ${NEXTEST_BINARIES_METADATA} ${NEXTEST_BUILD_KEY} -- ${nextestBinariesBuild(nextestToolConfigArg(workspace.projectRoot))}`;
|
|
3429
3637
|
}
|
|
3430
3638
|
|
|
@@ -3442,7 +3650,7 @@ function nextestRunnerCommand(
|
|
|
3442
3650
|
): string {
|
|
3443
3651
|
const toolConfig = nextestToolConfigArg(workspace.projectRoot);
|
|
3444
3652
|
// Relative to the runner's cwd, so the hashed command is the same in every checkout.
|
|
3445
|
-
const helper = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract',
|
|
3653
|
+
const helper = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract', NEXTEST_HELPER_BIN);
|
|
3446
3654
|
const reuseBuild =
|
|
3447
3655
|
`--binaries-metadata ${NEXTEST_BINARIES_METADATA} --cargo-metadata ${NEXTEST_CARGO_METADATA} ` +
|
|
3448
3656
|
`--target-dir-remap "$(${helper} target-dir)"`;
|
|
@@ -3462,7 +3670,8 @@ function cargoTestRunnerTarget(
|
|
|
3462
3670
|
return {
|
|
3463
3671
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
3464
3672
|
cache: true,
|
|
3465
|
-
|
|
3673
|
+
// The command (`target-dir`) and the fixture (`ensure`) run the nextest helper.
|
|
3674
|
+
inputs: [...inputs, ...nextestHelperInputs(nativeTools)],
|
|
3466
3675
|
dependsOn: [build, ...nativeToolDependsOn(nativeTools, 'nextest-extract')],
|
|
3467
3676
|
options: {
|
|
3468
3677
|
command: nextestRunnerCommand(
|
|
@@ -3500,7 +3709,7 @@ function cargoTestGroupTarget(
|
|
|
3500
3709
|
return {
|
|
3501
3710
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
3502
3711
|
cache: true,
|
|
3503
|
-
inputs: [...inputs, fileHashInput(PLUGIN_NEXTEST_CODE_BOUND)],
|
|
3712
|
+
inputs: [...inputs, fileHashInput(PLUGIN_NEXTEST_CODE_BOUND), ...nextestHelperInputs(nativeTools)],
|
|
3504
3713
|
dependsOn: [CARGO_TEST_BUILD_TARGET, ...nativeToolDependsOn(nativeTools, 'nextest-extract')],
|
|
3505
3714
|
options: {
|
|
3506
3715
|
command: nextestRunnerCommand('run', workspace, nativeTools, group.filter, ' --no-fail-fast --no-tests=fail'),
|
|
@@ -3513,21 +3722,3 @@ function cargoTestGroupTarget(
|
|
|
3513
3722
|
},
|
|
3514
3723
|
};
|
|
3515
3724
|
}
|
|
3516
|
-
|
|
3517
|
-
function hasCargoTargetDependency(
|
|
3518
|
-
dependencies: readonly CargoTargetDependency[],
|
|
3519
|
-
expected: CargoTargetDependency,
|
|
3520
|
-
): boolean {
|
|
3521
|
-
if (typeof expected === 'string') {
|
|
3522
|
-
return dependencies.includes(expected);
|
|
3523
|
-
}
|
|
3524
|
-
return dependencies.some(
|
|
3525
|
-
(dependency) =>
|
|
3526
|
-
typeof dependency !== 'string' &&
|
|
3527
|
-
dependency.target === expected.target &&
|
|
3528
|
-
Array.isArray(dependency.projects) &&
|
|
3529
|
-
Array.isArray(expected.projects) &&
|
|
3530
|
-
dependency.projects.length === expected.projects.length &&
|
|
3531
|
-
dependency.projects.every((project, index) => project === expected.projects?.[index]),
|
|
3532
|
-
);
|
|
3533
|
-
}
|