| 1 | import { execFileSync } from "node:child_process"; |
| 2 | import { readdirSync } from "node:fs"; |
| 3 | import path from "node:path"; |
| 4 | import { publishPackages } from "./publish.mjs"; |
| 5 | |
| 6 | const [directory, version, candidateSha] = process.argv.slice(2); |
| 7 | if (!directory || !version || !candidateSha) { |
| 8 | throw new Error("usage: publish-candidate.mjs DIRECTORY VERSION CANDIDATE_SHA"); |
| 9 | } |
| 10 | |
| 11 | const packages = readdirSync(directory) |
| 12 | .filter(name => name.endsWith(".tgz")) |
| 13 | .sort() |
| 14 | .map(name => { |
| 15 | const tarball = path.resolve(directory, name); |
| 16 | const manifest = JSON.parse(execFileSync("tar", ["-xOf", tarball, "package/package.json"], { encoding: "utf8" })); |
| 17 | return { name: manifest.name, manifest, tarball, dir: process.cwd() }; |
| 18 | }); |
| 19 | |
| 20 | publishPackages({ packages, version, candidateSha }); |
| 21 |