Release Time Tools 0.1.0
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { format } from "prettier";
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const sourcePath = path.join(root, "src/toolbox/manifest.source.json");
|
||||
const outputPath = path.join(root, "public/toolbox-app.json");
|
||||
const source = JSON.parse(await readFile(sourcePath, "utf8"));
|
||||
const pkg = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
|
||||
const versionSource = await readFile(path.join(root, "src/version.ts"), "utf8");
|
||||
const appVersion = /^export const APP_VERSION = "([^"]+)";$/mu.exec(
|
||||
versionSource,
|
||||
)?.[1];
|
||||
const repository = "https://git.add-ideas.de/lotobo/" + pkg.name;
|
||||
if (source.version !== pkg.version || appVersion !== pkg.version)
|
||||
throw new Error("Version identity drift");
|
||||
if (
|
||||
source.id !== "de.add-ideas." + pkg.name ||
|
||||
source.source?.repository !== repository ||
|
||||
source.source?.license !== "GPL-3.0-or-later"
|
||||
)
|
||||
throw new Error("Manifest source identity is invalid");
|
||||
const serialized = await format(JSON.stringify(source), {
|
||||
filepath: outputPath,
|
||||
});
|
||||
if (process.argv.includes("--check")) {
|
||||
if ((await readFile(outputPath, "utf8").catch(() => "")) !== serialized)
|
||||
throw new Error("public/toolbox-app.json is stale");
|
||||
console.log("Toolbox manifest is synchronized");
|
||||
} else {
|
||||
await writeFile(outputPath, serialized);
|
||||
console.log("Generated public/toolbox-app.json");
|
||||
}
|
||||
Reference in New Issue
Block a user