feat: extension use the same version as packages

This commit is contained in:
Simon
2026-03-12 00:37:43 +08:00
parent a9f462ed37
commit a74b7542ba
9 changed files with 20 additions and 68 deletions

View File

@@ -1,41 +0,0 @@
#!/usr/bin/env node
/**
* Bump extension version and show git tag commands
*
* Usage:
* node scripts/ext-version.js 0.1.16
*/
import chalk from 'chalk'
import { readFileSync, writeFileSync } from 'fs'
import { dirname, join } from 'path'
import { exit } from 'process'
import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const pkgPath = join(__dirname, '..', 'packages', 'extension', 'package.json')
const newVersion = process.argv[2]
if (!newVersion) {
console.log(chalk.yellow('⚠️ Usage: npm run ext:version <version>\n'))
exit(1)
}
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
const oldVersion = pkg.version
pkg.version = newVersion
writeFileSync(pkgPath, JSON.stringify(pkg, null, ' ') + '\n')
console.log(
chalk.green.bold('\n✓') +
` ${chalk.bold('@page-agent/ext')}: ${chalk.dim(oldVersion)}${chalk.yellow(newVersion)}\n`
)
const tagName = `EXT_v${newVersion}`
console.log(chalk.cyan.bold('📋 Next steps:\n'))
console.log(chalk.blueBright(`npm i`))
console.log(
chalk.blueBright(`git add . && git commit -m "chore(ext): bump version to ${newVersion}"`)
)
console.log(chalk.blueBright(`git tag -a ${tagName} -m "${tagName}"`))
console.log(chalk.blueBright(`git push && git push origin ${tagName}\n`))

View File

@@ -4,7 +4,7 @@
*
* Usage:
* node scripts/sync-version.js # Sync current version from root
* node scripts/sync-version.js 0.1.0 # Set and sync new version
* node scripts/sync-version.js 0.1.0 # Set root version, then sync all packages
*/
import chalk from 'chalk'
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'fs'
@@ -15,19 +15,18 @@ import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const rootDir = join(__dirname, '..')
// Parse arguments
const versionArg = process.argv[2]
if (!versionArg) {
console.log(chalk.yellow('⚠️ No version specified.\n'))
exit(1)
}
// Read root package.json
const rootPkgPath = join(rootDir, 'package.json')
const rootPkg = JSON.parse(readFileSync(rootPkgPath, 'utf-8'))
const oldVersion = rootPkg.version
const newVersion = versionArg
const newVersion = versionArg ?? rootPkg.version
if (!newVersion) {
console.log(chalk.yellow('⚠️ No version found in root package.json.\n'))
exit(1)
}
console.log(chalk.cyan.bold('\n📦 Syncing version\n'))
@@ -35,7 +34,10 @@ console.log(chalk.cyan.bold('\n📦 Syncing version\n'))
if (versionArg) {
rootPkg.version = newVersion
writeFileSync(rootPkgPath, JSON.stringify(rootPkg, null, ' ') + '\n')
console.log(chalk.green('✓') + ` ${chalk.bold('root')}${chalk.yellow(newVersion)}`)
console.log(
chalk.green('✓') +
` ${chalk.bold('root')}: ${chalk.dim(oldVersion)}${chalk.yellow(newVersion)}`
)
} else {
console.log(chalk.dim(' root:') + ` ${chalk.yellow(newVersion)} ${chalk.dim('(source)')}`)
}
@@ -78,11 +80,8 @@ for (const pkg of packages) {
const pkgJson = JSON.parse(readFileSync(pkgPath, 'utf-8'))
let pkgChanged = false
// Skip extension package version (it has its own versioning)
const isExtension = pkg === 'extension'
// Update package version (skip extension)
if (!isExtension && pkgJson.version !== newVersion) {
// Update package version
if (pkgJson.version !== newVersion) {
pkgJson.version = newVersion
pkgChanged = true
}