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

2
package-lock.json generated
View File

@@ -11106,7 +11106,7 @@
}, },
"packages/extension": { "packages/extension": {
"name": "@page-agent/ext", "name": "@page-agent/ext",
"version": "0.1.17", "version": "1.5.5",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@page-agent/core": "1.5.5", "@page-agent/core": "1.5.5",

View File

@@ -32,7 +32,6 @@
"build:website": "npm run build:website --workspace=@page-agent/website", "build:website": "npm run build:website --workspace=@page-agent/website",
"build:ext": "npm run build:libs && npm run zip -w @page-agent/ext", "build:ext": "npm run build:libs && npm run zip -w @page-agent/ext",
"version": "node scripts/sync-version.js", "version": "node scripts/sync-version.js",
"version:ext": "node scripts/ext-version.js",
"lint": "eslint .", "lint": "eslint .",
"cleanup": "rm -rf packages/*/dist", "cleanup": "rm -rf packages/*/dist",
"prepare": "husky" "prepare": "husky"

View File

@@ -1,7 +1,7 @@
{ {
"name": "@page-agent/ext", "name": "@page-agent/ext",
"private": true, "private": true,
"version": "0.1.17", "version": "1.5.5",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "wxt", "dev": "wxt",

View File

@@ -110,9 +110,9 @@ export default defineUnlistedScript(() => {
) )
} }
;(window as any).PAGE_AGENT_EXT_VERSION = __EXT_VERSION__ ;(window as any).PAGE_AGENT_EXT_VERSION = __VERSION__
;(window as any).PAGE_AGENT_EXT = { ;(window as any).PAGE_AGENT_EXT = {
version: __EXT_VERSION__, version: __VERSION__,
execute, execute,
stop, stop,
} }

View File

@@ -321,10 +321,7 @@ export function ConfigPanel({ config, onSave, onClose }: ConfigPanelProps) {
<div className="flex flex-col items-end"> <div className="flex flex-col items-end">
<span> <span>
Extension <span className="font-mono">v{__EXT_VERSION__}</span> Version <span className="font-mono">v{__VERSION__}</span>
</span>
<span>
PageAgent <span className="font-mono">v{__CORE_VERSION__}</span>
</span> </span>
</div> </div>
</div> </div>

View File

@@ -1,2 +1 @@
declare const __EXT_VERSION__: string declare const __VERSION__: string
declare const __CORE_VERSION__: string

View File

@@ -19,8 +19,7 @@ export default defineConfig({
vite: () => ({ vite: () => ({
plugins: [tailwindcss()], plugins: [tailwindcss()],
define: { define: {
__EXT_VERSION__: JSON.stringify(pkg.version), __VERSION__: JSON.stringify(pkg.version),
__CORE_VERSION__: JSON.stringify(pkg.dependencies['@page-agent/core']),
}, },
optimizeDeps: { optimizeDeps: {
force: true, force: true,

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