import path from "node:path";
import { fileURLToPath } from "node:url";
import { installJavaPack } from "./java-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-java-engine.mjs [.engine-build/java]",
  );
}
const source = path.resolve(root, arguments_[0] ?? ".engine-build/java");
const result = await installJavaPack(source, root);
console.log(
  `Installed verified ${result.metadata.semanticIdentity} assets at ${result.output}.`,
);
