|
@@ -107,7 +107,7 @@ function handleTestBuild() {
|
|
|
|
|
|
try {
|
|
|
// 执行构建命令
|
|
|
- execSync('vite build', { stdio: 'inherit' })
|
|
|
+ execSync('vite build --mode test', { stdio: 'inherit' })
|
|
|
|
|
|
// 创建tag
|
|
|
execSync(`git tag ${tag}`, { stdio: 'inherit' })
|
|
@@ -172,8 +172,13 @@ function handlePublishBuild() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// 基于特定tag构建
|
|
|
-function handleBuildByTag() {
|
|
|
+// 基于特定tag构建 测试与生产环境 版本
|
|
|
+function handleBuildByTag(modeType) {
|
|
|
+ if (modeType !== 'test' && modeType !== 'pro') {
|
|
|
+ console.error('无效的构建类型,请确认构建类型为 test 或 pro')
|
|
|
+ process.exit(1)
|
|
|
+ }
|
|
|
+ console.log(`🚀🚀🚀 正在基于${modeType}构建...`)
|
|
|
const rl = readline.createInterface({
|
|
|
input: process.stdin,
|
|
|
output: process.stdout,
|
|
@@ -201,7 +206,11 @@ function handleBuildByTag() {
|
|
|
const version = pkgJson.version
|
|
|
|
|
|
// 执行构建命令
|
|
|
- execSync('vite build', { stdio: 'inherit' })
|
|
|
+ if (modeType === 'test') {
|
|
|
+ execSync('vite build --mode test', { stdio: 'inherit' })
|
|
|
+ } else if (modeType === 'pro') {
|
|
|
+ execSync('vite build', { stdio: 'inherit' })
|
|
|
+ }
|
|
|
|
|
|
// 生成版本信息文件
|
|
|
const buildType = tag.startsWith('test-') ? 'test' : 'publish'
|
|
@@ -239,8 +248,11 @@ function main() {
|
|
|
case 'publish':
|
|
|
handlePublishBuild()
|
|
|
break
|
|
|
- case 'build-by-tag':
|
|
|
- handleBuildByTag()
|
|
|
+ case 'test-by-tag':
|
|
|
+ handleBuildByTag('test')
|
|
|
+ break
|
|
|
+ case 'pro-by-tag':
|
|
|
+ handleBuildByTag('pro')
|
|
|
break
|
|
|
default:
|
|
|
console.log('用法: node version-script.js [test|publish|build-by-tag]')
|