Browse Source

clone:build后版本号自动增加

master
guoapeng 4 months ago
parent
commit
da11053343
  1. 23
      increment-version.js
  2. 9
      package.json
  3. 3
      pnpm-lock.yaml
  4. 4
      src/views/login/index.vue
  5. 8
      vite.config.ts

23
increment-version.js

@ -0,0 +1,23 @@
import fs from 'node:fs'
import path, { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import semver from 'semver'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const packagePath = path.resolve(__dirname, 'package.json')
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'))
// 读取命令行参数(默认使用 'patch')
const versionType = process.argv[2] || 'patch'
// 递增版本
const newVersion = semver.inc(packageJson.version, versionType)
if (!newVersion) {
throw new Error(`Invalid version type: ${versionType}`)
}
packageJson.version = newVersion
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2))
console.log(`Version updated to: ${newVersion}`)

9
package.json

@ -1,7 +1,7 @@
{
"name": "matrix-spray-web",
"type": "module",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"author": "",
"license": "ISC",
@ -13,7 +13,9 @@
"dev:prod": "vite --mode prod",
"build": "vite build --mode dev",
"build:test": "vite build --mode test",
"build:prod": "vite build --mode prod",
"build:prod:patch": "node increment-version.js patch && vite build --mode prod",
"build:prod:minor": "node increment-version.js minor && vite build --mode prod",
"build:prod:major": "node increment-version.js major && vite build --mode prod",
"build:pre": "vite build --mode pre",
"build:dev": "vite build --mode dev",
"prepare": "husky",
@ -60,6 +62,7 @@
"lint-staged": "^15.4.3",
"prettier": "^3.5.2",
"sass": "^1.85.1",
"semver": "^7.7.1",
"typescript": "^5.7.3",
"unplugin-auto-import": "^19.1.1",
"unplugin-vue-components": "^28.4.1",
@ -80,4 +83,4 @@
"lint-staged"
]
}
}
}

3
pnpm-lock.yaml

@ -114,6 +114,9 @@ importers:
sass:
specifier: ^1.85.1
version: 1.85.1
semver:
specifier: ^7.7.1
version: 7.7.1
typescript:
specifier: ^5.7.3
version: 5.7.3

4
src/views/login/index.vue

@ -7,7 +7,7 @@ const router = useRouter()
const progress = ref(0) //
let timer: any = null //
const version = __APP_VERSION__
//
const startProgress = () => {
timer = setInterval(() => {
@ -46,7 +46,7 @@ onBeforeUnmount(() => {
<div class="progress-container">
<div class="progress-bar" :style="{ width: `${progress}%` }" />
<div class="progress-text">
v1.0.1系统初始化中 {{ progress }}%
v{{ version }}系统初始化中 {{ progress }}%
</div>
</div>
</div>

8
vite.config.ts

@ -5,9 +5,13 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { defineConfig } from 'vite'
import viteCompression from 'vite-plugin-compression'
import eslintPlugin from 'vite-plugin-eslint'
import packageJson from './package.json'
const Timestamp = new Date().getTime()
export default defineConfig({
define: {
__APP_VERSION__: JSON.stringify(packageJson.version),
},
base: './',
envPrefix: 'FT_',
esbuild: {
@ -80,8 +84,8 @@ export default defineConfig({
host: '0.0.0.0',
proxy: {
'/api': {
// target: 'http://192.168.1.199:8080',
target: 'http://192.168.1.200:8080',
target: 'http://192.168.1.199:8080',
// target: 'http://192.168.1.200:8080',
// secure: false,
changeOrigin: true, // 是否跨域
rewrite: path => path.replace(/^\/api/, 'api'),

Loading…
Cancel
Save