refactor(release): polish Effect publish scripts
Use Effect.ensuring to restore temporary package manifests on failure and tidy the opencode packager with a small parallel hash helper so the stacked Effect rewrite reads cleaner without changing behavior.
This commit is contained in:
parent
7f4dc4a249
commit
3496b9caf5
3 changed files with 51 additions and 20 deletions
|
|
@ -34,6 +34,13 @@ const published = (name: string, version: string) =>
|
|||
Effect.map((result) => result.exitCode === 0),
|
||||
)
|
||||
|
||||
const withPackageJson = (pkg: ReturnType<typeof packageJson>, next: ReturnType<typeof packageJson>) =>
|
||||
Effect.promise(() => Bun.write("package.json", JSON.stringify(next, null, 2))).pipe(
|
||||
Effect.zipRight(Effect.promise(() => $`bun pm pack`)),
|
||||
Effect.zipRight(Effect.promise(() => $`npm publish *.tgz --tag ${Script.channel} --access public`)),
|
||||
Effect.ensuring(Effect.promise(() => Bun.write("package.json", JSON.stringify(pkg, null, 2)))),
|
||||
)
|
||||
|
||||
function transformExports(exports: Record<string, unknown>) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(exports).map(([key, value]) => {
|
||||
|
|
@ -59,10 +66,7 @@ const program = Effect.gen(function* () {
|
|||
exports: transformExports(pkg.exports),
|
||||
}
|
||||
|
||||
yield* Effect.promise(() => Bun.write("package.json", JSON.stringify(next, null, 2)))
|
||||
yield* Effect.promise(() => $`bun pm pack`)
|
||||
yield* Effect.promise(() => $`npm publish *.tgz --tag ${Script.channel} --access public`)
|
||||
yield* Effect.promise(() => Bun.write("package.json", JSON.stringify(pkg, null, 2)))
|
||||
yield* withPackageJson(pkg, next)
|
||||
})
|
||||
|
||||
await Effect.runPromise(program)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue