@@ -47,11 +47,12 @@ const altPkgRootFolder = configOptions.altPkgRootFolder;
47
47
// command line options
48
48
const yargsConf = yargs
49
49
. usage ( 'Usage: $0 <version> [--preid <identifier>]' )
50
- . example ( '$0 minor --preid beta' , 'Release with minor version bump with pre-release tag' )
50
+ . example ( '$0 minor --preid beta' , 'Release with minor version bump with pre-release tag. (npm tag `beta`) ' )
51
51
. example ( '$0 major' , 'Release with major version bump' )
52
52
. example ( '$0 major --notes "This is new cool version"' , 'Add a custom message to release' )
53
53
. example ( '$0 major --dry-run' , 'Release dry run with patch version bump' )
54
- . example ( '$0 --preid beta' , 'Release same version with pre-release bump' )
54
+ . example ( '$0 --preid alpha' , 'Release same version with pre-release bump. (npm tag `alpha`)' )
55
+ . example ( '$0 0.101.0 --preid rc --tag canary' , 'Release `v0.101.0-rc.0` pre-release version with npm tag `canary`' )
55
56
. command ( 'patch' , 'Release patch' )
56
57
. command ( 'minor' , 'Release minor' )
57
58
. command ( 'major' , 'Release major' )
@@ -61,11 +62,16 @@ const yargsConf = yargs
61
62
describe : 'pre-release identifier' ,
62
63
type : 'string'
63
64
} )
65
+ . option ( 'tag' , {
66
+ demand : false ,
67
+ describe : 'Npm tag name for the pre-release version.\nIf it is not provided, then `preid` value is used' ,
68
+ type : 'string'
69
+ } )
64
70
. option ( 'dry-run' , {
65
71
alias : 'n' ,
66
72
demand : false ,
67
73
default : false ,
68
- describe : 'Execute command in dry run mode. Will not commit, tag, push, or publish anything. Userful for testing.'
74
+ describe : 'Execute command in dry run mode.\nWill not commit, tag, push, or publish anything.\nUserful for testing.'
69
75
} )
70
76
. option ( 'verbose' , {
71
77
demand : false ,
@@ -75,7 +81,7 @@ const yargsConf = yargs
75
81
. option ( 'notes' , {
76
82
demand : false ,
77
83
default : false ,
78
- describe : 'A custom message for release. Overrides [rf|mt]changelog message'
84
+ describe : 'A custom message for release.\nOverrides [rf|mt]changelog message'
79
85
} ) ;
80
86
81
87
const argv = yargsConf . argv ;
@@ -86,7 +92,8 @@ config.silent = !argv.verbose;
86
92
87
93
const versionBumpOptions = {
88
94
type : argv . _ [ 0 ] ,
89
- preid : argv . preid
95
+ preid : argv . preid ,
96
+ npmTagName : argv . tag || argv . preid
90
97
} ;
91
98
92
99
if ( versionBumpOptions . type === undefined && versionBumpOptions . preid === undefined ) {
@@ -133,7 +140,7 @@ function getOwnerAndRepo(url) {
133
140
return ( gitUrlBase || url ) . split ( '/' ) ;
134
141
}
135
142
136
- function release ( { type, preid } ) {
143
+ function release ( { type, preid, npmTagName } ) {
137
144
if ( type === undefined && ! preid ) printErrorAndExit ( 'Must specify version type or preid' ) ;
138
145
139
146
// ensure git repo has no pending changes
@@ -263,6 +270,8 @@ function release({ type, preid }) {
263
270
} else {
264
271
console . log ( 'Releasing: ' . cyan + 'npm package' . green ) ;
265
272
273
+ const npmPublishCmd = preid ? `npm publish --tag ${ npmTagName } ` : 'npm publish' ;
274
+
266
275
// publishing just /altPkgRootFolder content
267
276
if ( altPkgRootFolder ) {
268
277
// prepare custom `package.json` without `scripts` and `devDependencies`
@@ -276,10 +285,10 @@ function release({ type, preid }) {
276
285
`${ JSON . stringify ( npmjson , null , 2 ) } \n` . to ( path . join ( altPkgRootFolder , 'package.json' ) ) ;
277
286
278
287
pushd ( altPkgRootFolder ) ;
279
- safeRun ( 'npm publish' ) ;
288
+ safeRun ( npmPublishCmd ) ;
280
289
popd ( ) ;
281
290
} else {
282
- safeRun ( 'npm publish' ) ;
291
+ safeRun ( npmPublishCmd ) ;
283
292
}
284
293
285
294
console . log ( 'Released: ' . cyan + 'npm package' . green ) ;
0 commit comments