Skip to content

Commit 10501ff

Browse files
committed
fix: preserve all snapshot packages when pushing config
Previously only packages matching the openboot catalog were stored (via catalog_match.matched), silently dropping custom installs like ack, awscli, copilot-cli. Now reads directly from snapshot.packages.* so every installed package is preserved regardless of catalog membership.
1 parent 1f6eb16 commit 10501ff

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,22 @@ export const POST: RequestHandler = async ({ platform, cookies, request }) => {
3838
return json({ error: 'Snapshot payload too large (max 100KB)' }, { status: 400 });
3939
}
4040

41-
const matchedNames: string[] = snapshot.catalog_match?.matched || [];
4241
const base_preset = snapshot.matched_preset || 'developer';
4342

44-
// Convert plain string names from CLI snapshot into typed package objects
45-
const snapshotCasks = new Set<string>(snapshot.packages?.casks || []);
46-
const snapshotNpm = new Set<string>(snapshot.packages?.npm || []);
47-
const packages = matchedNames.map((name: string) => {
48-
if (snapshotCasks.has(name)) return { name, type: 'cask' };
49-
if (snapshotNpm.has(name)) return { name, type: 'npm' };
50-
return { name, type: 'formula' };
51-
});
43+
// Build typed package objects from the full snapshot.
44+
// catalog_match.matched only contains packages known to the catalog; custom
45+
// packages (e.g. ack, awscli) would be silently dropped if we relied on it.
46+
// Instead, read directly from snapshot.packages.* so every installed package
47+
// is preserved regardless of whether it appears in the catalog.
48+
const snapshotFormulae: string[] = snapshot.packages?.formulae || [];
49+
const snapshotCasks: string[] = snapshot.packages?.casks || [];
50+
const snapshotNpm: string[] = snapshot.packages?.npm || [];
51+
52+
const packages = [
53+
...snapshotFormulae.map((name: string) => ({ name, type: 'formula' })),
54+
...snapshotCasks.map((name: string) => ({ name, type: 'cask' })),
55+
...snapshotNpm.map((name: string) => ({ name, type: 'npm' })),
56+
];
5257

5358
const pv = validatePackages(packages);
5459
if (!pv.valid) return json({ error: pv.error }, { status: 400 });

0 commit comments

Comments
 (0)