|
|
@@ -32,6 +32,7 @@ var getCredentials = function(){ |
|
|
|
var creds = fs.readFileSync(path.normalize(`${homedir}/.elxrcredentials`), { encoding: 'utf8' }); |
|
|
|
var creds = creds.split('\n').map( c => c.trim() && new URL(c)); |
|
|
|
console.log(creds); |
|
|
|
creds.forEach(cred => {console.log( cred.hostname ); console.log( cred.username )} ); |
|
|
|
|
|
|
|
// Subsequent calls |
|
|
|
getCredentials = ()=>{ return creds } |
|
|
@@ -126,6 +127,76 @@ const dirs = async (perform, path) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var templateprocess = function(str, substitutes){ |
|
|
|
const regex = /__(.*?)__/gm; |
|
|
|
// const str = `__link____instance__server-lib__name__`; |
|
|
|
let m; |
|
|
|
|
|
|
|
return str.replace(regex, function(match, key) { |
|
|
|
console.log(`Found match, group ${match}: ${key}`); |
|
|
|
return substitutes[key] || match; |
|
|
|
}) |
|
|
|
|
|
|
|
// while ((m = regex.exec(str)) !== null) { |
|
|
|
// // This is necessary to avoid infinite loops with zero-width matches |
|
|
|
// if (m.index === regex.lastIndex) { |
|
|
|
// regex.lastIndex++; |
|
|
|
// } |
|
|
|
|
|
|
|
// var rstr = str; |
|
|
|
// // The result can be accessed through the `m`-variable. |
|
|
|
// m.forEach((match, groupIndex) => { |
|
|
|
|
|
|
|
// // rstr = rstr.replace( groupIndex |
|
|
|
// console.log(`Found match, group ${groupIndex}: ${match}`); |
|
|
|
// if(groupIndex === 0) return |
|
|
|
|
|
|
|
// }); |
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function copyFileSync( source, target , options) { |
|
|
|
|
|
|
|
var targetFile = target; |
|
|
|
|
|
|
|
// If target is a directory, a new file with the same name will be created |
|
|
|
if ( fs.existsSync( target ) ) { |
|
|
|
if ( fs.lstatSync( target ).isDirectory() ) { |
|
|
|
targetFile = path.join( target, path.basename( source ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fs.writeFileSync(targetFile, fs.readFileSync(source)); |
|
|
|
} |
|
|
|
|
|
|
|
function copyFolderRecursiveSync( source, target, options ) { |
|
|
|
var files = []; |
|
|
|
|
|
|
|
// Check if folder needs to be created or integrated |
|
|
|
var targetFolder = path.join( target, path.basename( source ) ); |
|
|
|
if ( !fs.existsSync( targetFolder ) ) { |
|
|
|
fs.mkdirSync( targetFolder ); |
|
|
|
} |
|
|
|
|
|
|
|
// Copy |
|
|
|
if ( fs.lstatSync( source ).isDirectory() ) { |
|
|
|
files = fs.readdirSync( source ); |
|
|
|
files.forEach( function ( file ) { |
|
|
|
var curSource = path.join( source, file ); |
|
|
|
if ( fs.lstatSync( curSource ).isDirectory() ) { |
|
|
|
copyFolderRecursiveSync( curSource, targetFolder ); |
|
|
|
} else { |
|
|
|
copyFileSync( curSource, targetFolder ); |
|
|
|
} |
|
|
|
} ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var getShellTask = (command, args, options) => { |
|
|
|
options = options || {} |
|
|
|
var callshell = command === 'rm' ? getgitbashtask : getshelltask; |
|
|
@@ -1512,6 +1583,8 @@ var op = { |
|
|
|
} |
|
|
|
else return op['runas']() |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
, 'use' : () => { |
|
|
|
// use a certain named instance. |
|
|
|
// Eg : |
|
|
@@ -1785,10 +1858,11 @@ var op = { |
|
|
|
// 2nd use Pharmacy needs justification Form. |
|
|
|
// Approval after a certain period of time. |
|
|
|
} |
|
|
|
, 'g': () => { |
|
|
|
, 'g' : () => { |
|
|
|
if (processedArgs.h) { |
|
|
|
|
|
|
|
console.log('elxr g [modelname] => generate a model named [modelname]'); |
|
|
|
console.log('elxr g model [modelname] => generate a model named [modelname]'); |
|
|
|
console.log('elxr g vmodel [modelname] => generate a model named [modelname]'); |
|
|
|
console.log('elxr g => regenerate all known models'); |
|
|
|
return |
|
|
|
} |
|
|
@@ -1885,6 +1959,20 @@ var op = { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
, 'undefined' : ()=>{ |
|
|
|
console.warn('Are you sure you want to refresh all the models.'); |
|
|
|
throw 'NOT YET IMPLMENTED' |
|
|
|
} |
|
|
|
|
|
|
|
, 'vmodel' : ()=>{ |
|
|
|
var verse = [ '__universe__/vmodel' ] |
|
|
|
|
|
|
|
// console.dir(templateprocess(`__link____instance__server-lib__name__`, { link( ){ |
|
|
|
// return processed }, instance : 'elixir-', name : 'newmodel' } ) |
|
|
|
// ) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
g[processedArgs._[1]](); |
|
|
@@ -1959,6 +2047,12 @@ var cmds = { |
|
|
|
, cmd : 'users list' |
|
|
|
, noprerequisites : true |
|
|
|
} |
|
|
|
, 'g' : { |
|
|
|
cmdFn : op['g'] // default |
|
|
|
, cmd : 'g' |
|
|
|
, noprerequisites : true |
|
|
|
, getPossiblePrompts(){ return {} } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var elxrcmd = (function(){ |
|
|
@@ -1995,6 +2089,7 @@ var elxrcmd = (function(){ |
|
|
|
})() |
|
|
|
|
|
|
|
elxrcmd.create(cmds['users']) |
|
|
|
elxrcmd.create(cmds['g']) |
|
|
|
|
|
|
|
var interpretrun = function(){ |
|
|
|
|