Skip to content

Commit 3c93c29

Browse files
committed
chore: update release script
1 parent 145a5ed commit 3c93c29

8 files changed

Lines changed: 55 additions & 20 deletions

File tree

packages/comark-ansi/.release-it.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
},
1212
"npm": {
1313
"publish": true,
14-
"publishPath": "."
14+
"publishPath": ".",
15+
"publishPackageManager": "pnpm",
16+
"publishArgs": ["--no-git-checks"]
1517
},
1618
"plugins": {
1719
"@release-it/conventional-changelog": {

packages/comark-html/.release-it.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
},
1212
"npm": {
1313
"publish": true,
14-
"publishPath": "."
14+
"publishPath": ".",
15+
"publishPackageManager": "pnpm",
16+
"publishArgs": ["--no-git-checks"]
1517
},
1618
"plugins": {
1719
"@release-it/conventional-changelog": {

packages/comark-nuxt/.release-it.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
},
1212
"npm": {
1313
"publish": true,
14-
"publishPath": "."
14+
"publishPath": ".",
15+
"publishPackageManager": "pnpm",
16+
"publishArgs": ["--no-git-checks"]
1517
},
1618
"plugins": {
1719
"@release-it/conventional-changelog": {

packages/comark-react/.release-it.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
},
1212
"npm": {
1313
"publish": true,
14-
"publishPath": "."
14+
"publishPath": ".",
15+
"publishPackageManager": "pnpm",
16+
"publishArgs": ["--no-git-checks"]
1517
},
1618
"plugins": {
1719
"@release-it/conventional-changelog": {

packages/comark-svelte/.release-it.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
},
1212
"npm": {
1313
"publish": true,
14-
"publishPath": "."
14+
"publishPath": ".",
15+
"publishPackageManager": "pnpm",
16+
"publishArgs": ["--no-git-checks"]
1517
},
1618
"plugins": {
1719
"@release-it/conventional-changelog": {

packages/comark-vue/.release-it.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
},
1212
"npm": {
1313
"publish": true,
14-
"publishPath": "."
14+
"publishPath": ".",
15+
"publishPackageManager": "pnpm",
16+
"publishArgs": ["--no-git-checks"]
1517
},
1618
"plugins": {
1719
"@release-it/conventional-changelog": {

packages/comark/.release-it.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
},
1212
"npm": {
1313
"publish": true,
14-
"publishPath": "."
14+
"publishPath": ".",
15+
"publishPackageManager": "pnpm",
16+
"publishArgs": ["--no-git-checks"]
1517
},
1618
"plugins": {
1719
"@release-it/conventional-changelog": {

scripts/release.mjs

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
import { execSync, spawnSync } from 'node:child_process'
16-
import { existsSync, readdirSync, readFileSync } from 'node:fs'
16+
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
1717
import { join, relative } from 'node:path'
1818
import { fileURLToPath } from 'node:url'
1919

@@ -88,7 +88,28 @@ function getReleasablePackages() {
8888
}
8989

9090
/**
91-
* Wait for a package to appear on npm, then update its version across the monorepo.
91+
* Bump a package's version in the pnpm-workspace.yaml catalog. Returns true on
92+
* success. Other workspace packages depend on this package via "catalog:", so
93+
* updating the catalog is what makes pnpm publish resolve to the new version.
94+
*/
95+
function updateCatalogVersion(name, newVersion) {
96+
const yamlPath = join(root, 'pnpm-workspace.yaml')
97+
const content = readFileSync(yamlPath, 'utf-8')
98+
const escaped = name.replace(/\./g, '\\.')
99+
const re = new RegExp(`^(\\s*"?${escaped}"?\\s*:\\s*)\\^?[^\\s#]+`, 'm')
100+
if (!re.test(content)) {
101+
console.error(` Could not find catalog entry for ${name} in pnpm-workspace.yaml`)
102+
return false
103+
}
104+
const updated = content.replace(re, `$1^${newVersion}`)
105+
if (updated === content) return false
106+
writeFileSync(yamlPath, updated)
107+
return true
108+
}
109+
110+
/**
111+
* Wait for a package to appear on npm, then bump its catalog entry so the next
112+
* package release picks up the new version through pnpm's catalog resolution.
92113
*/
93114
function waitAndUpdateDependents(pkg) {
94115
const newVersion = JSON.parse(readFileSync(join(pkg.dir, 'package.json'), 'utf-8')).version
@@ -112,21 +133,21 @@ function waitAndUpdateDependents(pkg) {
112133
}
113134

114135
if (!available) {
115-
console.error(`\n${pkg.name}@${newVersion} did not appear on npm after ${maxAttempts} attempts. Skipping dependency update.`)
136+
console.error(`\n${pkg.name}@${newVersion} did not appear on npm after ${maxAttempts} attempts. Skipping catalog bump.`)
116137
return
117138
}
118139

119-
console.log(`Updating ${pkg.name} version in all packages...\n`)
120-
const ncuResult = spawnSync('npx', ['npm-check-updates', '-u', '--deep', '--filter', pkg.name], {
121-
cwd: root,
122-
stdio: 'inherit',
123-
env: process.env,
124-
})
125-
if (ncuResult.status === 0) {
126-
spawnSync('pnpm', ['install'], { cwd: root, stdio: 'inherit', env: process.env })
127-
spawnSync('git', ['add', '-A'], { cwd: root, stdio: 'inherit', env: process.env })
128-
spawnSync('git', ['commit', '-m', `chore(deps): update ${pkg.name} to v${newVersion}`], { cwd: root, stdio: 'inherit', env: process.env })
140+
console.log(`Bumping ${pkg.name} catalog entry to ^${newVersion}...\n`)
141+
if (!updateCatalogVersion(pkg.name, newVersion)) return
142+
143+
const installResult = spawnSync('pnpm', ['install'], { cwd: root, stdio: 'inherit', env: process.env })
144+
if (installResult.status !== 0) {
145+
console.error(` pnpm install failed; leaving catalog change uncommitted.`)
146+
return
129147
}
148+
149+
spawnSync('git', ['add', 'pnpm-workspace.yaml', 'pnpm-lock.yaml'], { cwd: root, stdio: 'inherit', env: process.env })
150+
spawnSync('git', ['commit', '-m', `chore(deps): bump ${pkg.name} catalog to v${newVersion}`], { cwd: root, stdio: 'inherit', env: process.env })
130151
}
131152

132153
// --- Main ---

0 commit comments

Comments
 (0)