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 -1
View File
@@ -74,7 +74,7 @@ async function main() {
const staged = [...pinned, ...extra];
fs.writeFileSync(
path.join(destination, "bundled-index.json"),
`${JSON.stringify(buildBundledIndex(plugins, staged), null, 2)}
`${JSON.stringify(buildBundledIndex(plugins, staged, profile), null, 2)}
`,
);
+28 -1
View File
@@ -221,7 +221,34 @@ describe("buildBundledIndex", () => {
];
expect(buildBundledIndex(plugins, ["a", "c", "local"])).toEqual({
version: 1,
profile: "standard",
plugins: { a: { onboarding: { recommended: true, consent: false } } },
catalog: {
a: { tier: "full" },
b: { tier: "full" },
c: { tier: "full" },
},
});
});
it("lists every pin with its tier and version", () => {
const plugins = [
{
id: "a",
tier: "standard",
url: "https://example.com/v1.2.0/a-1.2.0.tmxplug",
onboarding: null,
},
{
id: "b",
tier: "minimal",
path: "x/b-2.0.0-beta.1.tmxplug",
onboarding: null,
},
];
expect(buildBundledIndex(plugins, [], "minimal").catalog).toEqual({
a: { tier: "standard", version: "1.2.0" },
b: { tier: "minimal", version: "2.0.0-beta.1" },
});
});
});
@@ -520,7 +547,7 @@ describe("default look", () => {
],
["look", "plain"],
),
).toEqual({ version: 1, plugins: { look: { defaultLook: true } } });
).toMatchObject({ version: 1, plugins: { look: { defaultLook: true } } });
const index = {
plugins: [
+13 -3
View File
@@ -236,12 +236,22 @@ async function extractArtifact(buffer, outDir, id) {
/**
* What dist/plugins/bundled-index.json holds: the onboarding defaults of each
* staged plugin, read by the backend when it seeds a fresh install.
* staged plugin, read by the backend when it seeds a fresh install, plus the
* profile and every pin it ships, so an existing install can fetch a shipped
* plugin it finds missing.
*/
function buildBundledIndex(plugins, stagedIds) {
function buildBundledIndex(plugins, stagedIds, profile = DEFAULT_PROFILE) {
const staged = new Set(stagedIds);
const out = {};
const catalog = {};
for (const plugin of plugins) {
const version = /-(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)\.tmxplug$/.exec(
plugin.url ?? plugin.path ?? "",
)?.[1];
catalog[plugin.id] = {
tier: plugin.tier ?? "full",
...(version ? { version } : {}),
};
if (!staged.has(plugin.id)) continue;
if (!plugin.onboarding && !plugin.defaultLook) continue;
out[plugin.id] = {
@@ -249,7 +259,7 @@ function buildBundledIndex(plugins, stagedIds) {
...(plugin.defaultLook ? { defaultLook: true } : {}),
};
}
return { version: 1, plugins: out };
return { version: 1, profile, plugins: out, catalog };
}
/** The profile to build: --profile, then TERMIX_PLUGIN_PROFILE, then standard. */