feat: publish Regex Tools 0.2.0
This commit is contained in:
@@ -1,8 +1,25 @@
|
||||
import { lstat, readFile, readdir } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { verifyPcre2Pack } from "./pcre2-engine-pack.mjs";
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const arguments_ = process.argv.slice(2);
|
||||
|
||||
if (arguments_.length > 0) {
|
||||
if (arguments_.length !== 2 || arguments_[0] !== "--pcre2-pack") {
|
||||
throw new Error(
|
||||
"Usage: node scripts/verify-engine-assets.mjs [--pcre2-pack PATH]",
|
||||
);
|
||||
}
|
||||
const pack = path.resolve(root, arguments_[1]);
|
||||
const metadata = await verifyPcre2Pack(pack, root);
|
||||
console.log(
|
||||
`Verified staged PCRE2 ${metadata.engineVersion} pack and WebAssembly bridge smoke test.`,
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const engineDirectory = path.join(root, "dist", "engines");
|
||||
const details = await lstat(engineDirectory);
|
||||
if (details.isSymbolicLink() || !details.isDirectory()) {
|
||||
@@ -14,21 +31,21 @@ const entries = (await readdir(engineDirectory, { withFileTypes: true })).sort(
|
||||
left.name < right.name ? -1 : left.name > right.name ? 1 : 0,
|
||||
);
|
||||
if (
|
||||
entries.length !== 1 ||
|
||||
entries.length !== 2 ||
|
||||
!entries[0]?.isFile() ||
|
||||
entries[0].name !== "README.md"
|
||||
entries[0].name !== "README.md" ||
|
||||
!entries[1]?.isDirectory() ||
|
||||
entries[1].name !== "pcre2"
|
||||
) {
|
||||
throw new Error(
|
||||
"Regex Tools 0.1.0 must not ship an undeclared external engine pack.",
|
||||
"The production build must contain only README.md and the declared PCRE2 pack.",
|
||||
);
|
||||
}
|
||||
|
||||
const notice = await readFile(path.join(engineDirectory, "README.md"), "utf8");
|
||||
if (
|
||||
!notice.includes("native `RegExp`") ||
|
||||
!notice.includes("no external engine")
|
||||
) {
|
||||
if (!notice.includes("native `RegExp`") || !notice.includes("PCRE2 10.47")) {
|
||||
throw new Error("The engine asset notice does not describe this release.");
|
||||
}
|
||||
await verifyPcre2Pack(path.join(engineDirectory, "pcre2"), root);
|
||||
|
||||
console.log("Verified ECMAScript-only engine assets (no WebAssembly pack).");
|
||||
console.log("Verified native ECMAScript and bundled PCRE2 engine assets.");
|
||||
|
||||
Reference in New Issue
Block a user