|
| 1 | +#!/usr/bin/env node |
| 2 | +import fs from 'fs'; |
| 3 | +import path from 'path'; |
| 4 | +import {fileURLToPath} from 'url'; |
| 5 | + |
| 6 | +const __filename = fileURLToPath(import.meta.url); |
| 7 | +const __dirname = path.dirname(__filename); |
| 8 | + |
| 9 | +const newVersion = process.argv[2]; |
| 10 | +if (!newVersion) { |
| 11 | + console.error('请提供新版本号: node scripts/bump-version.js 25.0.1'); |
| 12 | + process.exit(1); |
| 13 | +} |
| 14 | + |
| 15 | +// 更新 package.json |
| 16 | +const packagePath = path.join(__dirname, '../package.json'); |
| 17 | +const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8')); |
| 18 | +packageJson.version = newVersion; |
| 19 | +fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2) + '\n'); |
| 20 | + |
| 21 | +// 更新 Cargo.toml |
| 22 | +const cargoPath = path.join(__dirname, '../src-tauri/Cargo.toml'); |
| 23 | +let cargoContent = fs.readFileSync(cargoPath, 'utf8'); |
| 24 | +cargoContent = cargoContent.replace(/^version = ".*"$/m, `version = "${newVersion}"`); |
| 25 | +fs.writeFileSync(cargoPath, cargoContent); |
| 26 | + |
| 27 | +// 更新 tauri.conf.json |
| 28 | +const tauriConfigPath = path.join(__dirname, '../src-tauri/tauri.conf.json'); |
| 29 | +const tauriConfig = JSON.parse(fs.readFileSync(tauriConfigPath, 'utf8')); |
| 30 | +tauriConfig.version = newVersion; |
| 31 | +fs.writeFileSync(tauriConfigPath, JSON.stringify(tauriConfig, null, 2) + '\n'); |
| 32 | + |
| 33 | +console.log(`✅ 版本已更新为 ${newVersion}`); |
0 commit comments