mirror of
https://fastgit.cc/https://github.com/anomalyco/opencode
synced 2026-04-23 10:23:09 +08:00
release: avoid package.json drift during publish
This commit is contained in:
@@ -15,11 +15,23 @@ const pkgjsons = await Array.fromAsync(
|
||||
).then((arr) => arr.filter((x) => !x.includes("node_modules") && !x.includes("dist")))
|
||||
|
||||
const extensionToml = fileURLToPath(new URL("../packages/extensions/zed/extension.toml", import.meta.url))
|
||||
const publishPackageJsons = ["packages/plugin/package.json", "packages/sdk/js/package.json"]
|
||||
|
||||
async function hasChanges() {
|
||||
return (await $`git diff --quiet && git diff --cached --quiet`.nothrow()).exitCode !== 0
|
||||
}
|
||||
|
||||
async function hasPublishPackageJsonChanges() {
|
||||
if ((await $`git diff --quiet -- ${publishPackageJsons}`.nothrow()).exitCode !== 0) return true
|
||||
return (await $`git diff --cached --quiet -- ${publishPackageJsons}`.nothrow()).exitCode !== 0
|
||||
}
|
||||
|
||||
async function logPublishPackageJsonChanges() {
|
||||
await $`git status --short -- ${publishPackageJsons}`
|
||||
await $`git diff -- ${publishPackageJsons}`
|
||||
await $`git diff --cached -- ${publishPackageJsons}`
|
||||
}
|
||||
|
||||
async function releaseTagExists() {
|
||||
return (await $`git rev-parse -q --verify refs/tags/${tag}`.nothrow()).exitCode === 0
|
||||
}
|
||||
@@ -76,6 +88,11 @@ if (Script.release) {
|
||||
|
||||
if (Script.release && !Script.preview) {
|
||||
await $`git fetch origin`
|
||||
if (await hasPublishPackageJsonChanges()) {
|
||||
console.error("publish scripts left package.json changes before syncing dev")
|
||||
await logPublishPackageJsonChanges()
|
||||
throw new Error("packages/plugin/package.json or packages/sdk/js/package.json changed during publish")
|
||||
}
|
||||
await $`git checkout -B dev origin/dev`
|
||||
await prepareReleaseFiles()
|
||||
if (await hasChanges()) {
|
||||
|
||||
Reference in New Issue
Block a user