1
1
"use strict" ;
2
2
var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
3
+ function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
3
4
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
4
5
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
5
6
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
6
- function step ( result ) { result . done ? resolve ( result . value ) : new P ( function ( resolve ) { resolve ( result . value ) ; } ) . then ( fulfilled , rejected ) ; }
7
+ function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
7
8
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
8
9
} ) ;
9
10
} ;
@@ -12,12 +13,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
13
} ;
13
14
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
14
15
const fs_1 = __importDefault ( require ( "fs" ) ) ;
16
+ const moment_1 = __importDefault ( require ( "moment" ) ) ;
15
17
const path_1 = __importDefault ( require ( "path" ) ) ;
16
18
const signale_1 = __importDefault ( require ( "signale" ) ) ;
17
- const moment_1 = __importDefault ( require ( "moment" ) ) ;
18
19
const child_process_1 = require ( "child_process" ) ;
19
20
const misc_1 = require ( "./misc" ) ;
20
- exports . deploy = ( tagName , octokit , context ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
21
+ exports . deploy = ( tagName , octokit , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
21
22
const workDir = path_1 . default . resolve ( misc_1 . getWorkspace ( ) , '.work' ) ;
22
23
const buildDir = path_1 . default . resolve ( workDir , 'build' ) ;
23
24
const pushDir = path_1 . default . resolve ( workDir , 'push' ) ;
@@ -40,14 +41,14 @@ exports.deploy = (tagName, octokit, context) => __awaiter(this, void 0, void 0,
40
41
return ;
41
42
yield updateRelease ( tagName , octokit , context ) ;
42
43
} ) ;
43
- exports . prepareFiles = ( buildDir , pushDir , tagName , context ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
44
+ exports . prepareFiles = ( buildDir , pushDir , tagName , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
44
45
signale_1 . default . info ( 'Preparing files for release' ) ;
45
46
fs_1 . default . mkdirSync ( buildDir , { recursive : true } ) ;
46
47
yield cloneForBuild ( buildDir , context ) ;
47
48
yield runBuild ( buildDir ) ;
48
49
return true ;
49
50
} ) ;
50
- const createBuildInfoFile = ( buildDir , tagName , branchName ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
51
+ const createBuildInfoFile = ( buildDir , tagName , branchName ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
51
52
const filename = misc_1 . getOutputBuildInfoFilename ( ) ;
52
53
if ( ! filename )
53
54
return true ;
@@ -65,7 +66,7 @@ const createBuildInfoFile = (buildDir, tagName, branchName) => __awaiter(this, v
65
66
} ) ) ;
66
67
return true ;
67
68
} ) ;
68
- const cloneForBranch = ( pushDir , branchName , context ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
69
+ const cloneForBranch = ( pushDir , branchName , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
69
70
signale_1 . default . info ( 'Cloning the branch %s from the remote repo' , branchName ) ;
70
71
const url = misc_1 . getGitUrl ( context ) ;
71
72
yield execAsync ( `git -C ${ pushDir } clone --quiet --branch=${ branchName } --depth=1 ${ url } .` , true , 'git clone' , true ) ;
@@ -80,29 +81,29 @@ const cloneForBranch = (pushDir, branchName, context) => __awaiter(this, void 0,
80
81
}
81
82
return true ;
82
83
} ) ;
83
- const getCurrentBranchName = ( pushDir ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
84
+ const getCurrentBranchName = ( pushDir ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
84
85
if ( ! fs_1 . default . existsSync ( path_1 . default . resolve ( pushDir , '.git' ) ) ) {
85
86
return '' ;
86
87
}
87
88
return ( yield execAsync ( `git -C ${ pushDir } branch -a | grep -E '^\\*' | cut -b 3-` ) ) . trim ( ) ;
88
89
} ) ;
89
- const gitInit = ( pushDir ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
90
+ const gitInit = ( pushDir ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
90
91
signale_1 . default . info ( 'Initializing local git repo' ) ;
91
92
yield execAsync ( `git -C ${ pushDir } init .` ) ;
92
93
} ) ;
93
- const gitCheckout = ( pushDir , branchName ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
94
+ const gitCheckout = ( pushDir , branchName ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
94
95
signale_1 . default . info ( 'Checking out orphan branch %s' , branchName ) ;
95
96
yield execAsync ( `git -C ${ pushDir } checkout --orphan "${ branchName } "` ) ;
96
97
} ) ;
97
- const config = ( pushDir ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
98
+ const config = ( pushDir ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
98
99
const name = misc_1 . getCommitName ( ) ;
99
100
const email = misc_1 . getCommitEmail ( ) ;
100
101
signale_1 . default . info ( 'Configuring git committer to be %s <%s>' , name , email ) ;
101
102
yield execAsync ( `git -C ${ pushDir } config user.name "${ name } "` ) ;
102
103
yield execAsync ( `git -C ${ pushDir } config user.email "${ email } "` ) ;
103
104
return true ;
104
105
} ) ;
105
- const commit = ( pushDir ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
106
+ const commit = ( pushDir ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
106
107
const message = misc_1 . getCommitMessage ( ) ;
107
108
yield execAsync ( `git -C ${ pushDir } add --all --force` ) ;
108
109
if ( ! ( yield checkDiff ( pushDir ) ) ) {
@@ -113,7 +114,7 @@ const commit = (pushDir) => __awaiter(this, void 0, void 0, function* () {
113
114
yield execAsync ( `git -C ${ pushDir } show --stat-count=10 HEAD` ) ;
114
115
return true ;
115
116
} ) ;
116
- const push = ( pushDir , tagName , branchName , context ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
117
+ const push = ( pushDir , tagName , branchName , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
117
118
signale_1 . default . info ( 'Pushing to %s@%s (tag: %s)' , misc_1 . getRepository ( context ) , branchName , tagName ) ;
118
119
const url = misc_1 . getGitUrl ( context ) ;
119
120
const tagNames = misc_1 . getCreateTags ( tagName ) ;
@@ -128,7 +129,7 @@ const push = (pushDir, tagName, branchName, context) => __awaiter(this, void 0,
128
129
yield execAsync ( `git -C ${ pushDir } push --quiet --tags "${ url } " "${ branchName } ":"refs/heads/${ branchName } "` , true , `git push --tags "${ branchName } ":"refs/heads/${ branchName } "` ) ;
129
130
return true ;
130
131
} ) ;
131
- const updateRelease = ( tagName , octokit , context ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
132
+ const updateRelease = ( tagName , octokit , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
132
133
const releases = yield octokit . repos . listReleases ( {
133
134
owner : context . repo . owner ,
134
135
repo : context . repo . repo ,
@@ -146,27 +147,27 @@ const updateRelease = (tagName, octokit, context) => __awaiter(this, void 0, voi
146
147
} ) ;
147
148
return true ;
148
149
} ) ;
149
- const cloneForBuild = ( buildDir , context ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
150
+ const cloneForBuild = ( buildDir , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
150
151
signale_1 . default . info ( 'Cloning the working commit from the remote repo for build' ) ;
151
152
const url = misc_1 . getGitUrl ( context ) ;
152
153
yield execAsync ( `git -C ${ buildDir } clone --depth=1 ${ url } .` , true , 'git clone --depth=1' ) ;
153
154
yield execAsync ( `git -C ${ buildDir } fetch "${ url } " ${ context . ref } ` , true , `git fetch origin ${ context . ref } ` ) ;
154
155
yield execAsync ( `git -C ${ buildDir } checkout -qf ${ context . sha } ` ) ;
155
156
} ) ;
156
- const runBuild = ( buildDir ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
157
+ const runBuild = ( buildDir ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
157
158
signale_1 . default . info ( '=== Running build for release ===' ) ;
158
159
const current = process . cwd ( ) ;
159
160
for ( const command of misc_1 . getBuildCommands ( buildDir ) ) {
160
161
yield execAsync ( `cd ${ buildDir } && ${ command } ` ) ;
161
162
}
162
163
yield execAsync ( `cd ${ current } ` ) ;
163
164
} ) ;
164
- const copyFiles = ( buildDir , pushDir ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
165
+ const copyFiles = ( buildDir , pushDir ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
165
166
signale_1 . default . info ( '=== Copying %s contents to %s ===' , buildDir , pushDir ) ;
166
167
yield execAsync ( `rsync -rl --exclude .git --delete "${ buildDir } /" ${ pushDir } ` ) ;
167
168
return true ;
168
169
} ) ;
169
- const checkDiff = ( pushDir ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
170
+ const checkDiff = ( pushDir ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
170
171
return ( yield execAsync ( `git -C ${ pushDir } status --short -uno` , false , null , false , true ) ) . split ( / \r \n | \n / ) . filter ( line => line . match ( / ^ [ M D A ] \s + / ) ) . length > 0 ;
171
172
} ) ;
172
173
const execAsync = ( command , quiet = false , altCommand = null , suppressError = false , suppressOutput = false ) => new Promise ( ( resolve , reject ) => {
0 commit comments