@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/dist/bun-lock-scope.js
CHANGED
|
@@ -8,17 +8,25 @@ import { TargetProjectLocator } from 'nx/src/plugins/js/project-graph/build-depe
|
|
|
8
8
|
*
|
|
9
9
|
* A lock-scope node is the part of bun.lock one manifest reaches: what the
|
|
10
10
|
* package can load. Its edges go to the npm nodes the manifest's dependencies
|
|
11
|
-
* resolve to
|
|
12
|
-
*
|
|
13
|
-
* the
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* the
|
|
11
|
+
* resolve to and to the node of each workspace member it depends on, the
|
|
12
|
+
* root's manifest included. Nx's lockfile parser links each versioned npm node
|
|
13
|
+
* to the packages it depends on, and the plugin links each unversioned alias
|
|
14
|
+
* to its versioned node ({@link bunVersionAliasDependencies}), so a target naming a node in its
|
|
15
|
+
* `externalDependencies` is keyed on every package of that closure by the hash
|
|
16
|
+
* bun.lock records for it, and on nothing else in the lockfile. That replaces
|
|
17
|
+
* bun.lock as a file input: a lockfile edit re-keys the tasks that can load
|
|
18
|
+
* what changed.
|
|
19
|
+
*
|
|
20
|
+
* A member's node has no edge to the root's. Bun's isolated linker links into
|
|
21
|
+
* a directory's `node_modules` exactly the packages its manifest declares, but
|
|
22
|
+
* Node's lookup from a member continues into the root's `node_modules`, so a
|
|
23
|
+
* member can load any package the root declares. Two rules keep the member's
|
|
24
|
+
* own closure the whole of what it loads: a source import of a package outside
|
|
25
|
+
* that closure refuses the graph ({@link undeclaredImports}), and a tool a
|
|
26
|
+
* target runs names each package it loads by name from a directory by the
|
|
27
|
+
* scope that declares it ({@link bunLoadInput}). The root's own tooling (Nx
|
|
28
|
+
* plugins and generators, release and mutation tooling) then keys only the
|
|
29
|
+
* tasks that load it.
|
|
22
30
|
*
|
|
23
31
|
* The nodes carry no content of their own; Nx hashes a node's version and the
|
|
24
32
|
* nodes it reaches.
|
|
@@ -28,8 +36,15 @@ export const BUN_LOCK_NODE_PREFIX = 'bun-lock:';
|
|
|
28
36
|
export function bunLockNodeName(projectRoot) {
|
|
29
37
|
return `${BUN_LOCK_NODE_PREFIX}${posix.normalize(projectRoot === '' ? '.' : projectRoot)}`;
|
|
30
38
|
}
|
|
31
|
-
/** The node of the workspace root manifest
|
|
39
|
+
/** The node of the workspace root manifest. */
|
|
32
40
|
export const BUN_ROOT_LOCK_NODE = bunLockNodeName('.');
|
|
41
|
+
/**
|
|
42
|
+
* The named input every `package.json` project defines as its own lock-scope
|
|
43
|
+
* input. `externalDependencies` takes no `{projectRoot}` token, so a
|
|
44
|
+
* workspace-wide named input or target default names this to key each
|
|
45
|
+
* project's targets on its own manifest's closure.
|
|
46
|
+
*/
|
|
47
|
+
export const BUN_LOCK_SCOPE_NAMED_INPUT = 'bunLockScope';
|
|
33
48
|
/** The input that keys a target on the bun.lock entries its project's manifest reaches. */
|
|
34
49
|
export function bunLockInput(projectRoot) {
|
|
35
50
|
return { externalDependencies: [bunLockNodeName(projectRoot)] };
|
|
@@ -39,16 +54,51 @@ export function bunLockNode(projectRoot) {
|
|
|
39
54
|
const name = bunLockNodeName(projectRoot);
|
|
40
55
|
return { type: 'bun', name, data: { packageName: name, version: '0.0.0' } };
|
|
41
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Every bun runtime-scope node's name starts with this; the rest is a project
|
|
59
|
+
* root. It is the part of bun.lock a dependent loads through that package: the
|
|
60
|
+
* closure of its `dependencies`, `optionalDependencies` and
|
|
61
|
+
* `peerDependencies`. A package's devDependencies are installed for its own
|
|
62
|
+
* targets only, so a dependent's lock-scope node reaches the runtime node of
|
|
63
|
+
* each member it declares, never that member's own node.
|
|
64
|
+
*/
|
|
65
|
+
export const BUN_LOCK_RUNTIME_NODE_PREFIX = 'bun-lock-runtime:';
|
|
66
|
+
/** The runtime-scope node of the project at `projectRoot`. */
|
|
67
|
+
export function bunLockRuntimeNodeName(projectRoot) {
|
|
68
|
+
return `${BUN_LOCK_RUNTIME_NODE_PREFIX}${posix.normalize(projectRoot === '' ? '.' : projectRoot)}`;
|
|
69
|
+
}
|
|
70
|
+
/** The runtime-scope node itself, published by its project beside its lock-scope node. */
|
|
71
|
+
export function bunLockRuntimeNode(projectRoot) {
|
|
72
|
+
const name = bunLockRuntimeNodeName(projectRoot);
|
|
73
|
+
return { type: 'bun', name, data: { packageName: name, version: '0.0.0' } };
|
|
74
|
+
}
|
|
42
75
|
/** The manifest sections Nx reads a project's package dependencies from, in the order it lets them override. */
|
|
43
76
|
const DEPENDENCY_SECTIONS = ['optionalDependencies', 'peerDependencies', 'devDependencies', 'dependencies'];
|
|
77
|
+
/** The sections a dependent loads through a package: all but its devDependencies. */
|
|
78
|
+
const RUNTIME_SECTIONS = ['optionalDependencies', 'peerDependencies', 'dependencies'];
|
|
79
|
+
/** Each package a manifest declares in `sections`, with the specifier of the section Nx lets win. */
|
|
80
|
+
function declaredSpecifiers(manifest, sections = DEPENDENCY_SECTIONS) {
|
|
81
|
+
const specifiers = new Map();
|
|
82
|
+
for (const section of sections) {
|
|
83
|
+
const declared = manifest[section];
|
|
84
|
+
if (typeof declared !== 'object' || declared === null)
|
|
85
|
+
continue;
|
|
86
|
+
for (const [name, specifier] of Object.entries(declared)) {
|
|
87
|
+
if (typeof specifier === 'string')
|
|
88
|
+
specifiers.set(name, specifier);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return specifiers;
|
|
92
|
+
}
|
|
44
93
|
/**
|
|
45
|
-
* The edges of every published bun lock-scope node. A
|
|
46
|
-
* are resolved exactly as Nx resolves a project's own
|
|
47
|
-
* (`buildExplicitPackageJsonDependencies`, one
|
|
48
|
-
* the same projects and lockfile nodes): an
|
|
49
|
-
* to its npm node, a workspace member
|
|
50
|
-
* that member's node, and a package that resolves to no node
|
|
51
|
-
* exactly as Nx skips it.
|
|
94
|
+
* The edges of every published bun lock-scope and runtime-scope node. A
|
|
95
|
+
* manifest's dependencies are resolved exactly as Nx resolves a project's own
|
|
96
|
+
* package edges (`buildExplicitPackageJsonDependencies`, one
|
|
97
|
+
* `TargetProjectLocator` over the same projects and lockfile nodes): an
|
|
98
|
+
* installed package becomes an edge to its npm node, a workspace member an
|
|
99
|
+
* edge to that member's runtime node, and a package that resolves to no node
|
|
100
|
+
* is skipped exactly as Nx skips it. The lock-scope node takes every section,
|
|
101
|
+
* the runtime node all but devDependencies.
|
|
52
102
|
*/
|
|
53
103
|
export function bunLockDependencies(context) {
|
|
54
104
|
const externalNodes = context.externalNodes ?? {};
|
|
@@ -57,41 +107,214 @@ export function bunLockDependencies(context) {
|
|
|
57
107
|
nodes[name] = { name, type: data.projectType === 'application' ? 'app' : 'lib', data };
|
|
58
108
|
}
|
|
59
109
|
const locator = new TargetProjectLocator(nodes, externalNodes);
|
|
60
|
-
const nodeOfMember = (member) => {
|
|
61
|
-
const root = context.projects[member]?.root;
|
|
62
|
-
return root === undefined ? null : bunLockNodeName(root);
|
|
63
|
-
};
|
|
64
110
|
const dependencies = [];
|
|
65
111
|
for (const project of Object.values(context.projects).sort((left, right) => left.root < right.root ? -1 : left.root > right.root ? 1 : 0)) {
|
|
66
|
-
const source = bunLockNodeName(project.root);
|
|
67
|
-
if (externalNodes[source] === undefined)
|
|
68
|
-
continue;
|
|
69
112
|
const manifestPath = posix.join(project.root, 'package.json');
|
|
70
113
|
if (!existsSync(join(context.workspaceRoot, manifestPath)))
|
|
71
114
|
continue;
|
|
72
115
|
const manifest = readJsonFile(join(context.workspaceRoot, manifestPath));
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
116
|
+
for (const [source, sections] of [
|
|
117
|
+
[bunLockNodeName(project.root), DEPENDENCY_SECTIONS],
|
|
118
|
+
[bunLockRuntimeNodeName(project.root), RUNTIME_SECTIONS],
|
|
119
|
+
]) {
|
|
120
|
+
if (externalNodes[source] === undefined)
|
|
77
121
|
continue;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
122
|
+
const targets = new Set();
|
|
123
|
+
for (const [name, specifier] of declaredSpecifiers(manifest, sections)) {
|
|
124
|
+
const member = locator.findDependencyInWorkspaceProjects(manifestPath, name, specifier);
|
|
125
|
+
const memberRoot = member === null ? undefined : context.projects[member]?.root;
|
|
126
|
+
const target = member === null
|
|
127
|
+
? locator.findNpmProjectFromImport(name, manifestPath)
|
|
128
|
+
: memberRoot === undefined
|
|
129
|
+
? null
|
|
130
|
+
: bunLockRuntimeNodeName(memberRoot);
|
|
131
|
+
if (target !== null && target !== source && externalNodes[target] !== undefined)
|
|
132
|
+
targets.add(target);
|
|
133
|
+
}
|
|
134
|
+
for (const target of [...targets].sort()) {
|
|
135
|
+
dependencies.push({ source, target, type: DependencyType.static });
|
|
81
136
|
}
|
|
82
137
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
138
|
+
}
|
|
139
|
+
return dependencies;
|
|
140
|
+
}
|
|
141
|
+
/** The package a bare specifier names: its scope and name, without the subpath. */
|
|
142
|
+
export function specifierPackage(specifier) {
|
|
143
|
+
const parts = specifier.split('/');
|
|
144
|
+
return (specifier.startsWith('@') ? parts.slice(0, 2) : parts.slice(0, 1)).join('/');
|
|
145
|
+
}
|
|
146
|
+
/** The manifests at and above the workspace-relative `directory`, nearest first, ending with the root's. */
|
|
147
|
+
export function manifestsAbove(workspaceRoot, directory) {
|
|
148
|
+
const manifests = [];
|
|
149
|
+
for (let current = posix.normalize(directory === '' ? '.' : directory);; current = posix.dirname(current)) {
|
|
150
|
+
const path = join(workspaceRoot, current, 'package.json');
|
|
151
|
+
if (existsSync(path)) {
|
|
152
|
+
manifests.push({ root: current, declared: new Set(declaredSpecifiers(readJsonFile(path)).keys()) });
|
|
91
153
|
}
|
|
92
|
-
|
|
93
|
-
|
|
154
|
+
if (current === '.')
|
|
155
|
+
return manifests;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The `externalDependencies` entry that keys package `name` as a process loads
|
|
160
|
+
* it by name from a directory, given the manifests at and above it, nearest
|
|
161
|
+
* first; `null` when none declares it, so nothing on that path loads it. Node's
|
|
162
|
+
* lookup walks the directory's ancestors' `node_modules`, and bun's isolated
|
|
163
|
+
* linker links into each exactly what its manifest declares, so the nearest
|
|
164
|
+
* declaring manifest decides what loads. A member's declaration is keyed by its
|
|
165
|
+
* lock-scope node. The root's is named by itself, and Nx keys that package's
|
|
166
|
+
* node and what it reaches: the root's node would key the whole of the root's
|
|
167
|
+
* tooling.
|
|
168
|
+
*/
|
|
169
|
+
export function bunLoadScope(manifests, name) {
|
|
170
|
+
const declaring = manifests.find((manifest) => manifest.declared.has(name));
|
|
171
|
+
if (declaring === undefined)
|
|
172
|
+
return null;
|
|
173
|
+
return declaring.root === '.' ? name : bunLockNodeName(declaring.root);
|
|
174
|
+
}
|
|
175
|
+
/** The lock scope of each package load, from the manifests above its directory; sorted, each once. */
|
|
176
|
+
export function bunLoadScopes(workspaceRoot, loads) {
|
|
177
|
+
const manifests = new Map();
|
|
178
|
+
const scopes = new Set();
|
|
179
|
+
for (const { directory, name } of loads) {
|
|
180
|
+
let above = manifests.get(directory);
|
|
181
|
+
if (above === undefined) {
|
|
182
|
+
above = manifestsAbove(workspaceRoot, directory);
|
|
183
|
+
manifests.set(directory, above);
|
|
94
184
|
}
|
|
185
|
+
const scope = bunLoadScope(above, name);
|
|
186
|
+
if (scope !== null)
|
|
187
|
+
scopes.add(scope);
|
|
95
188
|
}
|
|
96
|
-
return
|
|
189
|
+
return [...scopes].sort();
|
|
190
|
+
}
|
|
191
|
+
/** A target's one `externalDependencies` input: its project's lock-scope node first, then each other scope once, sorted. */
|
|
192
|
+
export function bunScopeInput(projectRoot, ...scopes) {
|
|
193
|
+
const own = bunLockNodeName(projectRoot);
|
|
194
|
+
return { externalDependencies: [own, ...[...new Set(scopes.flat())].filter((scope) => scope !== own).sort()] };
|
|
195
|
+
}
|
|
196
|
+
/** The input keying every package of `names` a process loads by name from the directory `manifests` stand above. */
|
|
197
|
+
export function bunLoadInput(manifests, names) {
|
|
198
|
+
const scopes = new Set();
|
|
199
|
+
for (const name of names) {
|
|
200
|
+
const scope = bunLoadScope(manifests, name);
|
|
201
|
+
if (scope !== null)
|
|
202
|
+
scopes.add(scope);
|
|
203
|
+
}
|
|
204
|
+
return { externalDependencies: [...scopes].sort() };
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The packages a TypeScript compile in a directory loads by name beyond its
|
|
208
|
+
* sources' imports: every `@types` package a manifest at or above it declares
|
|
209
|
+
* (TypeScript includes each ancestor's `node_modules/@types` unless the config
|
|
210
|
+
* lists `types`, a narrower set), and the `tslib` an `importHelpers` compile
|
|
211
|
+
* resolves.
|
|
212
|
+
*/
|
|
213
|
+
export function typescriptLoads(manifests) {
|
|
214
|
+
const names = new Set(['tslib']);
|
|
215
|
+
for (const manifest of manifests) {
|
|
216
|
+
for (const name of manifest.declared) {
|
|
217
|
+
if (name.startsWith('@types/'))
|
|
218
|
+
names.add(name);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return [...names].sort();
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The npm packages each workspace member's sources import (Nx's own `static`
|
|
225
|
+
* and `dynamic` edges) that its lock-scope node does not reach. Node loads such
|
|
226
|
+
* a package through an ancestor's `node_modules`, the root's, and the
|
|
227
|
+
* project's targets, keyed on the member's own closure, would miss it. The
|
|
228
|
+
* root's project is exempt: its node reaches everything its manifest declares.
|
|
229
|
+
* So is a `@types` package: TypeScript loads it by ancestry, not Node, and
|
|
230
|
+
* every TypeScript target keys the `@types` the manifests above it declare
|
|
231
|
+
* ({@link typescriptLoads}). A package is compared by name and version, never
|
|
232
|
+
* by node name: Nx publishes a hoisted package as both `npm:<name>` and
|
|
233
|
+
* `npm:<name>@<version>`, and its locator resolves a declaration and an
|
|
234
|
+
* import to either ({@link bunVersionAliasDependencies}).
|
|
235
|
+
*/
|
|
236
|
+
export function undeclaredImports(graph) {
|
|
237
|
+
const externalNodes = graph.externalNodes ?? {};
|
|
238
|
+
const identity = (name) => {
|
|
239
|
+
const node = externalNodes[name];
|
|
240
|
+
return node?.type === 'npm' ? `${node.data.packageName}@${node.data.version}` : null;
|
|
241
|
+
};
|
|
242
|
+
const namesOf = new Map();
|
|
243
|
+
for (const name of Object.keys(externalNodes)) {
|
|
244
|
+
const key = identity(name);
|
|
245
|
+
if (key !== null)
|
|
246
|
+
namesOf.set(key, [...(namesOf.get(key) ?? []), name]);
|
|
247
|
+
}
|
|
248
|
+
const findings = [];
|
|
249
|
+
for (const [project, node] of Object.entries(graph.nodes).sort(([left], [right]) => (left < right ? -1 : 1))) {
|
|
250
|
+
const scope = bunLockNodeName(node.data.root);
|
|
251
|
+
if (scope === BUN_ROOT_LOCK_NODE || externalNodes[scope] === undefined)
|
|
252
|
+
continue;
|
|
253
|
+
const reached = new Set();
|
|
254
|
+
for (let pending = [scope]; pending.length > 0;) {
|
|
255
|
+
const next = [];
|
|
256
|
+
for (const name of pending) {
|
|
257
|
+
if (reached.has(name))
|
|
258
|
+
continue;
|
|
259
|
+
reached.add(name);
|
|
260
|
+
for (const edge of graph.dependencies[name] ?? [])
|
|
261
|
+
next.push(edge.target);
|
|
262
|
+
const key = identity(name);
|
|
263
|
+
if (key !== null)
|
|
264
|
+
next.push(...(namesOf.get(key) ?? []));
|
|
265
|
+
}
|
|
266
|
+
pending = next;
|
|
267
|
+
}
|
|
268
|
+
const missing = new Set();
|
|
269
|
+
for (const edge of graph.dependencies[project] ?? []) {
|
|
270
|
+
if (edge.type === DependencyType.implicit)
|
|
271
|
+
continue;
|
|
272
|
+
const external = externalNodes[edge.target];
|
|
273
|
+
if (external === undefined || external.type !== 'npm' || reached.has(edge.target))
|
|
274
|
+
continue;
|
|
275
|
+
if (external.data.packageName.startsWith('@types/'))
|
|
276
|
+
continue;
|
|
277
|
+
missing.add(external.data.packageName);
|
|
278
|
+
}
|
|
279
|
+
for (const packageName of [...missing].sort())
|
|
280
|
+
findings.push({ project, root: node.data.root, packageName });
|
|
281
|
+
}
|
|
282
|
+
return findings;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* An edge from each unversioned npm node to the versioned node of the same
|
|
286
|
+
* package and version. Nx's bun lockfile parser publishes a hoisted package as
|
|
287
|
+
* both `npm:<name>` and `npm:<name>@<version>`, with one integrity, and links
|
|
288
|
+
* only the versioned node to the package's dependencies. A key on the
|
|
289
|
+
* unversioned node (an `externalDependencies` entry naming a package, or a
|
|
290
|
+
* lock-scope edge the locator resolved to it) then held the package's own
|
|
291
|
+
* integrity and none of its closure; through this edge it holds both.
|
|
292
|
+
*/
|
|
293
|
+
export function bunVersionAliasDependencies(externalNodes) {
|
|
294
|
+
const dependencies = [];
|
|
295
|
+
for (const [name, node] of Object.entries(externalNodes)) {
|
|
296
|
+
if (node.type !== 'npm')
|
|
297
|
+
continue;
|
|
298
|
+
const target = `npm:${node.data.packageName}@${node.data.version}`;
|
|
299
|
+
const versioned = externalNodes[target];
|
|
300
|
+
if (target === name || versioned?.type !== 'npm' || versioned.data.version !== node.data.version)
|
|
301
|
+
continue;
|
|
302
|
+
dependencies.push({ source: name, target, type: DependencyType.static });
|
|
303
|
+
}
|
|
304
|
+
return dependencies.sort((left, right) => (left.source < right.source ? -1 : left.source > right.source ? 1 : 0));
|
|
305
|
+
}
|
|
306
|
+
export class UndeclaredImportError extends Error {
|
|
307
|
+
findings;
|
|
308
|
+
constructor(findings) {
|
|
309
|
+
super('Workspace members import packages their package.json does not declare. Node loads each through the root' +
|
|
310
|
+
"'s node_modules, and no lock-scope node of the member keys it; declare each in the member's package.json:\n" +
|
|
311
|
+
findings.map(({ project, root, packageName }) => ` ${project} (${root}): ${packageName}`).join('\n'));
|
|
312
|
+
this.findings = findings;
|
|
313
|
+
this.name = 'UndeclaredImportError';
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
export function refuseUndeclaredImports(graph) {
|
|
317
|
+
const findings = undeclaredImports(graph);
|
|
318
|
+
if (findings.length > 0)
|
|
319
|
+
throw new UndeclaredImportError(findings);
|
|
97
320
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProjectGraphExternalNode, TargetConfiguration } from 'nx/src/devkit-exports.js';
|
|
2
|
-
import { type CargoResolve, type CompiledCargoInput } from './cargo-source-hash.js';
|
|
2
|
+
import { type CargoResolve, type CargoSourceIndex, type CompiledCargoInput } from './cargo-source-hash.js';
|
|
3
3
|
/**
|
|
4
4
|
* The named input the plugin infers for every project with crates of a Cargo
|
|
5
5
|
* workspace under its root: the mutable sources of the Cargo-resolved
|
|
@@ -32,20 +32,22 @@ export interface CargoClosureSource {
|
|
|
32
32
|
readonly cargo: CargoResolve;
|
|
33
33
|
/** Every `Cargo.toml` in Nx's file index, relative to the workspace root. */
|
|
34
34
|
readonly indexed: ReadonlySet<string>;
|
|
35
|
+
/** The Rust sources and packages of Nx's file index the compiled-in scan reads. */
|
|
36
|
+
readonly sources: CargoSourceIndex;
|
|
35
37
|
readonly compiledFilesCache: Map<string, CompiledCargoInput[]>;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
|
-
*
|
|
39
|
-
* applied, `node_modules` never entered. A package whose manifest is missing
|
|
40
|
-
*
|
|
40
|
+
* The Cargo manifests and Rust sources of Nx's workspace file index, with Nx's content hash of each source:
|
|
41
|
+
* .gitignore and .nxignore applied, `node_modules` never entered. A package whose manifest is missing here has no
|
|
42
|
+
* files a fileset input can hash. Scans of source texts no longer indexed are forgotten here.
|
|
41
43
|
*/
|
|
42
|
-
export declare function
|
|
44
|
+
export declare function indexedCargoSources(workspaceRoot: string): Promise<CargoSourceIndex>;
|
|
43
45
|
/**
|
|
44
46
|
* Content-keyed locked offline metadata. A refusal fails graph inference:
|
|
45
47
|
* a stale closure or runtime whole-workspace fallback cannot establish the
|
|
46
48
|
* precise set of cache inputs.
|
|
47
49
|
*/
|
|
48
|
-
export declare function resolveCargoClosureSource(manifest: string, workspaceRoot: string, indexed: Promise<
|
|
50
|
+
export declare function resolveCargoClosureSource(manifest: string, workspaceRoot: string, indexed: Promise<CargoSourceIndex>, compiledFilesCache: Map<string, CompiledCargoInput[]>): Promise<CargoClosureSource>;
|
|
49
51
|
/**
|
|
50
52
|
* The `cargoClosure` definition for the project at `projectRoot`: for each
|
|
51
53
|
* Cargo workspace with crates under it, the resolve closure of those crates,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo-closure-input.d.ts","sourceRoot":"","sources":["../src/cargo-closure-input.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE9F,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"cargo-closure-input.d.ts","sourceRoot":"","sources":["../src/cargo-closure-input.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,w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BAAgB,CAAC,CAK1F;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAClC,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,GACpD,OAAO,CAAC,kBAAkB,CAAC,CAI7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,OAAO,CAAC,KAAK,EAAE,CAAC,CAgBlB;AAgGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,OAAO,CAAC,wBAAwB,CAAC,CAwBnC;AACD,wHAAwH;AACxH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAMlH"}
|
|
@@ -2,9 +2,9 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { realpath } from 'node:fs/promises';
|
|
3
3
|
import { isAbsolute, join, posix, relative, sep } from 'node:path';
|
|
4
4
|
import { CARGO_ANCESTOR_INPUTS } from '@smoothbricks/cargo-retain/cargo-ancestor-inputs';
|
|
5
|
-
import { compiledInFiles, dependencyClosure, HASH_SKIPPED_DIRECTORIES, readCargoResolve, } from './cargo-source-hash.js';
|
|
5
|
+
import { cargoSourceIndex, compiledInFiles, dependencyClosure, HASH_SKIPPED_DIRECTORIES, readCargoResolve, retainIncludeScans, } from './cargo-source-hash.js';
|
|
6
6
|
import { runtimeInput, shellWord } from './runtime-input.js';
|
|
7
|
-
import { globIndexedFiles } from './workspace-index.js';
|
|
7
|
+
import { globIndexedFiles, indexedFileData } from './workspace-index.js';
|
|
8
8
|
/**
|
|
9
9
|
* The named input the plugin infers for every project with crates of a Cargo
|
|
10
10
|
* workspace under its root: the mutable sources of the Cargo-resolved
|
|
@@ -51,12 +51,15 @@ const SKIPPED_TREES = `**/{${HASH_SKIPPED_DIRECTORIES.join(',')}}/**`;
|
|
|
51
51
|
/** A path holding any of these would be read as a pattern, not as itself. */
|
|
52
52
|
const GLOB_SYNTAX = /[*?[\]{}()!,]/;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
* applied, `node_modules` never entered. A package whose manifest is missing
|
|
56
|
-
*
|
|
54
|
+
* The Cargo manifests and Rust sources of Nx's workspace file index, with Nx's content hash of each source:
|
|
55
|
+
* .gitignore and .nxignore applied, `node_modules` never entered. A package whose manifest is missing here has no
|
|
56
|
+
* files a fileset input can hash. Scans of source texts no longer indexed are forgotten here.
|
|
57
57
|
*/
|
|
58
|
-
export async function
|
|
59
|
-
|
|
58
|
+
export async function indexedCargoSources(workspaceRoot) {
|
|
59
|
+
const [root, files] = await Promise.all([realpath(workspaceRoot), indexedFileData(workspaceRoot)]);
|
|
60
|
+
const index = cargoSourceIndex(root, files);
|
|
61
|
+
retainIncludeScans(index);
|
|
62
|
+
return index;
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
65
|
* Content-keyed locked offline metadata. A refusal fails graph inference:
|
|
@@ -64,9 +67,9 @@ export async function indexedCargoManifests(workspaceRoot) {
|
|
|
64
67
|
* precise set of cache inputs.
|
|
65
68
|
*/
|
|
66
69
|
export async function resolveCargoClosureSource(manifest, workspaceRoot, indexed, compiledFilesCache) {
|
|
67
|
-
const [root,
|
|
68
|
-
const cargo = await readCargoResolve(join(root, manifest), root,
|
|
69
|
-
return { manifest, workspaceRoot, root, cargo, indexed:
|
|
70
|
+
const [root, sources] = await Promise.all([realpath(workspaceRoot), indexed]);
|
|
71
|
+
const cargo = await readCargoResolve(join(root, manifest), root, sources.manifests);
|
|
72
|
+
return { manifest, workspaceRoot, root, cargo, indexed: sources.manifests, sources, compiledFilesCache };
|
|
70
73
|
}
|
|
71
74
|
/**
|
|
72
75
|
* The `cargoClosure` definition for the project at `projectRoot`: for each
|
|
@@ -135,7 +138,7 @@ async function workspaceClosureInputs(projectRoot, source) {
|
|
|
135
138
|
if (!indexed.has(posix.join(directory, 'Cargo.toml'))) {
|
|
136
139
|
throw new Error(`the Cargo package ${directory} is not in Nx's file index (an ignored directory)`);
|
|
137
140
|
}
|
|
138
|
-
for (const compiled of compiledInFiles(pkg.directory, source.compiledFilesCache)) {
|
|
141
|
+
for (const compiled of compiledInFiles(pkg.directory, source.sources, source.compiledFilesCache)) {
|
|
139
142
|
const file = indexablePath(root, compiled.file);
|
|
140
143
|
if (file === null)
|
|
141
144
|
throw new Error(`${directory} compiles ${compiled.file}, which Nx's file index cannot hold`);
|
|
@@ -239,7 +242,7 @@ export async function cargoLockNode(directory, sources) {
|
|
|
239
242
|
const paths = new Map(cargo.local.map((pkg) => [pkg.id, `path:${pkg.name}`]));
|
|
240
243
|
const label = (id) => paths.get(id) ?? id;
|
|
241
244
|
const rows = [...closure]
|
|
242
|
-
.map(([id, built]) => [label(id), cargo.
|
|
245
|
+
.map(([id, built]) => [label(id), cargo.pinned.get(id)?.source ?? '', ...built.map(label).sort()].join('\t'))
|
|
243
246
|
.sort();
|
|
244
247
|
hash.update(`${source.manifest}\n${rows.join('\n')}\n\0`);
|
|
245
248
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly pkg: string;
|
|
4
|
-
/** Cargo builds this dependency for the dependent's tests, examples and benches only. */
|
|
5
|
-
readonly devOnly: boolean;
|
|
6
|
-
}
|
|
7
|
-
/** Every package Cargo builds for a selection, by package id, each with the dependencies Cargo builds for it. */
|
|
8
|
-
export type CargoClosure = ReadonlyMap<string, readonly string[]>;
|
|
1
|
+
import { type CargoClosure, type CargoEdge, type PinnedCargoPackage } from '@smoothbricks/build-inputs/cargo-closure';
|
|
2
|
+
import { type FileData } from 'nx/src/native/index.js';
|
|
9
3
|
/** A mutable (path) package in Cargo's locked resolve. Every path is canonical. */
|
|
10
4
|
export interface LocalCargoPackage {
|
|
11
5
|
readonly id: string;
|
|
@@ -24,11 +18,8 @@ export interface CargoResolve {
|
|
|
24
18
|
/** The workspace's own members: `root`'s manifest governs each of them. */
|
|
25
19
|
readonly members: ReadonlySet<string>;
|
|
26
20
|
readonly local: readonly LocalCargoPackage[];
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
* dependency names the locked commit that the id alone does not.
|
|
30
|
-
*/
|
|
31
|
-
readonly locked: ReadonlyMap<string, string>;
|
|
21
|
+
/** Every package Cargo.lock pins (registry, git, alternate registry), by package id. */
|
|
22
|
+
readonly pinned: ReadonlyMap<string, PinnedCargoPackage>;
|
|
32
23
|
/** Every dependency edge by package id, or null when Cargo reported no resolution. */
|
|
33
24
|
readonly edges: ReadonlyMap<string, readonly CargoEdge[]> | null;
|
|
34
25
|
}
|
|
@@ -85,14 +76,6 @@ export declare function hashCargoPathInputs(manifestPath: string, workspaceRoot:
|
|
|
85
76
|
* selected.
|
|
86
77
|
*/
|
|
87
78
|
export declare function dependencyClosure(cargo: CargoResolve, directory: string): Promise<CargoClosure>;
|
|
88
|
-
/**
|
|
89
|
-
* The packages Cargo compiles to build, test or run the `selected` ones, each with the dependencies Cargo builds for
|
|
90
|
-
* it. A selected package's targets reach every dependency kind: its library and binaries the normal ones, its build
|
|
91
|
-
* script the build ones, its tests, examples and benches the dev ones. Below the selection Cargo builds a package for
|
|
92
|
-
* its library and build script alone, so a dependency's own dev-dependencies never compile into a selected package's
|
|
93
|
-
* binaries and are not part of what it builds.
|
|
94
|
-
*/
|
|
95
|
-
export declare function buildClosure(cargo: CargoResolve, selected: readonly string[]): CargoClosure;
|
|
96
79
|
/** A compiled-in value, with the source spelling that identifies it across checkouts. */
|
|
97
80
|
export interface CompiledCargoInput {
|
|
98
81
|
readonly file: string;
|
|
@@ -100,9 +83,27 @@ export interface CompiledCargoInput {
|
|
|
100
83
|
readonly literal: string;
|
|
101
84
|
}
|
|
102
85
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
86
|
+
* The Rust sources and Cargo packages of Nx's workspace file index (.gitignore and .nxignore applied, as for every
|
|
87
|
+
* fileset input), canonical and absolute. A graph computation takes a package's sources and nested packages from
|
|
88
|
+
* here, so it lists no directory and probes no path for a manifest.
|
|
89
|
+
*/
|
|
90
|
+
export interface CargoSourceIndex {
|
|
91
|
+
/** Every `Cargo.toml` in the index, relative to the workspace root. */
|
|
92
|
+
readonly manifests: ReadonlySet<string>;
|
|
93
|
+
/** Every directory holding an indexed `Cargo.toml`. */
|
|
94
|
+
readonly packageDirectories: ReadonlySet<string>;
|
|
95
|
+
/** Nx's content hash of every indexed `.rs` file. */
|
|
96
|
+
readonly rustSources: ReadonlyMap<string, string>;
|
|
97
|
+
}
|
|
98
|
+
/** {@link CargoSourceIndex} of Nx's file data (workspace-relative paths and content hashes) under the canonical `root`. */
|
|
99
|
+
export declare function cargoSourceIndex(root: string, files: Iterable<FileData>): CargoSourceIndex;
|
|
100
|
+
/** Forgets the scan of every source text `index` no longer holds. */
|
|
101
|
+
export declare function retainIncludeScans(index: CargoSourceIndex): void;
|
|
102
|
+
/**
|
|
103
|
+
* Existing literal include_str!/include_bytes! files read by this package's Rust sources, as Nx's file index holds
|
|
104
|
+
* them: a generated (ignored) source is its producer's output and keys a consumer through its dependency outputs.
|
|
105
|
+
* One graph owns the memo; runtime hashing consumes the same discovery alongside source bytes. Nested packages own
|
|
106
|
+
* their sources separately. Computed paths remain explicit inputs.
|
|
106
107
|
*/
|
|
107
|
-
export declare function compiledInFiles(root: string, cache: Map<string, CompiledCargoInput[]>): CompiledCargoInput[];
|
|
108
|
+
export declare function compiledInFiles(root: string, index: CargoSourceIndex, cache: Map<string, CompiledCargoInput[]>): CompiledCargoInput[];
|
|
108
109
|
//# sourceMappingURL=cargo-source-hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo-source-hash.d.ts","sourceRoot":"","sources":["../src/cargo-source-hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cargo-source-hash.d.ts","sourceRoot":"","sources":["../src/cargo-source-hash.ts"],"names":[],"mappings":"AAkBA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,SAAS,EAId,KAAK,kBAAkB,EAGxB,MAAM,0CAA0C,CAAC;AAElD,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAU/D,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iHAAiH;IACjH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAED,kGAAkG;AAClG,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACzD,sFAAsF;IACtF,QAA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