@smoothbricks/nx-plugin 0.4.24 → 0.4.26
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 +147 -37
- package/dist/bin/smoo-nx-exec.js +3 -14
- package/dist/cargo-closure-input.d.ts +13 -15
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +29 -37
- package/dist/cargo-source-hash.d.ts +12 -7
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +416 -32
- package/dist/cargo-workspace.d.ts +7 -7
- package/dist/cargo-workspace.js +8 -8
- package/dist/ensure-built.d.ts +6 -0
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +79 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -96
- package/dist/managed-assets.d.ts +6 -0
- package/dist/managed-assets.d.ts.map +1 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +6 -0
- package/dist/manifest-hash.d.ts.map +1 -1
- package/dist/manifest-hash.js +6 -2
- package/dist/workspace-manifest.d.ts +0 -1
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/managed/raw/envrc +15 -0
- package/managed/raw/git-format-staged.yml +1 -0
- package/managed/raw/tooling/direnv/developer-links.ts +43 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +5 -0
- package/managed/raw/tooling/direnv/inherited-devenv.ts +665 -0
- package/managed/raw/tooling/direnv/setup-environment.ts +123 -7
- package/nextest.toml +3 -37
- package/package.json +40 -3
- package/src/__tests__/counted-cargo-process.ts +286 -0
- package/src/__tests__/counted-cargo.ts +711 -0
- package/src/__tests__/fixture-cargo-home.ts +36 -0
- package/src/__tests__/fixture-nx-env.ts +93 -3
- package/src/bin/smoo-nx-exec.ts +3 -14
- package/src/bounded-test-policy.test.ts +0 -1
- package/src/cargo-closure-input.test.ts +313 -15
- package/src/cargo-closure-input.ts +42 -50
- package/src/cargo-resolve-cache.test.ts +975 -0
- package/src/cargo-source-hash.test.ts +17 -3
- package/src/cargo-source-hash.ts +447 -37
- package/src/cargo-workspace.ts +8 -8
- package/src/ensure-built.test.ts +122 -20
- package/src/ensure-built.ts +82 -5
- package/src/index.test.ts +203 -107
- package/src/index.ts +86 -115
- package/src/managed-assets.ts +12 -0
- package/src/managed-files/files.ts +6 -0
- package/src/manifest-hash.ts +7 -2
- package/src/nextest-partitions.test.ts +150 -0
- package/src/nx-cache-bound.test.ts +114 -0
- package/src/nx-resident-graph-workers.test.ts +121 -0
- package/src/nx-store-resolution.test.ts +98 -0
- package/src/task-history-namespace.test.ts +183 -0
- package/src/workspace-manifest.ts +0 -1
- package/test-timings.json +35 -0
- package/src/__tests__/in-process-nx-index.ts +0 -9
|
@@ -28,6 +28,16 @@
|
|
|
28
28
|
* before the install, with a warning, so that install puts the lockfile's
|
|
29
29
|
* version in its place.
|
|
30
30
|
*
|
|
31
|
+
* An install that exists to replace links says which: `{ relink }` names the
|
|
32
|
+
* packages (`name` or `@scope/name`) it is meant to relink, in the root's
|
|
33
|
+
* tree and in every member's. When the install resolves, what it left at
|
|
34
|
+
* those names stays (a `bun link` run against providers a developer
|
|
35
|
+
* registered anew) and every other developer link is put back as before.
|
|
36
|
+
* When it rejects, every link is put back, the named ones included, so a
|
|
37
|
+
* failed relink changes nothing. A named package with no developer link when
|
|
38
|
+
* the install starts has nothing to put back, and a named link that dangled
|
|
39
|
+
* is removed first, as for any install.
|
|
40
|
+
*
|
|
31
41
|
* Like secret-references.ts, this is a managed raw script: shell entry imports
|
|
32
42
|
* it before anything is installed, and `smoo monorepo update` loads the copy
|
|
33
43
|
* the nx-plugin ships. Because both use the one implementation, the shell and
|
|
@@ -42,9 +52,11 @@ import {
|
|
|
42
52
|
readFileSync,
|
|
43
53
|
readlinkSync,
|
|
44
54
|
rmSync,
|
|
55
|
+
statSync,
|
|
45
56
|
symlinkSync,
|
|
46
57
|
} from 'node:fs';
|
|
47
58
|
import path from 'node:path';
|
|
59
|
+
import type { KeepDeveloperLinksOptions } from '@smoothbricks/nx-plugin/managed-assets';
|
|
48
60
|
|
|
49
61
|
interface DeveloperLink {
|
|
50
62
|
/** Where the link is, relative to the project root. */
|
|
@@ -60,24 +72,40 @@ interface DeveloperLinks {
|
|
|
60
72
|
}
|
|
61
73
|
|
|
62
74
|
/**
|
|
63
|
-
* Runs `install`
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
75
|
+
* Runs `install` while preserving the developer links captured under `root`.
|
|
76
|
+
* On rejection every captured live link is restored, less links that already
|
|
77
|
+
* dangled; a resolved install keeps its selected `relink` replacements.
|
|
78
|
+
* This is not a transaction over new entries created by the install. Relink
|
|
79
|
+
* intent reports the actual final link state on either outcome.
|
|
67
80
|
*/
|
|
68
|
-
export async function keepDeveloperLinks<T>(
|
|
81
|
+
export async function keepDeveloperLinks<T>(
|
|
82
|
+
root: string,
|
|
83
|
+
install: () => Promise<T>,
|
|
84
|
+
options?: KeepDeveloperLinksOptions,
|
|
85
|
+
): Promise<T> {
|
|
69
86
|
const { live, dangling } = findDeveloperLinks(root);
|
|
70
87
|
for (const link of dangling) {
|
|
71
88
|
rmSync(path.join(root, link.path), { force: true });
|
|
72
89
|
console.error(`! removed developer link ${link.path}: its target ${resolvedTarget(root, link)} no longer exists`);
|
|
73
90
|
}
|
|
91
|
+
// Only an install that resolved leaves the links it was meant to replace as
|
|
92
|
+
// it made them; a rejected one puts every captured live link back.
|
|
93
|
+
let replaced: readonly string[] | undefined;
|
|
74
94
|
try {
|
|
75
|
-
|
|
95
|
+
const result = await install();
|
|
96
|
+
replaced = options?.relink;
|
|
97
|
+
return result;
|
|
76
98
|
} finally {
|
|
77
99
|
for (const link of live) {
|
|
78
|
-
|
|
100
|
+
if (!replaced?.length || !replaced.includes(packageName(link))) {
|
|
101
|
+
restoreLink(root, link);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (options !== undefined) {
|
|
105
|
+
reportDeveloperLinks(root);
|
|
106
|
+
} else {
|
|
107
|
+
describeDeveloperLinks(root, live);
|
|
79
108
|
}
|
|
80
|
-
describeDeveloperLinks(root, live);
|
|
81
109
|
}
|
|
82
110
|
}
|
|
83
111
|
|
|
@@ -93,6 +121,11 @@ export function reportDeveloperLinks(root: string): void {
|
|
|
93
121
|
describeDeveloperLinks(root, findDeveloperLinks(root).live);
|
|
94
122
|
}
|
|
95
123
|
|
|
124
|
+
/** The package a link stands for in its tree: `name` or `@scope/name`. */
|
|
125
|
+
function packageName(link: DeveloperLink): string {
|
|
126
|
+
return link.path.slice(link.path.lastIndexOf('node_modules/') + 'node_modules/'.length);
|
|
127
|
+
}
|
|
128
|
+
|
|
96
129
|
/** A package linked from many members is named once, with its count. */
|
|
97
130
|
function describeDeveloperLinks(root: string, links: readonly DeveloperLink[]): void {
|
|
98
131
|
if (links.length === 0) {
|
|
@@ -100,8 +133,7 @@ function describeDeveloperLinks(root: string, links: readonly DeveloperLink[]):
|
|
|
100
133
|
}
|
|
101
134
|
const counts = new Map<string, number>();
|
|
102
135
|
for (const link of links) {
|
|
103
|
-
const
|
|
104
|
-
const named = `${name} -> ${resolvedTarget(root, link)}`;
|
|
136
|
+
const named = `${packageName(link)} -> ${resolvedTarget(root, link)}`;
|
|
105
137
|
counts.set(named, (counts.get(named) ?? 0) + 1);
|
|
106
138
|
}
|
|
107
139
|
const entries = [...counts].map(([named, count]) => (count === 1 ? named : `${named} (${count} links)`));
|
|
@@ -117,7 +149,7 @@ function findDeveloperLinks(root: string): DeveloperLinks {
|
|
|
117
149
|
const target = resolvedTarget(root, link);
|
|
118
150
|
const relative = path.relative(root, target);
|
|
119
151
|
if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
120
|
-
(
|
|
152
|
+
(statSync(target, { throwIfNoEntry: false }) === undefined ? dangling : live).push(link);
|
|
121
153
|
}
|
|
122
154
|
}
|
|
123
155
|
}
|
|
@@ -386,6 +386,10 @@ in {
|
|
|
386
386
|
# a subprocess of either), and one socket dir for two workspaces makes the
|
|
387
387
|
# daemon refuse whichever came second ("received a message from a
|
|
388
388
|
# different workspace"). Nobody supplies this deliberately.
|
|
389
|
+
#
|
|
390
|
+
# In a cowshed sandbox an inherited private .devenv can supply the
|
|
391
|
+
# evaluated shell after its inputs and task graph are checked. The merged
|
|
392
|
+
# hook still runs only when direnv imports the workspace's own export.
|
|
389
393
|
(lib.mkBefore ''
|
|
390
394
|
cd "$DEVENV_ROOT/../.."
|
|
391
395
|
export PATH="$("$PWD/tooling/direnv/repo-path")"
|
|
@@ -416,6 +420,7 @@ in {
|
|
|
416
420
|
# workspace"), which reads as a hung Nx in a workspace that did nothing
|
|
417
421
|
# wrong. Nx's own diagnostic names this exact cause.
|
|
418
422
|
nx_workspace_root="$(cd "$DEVENV_ROOT/../.." >/dev/null 2>&1 && pwd || printf '%s' "$PWD")"
|
|
423
|
+
export NX_WORKSPACE_ROOT_PATH="$nx_workspace_root"
|
|
419
424
|
export NX_SOCKET_DIR="$DEVENV_RUNTIME/nx-$(printf '%s' "$nx_workspace_root" | cksum | cut -d' ' -f1)"
|
|
420
425
|
mkdir -p "$NX_SOCKET_DIR"
|
|
421
426
|
${lib.optionalString pkgs.stdenv.isDarwin ''
|