diff --git a/package.json b/package.json index 0b1508ae..36e475bc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "dragonfly", "private": true, - "version": "0.1.0", + "version": "0.1.5", "description": "A modern, high-performance SSH client built with Tauri and React.", "author": "CoderKang", "homepage": "https://github.com/CoderKang/Dragonfly", @@ -14,8 +14,10 @@ }, "type": "module", "scripts": { + "version-sync": "node scripts/sync-version.mjs", + "release": "node scripts/sync-version.mjs --commit && tsc && vite build", "dev": "vite", - "build": "tsc && vite build", + "build": "node scripts/sync-version.mjs && tsc && vite build", "preview": "vite preview", "tauri": "tauri", "lint": "biome check src/", diff --git a/scripts/sync-version.mjs b/scripts/sync-version.mjs new file mode 100644 index 00000000..4c31c97e --- /dev/null +++ b/scripts/sync-version.mjs @@ -0,0 +1,28 @@ +import { readFileSync, writeFileSync } from 'fs'; +import { execSync } from 'child_process'; + +const pkg = JSON.parse(readFileSync('package.json', 'utf-8')); +const version = pkg.version; + +// 同步到 tauri.conf.json +const tauriConf = JSON.parse(readFileSync('src-tauri/tauri.conf.json', 'utf-8')); +tauriConf.version = version; +writeFileSync('src-tauri/tauri.conf.json', JSON.stringify(tauriConf, null, 2) + '\n'); + +// 同步到 Cargo.toml(仅替换 [package] 下的 version,不影响依赖项的 version) +let cargo = readFileSync('src-tauri/Cargo.toml', 'utf-8'); +cargo = cargo.replace( + /(\[package\]\s*\nname\s*=\s*"[^"]*"\s*\n)version\s*=\s*"[^"]*"/, + `$1version = "${version}"` +); +writeFileSync('src-tauri/Cargo.toml', cargo); + +console.log(`✅ Version synced to ${version}`); + +// 如果传入 --commit 参数,自动提交版本变更 +if (process.argv.includes('--commit')) { + const files = ['package.json', 'src-tauri/tauri.conf.json', 'src-tauri/Cargo.toml']; + execSync(`git add ${files.join(' ')}`, { stdio: 'inherit' }); + execSync(`git commit -m "chore: bump version to v${version}"`, { stdio: 'inherit' }); + console.log(`✅ Committed: chore: bump version to v${version}`); +} diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 01004d24..029abe0b 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1237,7 +1237,7 @@ dependencies = [ [[package]] name = "dragonfly" -version = "0.1.0" +version = "0.1.5" dependencies = [ "aes-gcm", "async-http-proxy", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 6b3d60a6..c8e6ede1 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dragonfly" -version = "0.1.0" +version = "0.1.5" description = "A Tauri App" authors = ["Kang"] edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 80bd4e99..d433b9aa 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Dragonfly", - "version": "0.1.0", + "version": "0.1.5", "identifier": "com.kang.dragonfly", "build": { "beforeDevCommand": "pnpm dev", @@ -34,4 +34,4 @@ "icons/icon.ico" ] } -} \ No newline at end of file +}