fix: prepare

This commit is contained in:
orion 2024-04-03 16:41:53 -05:00
parent 154fb0f1e7
commit 60f442fc21
Signed by: orion
GPG Key ID: 6D4165AE4C928719

View File

@ -1,15 +1,17 @@
import {readFile, writeFile} from 'fs/promises'
import {execSync} from 'child_process'
const ver = process.argv[2]
let ver = process.argv[2]
if (!ver) {
console.error(`tag required: bun bun/prepare.js v1.0.0`)
} else if (!/v\d+\.\d+\.\d+/.test(ver)) {
console.error(`invalid tag: ${ver}`)
}
ver = (/\d+\.\d+\.\d+/.exec(ver) || [])[0] || ''
const pkg = await readFile('./package.json', 'utf8')
const pkgnew = pkg.replace(/"version": ".+"/, `"version": "${ver}"`)
const pkgnew = pkg.replace(/"version": ".+"/, `"version": "v${ver}"`)
await writeFile('./package.json', pkgnew)
const spago = await readFile('./spago.yaml', 'utf8')
@ -17,7 +19,7 @@ const spagonew = spago.replace(/version: .+/, `version: '${ver}'`)
await writeFile('./spago.yaml', spagonew)
const readme = await readFile('./README.md', 'utf8')
const readmenew = readme.replace(/packages\/postgresql\/.+?\//g, `/packages/postgresql/${ver}/`)
const readmenew = readme.replace(/packages\/purescript-postgresql\/.+?\//g, `/packages/purescript-postgresql/${ver}/`)
await writeFile('./README.md', readmenew)
execSync(`git add spago.yaml package.json README.md`)