@@ -12,7 +12,15 @@ import { fileURLToPath } from 'node:url'
12
12
const { prompt } = enquirer
13
13
const currentVersion = createRequire ( import . meta. url ) ( '../package.json' ) . version
14
14
const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
15
- const args = minimist ( process . argv . slice ( 2 ) )
15
+ const args = minimist ( process . argv . slice ( 2 ) , {
16
+ alias : {
17
+ skipBuild : 'skip-build' ,
18
+ skipTests : 'skip-tests' ,
19
+ skipGit : 'skip-git' ,
20
+ skipPrompts : 'skip-prompts'
21
+ }
22
+ } )
23
+
16
24
const preId = args . preid || semver . prerelease ( currentVersion ) ?. [ 0 ]
17
25
const isDryRun = args . dry
18
26
let skipTests = args . skipTests
@@ -74,17 +82,21 @@ async function main() {
74
82
let targetVersion = args . _ [ 0 ]
75
83
76
84
if ( isCanary ) {
77
- // The canary version string format is `3.yyyyMMdd.0`.
85
+ // The canary version string format is `3.yyyyMMdd.0` (or `3.yyyyMMdd.0-minor.0` for minor)
78
86
// Use UTC date so that it's consistent across CI and maintainers' machines
79
87
const date = new Date ( )
80
88
const yyyy = date . getUTCFullYear ( )
81
89
const MM = ( date . getUTCMonth ( ) + 1 ) . toString ( ) . padStart ( 2 , '0' )
82
90
const dd = date . getUTCDate ( ) . toString ( ) . padStart ( 2 , '0' )
83
91
84
92
const major = semver . major ( currentVersion )
85
- const minor = `${ yyyy } ${ MM } ${ dd } `
86
- const patch = 0
87
- let canaryVersion = `${ major } .${ minor } .${ patch } `
93
+ const datestamp = `${ yyyy } ${ MM } ${ dd } `
94
+ let canaryVersion
95
+
96
+ canaryVersion = `${ major } .${ datestamp } .0`
97
+ if ( args . tag && args . tag !== 'latest' ) {
98
+ canaryVersion = `${ major } .${ datestamp } .0-${ args . tag } .0`
99
+ }
88
100
89
101
// check the registry to avoid version collision
90
102
// in case we need to publish more than one canary versions in a day
@@ -100,9 +112,15 @@ async function main() {
100
112
const latestSameDayPatch = /** @type {string } */ (
101
113
semver . maxSatisfying ( versions , `~${ canaryVersion } ` )
102
114
)
115
+
103
116
canaryVersion = /** @type {string } */ (
104
117
semver . inc ( latestSameDayPatch , 'patch' )
105
118
)
119
+ if ( args . tag && args . tag !== 'latest' ) {
120
+ canaryVersion = /** @type {string } */ (
121
+ semver . inc ( latestSameDayPatch , 'prerelease' , args . tag )
122
+ )
123
+ }
106
124
} catch ( e ) {
107
125
if ( / E 4 0 4 / . test ( e . message ) ) {
108
126
// the first patch version on that day
0 commit comments