Skip to content

Commit c049afd

Browse files
committed
feat(snapshot): accept bun globals from CLI publish payload
- Read `snapshot.packages.bun` from the upload body - Bucket bun globals as `type: 'npm'` in the typed packages array so the downstream alias/install endpoints (which only special-case `npm` and `cask`) install them via `npm install -g` from the same registry, rather than misrouting them to `brew install` - Dedupe against existing npm entries - Bun provenance preserved in the raw `snapshot.packages.bun` blob for future UI work
1 parent b69df5e commit c049afd

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/routes/api/configs/from-snapshot/+server.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const POST: RequestHandler = async ({ platform, cookies, request }) => {
5555
const base_preset = snapshot.matched_preset || 'developer';
5656

5757
// Validate snapshot.packages is the canonical structured format:
58-
// { formulae: string[], casks: string[], taps: string[], npm: string[] }
58+
// { formulae: string[], casks: string[], taps: string[], npm: string[], bun?: string[] }
5959
if (!snapshot.packages || typeof snapshot.packages !== 'object' || Array.isArray(snapshot.packages)) {
6060
return json({ error: 'snapshot.packages must be an object with formulae, casks, taps, npm arrays' }, { status: 400 });
6161
}
@@ -66,6 +66,7 @@ export const POST: RequestHandler = async ({ platform, cookies, request }) => {
6666
const snapshotFormulae: string[] = snapshot.packages?.formulae || [];
6767
const snapshotCasks: string[] = snapshot.packages?.casks || [];
6868
const snapshotNpm: string[] = snapshot.packages?.npm || [];
69+
const snapshotBun: string[] = snapshot.packages?.bun || [];
6970
const snapshotTaps: string[] = snapshot.packages?.taps || [];
7071

7172
// Build a set of formula names that are already covered by a tap entry
@@ -81,12 +82,20 @@ export const POST: RequestHandler = async ({ platform, cookies, request }) => {
8182
}
8283
}
8384

85+
// Bun globals come from the npm registry and install fine via `npm install -g`,
86+
// so we bucket them with npm in the typed `packages` array (the canonical
87+
// downstream schema only special-cases `npm` and `cask`). Bun provenance is
88+
// still preserved in the raw `snapshot.packages.bun` blob for future use.
89+
const npmSet = new Set(snapshotNpm);
90+
const bunAsNpm = snapshotBun.filter((name) => !npmSet.has(name));
91+
8492
const packages = [
8593
...snapshotFormulae
8694
.filter((name) => !tapFormulaNames.has(name))
8795
.map((name) => ({ name, type: 'formula' })),
8896
...snapshotCasks.map((name) => ({ name, type: 'cask' })),
8997
...snapshotNpm.map((name) => ({ name, type: 'npm' })),
98+
...bunAsNpm.map((name) => ({ name, type: 'npm' })),
9099
...snapshotTaps.map((name) => ({ name, type: 'tap' })),
91100
];
92101

0 commit comments

Comments
 (0)