@@ -12,7 +12,15 @@ import { fileURLToPath } from 'node:url'
1212const { prompt } = enquirer
1313const currentVersion = createRequire ( import . meta. url ) ( '../package.json' ) . version
1414const __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+
1624const preId = args . preid || semver . prerelease ( currentVersion ) ?. [ 0 ]
1725const isDryRun = args . dry
1826let skipTests = args . skipTests
@@ -74,17 +82,21 @@ async function main() {
7482 let targetVersion = args . _ [ 0 ]
7583
7684 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)
7886 // Use UTC date so that it's consistent across CI and maintainers' machines
7987 const date = new Date ( )
8088 const yyyy = date . getUTCFullYear ( )
8189 const MM = ( date . getUTCMonth ( ) + 1 ) . toString ( ) . padStart ( 2 , '0' )
8290 const dd = date . getUTCDate ( ) . toString ( ) . padStart ( 2 , '0' )
8391
8492 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+ }
88100
89101 // check the registry to avoid version collision
90102 // in case we need to publish more than one canary versions in a day
@@ -100,9 +112,15 @@ async function main() {
100112 const latestSameDayPatch = /** @type {string } */ (
101113 semver . maxSatisfying ( versions , `~${ canaryVersion } ` )
102114 )
115+
103116 canaryVersion = /** @type {string } */ (
104117 semver . inc ( latestSameDayPatch , 'patch' )
105118 )
119+ if ( args . tag && args . tag !== 'latest' ) {
120+ canaryVersion = /** @type {string } */ (
121+ semver . inc ( latestSameDayPatch , 'prerelease' , args . tag )
122+ )
123+ }
106124 } catch ( e ) {
107125 if ( / E 4 0 4 / . test ( e . message ) ) {
108126 // the first patch version on that day
0 commit comments