Ver código fonte

feat:更新部署文件

liujia 2 meses atrás
pai
commit
ca97b31cf2
1 arquivos alterados com 12 adições e 11 exclusões
  1. 12 11
      scripts/release.js

+ 12 - 11
scripts/release.js

@@ -14,12 +14,13 @@ function getVersion() {
 async function main() {
   console.log('🚀 开始发布流程...')
 
-  // 1. 选择版本类型
+  // 1. 选择版本类型(默认 minor)
   const { versionType } = await inquirer.prompt([
     {
       type: 'list',
       name: 'versionType',
       message: '请选择版本类型:',
+      default: 'patch',
       choices: [
         { name: '补丁版本 (patch)', value: 'patch' },
         { name: '小版本 (minor)', value: 'minor' },
@@ -28,12 +29,17 @@ async function main() {
     },
   ])
 
-  // 2. 选择日志生成模式
+  // 2. 更新版本号并生成 tag(保证 changelog 最新)
+  run(`npm version ${versionType} -m "new version published: v%s"`)
+  const version = getVersion()
+
+  // 3. 选择日志生成模式(默认增量)
   const { changelogMode } = await inquirer.prompt([
     {
       type: 'list',
       name: 'changelogMode',
       message: '请选择 changelog 生成模式:',
+      default: 'incremental',
       choices: [
         { name: '全量生成(会覆盖整个文件)', value: 'full' },
         { name: '增量生成(只追加本次更新的内容)', value: 'incremental' },
@@ -41,7 +47,7 @@ async function main() {
     },
   ])
 
-  // 3. 根据模式生成 changelog
+  // 4. 根据模式生成 changelog
   console.log('📝 正在生成 changelog...')
   if (changelogMode === 'full') {
     run('npx conventional-changelog -p angular -i CHANGELOG.md -s -r 0')
@@ -49,19 +55,14 @@ async function main() {
     run('npx conventional-changelog -p angular -i CHANGELOG.md -s')
   }
 
-  // 4. 提交 changelog
+  // 5. 将 changelog 合并到刚才的版本提交里
   run('git add CHANGELOG.md')
-  run('git commit -m "chore: update changelog"')
-
-  // 5. 更新版本号并生成 tag(会合并 changelog 提交)
-  run(`npm version ${versionType} -m "new version published: v%s"`)
-
-  const version = getVersion()
+  run('git commit --amend --no-edit')
 
   // 6. 推送代码 & tag
   run('git push --follow-tags')
 
-  // 7. 彩色提示
+  // 7. 提示
   console.log('\x1b[36m=========================\x1b[0m')
   console.log('\x1b[32m🎉 发布成功!\x1b[0m')
   console.log(`\x1b[33m📦 版本号:v${version}\x1b[0m`)