From a01baeaa025f8d61bce07663bdc9b3c86e7361f4 Mon Sep 17 00:00:00 2001 From: log1997 <2694233102@qq.com> Date: Wed, 31 Dec 2025 12:46:25 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E2=9C=8F=EF=B8=8F=20=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E7=89=88=E6=9C=AC+=E5=8D=87=E7=BA=A7=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/updateVersion.js | 58 ++++++++++ package.json | 223 +++++++++++++++++++------------------- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 4 +- 4 files changed, 173 insertions(+), 114 deletions(-) create mode 100644 build/updateVersion.js diff --git a/build/updateVersion.js b/build/updateVersion.js new file mode 100644 index 0000000..0e10521 --- /dev/null +++ b/build/updateVersion.js @@ -0,0 +1,58 @@ +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +// 从命令行参数获取版本号 +const args = process.argv.slice(2); +let version = args[0]; + +if (!version) { + console.error('错误: 请提供版本号作为参数'); + console.error('用法: node build/updateVersion.js '); + process.exit(1); +} + +// 验证版本号格式 (遵循语义化版本号格式,如 x.y.z) +const versionRegex = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/; +if (!versionRegex.test(version)) { + console.error(`错误: 版本号格式不正确: ${version}`); + console.error('正确的版本号格式示例: 1.0.0, 2.1.3, 0.5.0-beta 等'); + process.exit(1); +} + +// 更新 package.json +const packageJsonPath = path.join(__dirname, '..', 'package.json'); +const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); +packageJson.version = version; +fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); + +// 读取并更新 tauri.conf.json +const tauriConfPath = path.join(__dirname, '..', 'src-tauri', 'tauri.conf.json'); +const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8')); + +// 更新版本号 +tauriConf.version = version; + +// 写回 tauri.conf.json +fs.writeFileSync(tauriConfPath, JSON.stringify(tauriConf, null, 2)); + +// 读取并更新 Cargo.toml +const cargoTomlPath = path.join(__dirname, '..', 'src-tauri', 'Cargo.toml'); +let cargoToml = fs.readFileSync(cargoTomlPath, 'utf8'); + +// 使用正则表达式替换版本号 +cargoToml = cargoToml.replace( + /^(\s*version\s*=\s*["'])([^"']*)(["']\s*)$/m, + `$1${version}$3` +); + +// 写回 Cargo.toml +fs.writeFileSync(cargoTomlPath, cargoToml); + +console.log(`版本号已更新至: ${version}`); +console.log(`- package.json`); +console.log(`- tauri.conf.json`); +console.log(`- Cargo.toml`); \ No newline at end of file diff --git a/package.json b/package.json index 60f0fc1..18dad66 100644 --- a/package.json +++ b/package.json @@ -1,113 +1,114 @@ { - "name": "log-lottery", - "private": true, - "version": "0.5.0", - "type": "module", - "license": "MIT", - "scripts": { - "dev": "vite --host 0.0.0.0", - "build": "vue-tsc --noEmit && vite build", - "build:pre": "vue-tsc --noEmit && vite build --mode prebuild", - "build:file": "vue-tsc --noEmit && vite build --mode file", - "tauri": "node ./build/syncVersion.js && tauri", - "test": "vitest", - "test:ui": "vitest --ui", - "preview": "vite preview", - "lint": "eslint ./src", - "lint:fix": "eslint ./src --fix", - "prepare": "husky" - }, - "dependencies": { - "@tweenjs/tween.js": "23.1.2", - "@vueuse/core": "^14.1.0", - "axios": "^1.13.2", - "canvas-confetti": "^1.9.4", - "class-variance-authority": "^0.7.1", - "clsx": "^2.1.1", - "dayjs": "^1.11.19", - "dexie": "^4.2.1", - "github-markdown-css": "^5.8.1", - "gsap": "^3.14.2", - "localforage": "^1.10.0", - "lodash-es": "^4.17.22", - "lucide-vue-next": "^0.562.0", - "markdown-it": "^14.1.0", - "masonry-layout": "^4.2.2", - "pinia": "^3.0.4", - "pinia-plugin-persist": "^1.0.0", - "reka-ui": "^2.7.0", - "sparticles": "^1.3.1", - "tailwind-merge": "^3.4.0", - "three": "0.166.0", - "three-css3d": "1.0.6", - "uuid": "^13.0.0", - "vue": "^3.5.26", - "vue-dompurify-html": "^5.3.0", - "vue-draggable-plus": "^0.6.0", - "vue-i18n": "^11.2.7", - "vue-router": "^4.6.4", - "vue-sonner": "^2.0.9", - "vue-toast-notification": "^3", - "vue3-colorpicker": "^2.3.0", - "xlsx": "^0.18.5", - "zod": "^4.2.1" - }, - "devDependencies": { - "@antfu/eslint-config": "^6.7.3", - "@eslint/eslintrc": "^3.3.3", - "@eslint/js": "^9.39.2", - "@iconify-json/ep": "^1.2.3", - "@iconify-json/fluent": "^1.2.36", - "@tailwindcss/typography": "^0.5.19", - "@tailwindcss/vite": "^4.1.18", - "@tauri-apps/cli": "^2.9.6", - "@testing-library/vue": "^8.1.0", - "@types/canvas-confetti": "^1.9.0", - "@types/lodash-es": "^4.17.12", - "@types/markdown-it": "^14.1.2", - "@types/masonry-layout": "^4.2.8", - "@types/node": "^25.0.3", - "@types/three": "0.166.0", - "@typescript-eslint/eslint-plugin": "^8.50.1", - "@typescript-eslint/parser": "^8.50.1", - "@vitejs/plugin-legacy": "^7.2.1", - "@vitejs/plugin-vue": "^6.0.3", - "@vitest/ui": "^4.0.16", - "@vue/test-utils": "^2.4.6", - "@vue/tsconfig": "^0.8.1", - "autoprefixer": "^10.4.23", - "baseline-browser-mapping": "^2.9.11", - "child_process": "^1.0.2", - "daisyui": "^5.5.14", - "eslint": "^9.39.2", - "eslint-plugin-vue": "^10.6.2", - "fast-glob": "^3.3.3", - "globals": "^16.5.0", - "happy-dom": "^20.0.11", - "husky": "^9.1.7", - "jsdom": "^27.3.0", - "path": "^0.12.7", - "postcss": "^8.5.6", - "rollup-plugin-visualizer": "^6.0.5", - "sass": "^1.97.1", - "sass-loader": "^16.0.6", - "tailwindcss": "^4.1.18", - "terser": "^5.44.1", - "tw-animate-css": "^1.4.0", - "typescript": "~5.9.3", - "unplugin-auto-import": "^20.3.0", - "unplugin-icons": "^22.5.0", - "unplugin-vue-components": "^30.0.0", - "vite": "^7.3.0", - "vite-plugin-compression": "^0.5.1", - "vite-plugin-inspect": "^11.3.3", - "vite-plugin-svg-icons": "^2.0.1", - "vite-plugin-vue-devtools": "^8.0.5", - "vitest": "^4.0.16", - "vue-tsc": "^3.2.1" - }, - "engines": { - "node": ">=22.x" - }, - "packageManager": "pnpm@10.26.1" + "name": "log-lottery", + "private": true, + "version": "0.5.2", + "type": "module", + "license": "MIT", + "scripts": { + "dev": "vite --host 0.0.0.0", + "build": "vue-tsc --noEmit && vite build", + "build:pre": "vue-tsc --noEmit && vite build --mode prebuild", + "build:file": "vue-tsc --noEmit && vite build --mode file", + "tauri": "node ./build/syncVersion.js && tauri", + "update-version": "node ./build/updateVersion.js", + "test": "vitest", + "test:ui": "vitest --ui", + "preview": "vite preview", + "lint": "eslint ./src", + "lint:fix": "eslint ./src --fix", + "prepare": "husky" + }, + "dependencies": { + "@tweenjs/tween.js": "23.1.2", + "@vueuse/core": "^14.1.0", + "axios": "^1.13.2", + "canvas-confetti": "^1.9.4", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "dayjs": "^1.11.19", + "dexie": "^4.2.1", + "github-markdown-css": "^5.8.1", + "gsap": "^3.14.2", + "localforage": "^1.10.0", + "lodash-es": "^4.17.22", + "lucide-vue-next": "^0.562.0", + "markdown-it": "^14.1.0", + "masonry-layout": "^4.2.2", + "pinia": "^3.0.4", + "pinia-plugin-persist": "^1.0.0", + "reka-ui": "^2.7.0", + "sparticles": "^1.3.1", + "tailwind-merge": "^3.4.0", + "three": "0.166.0", + "three-css3d": "1.0.6", + "uuid": "^13.0.0", + "vue": "^3.5.26", + "vue-dompurify-html": "^5.3.0", + "vue-draggable-plus": "^0.6.0", + "vue-i18n": "^11.2.7", + "vue-router": "^4.6.4", + "vue-sonner": "^2.0.9", + "vue-toast-notification": "^3", + "vue3-colorpicker": "^2.3.0", + "xlsx": "^0.18.5", + "zod": "^4.2.1" + }, + "devDependencies": { + "@antfu/eslint-config": "^6.7.3", + "@eslint/eslintrc": "^3.3.3", + "@eslint/js": "^9.39.2", + "@iconify-json/ep": "^1.2.3", + "@iconify-json/fluent": "^1.2.36", + "@tailwindcss/typography": "^0.5.19", + "@tailwindcss/vite": "^4.1.18", + "@tauri-apps/cli": "^2.9.6", + "@testing-library/vue": "^8.1.0", + "@types/canvas-confetti": "^1.9.0", + "@types/lodash-es": "^4.17.12", + "@types/markdown-it": "^14.1.2", + "@types/masonry-layout": "^4.2.8", + "@types/node": "^25.0.3", + "@types/three": "0.166.0", + "@typescript-eslint/eslint-plugin": "^8.50.1", + "@typescript-eslint/parser": "^8.50.1", + "@vitejs/plugin-legacy": "^7.2.1", + "@vitejs/plugin-vue": "^6.0.3", + "@vitest/ui": "^4.0.16", + "@vue/test-utils": "^2.4.6", + "@vue/tsconfig": "^0.8.1", + "autoprefixer": "^10.4.23", + "baseline-browser-mapping": "^2.9.11", + "child_process": "^1.0.2", + "daisyui": "^5.5.14", + "eslint": "^9.39.2", + "eslint-plugin-vue": "^10.6.2", + "fast-glob": "^3.3.3", + "globals": "^16.5.0", + "happy-dom": "^20.0.11", + "husky": "^9.1.7", + "jsdom": "^27.3.0", + "path": "^0.12.7", + "postcss": "^8.5.6", + "rollup-plugin-visualizer": "^6.0.5", + "sass": "^1.97.1", + "sass-loader": "^16.0.6", + "tailwindcss": "^4.1.18", + "terser": "^5.44.1", + "tw-animate-css": "^1.4.0", + "typescript": "~5.9.3", + "unplugin-auto-import": "^20.3.0", + "unplugin-icons": "^22.5.0", + "unplugin-vue-components": "^30.0.0", + "vite": "^7.3.0", + "vite-plugin-compression": "^0.5.1", + "vite-plugin-inspect": "^11.3.3", + "vite-plugin-svg-icons": "^2.0.1", + "vite-plugin-vue-devtools": "^8.0.5", + "vitest": "^4.0.16", + "vue-tsc": "^3.2.1" + }, + "engines": { + "node": ">=22.x" + }, + "packageManager": "pnpm@10.26.1" } \ No newline at end of file diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 271af99..91204f5 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "app" -version = "0.5.0" +version = "0.5.2" description = "A Tauri App" authors = ["you"] license = "" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index a96850f..3c245a4 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "log-lottery", - "version": "0.5.0", + "version": "0.5.2", "identifier": "to2026.xyz", "build": { "frontendDist": "../dist", @@ -34,4 +34,4 @@ "icons/icon.ico" ] } -} +} \ No newline at end of file