@10stars/config 17.0.4 → 17.0.5
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/package.json +1 -1
- package/src/link-remote.ts +28 -16
package/package.json
CHANGED
package/src/link-remote.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { promisify } from "node:util"
|
|
|
5
5
|
|
|
6
6
|
import type * as TF from "type-fest"
|
|
7
7
|
|
|
8
|
-
import { dedupeSingletons } from "./link-packages"
|
|
8
|
+
import { dedupeSingletons, linkSelf } from "./link-packages"
|
|
9
9
|
|
|
10
10
|
interface Config {
|
|
11
11
|
dedupeSingletons?: boolean | string[]
|
|
@@ -57,8 +57,16 @@ const tryGit = (args: string[], cwd?: string): string | null => {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
// --ignore-scripts: a sibling is only a dependency here, so skip its postinstall (`config prepare`)
|
|
61
|
+
// — its Vanilla-Extract patch isn't needed (nothing builds it; typecheck doesn't run VE) and the
|
|
62
|
+
// cross-repo `@types/*` dedupe runs once via the consumer's `dedupe` afterwards. We still restore
|
|
63
|
+
// the one thing a sibling's own src needs: its self-symlink, so `<self>/src/…` self-imports resolve
|
|
64
|
+
// at realpath in the flat-peer layout. (Workspace-root siblings, e.g. backend-api, get their
|
|
65
|
+
// subpackage self-links from bun's own workspace linking, so linkSelf no-ops on them.)
|
|
66
|
+
const bunInstall = async (cwd: string): Promise<void> => {
|
|
67
|
+
await execFileAsync(`bun`, [`install`, `--ignore-scripts`], { cwd })
|
|
68
|
+
await linkSelf(cwd)
|
|
69
|
+
}
|
|
62
70
|
|
|
63
71
|
const exists = (p: string): Promise<boolean> =>
|
|
64
72
|
fs
|
|
@@ -136,7 +144,8 @@ const bfsSiblings = async (
|
|
|
136
144
|
level.push(sib)
|
|
137
145
|
}
|
|
138
146
|
}
|
|
139
|
-
|
|
147
|
+
// clone this level's siblings in parallel; unbounded fan-out, fine for the handful in practice
|
|
148
|
+
await Promise.all(level.map(visit))
|
|
140
149
|
order.push(...level)
|
|
141
150
|
frontier = level
|
|
142
151
|
}
|
|
@@ -267,7 +276,7 @@ const linkRemoteFromManifest = async (cwd: string, manifestPath: string): Promis
|
|
|
267
276
|
}
|
|
268
277
|
|
|
269
278
|
// Pinned clones are mutually independent (each at a recorded SHA, no discovery), so materialize
|
|
270
|
-
// them all in parallel;
|
|
279
|
+
// them all in parallel; the installs below are likewise parallel and order-independent.
|
|
271
280
|
await Promise.all(
|
|
272
281
|
manifest.siblings.map(async (sib) => {
|
|
273
282
|
const abs = path.resolve(cwd, sib.path)
|
|
@@ -281,29 +290,32 @@ const linkRemoteFromManifest = async (cwd: string, manifestPath: string): Promis
|
|
|
281
290
|
}),
|
|
282
291
|
)
|
|
283
292
|
|
|
284
|
-
|
|
293
|
+
await installSiblings(
|
|
285
294
|
cwd,
|
|
286
295
|
manifest.siblings.map((s) => path.resolve(cwd, s.path)),
|
|
287
296
|
)
|
|
288
297
|
}
|
|
289
298
|
|
|
290
299
|
/**
|
|
291
|
-
* Install
|
|
292
|
-
*
|
|
293
|
-
*
|
|
300
|
+
* Install every cloned sibling, in parallel. `--ignore-scripts` (in bunInstall) removes the
|
|
301
|
+
* postinstall that used to make this order-sensitive, so ordering no longer matters: each install
|
|
302
|
+
* is independent — it resolves its own `file:` deps from their on-disk package.json and hoists into
|
|
303
|
+
* its OWN node_modules, writing nobody else's tree. (Bun's global cache is concurrency-safe.)
|
|
294
304
|
*/
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
305
|
+
const installSiblings = async (cwd: string, siblings: string[]): Promise<void> => {
|
|
306
|
+
await Promise.all(
|
|
307
|
+
siblings.map(async (abs) => {
|
|
308
|
+
console.info(`linkRemote: bun install in ${path.relative(cwd, abs)}`)
|
|
309
|
+
await bunInstall(abs)
|
|
310
|
+
}),
|
|
311
|
+
)
|
|
300
312
|
}
|
|
301
313
|
|
|
302
314
|
/**
|
|
303
315
|
* CI: materialize the transitive `file:` sibling graph that a standalone checkout lacks.
|
|
304
316
|
*
|
|
305
317
|
* Default (branch-first): BFS the graph, shallow single-branch clone each missing sibling at
|
|
306
|
-
* its resolved ref, then `bun install`
|
|
318
|
+
* its resolved ref, then `bun install --ignore-scripts` each in parallel. `--emit-manifest` records the exact
|
|
307
319
|
* {repo, ref, sha, version} set (a cross-repo lockfile snapshot for revert). `--from` skips
|
|
308
320
|
* branch-first and pin-clones each sibling at the manifest's recorded SHA.
|
|
309
321
|
*
|
|
@@ -320,7 +332,7 @@ export const linkRemote = async (cwd: string, opts: LinkRemoteOptions = {}): Pro
|
|
|
320
332
|
return
|
|
321
333
|
}
|
|
322
334
|
|
|
323
|
-
|
|
335
|
+
await installSiblings(
|
|
324
336
|
cwd,
|
|
325
337
|
siblings.map((s) => s.abs),
|
|
326
338
|
)
|