From 5f43b76b575adbbe3fc9b3b29f8aaf55f517ed08 Mon Sep 17 00:00:00 2001 From: Simon <10131203+gaomeng1900@users.noreply.github.com> Date: Mon, 9 Mar 2026 17:15:16 +0800 Subject: [PATCH] chore: improve scripts for extension --- CONTRIBUTING.md | 1 + package.json | 11 +++++++---- scripts/ext-version.js | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 scripts/ext-version.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d267139..7eb3a82 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,7 @@ Thank you for your interest in contributing to PageAgent! We welcome contributio ```bash npm ci npm start # Start demo and documentation site + npm run build # Build libs and website ``` ### Project Structure diff --git a/package.json b/package.json index 066de24..ab84e4f 100644 --- a/package.json +++ b/package.json @@ -24,14 +24,17 @@ "node": "^20.19.0 || ^22.13.0 || >=24" }, "scripts": { - "cleanup": "rm -rf packages/*/dist", "start": "npm run dev --workspace=@page-agent/website", - "build:website": "npm run build:website --workspace=@page-agent/website", - "build:libs": "npm run build --workspaces --if-present", - "build": "npm run build:libs && npm run build:website", + "dev:ext": "npm run dev -w @page-agent/ext", "dev:demo": "npm run dev:demo --workspace=page-agent", + "build": "npm run build:libs && npm run build:website", + "build:libs": "npm run build --workspaces --if-present", + "build:website": "npm run build:website --workspace=@page-agent/website", + "build:ext": "npm run build:libs && npm run build:ext -w @page-agent/ext", "version": "node scripts/sync-version.js", + "version:ext": "node scripts/ext-version.js", "lint": "eslint .", + "cleanup": "rm -rf packages/*/dist", "prepare": "husky" }, "devDependencies": { diff --git a/scripts/ext-version.js b/scripts/ext-version.js new file mode 100644 index 0000000..e7d2cff --- /dev/null +++ b/scripts/ext-version.js @@ -0,0 +1,40 @@ +#!/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 \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(`git add . && git commit -m "chore(extension): 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`))