@@ -50,7 +50,7 @@ const altPkgRootFolder = configOptions.altPkgRootFolder;
50
50
//------------------------------------------------------------------------------
51
51
// command line options
52
52
const yargsConf = yargs
53
- . usage ( 'Usage: $0 <version> [--preid <identifier>]' )
53
+ . usage ( 'Usage: $0 <version> [--preid <identifier>]\nor\nUsage: $0 --only-docs ' )
54
54
. example ( '$0 minor --preid beta' , 'Release with minor version bump with pre-release tag. (npm tag `beta`)' )
55
55
. example ( '$0 major' , 'Release with major version bump' )
56
56
. example ( '$0 major --notes "This is new cool version"' , 'Add a custom message to release' )
@@ -71,6 +71,12 @@ const yargsConf = yargs
71
71
describe : 'Npm tag name for the pre-release version.\nIf it is not provided, then `preid` value is used' ,
72
72
type : 'string'
73
73
} )
74
+ . option ( 'only-docs' , {
75
+ alias : 'docs' ,
76
+ demand : false ,
77
+ default : false ,
78
+ describe : 'Publish only documents'
79
+ } )
74
80
. option ( 'dry-run' , {
75
81
alias : 'n' ,
76
82
demand : false ,
@@ -91,12 +97,13 @@ const yargsConf = yargs
91
97
const argv = yargsConf . argv ;
92
98
93
99
if ( argv . dryRun ) console . log ( 'DRY RUN' . magenta ) ;
100
+ if ( argv . onlyDocs ) console . log ( 'Publish only documents' . magenta ) ;
94
101
95
102
config . silent = ! argv . verbose ;
96
103
97
104
const versionBumpOptions = {
98
105
type : argv . _ [ 0 ] ,
99
- preid : argv . preid ,
106
+ preid : argv . onlyDocs ? 'docs' : argv . preid ,
100
107
npmTagName : argv . tag || argv . preid
101
108
} ;
102
109
@@ -250,85 +257,87 @@ function release({ type, preid, npmTagName }) {
250
257
safeRun ( 'git push --follow-tags' ) ;
251
258
console . log ( 'Tagged: ' . cyan + vVersion . green ) ;
252
259
253
- // publish to GitHub
254
- if ( githubToken ) {
255
- console . log ( `GitHub token found ${ githubToken } ` . green ) ;
256
- console . log ( 'Publishing to GitHub: ' . cyan + vVersion . green ) ;
260
+ if ( ! argv . onlyDocs ) {
261
+ // publish to GitHub
262
+ if ( githubToken ) {
263
+ console . log ( `GitHub token found ${ githubToken } ` . green ) ;
264
+ console . log ( 'Publishing to GitHub: ' . cyan + vVersion . green ) ;
265
+
266
+ if ( argv . dryRun ) {
267
+ console . log ( `[publishing to GitHub]` . grey , 'DRY RUN' . magenta ) ;
268
+ } else {
269
+ const [ githubOwner , githubRepo ] = getOwnerAndRepo ( npmjson . repository . url || npmjson . repository ) ;
270
+
271
+ request ( {
272
+ uri : `https://api.github.com/repos/${ githubOwner } /${ githubRepo } /releases` ,
273
+ method : 'POST' ,
274
+ json : true ,
275
+ body : {
276
+ tag_name : vVersion , // eslint-disable-line camelcase
277
+ name : `${ githubRepo } ${ vVersion } ` ,
278
+ body : notesForRelease ,
279
+ draft : false ,
280
+ prerelease : ! ! preid
281
+ } ,
282
+ headers : {
283
+ 'Authorization' : `token ${ githubToken } ` ,
284
+ 'User-Agent' : 'release-script (https://github.com/alexkval/release-script)'
285
+ }
286
+ } , function ( err , res , body ) {
287
+ if ( err ) {
288
+ console . log ( 'API request to GitHub, error has occured:' . red ) ;
289
+ console . log ( err ) ;
290
+ console . log ( 'Skip GitHub releasing' . yellow ) ;
291
+ } else if ( res . statusMessage === 'Unauthorized' ) {
292
+ console . log ( `GitHub token ${ githubToken } is wrong` . red ) ;
293
+ console . log ( 'Skip GitHub releasing' . yellow ) ;
294
+ } else {
295
+ console . log ( `Published at ${ body . html_url } ` . green ) ;
296
+ }
297
+ } ) ;
298
+ }
299
+ }
257
300
258
- if ( argv . dryRun ) {
259
- console . log ( `[publishing to GitHub]` . grey , 'DRY RUN' . magenta ) ;
301
+ // npm
302
+ if ( isPrivate ) {
303
+ console . log ( 'Package is private, skipping npm release' . yellow ) ;
260
304
} else {
261
- const [ githubOwner , githubRepo ] = getOwnerAndRepo ( npmjson . repository . url || npmjson . repository ) ;
262
-
263
- request ( {
264
- uri : `https://api.github.com/repos/${ githubOwner } /${ githubRepo } /releases` ,
265
- method : 'POST' ,
266
- json : true ,
267
- body : {
268
- tag_name : vVersion , // eslint-disable-line camelcase
269
- name : `${ githubRepo } ${ vVersion } ` ,
270
- body : notesForRelease ,
271
- draft : false ,
272
- prerelease : ! ! preid
273
- } ,
274
- headers : {
275
- 'Authorization' : `token ${ githubToken } ` ,
276
- 'User-Agent' : 'release-script (https://github.com/alexkval/release-script)'
277
- }
278
- } , function ( err , res , body ) {
279
- if ( err ) {
280
- console . log ( 'API request to GitHub, error has occured:' . red ) ;
281
- console . log ( err ) ;
282
- console . log ( 'Skip GitHub releasing' . yellow ) ;
283
- } else if ( res . statusMessage === 'Unauthorized' ) {
284
- console . log ( `GitHub token ${ githubToken } is wrong` . red ) ;
285
- console . log ( 'Skip GitHub releasing' . yellow ) ;
286
- } else {
287
- console . log ( `Published at ${ body . html_url } ` . green ) ;
288
- }
289
- } ) ;
305
+ console . log ( 'Releasing: ' . cyan + 'npm package' . green ) ;
306
+
307
+ const npmPublishCmd = preid ? `npm publish --tag ${ npmTagName } ` : 'npm publish' ;
308
+
309
+ // publishing just /altPkgRootFolder content
310
+ if ( altPkgRootFolder ) {
311
+ // prepare custom `package.json` without `scripts` and `devDependencies`
312
+ // because it already has been saved, we safely can use the same object
313
+ delete npmjson . files ; // because otherwise it would be wrong
314
+ delete npmjson . scripts ;
315
+ delete npmjson . devDependencies ;
316
+ delete npmjson [ 'release-script' ] ; // this also doesn't belong to output
317
+ const regexp = new RegExp ( altPkgRootFolder + '\\/?' ) ;
318
+ npmjson . main = npmjson . main . replace ( regexp , '' ) ; // remove folder part from path
319
+ `${ JSON . stringify ( npmjson , null , 2 ) } \n` . to ( path . join ( altPkgRootFolder , 'package.json' ) ) ;
320
+
321
+ pushd ( altPkgRootFolder ) ;
322
+ safeRun ( npmPublishCmd ) ;
323
+ popd ( ) ;
324
+ } else {
325
+ safeRun ( npmPublishCmd ) ;
326
+ }
327
+
328
+ console . log ( 'Released: ' . cyan + 'npm package' . green ) ;
290
329
}
291
- }
292
330
293
- // npm
294
- if ( isPrivate ) {
295
- console . log ( 'Package is private, skipping npm release' . yellow ) ;
296
- } else {
297
- console . log ( 'Releasing: ' . cyan + 'npm package' . green ) ;
298
-
299
- const npmPublishCmd = preid ? `npm publish --tag ${ npmTagName } ` : 'npm publish' ;
300
-
301
- // publishing just /altPkgRootFolder content
302
- if ( altPkgRootFolder ) {
303
- // prepare custom `package.json` without `scripts` and `devDependencies`
304
- // because it already has been saved, we safely can use the same object
305
- delete npmjson . files ; // because otherwise it would be wrong
306
- delete npmjson . scripts ;
307
- delete npmjson . devDependencies ;
308
- delete npmjson [ 'release-script' ] ; // this also doesn't belong to output
309
- const regexp = new RegExp ( altPkgRootFolder + '\\/?' ) ;
310
- npmjson . main = npmjson . main . replace ( regexp , '' ) ; // remove folder part from path
311
- `${ JSON . stringify ( npmjson , null , 2 ) } \n` . to ( path . join ( altPkgRootFolder , 'package.json' ) ) ;
312
-
313
- pushd ( altPkgRootFolder ) ;
314
- safeRun ( npmPublishCmd ) ;
315
- popd ( ) ;
331
+ // bower
332
+ if ( isPrivate ) {
333
+ console . log ( 'Package is private, skipping bower release' . yellow ) ;
334
+ } else if ( bowerRepo ) {
335
+ console . log ( 'Releasing: ' . cyan + 'bower package' . green ) ;
336
+ releaseAdRepo ( bowerRepo , bowerRoot , tmpBowerRepo , vVersion ) ;
337
+ console . log ( 'Released: ' . cyan + 'bower package' . green ) ;
316
338
} else {
317
- safeRun ( npmPublishCmd ) ;
339
+ console . log ( 'The "bowerRepo" is not set in package.json. Not publishing bower.' . yellow ) ;
318
340
}
319
-
320
- console . log ( 'Released: ' . cyan + 'npm package' . green ) ;
321
- }
322
-
323
- // bower
324
- if ( isPrivate ) {
325
- console . log ( 'Package is private, skipping bower release' . yellow ) ;
326
- } else if ( bowerRepo ) {
327
- console . log ( 'Releasing: ' . cyan + 'bower package' . green ) ;
328
- releaseAdRepo ( bowerRepo , bowerRoot , tmpBowerRepo , vVersion ) ;
329
- console . log ( 'Released: ' . cyan + 'bower package' . green ) ;
330
- } else {
331
- console . log ( 'The "bowerRepo" is not set in package.json. Not publishing bower.' . yellow ) ;
332
341
}
333
342
334
343
// documents site
0 commit comments