feat: publish Regex Tools 0.1.0
This commit is contained in:
42
scripts/generate-toolbox-manifest.mjs
Normal file
42
scripts/generate-toolbox-manifest.mjs
Normal file
@@ -0,0 +1,42 @@
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import { dirname, join, relative } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { format } from "prettier";
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const sourcePath = join(root, "src", "toolbox", "manifest.source.json");
|
||||
const outputPath = join(root, "public", "toolbox-app.json");
|
||||
const packagePath = join(root, "package.json");
|
||||
const checkOnly = process.argv.includes("--check");
|
||||
|
||||
const source = JSON.parse(await readFile(sourcePath, "utf8"));
|
||||
const packageJson = JSON.parse(await readFile(packagePath, "utf8"));
|
||||
|
||||
if (source.version !== packageJson.version) {
|
||||
throw new Error(
|
||||
`Manifest version ${source.version} differs from package version ${packageJson.version}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
source.source?.repository !== "https://git.add-ideas.de/zemion/regex-tools" ||
|
||||
source.source?.license !== "GPL-3.0-or-later"
|
||||
) {
|
||||
throw new Error("Manifest source identity is incomplete or inconsistent");
|
||||
}
|
||||
|
||||
const serialized = await format(JSON.stringify(source), {
|
||||
filepath: outputPath,
|
||||
});
|
||||
if (checkOnly) {
|
||||
const current = await readFile(outputPath, "utf8").catch(() => "");
|
||||
if (current !== serialized) {
|
||||
throw new Error(
|
||||
`${relative(root, outputPath)} is stale; run npm run manifest:generate`,
|
||||
);
|
||||
}
|
||||
console.log("Toolbox manifest is synchronized");
|
||||
} else {
|
||||
await writeFile(outputPath, serialized);
|
||||
console.log(`Generated ${relative(root, outputPath)}`);
|
||||
}
|
||||
Reference in New Issue
Block a user