@@ -25,9 +25,8 @@ exports.replaceDirectory = (message) => {
2525} ;
2626const logger = new github_action_helper_1 . Logger ( exports . replaceDirectory ) ;
2727const command = new github_action_helper_1 . Command ( logger ) ;
28- const helper = new github_action_helper_1 . GitHelper ( logger , { depth : misc_1 . getFetchDepth ( ) } ) ;
2928const { startProcess, info } = logger ;
30- exports . prepareFiles = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
29+ exports . prepareFiles = ( helper , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
3130 const { buildDir } = misc_1 . getParams ( ) ;
3231 fs_1 . default . mkdirSync ( buildDir , { recursive : true } ) ;
3332 startProcess ( 'Cloning the remote repo for build...' ) ;
@@ -59,14 +58,14 @@ exports.createBuildInfoFile = (context) => __awaiter(void 0, void 0, void 0, fun
5958 'updated_at' : moment_1 . default ( ) . toISOString ( ) ,
6059 } ) ) ;
6160} ) ;
62- exports . clone = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
61+ exports . clone = ( helper , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
6362 const { pushDir, branchName } = misc_1 . getParams ( ) ;
6463 startProcess ( 'Fetching...' ) ;
6564 yield helper . fetchOrigin ( pushDir , context , [ '--no-tags' ] , [ `+refs/heads/${ branchName } :refs/remotes/origin/${ branchName } ` ] ) ;
6665 startProcess ( 'Switching branch to [%s]...' , branchName ) ;
6766 yield helper . switchBranch ( pushDir , branchName ) ;
6867} ) ;
69- exports . checkBranch = ( clonedBranch ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
68+ exports . checkBranch = ( clonedBranch , helper ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
7069 const { pushDir, branchName } = misc_1 . getParams ( ) ;
7170 if ( branchName !== clonedBranch ) {
7271 info ( 'remote branch %s not found.' , branchName ) ;
@@ -75,36 +74,36 @@ exports.checkBranch = (clonedBranch) => __awaiter(void 0, void 0, void 0, functi
7574 yield helper . gitInit ( pushDir , branchName ) ;
7675 }
7776} ) ;
78- exports . config = ( ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
77+ exports . config = ( helper ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
7978 const { pushDir } = misc_1 . getParams ( ) ;
8079 const name = misc_1 . getCommitName ( ) ;
8180 const email = misc_1 . getCommitEmail ( ) ;
8281 startProcess ( 'Configuring git committer to be %s <%s>...' , name , email ) ;
8382 yield helper . config ( pushDir , name , email ) ;
8483} ) ;
85- exports . commit = ( ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) { return helper . commit ( misc_1 . getParams ( ) . pushDir , misc_1 . getCommitMessage ( ) ) ; } ) ;
86- exports . getDeleteTestTag = ( tagName , prefix ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
84+ exports . commit = ( helper ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) { return helper . commit ( misc_1 . getParams ( ) . pushDir , misc_1 . getCommitMessage ( ) ) ; } ) ;
85+ exports . getDeleteTestTag = ( tagName , prefix , helper ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
8786 return ( yield helper . getTags ( misc_1 . getParams ( ) . pushDir ) )
8887 . filter ( tag => getPrefixRegExp ( prefix ) . test ( tag ) )
8988 . map ( tag => tag . replace ( getPrefixRegExp ( prefix ) , '' ) )
9089 . filter ( tag => versionCompare ( tag , tagName , false ) < 0 ) // eslint-disable-line no-magic-numbers
9190 . map ( tag => `${ prefix } ${ tag } ` ) ;
9291} ) ;
93- exports . deleteTestTags = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
92+ exports . deleteTestTags = ( helper , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
9493 const tagName = getTagName ( context ) ;
9594 const { pushDir } = misc_1 . getParams ( ) ;
9695 if ( ! misc_1 . isTestTag ( tagName ) && misc_1 . isEnabledCleanTestTag ( ) ) {
9796 const prefixForTestTag = misc_1 . getTestTagPrefix ( ) ;
9897 if ( prefixForTestTag ) {
99- yield helper . deleteTag ( pushDir , yield exports . getDeleteTestTag ( tagName , prefixForTestTag ) , context ) ;
98+ yield helper . deleteTag ( pushDir , yield exports . getDeleteTestTag ( tagName , prefixForTestTag , helper ) , context ) ;
10099 const prefixForOriginalTag = misc_1 . getOriginalTagPrefix ( ) ;
101100 if ( prefixForOriginalTag ) {
102- yield helper . deleteTag ( pushDir , yield exports . getDeleteTestTag ( tagName , prefixForOriginalTag + prefixForTestTag ) , context ) ;
101+ yield helper . deleteTag ( pushDir , yield exports . getDeleteTestTag ( tagName , prefixForOriginalTag + prefixForTestTag , helper ) , context ) ;
103102 }
104103 }
105104 }
106105} ) ;
107- exports . push = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
106+ exports . push = ( helper , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
108107 const { pushDir, branchName } = misc_1 . getParams ( ) ;
109108 const tagName = getTagName ( context ) ;
110109 startProcess ( 'Pushing to %s@%s (tag: %s)...' , getRepository ( context ) , branchName , tagName ) ;
@@ -116,7 +115,7 @@ exports.push = (context) => __awaiter(void 0, void 0, void 0, function* () {
116115 }
117116 const tagNames = misc_1 . getCreateTags ( tagName ) ;
118117 yield helper . fetchTags ( pushDir , context ) ;
119- yield exports . deleteTestTags ( context ) ;
118+ yield exports . deleteTestTags ( helper , context ) ;
120119 // eslint-disable-next-line no-magic-numbers
121120 yield helper . deleteTag ( pushDir , tagNames , context , 1 ) ;
122121 yield helper . addLocalTag ( pushDir , tagNames ) ;
@@ -150,26 +149,27 @@ exports.copyFiles = () => __awaiter(void 0, void 0, void 0, function* () {
150149 args : [ '-rl' , '--exclude' , '.git' , '--delete' , `${ buildDir } /` , pushDir ] ,
151150 } ) ;
152151} ) ;
153- exports . prepareCommit = ( context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
154- yield exports . clone ( context ) ;
155- yield exports . checkBranch ( yield helper . getCurrentBranchName ( misc_1 . getParams ( ) . pushDir ) ) ;
156- yield exports . prepareFiles ( context ) ;
152+ exports . prepareCommit = ( helper , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
153+ yield exports . clone ( helper , context ) ;
154+ yield exports . checkBranch ( yield helper . getCurrentBranchName ( misc_1 . getParams ( ) . pushDir ) , helper ) ;
155+ yield exports . prepareFiles ( helper , context ) ;
157156 yield exports . createBuildInfoFile ( context ) ;
158157 yield exports . copyFiles ( ) ;
159158} ) ;
160- const executeCommit = ( release , octokit , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
161- yield exports . config ( ) ;
162- if ( ! ( yield exports . commit ( ) ) ) {
159+ const executeCommit = ( release , helper , octokit , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
160+ yield exports . config ( helper ) ;
161+ if ( ! ( yield exports . commit ( helper ) ) ) {
163162 return false ;
164163 }
165- yield exports . push ( context ) ;
164+ yield exports . push ( helper , context ) ;
166165 yield exports . updateRelease ( release , octokit , context ) ;
167166 return true ;
168167} ) ;
169168exports . deploy = ( octokit , context ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
170169 const { branchName } = misc_1 . getParams ( ) ;
171170 startProcess ( 'Deploying branch %s to %s...' , branchName , getRepository ( context ) ) ;
171+ const helper = new github_action_helper_1 . GitHelper ( logger , { depth : misc_1 . getFetchDepth ( ) } ) ;
172172 const release = yield findRelease ( octokit , context ) ;
173- yield exports . prepareCommit ( context ) ;
174- yield executeCommit ( release , octokit , context ) ;
173+ yield exports . prepareCommit ( helper , context ) ;
174+ yield executeCommit ( release , helper , octokit , context ) ;
175175} ) ;
0 commit comments