@@ -7,14 +7,16 @@ import preConditions from './pre-conditions';
7
7
import versionBump from './version-bump' ;
8
8
import addChangelog from './changelog' ;
9
9
import repoRelease from './repo-release' ;
10
+ import tag from './tag' ;
10
11
import tagAndPublish from './tag-and-publish' ;
11
- import test from './test' ;
12
+ import test , { lint } from '../release-scripts /test' ;
12
13
import build from '../build' ;
13
14
14
15
import { bowerRepo , bowerRoot , tmpBowerRepo , docsRoot , docsRepo , tmpDocsRepo } from '../constants' ;
15
16
16
17
const yargsConf = yargs
17
- . usage ( 'Usage: $0 <version> [--preid <identifier>]' )
18
+ . usage ( 'Usage: $0 <version> [--preid <identifier>]\nor\nUsage: $0 --docs' )
19
+ . example ( '$0 --docs' , 'Release only docs' )
18
20
. example ( '$0 minor --preid beta' , 'Release with minor version bump with pre-release tag' )
19
21
. example ( '$0 major' , 'Release with major version bump' )
20
22
. example ( '$0 major --dry-run' , 'Release dry run with patch version bump' )
@@ -23,6 +25,10 @@ const yargsConf = yargs
23
25
. command ( 'minor' , 'Release minor' )
24
26
. command ( 'major' , 'Release major' )
25
27
. command ( '<version>' , 'Release specific version' )
28
+ . option ( 'docs' , {
29
+ demand : false ,
30
+ describe : 'Release only docs'
31
+ } )
26
32
. option ( 'preid' , {
27
33
demand : false ,
28
34
describe : 'pre-release identifier' ,
@@ -50,37 +56,23 @@ if (argv.dryRun) {
50
56
let version ;
51
57
52
58
const versionBumpOptions = {
53
- preid : argv . preid ,
59
+ preid : argv . docs ? 'docs' : argv . preid ,
54
60
type : argv . _ [ 0 ]
55
61
} ;
56
62
57
- if ( versionBumpOptions . type === undefined && versionBumpOptions . preid === undefined ) {
58
- console . log ( 'Must provide either a version bump type, preid, or both' . red ) ;
63
+ if ( ! argv . docs && versionBumpOptions . type === undefined && versionBumpOptions . preid === undefined ) {
64
+ console . log ( 'Must provide either --docs or a version bump type, preid ( or both) ' . red ) ;
59
65
console . log ( yargsConf . help ( ) ) ;
60
66
process . exit ( 1 ) ;
61
67
}
62
68
63
- preConditions ( )
64
- . then ( test )
65
- . then ( versionBump ( versionBumpOptions ) )
66
- . then ( v => { version = v ; } )
67
- . then ( ( ) => addChangelog ( version ) )
68
- . then ( ( ) => {
69
- return build ( argv . verbose )
70
- . catch ( err => {
71
- console . log ( 'Build failed, reverting version bump' . red ) ;
72
-
73
- return exec ( 'git reset HEAD .' )
74
- . then ( ( ) => exec ( 'git checkout package.json' ) )
75
- . then ( ( ) => exec ( 'git checkout CHANGELOG.md' ) )
76
- . then ( ( ) => console . log ( 'Version bump reverted' . red ) )
77
- . then ( ( ) => {
78
- throw err ;
79
- } ) ;
80
- } ) ;
81
- } )
82
- . then ( ( ) => safeExec ( `git commit -m "Release v${ version } "` ) )
83
- . then ( ( ) => {
69
+ function tagAndRelease ( ) {
70
+ if ( argv . docs ) {
71
+ return Promise . all ( [
72
+ tag ( version ) ,
73
+ repoRelease ( docsRepo , docsRoot , tmpDocsRepo , version )
74
+ ] ) ;
75
+ } else {
84
76
let releases = [
85
77
tagAndPublish ( version ) ,
86
78
repoRelease ( bowerRepo , bowerRoot , tmpBowerRepo , version )
@@ -91,7 +83,33 @@ preConditions()
91
83
}
92
84
93
85
return Promise . all ( releases ) ;
94
- } )
86
+ }
87
+ }
88
+
89
+ function prepareRepo ( ) {
90
+ if ( argv . docs ) {
91
+ return exec ( `npm run docs-build${ argv . verbose ? ' -- --verbose' : '' } ` ) ;
92
+ } else {
93
+ return build ( argv . verbose ) . then ( ( ) => addChangelog ( version ) ) ;
94
+ }
95
+ }
96
+
97
+ function revertAndThrow ( err ) {
98
+ console . log ( 'Build failed, reverting version bump' . red ) ;
99
+
100
+ return exec ( 'git reset HEAD .' )
101
+ . then ( ( ) => exec ( 'git checkout package.json' ) )
102
+ . then ( ( ) => console . log ( 'Version bump reverted' . red ) )
103
+ . then ( ( ) => { throw err ; } ) ;
104
+ }
105
+
106
+ preConditions ( )
107
+ . then ( argv . docs ? lint : test )
108
+ . then ( versionBump ( versionBumpOptions ) )
109
+ . then ( v => { version = v ; } )
110
+ . then ( ( ) => prepareRepo ( ) . catch ( err => revertAndThrow ( err ) ) )
111
+ . then ( ( ) => safeExec ( `git commit -m "Release v${ version } "` ) )
112
+ . then ( tagAndRelease )
95
113
. then ( ( ) => console . log ( 'Version ' . cyan + `v${ version } ` . green + ' released!' . cyan ) )
96
114
. catch ( err => {
97
115
if ( ! err . __handled ) {
0 commit comments