Browse Source

Fixes

pull/6/head
guest 3 years ago
parent
commit
6896a8f241
2 changed files with 51 additions and 26 deletions
  1. 1
    1
      cliverse.js
  2. 50
    25
      index.js

+ 1
- 1
cliverse.js View File

var choices = choices || []; var choices = choices || [];
defaultchoice = defaultchoice || choices[0] || choices[Object.keys(choices)[0]] defaultchoice = defaultchoice || choices[0] || choices[Object.keys(choices)[0]]
return this.prompter.ask( return this.prompter.ask(
`${label} \n` + Object.keys(choices).map(choice => { var choice_label = isNaN(+choice) ? choice : choice; return ` ${choice_label}) ${choices[choice]} `}).join('\n') + `\n default ( <= ${ defaultchoice || choices[0]} ) : `
`${label} \n` + Object.keys(choices).map(choice => { var choice_label = isNaN(+choice) ? choice : ((+choice) + 1); return ` ${choice_label}) ${choices[choice]} `}).join('\n') + `\n default ( <= ${ defaultchoice || choices[0]} ) : `
).then(choice => { ).then(choice => {
// propName = promptable.interpret(propValue) // propName = promptable.interpret(propValue)
if(!choice) return defaultchoice || choices[0]; if(!choice) return defaultchoice || choices[0];

+ 50
- 25
index.js View File

} }


if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${owner}/${configrepo}.git/' not found`))){ if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${owner}/${configrepo}.git/' not found`))){
return cli.prompt( {
t : 'install a new temporary local instance with this name'
, i : 'create a new instance with this name => will fork the default config under your username'
, f : 'fork a new instance with this name for yourself for this node from another instance'
, o : 'fork a new instance with this name for your organization from another instance' // prompt organization name...
, c : 'create a custom config for yourself for this node' // prompt hostname as nodename
, p : 'create a custom config for yourself '
, e : 'exit'}
var choices = {
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 )`
, e : 'exit' }

if(selectedinstance.username !== 'guest' && selectedinstance.username !== 'demo') {
choices = utils.assign({
i : 'create a new instance with this name => will fork the default config under your username'
, f : 'fork a new instance with this name for yourself for this node from another instance'
, o : 'fork a new instance with this name for your organization from another instance' // prompt organization name...
, c : 'create a custom config for yourself for this node' // prompt hostname as nodename
, p : 'create a custom config for yourself '
}, choices)
}

return cli.prompt( choices
, 'Config for instance not found. Would you like to ', 'e' ).then(propValue => { , 'Config for instance not found. Would you like to ', 'e' ).then(propValue => {
if(propValue === 't') return eNotImplemented()
if(propValue === 't') return createInstance()
if(propValue === 'i') return eNotImplemented() if(propValue === 'i') return eNotImplemented()
if(propValue === 'f') return eNotImplemented() if(propValue === 'f') return eNotImplemented()
if(propValue === 'o') return eNotImplemented() if(propValue === 'o') return eNotImplemented()


function createInstance(selectedinstance) { function createInstance(selectedinstance) {


// http://try.gitea.io/api/v1/org/{org}/repos
console.dir(selectedinstance) console.dir(selectedinstance)
var server = new URL(selectedinstance.reposerver);
return GITEA.repository.fork( { hostname : server.host, protocol : server.protocol
, username : selectedinstance.username, password : selectedinstance.password
}
// , { repo : `${selectedinstance.instanceName}-config-${selectedinstance.instanceType}`}
, { repo : `chess-config`, owner : 'chess' }, {}, function( repository ){
return GITEA.repository.updateattributes( {
hostname : server.host, protocol : server.protocol
, username : selectedinstance.username, password : selectedinstance.password
}
, { repo : `chess-config`, owner : selectedinstance.username }
, { name : `${selectedinstance.instanceName}-config-${selectedinstance.instanceType}${selectedinstance.nodeName ? '-' + selectedinstance.nodeName : ''}`}
)
}
)
if(selectedinstance.local) {
selectedinstance
var args = {
remotebase : selectedinstance.reposerver + '/chess/'
, sourcerepo : 'chess-config'
, targetrepo : `${selectedinstance.instanceName}-config-${selectedinstance.instanceType}`
}

cmdseq = ['git', ['clone', `${args.remotebase}${args.sourcerepo}`, `${args.targetrepo}`], options]

return any(cmdseq.map(getshelltask)).then(() => {
return true
})
}
else {
// http://try.gitea.io/api/v1/org/{org}/repos
var server = new URL(selectedinstance.reposerver);
return GITEA.repository.fork( { hostname : server.host, protocol : server.protocol
, username : selectedinstance.username, password : selectedinstance.password
}
// , { repo : `${selectedinstance.instanceName}-config-${selectedinstance.instanceType}`}
, { repo : `chess-config`, owner : 'chess' }, {}, function( repository ){
return GITEA.repository.updateattributes( {
hostname : server.host, protocol : server.protocol
, username : selectedinstance.username, password : selectedinstance.password
}
, { repo : `chess-config`, owner : selectedinstance.username }
, { name : `${selectedinstance.instanceName}-config-${selectedinstance.instanceType}${selectedinstance.nodeName ? '-' + selectedinstance.nodeName : ''}`}
)
}
)
}
// GITEA.repository.updateattributes( { // GITEA.repository.updateattributes( {
// hostname : server.host, protocol : server.protocol // hostname : server.host, protocol : server.protocol

Loading…
Cancel
Save