mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-23 17:52:49 +00:00
* feat(plugins): enforce declared Paseo version requirements Treat manifests without a Paseo requirement as pre-0.8 plugins so the first breaking plugin release offers an explicit migration path. Check the daemon and app independently before plugin execution, and preserve installed Git revisions when updates are incompatible. * fix(nix): refresh dependency hash for plugin requirements * refactor(plugins): validate test manifest inputs and name compatibility input
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { cp, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { z } from "zod";
|
|
import appPackage from "../../../package.json";
|
|
|
|
export const pluginRequirements = { paseo: `>=${appPackage.version}` };
|
|
|
|
export async function copyPluginExample(name: string) {
|
|
const directory = await mkdtemp(path.join(tmpdir(), "paseo-plugin-example-"));
|
|
try {
|
|
await cp(path.resolve(__dirname, "../../../../../plugin-examples", name), directory, {
|
|
recursive: true,
|
|
});
|
|
const manifestPath = path.join(directory, "paseo-plugin.json");
|
|
const manifest = z
|
|
.record(z.string(), z.unknown())
|
|
.parse(JSON.parse(await readFile(manifestPath, "utf8")));
|
|
// Exercise example UI against the checkout runtime before its release version is bumped.
|
|
await writeFile(
|
|
manifestPath,
|
|
JSON.stringify({ ...manifest, requirements: pluginRequirements }),
|
|
);
|
|
return { directory, cleanup: () => rm(directory, { recursive: true, force: true }) };
|
|
} catch (error) {
|
|
await rm(directory, { recursive: true, force: true });
|
|
throw error;
|
|
}
|
|
}
|