@@ -38,16 +38,9 @@ const signale = new signale_1.Signale({
38
38
} ,
39
39
} ,
40
40
} ) ;
41
- const getParams = ( ) => {
42
- const workDir = path_1 . default . resolve ( misc_1 . getWorkspace ( ) , '.work' ) ;
43
- const buildDir = path_1 . default . resolve ( workDir , 'build' ) ;
44
- const pushDir = path_1 . default . resolve ( workDir , 'push' ) ;
45
- const branchName = misc_1 . getBranchName ( ) ;
46
- return { workDir, buildDir, pushDir, branchName } ;
47
- } ;
48
41
exports . replaceDirectory = ( message ) => {
49
- const { workDir , buildDir , pushDir } = getParams ( ) ;
50
- return message . replace ( buildDir , '<Build Directory>' ) . replace ( pushDir , '<Push Directory>' ) . replace ( workDir , '<Working Directory>' ) ;
42
+ const directories = misc_1 . getReplaceDirectory ( ) ;
43
+ return Object . keys ( directories ) . reduce ( ( value , directory ) => value . replace ( directory , directories [ directory ] ) , message ) ;
51
44
} ;
52
45
// eslint-disable-next-line @typescript-eslint/no-explicit-any
53
46
const output = ( type , message , ...args ) => {
@@ -60,9 +53,9 @@ const note = (message, ...args) => output('process', `[${message}]`, ...args);
60
53
// eslint-disable-next-line @typescript-eslint/no-explicit-any
61
54
const displayCommand = ( message , ...args ) => output ( 'command' , ` > ${ message } ` , ...args ) ;
62
55
// eslint-disable-next-line @typescript-eslint/no-explicit-any
63
- const displayStdout = ( message ) => message . replace ( / \r ? \n $ / , '' ) . split ( / \r ? \n / ) . forEach ( line => output ( 'command' , ` >> ${ line } ` ) ) ;
56
+ const displayStdout = ( message ) => message . replace ( / \r ? \n $ / , '' ) . split ( / \r ? \n / ) . forEach ( line => output ( 'command' , ` >> ${ line } ` ) ) ;
64
57
// eslint-disable-next-line @typescript-eslint/no-explicit-any
65
- const displayStderr = ( message ) => message . replace ( / \r ? \n $ / , '' ) . split ( / \r ? \n / ) . forEach ( line => output ( 'warn' , ` >> ${ line } ` ) ) ;
58
+ const displayStderr = ( message ) => message . replace ( / \r ? \n $ / , '' ) . split ( / \r ? \n / ) . forEach ( line => output ( 'warn' , ` >> ${ line } ` ) ) ;
66
59
// eslint-disable-next-line @typescript-eslint/no-explicit-any
67
60
const startProcess = ( message , ...args ) => {
68
61
signale . log ( ) ;
@@ -116,7 +109,7 @@ exports.execAsync = (args) => new Promise((resolve, reject) => {
116
109
} ) ;
117
110
const cloneForBuild = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
118
111
startProcess ( 'Cloning the working commit from the remote repo for build' ) ;
119
- const { buildDir } = getParams ( ) ;
112
+ const { buildDir } = misc_1 . getParams ( ) ;
120
113
const url = misc_1 . getGitUrl ( context ) ;
121
114
const depth = misc_1 . getFetchDepth ( ) ;
122
115
yield exports . execAsync ( { command : `git -C ${ buildDir } clone --depth=${ depth } ${ url } .` , quiet : true , altCommand : `git clone --depth=${ depth } ` } ) ;
@@ -131,7 +124,7 @@ const runBuild = (buildDir) => __awaiter(void 0, void 0, void 0, function* () {
131
124
} ) ;
132
125
exports . prepareFiles = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
133
126
startProcess ( 'Preparing files for release' ) ;
134
- const { buildDir } = getParams ( ) ;
127
+ const { buildDir } = misc_1 . getParams ( ) ;
135
128
fs_1 . default . mkdirSync ( buildDir , { recursive : true } ) ;
136
129
yield cloneForBuild ( context ) ;
137
130
yield runBuild ( buildDir ) ;
@@ -141,7 +134,7 @@ exports.createBuildInfoFile = (context) => __awaiter(void 0, void 0, void 0, fun
141
134
if ( ! filename ) {
142
135
return ;
143
136
}
144
- const { buildDir, branchName } = getParams ( ) ;
137
+ const { buildDir, branchName } = misc_1 . getParams ( ) ;
145
138
const tagName = misc_1 . getTagName ( context ) ;
146
139
startProcess ( 'Creating build info file' ) ;
147
140
const filepath = path_1 . default . resolve ( buildDir , filename ) ;
@@ -157,24 +150,24 @@ exports.createBuildInfoFile = (context) => __awaiter(void 0, void 0, void 0, fun
157
150
} ) ) ;
158
151
} ) ;
159
152
exports . getCurrentBranchName = ( ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
160
- const { pushDir } = getParams ( ) ;
153
+ const { pushDir } = misc_1 . getParams ( ) ;
161
154
if ( ! fs_1 . default . existsSync ( path_1 . default . resolve ( pushDir , '.git' ) ) ) {
162
155
return '' ;
163
156
}
164
157
return ( yield exports . execAsync ( { command : `git -C ${ pushDir } branch -a | grep -E '^\\*' | cut -b 3-` } ) ) . trim ( ) ;
165
158
} ) ;
166
159
const gitInit = ( ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
167
- const { pushDir } = getParams ( ) ;
160
+ const { pushDir } = misc_1 . getParams ( ) ;
168
161
startProcess ( 'Initializing local git repo' ) ;
169
162
yield exports . execAsync ( { command : `git -C ${ pushDir } init .` } ) ;
170
163
} ) ;
171
164
const gitCheckout = ( ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
172
- const { pushDir, branchName } = getParams ( ) ;
165
+ const { pushDir, branchName } = misc_1 . getParams ( ) ;
173
166
startProcess ( 'Checking out orphan branch %s' , branchName ) ;
174
167
yield exports . execAsync ( { command : `git -C ${ pushDir } checkout --orphan "${ branchName } "` } ) ;
175
168
} ) ;
176
169
exports . cloneForBranch = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
177
- const { pushDir, branchName } = getParams ( ) ;
170
+ const { pushDir, branchName } = misc_1 . getParams ( ) ;
178
171
startProcess ( 'Cloning the branch %s from the remote repo' , branchName ) ;
179
172
const url = misc_1 . getGitUrl ( context ) ;
180
173
const depth = misc_1 . getFetchDepth ( ) ;
@@ -186,7 +179,7 @@ exports.cloneForBranch = (context) => __awaiter(void 0, void 0, void 0, function
186
179
} ) ;
187
180
} ) ;
188
181
exports . checkBranch = ( clonedBranch ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
189
- const { pushDir, branchName } = getParams ( ) ;
182
+ const { pushDir, branchName } = misc_1 . getParams ( ) ;
190
183
if ( branchName !== clonedBranch ) {
191
184
info ( 'remote branch %s not found.' , branchName ) ;
192
185
info ( 'now branch: %s' , clonedBranch ) ;
@@ -197,23 +190,23 @@ exports.checkBranch = (clonedBranch) => __awaiter(void 0, void 0, void 0, functi
197
190
}
198
191
} ) ;
199
192
exports . config = ( ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
200
- const { pushDir } = getParams ( ) ;
193
+ const { pushDir } = misc_1 . getParams ( ) ;
201
194
const name = misc_1 . getCommitName ( ) ;
202
195
const email = misc_1 . getCommitEmail ( ) ;
203
196
startProcess ( 'Configuring git committer to be %s <%s>' , name , email ) ;
204
197
yield exports . execAsync ( { command : `git -C ${ pushDir } config user.name "${ name } "` } ) ;
205
198
yield exports . execAsync ( { command : `git -C ${ pushDir } config user.email "${ email } "` } ) ;
206
199
} ) ;
207
200
const checkDiff = ( ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
208
- const { pushDir } = getParams ( ) ;
201
+ const { pushDir } = misc_1 . getParams ( ) ;
209
202
return ! ! ( yield exports . execAsync ( {
210
203
command : `git -C ${ pushDir } status --short -uno` ,
211
204
quiet : false ,
212
205
suppressOutput : true ,
213
206
} ) ) . split ( / \r \n | \n / ) . filter ( line => line . match ( / ^ [ M D A ] \s + / ) ) . length ;
214
207
} ) ;
215
208
exports . commit = ( ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
216
- const { pushDir } = getParams ( ) ;
209
+ const { pushDir } = misc_1 . getParams ( ) ;
217
210
const message = misc_1 . getCommitMessage ( ) ;
218
211
yield exports . execAsync ( { command : `git -C ${ pushDir } add --all --force` } ) ;
219
212
if ( ! ( yield checkDiff ( ) ) ) {
@@ -225,7 +218,7 @@ exports.commit = () => __awaiter(void 0, void 0, void 0, function* () {
225
218
return true ;
226
219
} ) ;
227
220
exports . push = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
228
- const { pushDir, branchName } = getParams ( ) ;
221
+ const { pushDir, branchName } = misc_1 . getParams ( ) ;
229
222
const tagName = misc_1 . getTagName ( context ) ;
230
223
startProcess ( 'Pushing to %s@%s (tag: %s)' , misc_1 . getRepository ( context ) , branchName , tagName ) ;
231
224
const url = misc_1 . getGitUrl ( context ) ;
@@ -280,12 +273,12 @@ exports.updateRelease = (release, octokit, context) => __awaiter(void 0, void 0,
280
273
} ) ;
281
274
} ) ;
282
275
exports . copyFiles = ( ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
283
- const { buildDir, pushDir } = getParams ( ) ;
276
+ const { buildDir, pushDir } = misc_1 . getParams ( ) ;
284
277
startProcess ( 'Copying %s contents to %s' , buildDir , pushDir ) ;
285
278
yield exports . execAsync ( { command : `rsync -rl --exclude .git --delete "${ buildDir } /" ${ pushDir } ` } ) ;
286
279
} ) ;
287
280
exports . prepareCommit = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
288
- const { workDir, pushDir } = getParams ( ) ;
281
+ const { workDir, pushDir } = misc_1 . getParams ( ) ;
289
282
yield exports . execAsync ( { command : `rm -rdf ${ workDir } ` } ) ;
290
283
fs_1 . default . mkdirSync ( pushDir , { recursive : true } ) ;
291
284
yield exports . cloneForBranch ( context ) ;
@@ -304,7 +297,7 @@ const executeCommit = (release, octokit, context) => __awaiter(void 0, void 0, v
304
297
return true ;
305
298
} ) ;
306
299
exports . deploy = ( octokit , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
307
- const { branchName } = getParams ( ) ;
300
+ const { branchName } = misc_1 . getParams ( ) ;
308
301
startProcess ( 'Deploying branch %s to %s' , branchName , misc_1 . getRepository ( context ) ) ;
309
302
const release = yield findRelease ( octokit , context ) ;
310
303
yield exports . prepareCommit ( context ) ;
0 commit comments