Parcourir la source

feat: 更新部署脚本添加后续执行步骤提示

liujia il y a 2 mois
Parent
commit
975169a73a
1 fichiers modifiés avec 25 ajouts et 5 suppressions
  1. 25 5
      scripts/release.js

+ 25 - 5
scripts/release.js

@@ -1,11 +1,16 @@
 #!/usr/bin/env node
 import { execSync } from 'child_process'
 import inquirer from 'inquirer'
+import fs from 'fs'
 
 function run(cmd) {
   execSync(cmd, { stdio: 'inherit' })
 }
 
+function getVersion() {
+  return JSON.parse(fs.readFileSync('package.json', 'utf8')).version
+}
+
 async function main() {
   console.log('🚀 开始发布流程...')
 
@@ -23,22 +28,37 @@ async function main() {
     },
   ])
 
-  // 2. 更新版本号(生成新 tag)
+  // 2. 更新版本号(生成新 tag)
   run(`npm version ${versionType} -m "new version published: v%s"`)
 
-  // 3. 全量生成 changelog(覆盖原文件)
+  // 读取新版本号
+  const version = getVersion()
+
+  // 3. 全量生成 changelog
   console.log('📝 正在全量生成 changelog...')
   run('npx conventional-changelog -p angular -i CHANGELOG.md -s -r 0')
 
   // 4. 自动提交 changelog
   run('git add CHANGELOG.md')
-  run('git commit --amend --no-edit') // 直接加到刚才的版本提交里
+  run('git commit --amend --no-edit') // 合并到刚才的提交
 
-  // 5. 推送代码 & tag(tag 不变,提交更新了)
+  // 5. 推送代码 & tag
   run('git push --force-with-lease')
   run('git push --tags')
 
-  console.log('✅ 发布完成!')
+  // 6. 彩色提示
+  console.log('\x1b[36m=========================\x1b[0m')
+  console.log('\x1b[32m🎉 发布成功!\x1b[0m')
+  console.log(`\x1b[33m📦 版本号:v${version}\x1b[0m`)
+  console.log('\x1b[35m⚙️  部署:\x1b[0m')
+  console.log('\x1b[34m  * 打包并部署到测试环境(单机版):npm run deploy:test\x1b[0m')
+  console.log('\x1b[35m⚙️  打包:\x1b[0m')
+  console.log('\x1b[34m  * 开发环境:npm run build:dev\x1b[0m')
+  console.log('\x1b[34m  * 测试环境:npm run build:test\x1b[0m')
+  console.log('\x1b[34m  * 生产环境:npm run build\x1b[0m')
+  console.log('\x1b[35m⚙️  同步代码:\x1b[0m')
+  console.log('\x1b[34m  * 同步dev分支代码到prod分支:bash scripts/merge_dev_to_pro.sh\x1b[0m')
+  console.log('\x1b[36m=========================\x1b[0m')
 }
 
 main()