|
|
|
|
|
|
|
|
// PB : TODO -- add additional remotes after cloning and pull again... |
|
|
// PB : TODO -- add additional remotes after cloning and pull again... |
|
|
|
|
|
|
|
|
var task = ()=>{ |
|
|
var task = ()=>{ |
|
|
return nodeShellExec('git', ['clone', '-c', 'core.symlinks=true', selectedinstance.reposerver + `/${repoowner || defaultRepoOwner}/` + repo + '.git'], |
|
|
|
|
|
|
|
|
return nodeShellExec('git', ['clone', '-c', 'core.symlinks=true', selectedinstance.reposerver + `/${repodef.owner || repoowner || defaultRepoOwner}/` + repo + '.git'], |
|
|
{ |
|
|
{ |
|
|
inherit: true, shell: true, |
|
|
inherit: true, shell: true, |
|
|
env: process.env |
|
|
env: process.env |
|
|
, cwd : instanceroot |
|
|
|
|
|
|
|
|
, cwd : instanceroot |
|
|
, runas: processedArgs.runas |
|
|
, runas: processedArgs.runas |
|
|
}).then(() => { |
|
|
}).then(() => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
// PB : TODO -- Use the ORG level instance before falling back to common Instance coz common instance may not exist for certain orgs. |
|
|
// PB : TODO -- Use the ORG level instance before falling back to common Instance coz common instance may not exist for certain orgs. |
|
|
, commonInstance(selected) { return __acquireConfig(selected, { defaultRepoOwner } |
|
|
|
|
|
|
|
|
, commonInstance(selected) { return __acquireConfig(selected, { repoOwner : defaultRepoOwner } |
|
|
, undefined |
|
|
, undefined |
|
|
, function(e){ |
|
|
, function(e){ |
|
|
// PB : TODO -- console.info('This is probably an error unless the user is asking to create a new instance with this name.') |
|
|
// PB : TODO -- console.info('This is probably an error unless the user is asking to create a new instance with this name.') |
|
|
|
|
|
|
|
|
throw e |
|
|
throw e |
|
|
} |
|
|
} |
|
|
) } |
|
|
) } |
|
|
// , genericChessInstance(selected) { return __acquireConfig(selected) } |
|
|
|
|
|
|
|
|
// , genericChessInstance(selected) { return __acquireConfig(selected, { repoOwner : defaultRepoOwner }) } |
|
|
} |
|
|
} |
|
|
})() |
|
|
})() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
// PB : TODO -- Use the ORG level instance before falling back to common Instance coz common instance may not exist for certain orgs. |
|
|
// PB : TODO -- Use the ORG level instance before falling back to common Instance coz common instance may not exist for certain orgs. |
|
|
, commonInstance(selected) { return __acquireData(selected, { defaultRepoOwner } |
|
|
|
|
|
|
|
|
, commonInstance(selected) { return __acquireData(selected, { repoOwner : defaultRepoOwner } |
|
|
|
|
|
|
|
|
// , function(e){ console.info('This is probably an error unless the user is asking to create a new instance with this name.') } |
|
|
// , function(e){ console.info('This is probably an error unless the user is asking to create a new instance with this name.') } |
|
|
) } |
|
|
) } |
|
|
, genericChessInstance(selected) { return __acquireData(selected) } |
|
|
|
|
|
|
|
|
, genericChessInstance(selected) { return __acquireData(selected, { repoOwner : defaultRepoOwner }) } |
|
|
} |
|
|
} |
|
|
})() |
|
|
})() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// git config --global credential.helper 'store --file ~/.gitcredentials' |
|
|
// git config --global credential.helper 'store --file ~/.gitcredentials' |
|
|
// git credential-store --file ~/.gitcredentials store |
|
|
// git credential-store --file ~/.gitcredentials store |
|
|
// // notepad C:/Program Files/Git/etc/gitconfig |
|
|
// // notepad C:/Program Files/Git/etc/gitconfig |
|
|
// git config --global --unset credential |
|
|
|
|
|
// git config --edit --system |
|
|
// git config --edit --system |
|
|
// git config --global credential.helper "store --file ~/gitcredentials" |
|
|
// git config --global credential.helper "store --file ~/gitcredentials" |
|
|
// git credential fill |
|
|
// git credential fill |
|
|
|
|
|
|
|
|
var __acquireConfig = function (selected, options, configrepo, errHandler) { |
|
|
var __acquireConfig = function (selected, options, configrepo, errHandler) { |
|
|
|
|
|
|
|
|
configrepo = configrepo || selected.instanceName + '-config-' + selected.node_env; |
|
|
configrepo = configrepo || selected.instanceName + '-config-' + selected.node_env; |
|
|
|
|
|
var repoOwner = options.repoOwner || selected.username || options.defaultRepoOwner |
|
|
|
|
|
|
|
|
var errorHandler = (e) => { |
|
|
var errorHandler = (e) => { |
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: unable to access '${selectedinstance.reposerver}/${selected.username || options.defaultRepoOwner}/${configrepo}.git/': Failed to connect to .*? port .*? after .*? ms: Timed out`))){ |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: unable to access '${selectedinstance.reposerver}/${repoOwner}/${configrepo}.git/': Failed to connect to .*? port .*? after .*? ms: Timed out`))){ |
|
|
// console.error('Could not connect to repo server. Timed Out') |
|
|
// console.error('Could not connect to repo server. Timed Out') |
|
|
return cli.prompt( ['(y)es', '(n)o', '(r)etry'], 'Could not connect to repo server. Timed Out. Would you like to switch server ? (y/n) ', 'y' ).then(propValue => { |
|
|
return cli.prompt( ['(y)es', '(n)o', '(r)etry'], 'Could not connect to repo server. Timed Out. Would you like to switch server ? (y/n) ', 'y' ).then(propValue => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${selected.username || options.defaultRepoOwner}/${configrepo}.git/' not found`))){ |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${repoOwner}/${configrepo}.git/' not found`))){ |
|
|
var choices = { |
|
|
var choices = { |
|
|
t : `install a new temporary local instance with this name ( will not persist ). |
|
|
t : `install a new temporary local instance with this name ( will not persist ). |
|
|
Use your own username for additional options. You can request for a username at chess@bbh.org.in )` |
|
|
Use your own username for additional options. You can request for a username at chess@bbh.org.in )` |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return performPull( selected.reposindexed[configrepo] || { repo : configrepo } |
|
|
return performPull( selected.reposindexed[configrepo] || { repo : configrepo } |
|
|
, null, selected.username || options.defaultRepoOwner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler ) |
|
|
|
|
|
|
|
|
, null, repoOwner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler ) |
|
|
.catch( (e)=>{ |
|
|
.catch( (e)=>{ |
|
|
// if(e){ |
|
|
// if(e){ |
|
|
if(Promise.resolve(e) === e) return e; |
|
|
if(Promise.resolve(e) === e) return e; |
|
|
|
|
|
|
|
|
var __acquireData = function (selected, options, datarepo, errHandler) { |
|
|
var __acquireData = function (selected, options, datarepo, errHandler) { |
|
|
|
|
|
|
|
|
datarepo = datarepo || selected.instanceName + '-data'; |
|
|
datarepo = datarepo || selected.instanceName + '-data'; |
|
|
|
|
|
var repoOwner = options.repoOwner || selected.username || options.defaultRepoOwner |
|
|
|
|
|
|
|
|
var errorHandler = (e) => { |
|
|
var errorHandler = (e) => { |
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: unable to access '${selectedinstance.reposerver}/${selected.username || options.defaultRepoOwner}/${datarepo}.git/': Failed to connect to .*? port .*? after .*? ms: Timed out`))){ |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: unable to access '${selectedinstance.reposerver}/${repoOwner}/${datarepo}.git/': Failed to connect to .*? port .*? after .*? ms: Timed out`))){ |
|
|
// console.error('Could not connect to repo server. Timed Out') |
|
|
// console.error('Could not connect to repo server. Timed Out') |
|
|
return cli.prompt( ['(y)es', '(n)o', '(r)etry'], 'Could not connect to repo server. Timed Out. Would you like to switch server ? (y/n) ', 'y' ).then(propValue => { |
|
|
return cli.prompt( ['(y)es', '(n)o', '(r)etry'], 'Could not connect to repo server. Timed Out. Would you like to switch server ? (y/n) ', 'y' ).then(propValue => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${selected.username || options.defaultRepoOwner}/${datarepo}.git/' not found`))){ |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${repoOwner}/${datarepo}.git/' not found`))){ |
|
|
var choices = { |
|
|
var choices = { |
|
|
t : `install a temporary local data folder. |
|
|
t : `install a temporary local data folder. |
|
|
For more options. Request and use a personal username at chess@bbh.org.in )` |
|
|
For more options. Request and use a personal username at chess@bbh.org.in )` |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return performPull( selected.reposindexed[datarepo] || { repo : datarepo } |
|
|
return performPull( selected.reposindexed[datarepo] || { repo : datarepo } |
|
|
, null, selected.username || options.defaultRepoOwner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler ) |
|
|
|
|
|
|
|
|
, null, repoOwner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler ) |
|
|
.catch( (e)=>{ |
|
|
.catch( (e)=>{ |
|
|
// if(e){ |
|
|
// if(e){ |
|
|
if(Promise.resolve(e) === e) return e; |
|
|
if(Promise.resolve(e) === e) return e; |