feat: new bundled plugins start on only if recommended, fetch missing shipped ones

This commit is contained in:
LukeGus committed 2026-11-04 15:30:14 -06:00
1 parent 9613b787a7
commit c7aa1c64b5
9 files changed
+240 -24

No files matched your search

@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import {
missingShippedPluginIds,
newShippedPluginIds,
startablePluginIds,
} from "../../plugins/boot-state.js";
@@ -38,3 +39,20 @@ describe("missingShippedPluginIds", () => {
expect(missingShippedPluginIds(records, present, new Set())).toEqual([]);
});
});
describe("newShippedPluginIds", () => {
it("lists shipped plugins the install never had and that are not on disk", () => {
expect(
newShippedPluginIds(
["new", "known", "here", "removed", "another"],
[{ id: "known" }],
new Set(["here"]),
new Set(["removed"]),
),
).toEqual(["another", "new"]);
});
it("finds nothing for an empty catalog", () => {
expect(newShippedPluginIds([], [], new Set(), new Set())).toEqual([]);
});
});
@@ -8,14 +8,18 @@ import {
isDefaultLookPlugin,
onboardingDefaults,
resetBundledIndexCache,
shippedCatalog,
} from "../../plugins/bundled-index.js";
let dir: string;
function writeIndex(plugins: Record<string, unknown>) {
function writeIndex(
plugins: Record<string, unknown>,
extra: Record<string, unknown> = {},
) {
fs.writeFileSync(
path.join(dir, "bundled-index.json"),
JSON.stringify({ version: 1, plugins }),
JSON.stringify({ version: 1, plugins, ...extra }),
);
resetBundledIndexCache();
}
@@ -89,9 +93,10 @@ describe("initialPluginState", () => {
});
});
it("enables every bundled plugin on an existing install", () => {
expect(initialPluginState("other", "bundled", false)).toBe("enabled");
expect(initialPluginState("ask", "bundled", false)).toBe("enabled");
it("enables only recommended plugins an existing install sees for the first time", () => {
expect(initialPluginState("kept", "bundled", false)).toBe("enabled");
expect(initialPluginState("other", "bundled", false)).toBe("disabled");
expect(initialPluginState("ask", "bundled", false)).toBe("disabled");
});
it("enables only recommended, non-consent plugins on a fresh install", () => {
@@ -106,6 +111,40 @@ describe("initialPluginState", () => {
});
});
describe("shippedCatalog", () => {
it("is empty for an index without a catalog", () => {
writeIndex({});
expect(shippedCatalog().size).toBe(0);
});
it("keeps the pins of the image's tier and smaller ones", () => {
writeIndex(
{},
{
profile: "standard",
catalog: {
look: { tier: "minimal", version: "1.0.0" },
ops: { tier: "standard", version: "1.0.0" },
big: { tier: "full", version: "2.0.0" },
odd: { tier: "huge" },
},
},
);
expect([...shippedCatalog().keys()].sort()).toEqual(["look", "ops"]);
});
it("follows a minimal image", () => {
writeIndex(
{},
{
profile: "minimal",
catalog: { look: { tier: "minimal" }, ops: { tier: "standard" } },
},
);
expect([...shippedCatalog().keys()]).toEqual(["look"]);
});
});
describe("default look", () => {
it("lists the plugins flagged as the default look", () => {
writeIndex({