import path from "node:path";
import { fileURLToPath } from "node:url";
import { installPcre2Pack } from "./pcre2-engine-pack.mjs";

const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const arguments_ = process.argv.slice(2);
if (arguments_.length > 1) {
  throw new Error(
    "Usage: node scripts/install-pcre2-engine.mjs [.engine-build/pcre2]",
  );
}
const source = path.resolve(root, arguments_[0] ?? ".engine-build/pcre2");
const result = await installPcre2Pack(source, root);
console.log(
  `Installed verified PCRE2 ${result.metadata.engineVersion} runtime assets at ${result.output}.`,
);
