opencode/script/pack-npm.ts
Filip Hejmowski a26b0a73e4 fix(ci): keep dev previews and published libraries working with pack-npm
- when pack-npm fails on a non-release run, publish builds the libraries
  in place as before, so the CLI dev preview still ships after client
- library scripts skip versions already on npm in pack mode too, and
  NpmLibraries.verify accepts a missing tarball only for a published
  version, so a re-dispatched release does not rerun every check
- trim comments that restated code and correct inaccurate ones
2026-10-19 15:15:48 +02:00

23 lines
788 B
TypeScript
Executable file

#!/usr/bin/env bun
// publish.yml's pack-npm job: packs the npm libraries into OPENCODE_NPM_PACK_DIR with their own scripts and checks.
import { NpmLibraries } from "@opencode/script/npm"
import { $ } from "bun"
import { mkdir } from "node:fs/promises"
import { fileURLToPath } from "url"
import { packageJsons, prepareReleaseFiles } from "./release-files"
process.chdir(fileURLToPath(new URL("..", import.meta.url)))
if (!NpmLibraries.packDir) throw new Error("OPENCODE_NPM_PACK_DIR is required")
await mkdir(NpmLibraries.packDir, { recursive: true })
await prepareReleaseFiles(await packageJsons())
for (const name of NpmLibraries.names) {
console.log(`\n=== ${name} ===\n`)
await $`bun ./packages/${name}/script/publish.ts`
}
await NpmLibraries.verify(NpmLibraries.packDir)