11import fs from 'fs'
22import moment from 'moment'
33// @ts -ignore
4- import * as git from 'isomorphic-git/dist/for-node/isomorphic-git'
54import Model from './model'
5+ import GitProxy from './plugins/deploys/gitproxy'
6+
7+ const git = require ( 'isomorphic-git' )
68
79export default class Deploy extends Model {
810 outputDir : string = `${ this . appDir } /output`
@@ -11,9 +13,10 @@ export default class Deploy extends Model {
1113
1214 platformAddress = ''
1315
16+ http = new GitProxy ( this )
17+
1418 constructor ( appInstance : any ) {
1519 super ( appInstance )
16-
1720 const { setting } = this . db
1821 this . platformAddress = ( {
1922 github : 'github.com' ,
@@ -33,7 +36,7 @@ export default class Deploy extends Model {
3336 async remoteDetect ( ) {
3437 const result = {
3538 success : true ,
36- message : '' ,
39+ message : [ '' ] ,
3740 }
3841 try {
3942 const { setting } = this . db
@@ -53,13 +56,13 @@ export default class Deploy extends Model {
5356 }
5457 if ( ! isRepo ) {
5558 await git . init ( { fs, dir : this . outputDir } )
56- await git . config ( {
59+ await git . setConfig ( {
5760 fs,
5861 dir : this . outputDir ,
5962 path : 'user.name' ,
6063 value : setting . username ,
6164 } )
62- await git . config ( {
65+ await git . setConfig ( {
6366 fs,
6467 dir : this . outputDir ,
6568 path : 'user.email' ,
@@ -71,13 +74,13 @@ export default class Deploy extends Model {
7174 fs, dir : this . outputDir , remote : 'origin' , url : this . remoteUrl , force : true ,
7275 } )
7376 const info = await git . getRemoteInfo ( {
74- core : 'default' ,
77+ http : this . http ,
7578 url : this . remoteUrl ,
7679 } )
7780 console . log ( 'info' , info )
78- result . message = info
81+ result . message = info . capabilities
7982 } catch ( e ) {
80- console . log ( 'Test Remote Error: ' , e . message )
83+ console . log ( 'Test Remote Error: ' , e )
8184 result . success = false
8285 result . message = e . message
8386 }
@@ -113,13 +116,13 @@ export default class Deploy extends Model {
113116
114117 try {
115118 await git . init ( { fs, dir : this . outputDir } )
116- await git . config ( {
119+ await git . setConfig ( {
117120 fs,
118121 dir : this . outputDir ,
119122 path : 'user.name' ,
120123 value : setting . username ,
121124 } )
122- await git . config ( {
125+ await git . setConfig ( {
123126 fs,
124127 dir : this . outputDir ,
125128 path : 'user.email' ,
@@ -138,6 +141,7 @@ export default class Deploy extends Model {
138141 await this . checkCurrentBranch ( )
139142 const pushRes = await git . push ( {
140143 fs,
144+ http : this . http ,
141145 dir : this . outputDir ,
142146 remote : 'origin' ,
143147 ref : setting . branch ,
@@ -184,6 +188,7 @@ export default class Deploy extends Model {
184188
185189 const pushRes = await git . push ( {
186190 fs,
191+ http : this . http ,
187192 dir : this . outputDir ,
188193 remote : 'origin' ,
189194 ref : setting . branch ,
@@ -221,7 +226,7 @@ export default class Deploy extends Model {
221226 await git . branch ( { fs, dir : this . outputDir , ref : setting . branch } )
222227 }
223228
224- await git . fastCheckout ( { fs, dir : this . outputDir , ref : setting . branch } )
229+ await git . checkout ( { fs, dir : this . outputDir , ref : setting . branch } )
225230 }
226231 }
227232}
0 commit comments