|
|
@@ -424,6 +424,96 @@ var __runcmd = function(label){ |
|
|
|
, 'is-git-repo' : (dir)=>{ |
|
|
|
return nodeShellExec('git', ['-C', dir.name, 'rev-parse'], { stdio : 'ignore'}) |
|
|
|
} |
|
|
|
, 'add' : (remotename, url) => { |
|
|
|
remotename = remotename || processedArgs._[1] |
|
|
|
url = url || processedArgs._[2] |
|
|
|
var branch = 'master'; |
|
|
|
var serial_perform_git_add = (repo)=>{ |
|
|
|
var options = { cwd : repo } |
|
|
|
// console.log(repo) |
|
|
|
return [ |
|
|
|
['git', ['remote', 'add', remotename, url + '/' + repo], { cwd : repo }] |
|
|
|
, ['git', ['pull', remotename, branch], { cwd : repo }] |
|
|
|
, ['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd : repo }] |
|
|
|
] |
|
|
|
} |
|
|
|
var x = (args)=>{ |
|
|
|
return ()=>{ |
|
|
|
// console.log(args) |
|
|
|
return nodeShellExec.apply(null, args) |
|
|
|
} |
|
|
|
// return Promise.resolve(true) |
|
|
|
} |
|
|
|
var perform_git_add = (dir)=>{ |
|
|
|
op['is-git-repo'](dir).then((code)=>{ |
|
|
|
// console.log(code) |
|
|
|
if(code) { |
|
|
|
nodeShellExec('git',['remote', 'get-url', remotename], { cwd : dir.name, stdio : 'ignore' }).then(()=>{ |
|
|
|
console.log('skipped : ' + dir.name + ', reason : No remote named origin') |
|
|
|
}) |
|
|
|
.catch((e)=>{ |
|
|
|
any( serial_perform_git_add(dir.name).map(x) ) |
|
|
|
}) |
|
|
|
} |
|
|
|
// else console.log('Skipped : Not a Git Repo : ' + dir.name) |
|
|
|
}).catch((e)=>{ |
|
|
|
// console.log('Failed : ' + dir.name) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const { readdir } = require("fs").promises |
|
|
|
|
|
|
|
const dirs = async (perform, path) => { |
|
|
|
for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) { |
|
|
|
if (dir.isDirectory()) perform(dir) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
dirs(perform_git_add) |
|
|
|
} |
|
|
|
, 'remove' : (remotename) => { |
|
|
|
remotename = remotename || processedArgs._[1] |
|
|
|
var serial_perform_git_remove = (repo)=>{ |
|
|
|
var options = { cwd : repo } |
|
|
|
// console.log(repo) |
|
|
|
return [ |
|
|
|
['git', ['remote', 'remove', remotename], { cwd : repo }] |
|
|
|
] |
|
|
|
} |
|
|
|
var x = (args)=>{ |
|
|
|
return ()=>{ |
|
|
|
// console.log(args) |
|
|
|
return nodeShellExec.apply(null, args) |
|
|
|
} |
|
|
|
// return Promise.resolve(true) |
|
|
|
} |
|
|
|
var perform_git_remove = (dir)=>{ |
|
|
|
op['is-git-repo'](dir).then((code)=>{ |
|
|
|
// console.log(code) |
|
|
|
if(code) { |
|
|
|
nodeShellExec('git',['remote', 'get-url', remotename], { cwd : dir.name, stdio : 'ignore' }).then(()=>{ |
|
|
|
any( serial_perform_git_remove(dir.name).map(x) ) |
|
|
|
}) |
|
|
|
.catch((e)=>{ |
|
|
|
console.log('skipped : ' + dir.name + ', reason : No remote named origin') |
|
|
|
}) |
|
|
|
} |
|
|
|
// else console.log('Skipped : Not a Git Repo : ' + dir.name) |
|
|
|
}).catch((e)=>{ |
|
|
|
// console.log('Failed : ' + dir.name) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const { readdir } = require("fs").promises |
|
|
|
|
|
|
|
const dirs = async (perform, path) => { |
|
|
|
for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) { |
|
|
|
if (dir.isDirectory()) perform(dir) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
dirs(perform_git_remove) |
|
|
|
} |
|
|
|
, 'init-gitea' : (user) => { |
|
|
|
user = user || processedArgs._[1] |
|
|
|
if(!user) throw 'User name required' |
|
|
@@ -544,6 +634,12 @@ var __runcmd = function(label){ |
|
|
|
} |
|
|
|
) |
|
|
|
} |
|
|
|
, 'isInstalled' : ()=>{ |
|
|
|
return nodeShellExec('where', [processedArgs._[1]], { inherit : true} ).then(()=>{ |
|
|
|
console.log(processedArgs._[1] + ' exists.') |
|
|
|
return true; |
|
|
|
}); |
|
|
|
} |
|
|
|
, 'npmi' : ()=>{ |
|
|
|
var tasks = []; |
|
|
|
gitRepos.forEach(repo => { |