Procházet zdrojové kódy

fixes for launch path

pull/6/head
chess před 3 roky
rodič
revize
a0482343d2
3 změnil soubory, kde provedl 77 přidání a 17635 odebrání
  1. 0
    17590
      elxr.js
  2. 77
    41
      index.js
  3. 0
    4
      rollup.config.js

+ 0
- 17590
elxr.js
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 77
- 41
index.js Zobrazit soubor

@@ -63,11 +63,11 @@ console.dir(processedArgs)

var clioverrides = { }
processedArgs._[1] ? clioverrides.instanceName = processedArgs._[1]: null;
clioverrides.node_env = processedArgs.node_env ?
processedArgs.node_env || (process.env.NODE_ENV && process.env.NODE_ENV.trim())
processedArgs.node_env ? clioverrides.node_env = processedArgs.node_env
: (process.env.NODE_ENV && process.env.NODE_ENV.trim())
? (process.env.NODE_ENV && process.env.NODE_ENV.trim()): null;
clioverrides.reconfirm = processedArgs.reconfirm
? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) : null;

Object.keys(clioverrides).forEach( prop => { })

var globSync = require('glob').sync;

@@ -84,10 +84,11 @@ const dirs = async (perform, path) => {

var getShellTask = (command, args, options) => {
options = options || {}
var callshell = command === 'rm' ? callgitbashtask : callsheltask;
return () => {
var p = nodeShellExec.apply(null, [command, args, Object.assign({
inherit: true, shell: true, env: ENV, title: `${command} ${args}`
}, options)
var p = callshell( [command, args, Object.assign({
inherit: true, shell: true, env: ENV, title: `${command} ${args}`
}, options)
])
if (options.ignorefailures) {
return p.catch(e => {
@@ -98,12 +99,12 @@ var getShellTask = (command, args, options) => {
}
}

var callsheltask = (args) => { return () => { return nodeShellExec.apply(null, args) } }
var callsheltask = (args) => {
return args[0] === 'rm' ? callgitbashtask(args) : () => { return nodeShellExec.apply(null, args) } }
var callgitbashtask = (args) => { return () => {
return nodeShellExec( `"${gitbash}"`, ['-c', `"${args[0]} ${args[1].join(' ')}"`], args[2]) }
}


var getTaskCheckExists = (command, options) => {
options = options || {}
return () => {
@@ -1146,12 +1147,12 @@ var op = {
// () => {
// console.log(`--rm package-lock.json for ${repodef.repo}--------------------`)
// return nodeShellExec(`"${gitbash}"`, ['-c', '"rm package-lock.json"'], {
nodeShellExec('rm', ['package-lock.json'], {
(callShellTask(['rm', ['package-lock.json'], {
inherit: true, shell: true
, cwd: instanceroot + '/' + repodef.repo
, env: process.env
, title: `rm 'package-lock.json' for ${repodef.repo}`
})
}]))()
.then(()=>{
console.log(`--rm package-lock.json for ${repodef.repo}--------------------`)
}).catch((e) => { console.error(e) })
@@ -2004,8 +2005,9 @@ var acquireConfig = function (selected) {
}

var launchpath = process.cwd().replace(/\\/, '/')
var thisscriptdir = __dirname
var instanceroot = launchpath;
var thisscriptdir = __dirname; // PB : TODO -- Thisscriptdir could be dislocated when run as a standalone file... We need to detect this where and how we were run.
// The easisest would be to ask for a target directory and default to current dir....
var instanceroot = path.normalize(thisscriptdir) === path.normalize(launchpath) ? thisscriptdir + '/..' : launchpath ;

var __default = {

@@ -2035,13 +2037,18 @@ var __default = {
var detectInstance = function () {
console.log(`launchpath = ${launchpath}`)
console.log(`thisscriptdir = ${thisscriptdir}`)
console.log(`instanceroot = ${instanceroot}`)

var root = launchpath;
var root = instanceroot;

// We need a reference to the root director for elxr cli to be properly oriented.
if ((launchpath + path.normalize('/elxr')) === thisscriptdir) {
// We ran unbuilt from the proper root with elxr subfolder.
// We ran from the proper root with elxr subfolder.
// PB : TODO --- Additional checks required to verify elxr is the right folder
// should be a git repo. has elxr signature
// and .elxr folder signature... in the launchpath.
console.log(`Instance Path : ${root}`)
instanceroot = root = launchpath
}
else {
if (launchpath === thisscriptdir) {
@@ -2049,19 +2056,19 @@ var detectInstance = function () {
// It could be a standalone elxr build which may or maynot be in the proper location.
if (BUILD_VERSION.indexOf('Version: {version} - built on {date}') > -1) {
// Unbuilt therefore we are in the elxr directory.
root = path.normalize(launchpath + '/..');
instanceroot = root = path.normalize(launchpath + '/..');
}
else {
// Built version.
// check if we have a elxr subfolder.
if (fs.existsSync(launchpath + '/..' + path.normalize('/elxr'))) {
// Probably in the right place.
root = path.normalize(launchpath + '/..');
instanceroot = root = path.normalize(launchpath + '/..');
}
else {
// Assume launchpath is meaningless.
// Figure it out from the input instance name and environment parameters if we are in the right location.
root = path.normalize(launchpath + '/' + processedArgs._[1] + '/' + processedArgs.node_env)
instanceroot = root = path.normalize(launchpath + '/' + processedArgs._[1] + '/' + processedArgs.node_env)
}
}
}
@@ -2393,33 +2400,67 @@ function acquirelocalinstances(selected){
// function updateselection(selected) { selectedinstance = utils.assign(selectedinstance, selected) }
var selectedinstance = null;
var chessinstances = { current_run : {} };
var promptkeys = {
// Try not to prompt anything unless absolutely necessary or reconfirm is forced.
// 'instanceName' : true
// , 'node_env' : true
}

function createChessInsance( cfg ){
var inst = {};
var __new = Object.assign({}, __default, cfg)
inst[cfg.node_env] = __new; return inst;
}

acquireElevationState().then(() => {
var skipprerequisites = false;
function initinstances(selected) {
// PB : TODO -- processedArgs should already be part of selected.
var instanceName = processedArgs._[1] = processedArgs._[1] || chessinstances.current_run.instanceName || selected.instanceName;
var node_env = processedArgs.node_env = processedArgs.node_env || chessinstances.current_run.node_env || selected.node_env;
chessinstances[instanceName] = chessinstances[instanceName] || {}
chessinstances[instanceName][node_env] = chessinstances[instanceName][node_env] || selected;
chessinstances['current_run'] = chessinstances[instanceName][selected.node_env] ?
{ instanceName: instanceName, node_env: node_env } : (chessinstances['current_run'] || { instanceName: instanceName, node_env: node_env })
var instanceName = processedArgs._[1]
|| chessinstances.current_run.instanceName
|| selected.instanceName
|| clioverrides.instanceName;
var node_env = processedArgs.node_env
|| chessinstances.current_run.node_env
|| selected.node_env
|| clioverrides.node_env;
if(!instanceName) {
promptkeys['instanceName'] = instanceName = chessinstances.current_run.instanceName = promptkeys['instanceName'] || __default.instanceName;
promptkeys['node_env'] = node_env = chessinstances.current_run.node_env = promptkeys['node_env'] || __default.node_env;
promptkeys['reposerver'] = promptkeys['reposerver'] || __default.reposervers[0];
}
if(!node_env) {
promptkeys['node_env'] = node_env = chessinstances.current_run.node_env = promptkeys['node_env'] || __default.node_env;
promptkeys['reposerver'] = promptkeys['reposerver'] || __default.reposervers[0];
}

// chessinstances[chessinstances.current_run.instanceName] = chessinstances[chessinstances.current_run.instanceName] || {}
chessinstances[instanceName] = chessinstances[instanceName] || createChessInsance( {
instanceName, node_env, root : selected.root, reposerver : promptkeys['reposerver'] } );
chessinstances['current_run'] = { instanceName: instanceName, node_env: node_env }

if(path.normalize(selected.root) !== path.normalize(chessinstances[instanceName][node_env].root)) {
throw "Mismatched chessinstances config found " + chessinstances[instanceName][node_env].root + ' does not match ' + selected.root
}
// Override sequence.
// __default, chessinstances[current_run], instanceName-config-development, cliargs, interactve_promts
selectedinstance = Object.assign(
selectedinstance = utils.assign(
selected
, chessinstances[instanceName][node_env]
, clioverrides
// , __interactve_promts -- Cant just override. Also need selectedinstance to be ready...
);

chessinstances[instanceName] = chessinstances[instanceName] || {}
chessinstances[instanceName][node_env] = chessinstances[instanceName][node_env] || {}
// chessinstances[instanceName] = chessinstances[instanceName] || {}
// chessinstances[instanceName][node_env] = chessinstances[instanceName][node_env] || {}
// if(!selectedinstance.repos || selectedinstance.instanceName) {
// // Brand New.
// selectedinstance = Object.assign( __default, selectedinstance )
// }
if(!selectedinstance.repos[0].repo) {
console.warn('repo manifest has obsolete format. Attempting upgrade.')
selectedinstance.repos = selectedinstance.repos.map(function(repo){ return { repo } })
@@ -2488,18 +2529,14 @@ acquireElevationState().then(() => {

return detectInstance().then((detectedInstance)=>{
selectedinstance = Object.assign(detectedInstance || {}, clioverrides);
var todo = Promise.resolve(true);
var promptkeys = { 'instanceName' : clioverrides.instanceName, 'node_env' : clioverrides.node_env }

selectedinstance = utils.assign(detectedInstance || {}, clioverrides)
promptkeys = utils.assign(promptkeys, { 'instanceName' : clioverrides.instanceName, 'node_env' : clioverrides.node_env })
if(clioverrides.reconfirm) {
var reconfirm = {
'instanceName' : selectedinstance['instanceName'] === 'chess'
}
}
else {
var reconfirm = {};
var reconfirm = { 'instanceName' : selectedinstance['instanceName'] === 'chess' }
}
else { var reconfirm = {}; }

var prompts = [];
var eachPrompt = function(k, i, a){
@@ -2521,9 +2558,11 @@ acquireElevationState().then(() => {
delete promptkeys[k]
}
try {
chessinstances = acquirelocalinstances(selectedinstance);
initinstances(selectedinstance)
var todo = Promise.resolve(true);
var instanceNameChoices = new Set(Object.keys( chessinstances) )
instanceNameChoices.delete('current_run')
instanceNameChoices.add(selectedinstance['instanceName'])
@@ -2534,13 +2573,10 @@ acquireElevationState().then(() => {
, 'reposerver' : selectedinstance['reposervers']
}

Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts)
Object.keys(promptkeys).forEach(eachPrompt, promptkeys)
todo = any(prompts).then(()=>{ return selectedinstance })
}
catch (e) {
// PB : TODO -- verbose mode warning.. console.warn(e) // Missing chessinstances is not an error...

+ 0
- 4
rollup.config.js Zobrazit soubor

@@ -21,7 +21,3 @@ export default {
// exclude : [ 'chessinstances.js' ]
}), nodeResolve(), versionInjector()]
};

// Dr Kamat
// Rahul Roji
// 06259

Načítá se…
Zrušit
Uložit