@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/link-remote.ts +28 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@10stars/config",
3
- "version": "17.0.4",
3
+ "version": "17.0.5",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "config": "./src/index.ts"
@@ -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
- const bunInstall = (cwd: string): void =>
61
- void execFileSync(`bun`, [`install`], { cwd, stdio: `inherit` })
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
- await Promise.all(level.map(visit)) // clone this level's siblings in parallel
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; leaves-first install order is still enforced below.
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
- installLeavesFirst(
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 siblings leaves-first (reverse of dependents-first discovery order) so a hoisted
292
- * sibling (e.g. `common`) is installed before a repo that links into it.
293
- * Assumes an acyclic, mostly-linear `file:` graph; a diamond could need a real topological sort.
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 installLeavesFirst = (cwd: string, siblingsInDiscoveryOrder: string[]): void => {
296
- for (const abs of [...siblingsInDiscoveryOrder].reverse()) {
297
- console.info(`linkRemote: bun install in ${path.relative(cwd, abs)}`)
298
- bunInstall(abs)
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` leaves-first. `--emit-manifest` records the exact
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
- installLeavesFirst(
335
+ await installSiblings(
324
336
  cwd,
325
337
  siblings.map((s) => s.abs),
326
338
  )