|
|
|
|
|
|
|
|
var creds = fs.readFileSync(path.normalize(`${homedir}/.elxrcredentials`), { encoding: 'utf8' }); |
|
|
var creds = fs.readFileSync(path.normalize(`${homedir}/.elxrcredentials`), { encoding: 'utf8' }); |
|
|
var creds = creds.split('\n').map( c => c.trim() && new URL(c)); |
|
|
var creds = creds.split('\n').map( c => c.trim() && new URL(c)); |
|
|
console.log(creds); |
|
|
console.log(creds); |
|
|
|
|
|
creds.forEach(cred => {console.log( cred.hostname ); console.log( cred.username )} ); |
|
|
|
|
|
|
|
|
// Subsequent calls |
|
|
// Subsequent calls |
|
|
getCredentials = ()=>{ return creds } |
|
|
getCredentials = ()=>{ return creds } |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) => { |
|
|
var getShellTask = (command, args, options) => { |
|
|
options = options || {} |
|
|
options = options || {} |
|
|
var callshell = command === 'rm' ? getgitbashtask : getshelltask; |
|
|
var callshell = command === 'rm' ? getgitbashtask : getshelltask; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else return op['runas']() |
|
|
else return op['runas']() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
, 'use' : () => { |
|
|
, 'use' : () => { |
|
|
// use a certain named instance. |
|
|
// use a certain named instance. |
|
|
// Eg : |
|
|
// Eg : |
|
|
|
|
|
|
|
|
// 2nd use Pharmacy needs justification Form. |
|
|
// 2nd use Pharmacy needs justification Form. |
|
|
// Approval after a certain period of time. |
|
|
// Approval after a certain period of time. |
|
|
} |
|
|
} |
|
|
, 'g': () => { |
|
|
|
|
|
|
|
|
, 'g' : () => { |
|
|
if (processedArgs.h) { |
|
|
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'); |
|
|
console.log('elxr g => regenerate all known models'); |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
, '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]](); |
|
|
g[processedArgs._[1]](); |
|
|
|
|
|
|
|
|
, cmd : 'users list' |
|
|
, cmd : 'users list' |
|
|
, noprerequisites : true |
|
|
, noprerequisites : true |
|
|
} |
|
|
} |
|
|
|
|
|
, 'g' : { |
|
|
|
|
|
cmdFn : op['g'] // default |
|
|
|
|
|
, cmd : 'g' |
|
|
|
|
|
, noprerequisites : true |
|
|
|
|
|
, getPossiblePrompts(){ return {} } |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var elxrcmd = (function(){ |
|
|
var elxrcmd = (function(){ |
|
|
|
|
|
|
|
|
})() |
|
|
})() |
|
|
|
|
|
|
|
|
elxrcmd.create(cmds['users']) |
|
|
elxrcmd.create(cmds['users']) |
|
|
|
|
|
elxrcmd.create(cmds['g']) |
|
|
|
|
|
|
|
|
var interpretrun = function(){ |
|
|
var interpretrun = function(){ |
|
|
|
|
|
|