Browse Source

Merge branch 'master' of http://git.bbh/chess/elxr into master

master
samuel 3 years ago
parent
commit
07fd597ab5
2 changed files with 39 additions and 21 deletions
  1. 3
    2
      cliverse.js
  2. 36
    19
      index.js

+ 3
- 2
cliverse.js View File

}); });
} }
child.on('close', (code) => { child.on('close', (code) => {
if(+code !== 0 || opts.haserrors) success = false;
var logEntry = { code, success }
if(+code !== 0 || opts.haserrors) { success = false; logEntry = { result: `${opts.title} exited with code ${code}`, success, code }};
if(opts.stdio !== 'ignore') { if(opts.stdio !== 'ignore') {
var logEntry = { result: `${opts.title} exited with code ${code}`, messages }
logEntry = { result: `${opts.title} exited with code ${code}`, messages, code }
logEntry.success = success; logEntry.success = success;
if(opts.runas){ if(opts.runas){

+ 36
- 19
index.js View File

, 'is-git-repo': (dir) => { , 'is-git-repo': (dir) => {
return nodeShellExec('git', ['-C', dir.name, 'rev-parse'], { stdio: 'ignore' }) return nodeShellExec('git', ['-C', dir.name, 'rev-parse'], { stdio: 'ignore' })
} }
// git remote equivalents...
// git branch --set-upstream-to=elixir-unc/master master
// git push --set-upstream elixir-unc branch..
, 'set-url': (remotename, url) => { , 'set-url': (remotename, url) => {
var pushable = processedArgs.pushable || false; var pushable = processedArgs.pushable || false;
remotename = remotename || processedArgs._[1] remotename = remotename || processedArgs._[1]
} }


var perform_git_seturl = (dir) => { var perform_git_seturl = (dir) => {
op['is-git-repo'](dir).then((code) => {
op['is-git-repo'](dir).then((logEntry) => {
any(serial_perform_git_seturl(dir.name).map(x)) any(serial_perform_git_seturl(dir.name).map(x))
}).catch((e) => { }).catch((e) => {
// console.log('Failed : ' + dir.name) // console.log('Failed : ' + dir.name)
// return Promise.resolve(true) // return Promise.resolve(true)
} }
var perform_git_add = (dir) => { var perform_git_add = (dir) => {
op['is-git-repo'](dir).then((code) => {
op['is-git-repo'](dir).then((logEntry) => {
// console.log(code) // console.log(code)
if (code) {
if (logEntry.success) {
nodeShellExec('git', ['remote', 'get-url', remotename], { cwd: dir.name, stdio: 'ignore' }).then(() => { nodeShellExec('git', ['remote', 'get-url', remotename], { cwd: dir.name, stdio: 'ignore' }).then(() => {
console.log('skipped : ' + dir.name + ', reason : A remote with same name already exists.') console.log('skipped : ' + dir.name + ', reason : A remote with same name already exists.')
}) })
// return Promise.resolve(true) // return Promise.resolve(true)
} }
var perform_git_remove = (dir) => { var perform_git_remove = (dir) => {
op['is-git-repo'](dir).then((code) => {
op['is-git-repo'](dir).then((logEntry) => {
// console.log(code) // console.log(code)
// if (code) { // if (code) {
nodeShellExec('git', ['remote', 'get-url', remotename], { cwd: dir.name, stdio: 'ignore' }).then(() => { nodeShellExec('git', ['remote', 'get-url', remotename], { cwd: dir.name, stdio: 'ignore' }).then(() => {
// return Promise.resolve(true) // return Promise.resolve(true)
} }
var perform_init_gitea = (dir) => { var perform_init_gitea = (dir) => {
op['is-git-repo'](dir).then((code) => {
op['is-git-repo'](dir).then((logEntry) => {
// console.log(code) // console.log(code)
if (code) {
if (logEntry.success) {
nodeShellExec('git', ['remote', 'get-url', 'chess'], { cwd: dir.name, stdio: 'ignore' }).then(() => { nodeShellExec('git', ['remote', 'get-url', 'chess'], { cwd: dir.name, stdio: 'ignore' }).then(() => {
console.log('skipped : ' + dir.name + ', reason : Already has remote chess ') console.log('skipped : ' + dir.name + ', reason : Already has remote chess ')
}) })
return chessinstances return chessinstances
} }



var noprerequisites = {
add : true
}
var skipprereqs = {}
var maintask = () => { var maintask = () => {
// Default cmd to run ! // Default cmd to run !
processedArgs._[0] === processedArgs._[0] || 'pull'; processedArgs._[0] === processedArgs._[0] || 'pull';
// selectedinstance.reposerver = repomanifest.reposervers[0] // PB : TODO -- Attempt first one that is available and online from all that are available... // selectedinstance.reposerver = repomanifest.reposervers[0] // PB : TODO -- Attempt first one that is available and online from all that are available...
return prerequisites.git.verifyAndInstall().then(()=>{
var e = { message : 'verifyAndInstall', success : true}
return acquireConfig(selectedinstance, chessinstances).catch((err) => {
e = err;
console.error('Chosen cofiguraton failed or not found. Fix config and rerun or chose another.')
console.error(err)
}).then(() => { return elxrworker(true) })
// .finally(()=>{
// fs.writeFileSync('run.log', ', ' + JSON.stringify({ error: e.message }), { 'flag': 'a+' })
// if(!e.success) fs.writeFileSync('run.done', 'error');
// // return process.exit()
// })
})
if(!noprerequisites[processedArgs._[0]]
&& !skipprereqs[processedArgs._[0]]
) {
return prerequisites.git.verifyAndInstall().then(()=>{
var e = { message : 'verifyAndInstall', success : true}
return acquireConfig(selectedinstance, chessinstances).catch((err) => {
e = err;
console.error('Chosen cofiguraton failed or not found. Fix config and rerun or chose another.')
console.error(err)
}).then(() => { return elxrworker(true) })
// .finally(()=>{
// fs.writeFileSync('run.log', ', ' + JSON.stringify({ error: e.message }), { 'flag': 'a+' })
// if(!e.success) fs.writeFileSync('run.done', 'error');
// // return process.exit()
// })
})
}
else {
console.log('cmd has no preqs or has been configured to skip preqs')
return elxrworker()
}

} }


const retaincount = 2 const retaincount = 2

Loading…
Cancel
Save