28 lines
967 B
JavaScript
28 lines
967 B
JavaScript
import { readFile } from "node:fs/promises";
|
|
import { join, resolve } from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
import { atomicWrite, networkSpec, readManifest } from "./finalize-manifest.mjs";
|
|
|
|
export async function selectManifest({ root = process.cwd(), network }) {
|
|
const spec = networkSpec(network);
|
|
const source = join(root, "deployments", spec.canonical);
|
|
await readManifest(source);
|
|
const contents = await readFile(source);
|
|
const active = join(root, "deployments", "active.json");
|
|
await atomicWrite(active, contents);
|
|
return { source, active };
|
|
}
|
|
|
|
async function main(argv) {
|
|
if (argv.length !== 1) throw new Error("usage: select-manifest.mjs <anvil|base-sepolia>");
|
|
return selectManifest({ network: argv[0] });
|
|
}
|
|
|
|
if (process.argv[1] && pathToFileURL(resolve(process.argv[1])).href === import.meta.url) {
|
|
main(process.argv.slice(2)).catch((error) => {
|
|
console.error(error.message);
|
|
process.exitCode = 1;
|
|
});
|
|
}
|