()
| 403 | }; |
| 404 | |
| 405 | const main = async () => { |
| 406 | const { dryRun, prepareOnly } = parseArgs(process.argv.slice(2)); |
| 407 | |
| 408 | // Each package's own version determines its dist-tag (pre-release versions |
| 409 | // with `-` publish to `beta`, everything else to `latest`). Packages are |
| 410 | // only skipped when their current version is already on npm. |
| 411 | const mode = prepareOnly ? " [prepare-only]" : dryRun ? " [dry-run]" : ""; |
| 412 | console.log(`Publishing ${PACKAGE_SCOPE} packages${mode}`); |
| 413 | |
| 414 | await $`bun run build:packages`.cwd(repoRoot); |
| 415 | |
| 416 | // Snapshot the public package names and versions up front so public |
| 417 | // workspace dependencies can be written as exact versions in packed tarballs. |
| 418 | const publishable = new Set<string>(); |
| 419 | const publishableVersions = new Map<string, string>(); |
| 420 | for (const relDir of PUBLIC_PACKAGE_DIRS) { |
| 421 | const pkg = await readPackageMeta(join(repoRoot, relDir)); |
| 422 | publishable.add(pkg.name); |
| 423 | publishableVersions.set(pkg.name, pkg.version); |
| 424 | } |
| 425 | |
| 426 | if (prepareOnly) { |
| 427 | for (const relDir of PUBLIC_PACKAGE_DIRS) { |
| 428 | await prepareOnePackage(join(repoRoot, relDir), publishable, publishableVersions); |
| 429 | } |
| 430 | return; |
| 431 | } |
| 432 | |
| 433 | // Pack sequentially: packing rewrites each package.json in place and `bun |
| 434 | // pm pack` resolves against the shared workspace tree, so overlapping packs |
| 435 | // could observe each other's temporary manifests. |
| 436 | const packed: PackedPackage[] = []; |
| 437 | for (const relDir of PUBLIC_PACKAGE_DIRS) { |
| 438 | packed.push( |
| 439 | await packPackage(join(repoRoot, relDir), dryRun, publishable, publishableVersions), |
| 440 | ); |
| 441 | } |
| 442 | |
| 443 | if (dryRun) { |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | await publishAll(packed); |
| 448 | }; |
| 449 | |
| 450 | await main(); |
no test coverage detected