/** * Publish a prerelease to npm (publish-only, no build/test/bump). * * Version bumping is handled by bump-prerelease.ts in the secrets-free CI * build job. Build and test also run there. This script receives pre-built, * correctly-versioned artifacts and only performs the npm publish step. * * Always publishes with the "canary" dist-tag. * * Usage: tsx scripts/release/prerelease.ts --scope [--dry-run] */ import { spawnSync } from "child_process"; import { getCurrentVersion, getPackagesForScope } from "./lib/versions.js"; import { ROOT, loadConfig, type ReleaseScope } from "./lib/config.js"; function run(cmd: string, args: string[], opts?: { cwd?: string }) { const result = spawnSync(cmd, args, { cwd: opts?.cwd ?? ROOT, stdio: "inherit", encoding: "utf8", }); if (result.status !== 0) { throw new Error(`Command failed: ${cmd} ${args.join(" ")}`); } return result; } const VALID_SCOPES = ["monorepo", "angular"]; function main() { const argv = process.argv.slice(2); const dryRun = argv.includes("--dry-run"); const scopeIdx = argv.indexOf("--scope"); const scope = ( scopeIdx !== -1 ? argv[scopeIdx + 1] : null ) as ReleaseScope | null; if (!scope || !VALID_SCOPES.includes(scope)) { console.error( `Usage: prerelease.ts --scope <${VALID_SCOPES.join("|")}> [--suffix