Skip to content

Commit d5b0663

Browse files
committed
fix: 更精确的 release
1 parent 47a109d commit d5b0663

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
"preview:host": "vite preview --host",
2121
"preview:open": "vite preview --open",
2222
"lint": "eslint --ext .ts,.js,.jsx,.vue .",
23-
"build:debug": "cross-env NODE_ENV=debug vite build",
24-
"lint:fix": "eslint --fix --ext .ts,.js,.jsx,.vue .",
25-
"auto:create": "plop --plopfile scripts/create.cjs",
23+
"release": "plop --plopfile scripts/release.cjs",
2624
"auto:remove": "plop --plopfile scripts/remove.cjs",
27-
"release": "changelogen --release && git push --follow-tags"
25+
"auto:create": "plop --plopfile scripts/create.cjs",
26+
"build:debug": "cross-env NODE_ENV=debug vite build",
27+
"lint:fix": "eslint --fix --ext .ts,.js,.jsx,.vue ."
2828
},
2929
"engines": {
3030
"node": ">=v18.16.0"

scripts/release.cjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { execSync } = require('child_process')
2+
3+
/**
4+
* 自动发版
5+
* @param {import('plop').NodePlopAPI} plop
6+
*/
7+
function release(plop) {
8+
plop.setGenerator('controller', {
9+
description: '自动发版',
10+
prompts: [
11+
{
12+
name: 'type',
13+
type: 'list',
14+
default: 'patch',
15+
message: '你希望发布一个什么版本?',
16+
choices: [
17+
'patch',
18+
'minor',
19+
'major',
20+
'prepatch',
21+
'premajor',
22+
'preminor',
23+
'prerelease',
24+
],
25+
},
26+
],
27+
actions(answer) {
28+
const { type } = answer
29+
execSync(
30+
`npx changelogen --${type} --release && git push --follow-tags`,
31+
{
32+
stdio: 'inherit',
33+
}
34+
)
35+
return []
36+
},
37+
})
38+
}
39+
40+
module.exports = release

0 commit comments

Comments
 (0)