|
|
|
|
|
|
|
|
const BUILD_VERSION = '[VI]Version: {version} - built on {date}[/VI]'; |
|
|
const BUILD_VERSION = '[VI]Version: {version} - built on {date}[/VI]'; |
|
|
const runtimestamp = (new Date()).getTime(); |
|
|
const runtimestamp = (new Date()).getTime(); |
|
|
function getVersion() { return BUILD_VERSION; } |
|
|
function getVersion() { return BUILD_VERSION; } |
|
|
console.log(getVersion()) |
|
|
|
|
|
|
|
|
console.log(getVersion()); |
|
|
|
|
|
|
|
|
// 'use strict'; |
|
|
// 'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// support runas lauched directly from shell. |
|
|
// support runas lauched directly from shell. |
|
|
// pass in environment in hta to shellexecute. |
|
|
// pass in environment in hta to shellexecute. |
|
|
|
|
|
|
|
|
|
|
|
// PB : NOTE -- iife doesnt work if previous statement is not terminated by ; |
|
|
|
|
|
(function () { |
|
|
|
|
|
"use strict"; |
|
|
|
|
|
if (!Array.prototype.earlyreduce) { |
|
|
|
|
|
Array.prototype.earlyreduce = function(eachcallback, initialValue, donecallback){ |
|
|
|
|
|
var iterable = this; |
|
|
|
|
|
var donecallback = donecallback || (a=>a) |
|
|
|
|
|
var result = { value : initialValue === undefined ? iterable[0] : initialValue }; |
|
|
|
|
|
initialValue === undefined ? null : result = eachcallback(result, element, i, iterable); |
|
|
|
|
|
// function *earlyReduceGenerator(acc, v, i, a) { |
|
|
|
|
|
for(var i = initialValue === undefined ? 0 : 1; i < iterable.length; i++){ |
|
|
|
|
|
var element = iterable[i] |
|
|
|
|
|
result = eachcallback(result, element, i, iterable) |
|
|
|
|
|
if(result.done) return donecallback(result) |
|
|
|
|
|
} |
|
|
|
|
|
// } |
|
|
|
|
|
return donecallback(result) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}()); |
|
|
|
|
|
|
|
|
const { existsSync } = require('fs'); |
|
|
const { existsSync } = require('fs'); |
|
|
const fs = require('fs') |
|
|
const fs = require('fs') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
// } |
|
|
// }) |
|
|
// }) |
|
|
|
|
|
|
|
|
|
|
|
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()) |
|
|
|
|
|
: (process.env.NODE_ENV && process.env.NODE_ENV.trim()) |
|
|
|
|
|
? (process.env.NODE_ENV && process.env.NODE_ENV.trim()): null; |
|
|
|
|
|
clioverrides.reconfirm = processedArgs.reconfirm |
|
|
|
|
|
|
|
|
var globSync = require('glob').sync; |
|
|
var globSync = require('glob').sync; |
|
|
|
|
|
|
|
|
var ENV = Object.assign({}, process.env); // Shallow clone it. |
|
|
var ENV = Object.assign({}, process.env); // Shallow clone it. |
|
|
|
|
|
|
|
|
selectedinstance.elevated = selectedinstance.elevated.map(function(repo){ return { repo } }) |
|
|
selectedinstance.elevated = selectedinstance.elevated.map(function(repo){ return { repo } }) |
|
|
} |
|
|
} |
|
|
chessinstances[selected.instanceName][selected.node_env] = selectedinstance = utils.assign(selected, selectedinstance) |
|
|
chessinstances[selected.instanceName][selected.node_env] = selectedinstance = utils.assign(selected, selectedinstance) |
|
|
|
|
|
chessinstances[selected.instanceName][selected.node_env].reposervers = Array.from(new Set(chessinstances[selected.instanceName][selected.node_env].reposervers)) |
|
|
selectedinstance.reposerver = selectedinstance.reposerver || selectedinstance.reposervers[0] // PB : TODO -- Attempt first one that is available and online... |
|
|
selectedinstance.reposerver = selectedinstance.reposerver || selectedinstance.reposervers[0] // PB : TODO -- Attempt first one that is available and online... |
|
|
cacheWriteInstanceConfig(chessinstances) |
|
|
cacheWriteInstanceConfig(chessinstances) |
|
|
ENV.NODE_ENV = selectedinstance.node_env; |
|
|
ENV.NODE_ENV = selectedinstance.node_env; |
|
|
|
|
|
|
|
|
var launchpath = process.cwd().replace(/\\/, '/') |
|
|
var launchpath = process.cwd().replace(/\\/, '/') |
|
|
var thisscriptdir = __dirname |
|
|
var thisscriptdir = __dirname |
|
|
var instanceroot = launchpath; |
|
|
var instanceroot = launchpath; |
|
|
|
|
|
|
|
|
|
|
|
var __default = { |
|
|
|
|
|
|
|
|
|
|
|
// Default is public server only. |
|
|
|
|
|
// All public repos are by default available. |
|
|
|
|
|
reposervers: ['https://git.bbh.org.in'] |
|
|
|
|
|
, repos: [ |
|
|
|
|
|
{ repo : 'setup' } |
|
|
|
|
|
, { repo : 'elxr' } |
|
|
|
|
|
, { repo : 'loopback-connector-mysql' } |
|
|
|
|
|
, { repo : 'loopback-jsonapi-model-serializer' } |
|
|
|
|
|
, { repo : 'loopback-component-jsonapi' } |
|
|
|
|
|
, { repo : 'ember-service-worker' } |
|
|
|
|
|
, { repo : 'ember-service-worker-asset-cache' } |
|
|
|
|
|
, { repo : 'ember-service-worker-cache-fallback' } |
|
|
|
|
|
, { repo : 'ember-service-worker-index' } |
|
|
|
|
|
, { repo : 'ember-sw-client-route' } |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
, elevated: [] |
|
|
|
|
|
, exludeMergeRepos: {} |
|
|
|
|
|
, instanceName: 'chess' |
|
|
|
|
|
// Runas windowshta clobbers and removes the NODE_ENV !!! We therefore pass it in. |
|
|
|
|
|
, node_env: 'development' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var detectInstance = function () { |
|
|
var detectInstance = function () { |
|
|
console.log(`launchpath = ${launchpath}`) |
|
|
console.log(`launchpath = ${launchpath}`) |
|
|
console.log(`thisscriptdir = ${thisscriptdir}`) |
|
|
console.log(`thisscriptdir = ${thisscriptdir}`) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
instanceroot = root.replace(/\\/, '/'); |
|
|
|
|
|
|
|
|
instanceroot = root.replace(/\\/g, '/'); |
|
|
__default.root = root; |
|
|
__default.root = root; |
|
|
return Promise.resolve(__default); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
|
var __default = { |
|
|
|
|
|
|
|
|
|
|
|
// Default is public server only. |
|
|
|
|
|
// All public repos are by default available. |
|
|
|
|
|
reposervers: ['https://git.bbh.org.in'] |
|
|
|
|
|
, repos: [ |
|
|
|
|
|
'setup' |
|
|
|
|
|
, 'elxr' |
|
|
|
|
|
, 'loopback-connector-mysql' |
|
|
|
|
|
, 'loopback-jsonapi-model-serializer' |
|
|
|
|
|
, 'loopback-component-jsonapi' |
|
|
|
|
|
, 'ember-service-worker' |
|
|
|
|
|
, 'ember-service-worker-asset-cache' |
|
|
|
|
|
, 'ember-service-worker-cache-fallback' |
|
|
|
|
|
, 'ember-service-worker-index' |
|
|
|
|
|
, 'ember-sw-client-route' |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
, elevated: [] |
|
|
|
|
|
, exludeMergeRepos: {} |
|
|
|
|
|
, instanceName: 'chess' |
|
|
|
|
|
// Runas windowshta clobbers and removes the NODE_ENV !!! We therefore pass it in. |
|
|
|
|
|
, node_env: 'development' |
|
|
|
|
|
|
|
|
clioverrides.root = clioverrides.root || root; |
|
|
|
|
|
|
|
|
|
|
|
// Resolves undefined when No known instances detected. |
|
|
|
|
|
return Promise.resolve( |
|
|
|
|
|
// We can expect a .elxr at each level. |
|
|
|
|
|
['' /* instanceroot */, '../' /* instanceTypes or node_env */, '../..' /* instanceNames */].earlyreduce( ( acc, p, i, a )=>{ |
|
|
|
|
|
var root = `${instanceroot}/${p}.elxr`; |
|
|
|
|
|
if(existsSync( root )) { |
|
|
|
|
|
try { |
|
|
|
|
|
var chessinstances = acquirelocalinstances( { root } ) |
|
|
|
|
|
return Object.keys(chessinstances).earlyreduce( ( acc, instanceName) => { |
|
|
|
|
|
return Object.keys(chessinstances[instanceName]).earlyreduce( (acc, instanceType) => { |
|
|
|
|
|
if( path.normalize(chessinstances[instanceName][instanceType].root) === path.normalize(root) ) return { |
|
|
|
|
|
value : chessinstances[instanceName][instanceType] |
|
|
|
|
|
, done : true |
|
|
|
|
|
};s |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
catch(e){ |
|
|
|
|
|
return {} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else return {} |
|
|
|
|
|
}).value |
|
|
|
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var __interactve_promts = { |
|
|
var __interactve_promts = { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function acquirelocalinstances(selected){ |
|
|
|
|
|
var chessinstances = utils.assign(require(path.normalize(selected.root + '/chessinstances.js'))); |
|
|
|
|
|
return chessinstances |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// function updateselection(selected) { selectedinstance = utils.assign(selectedinstance, selected) } |
|
|
// function updateselection(selected) { selectedinstance = utils.assign(selectedinstance, selected) } |
|
|
var selectedinstance = null; |
|
|
var selectedinstance = null; |
|
|
var chessinstances = { current_run : {} }; |
|
|
var chessinstances = { current_run : {} }; |
|
|
acquireElevationState().then(() => { |
|
|
acquireElevationState().then(() => { |
|
|
var skipprerequisites = false; |
|
|
var skipprerequisites = false; |
|
|
var clioverrides = { } |
|
|
|
|
|
function initinstances(selected) { |
|
|
function initinstances(selected) { |
|
|
// PB : TODO -- processedArgs should already be part of selected. |
|
|
// PB : TODO -- processedArgs should already be part of selected. |
|
|
var instanceName = processedArgs._[1] = processedArgs._[1] || chessinstances.current_run.instanceName || selected.instanceName; |
|
|
var instanceName = processedArgs._[1] = processedArgs._[1] || chessinstances.current_run.instanceName || selected.instanceName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return chessinstances |
|
|
return chessinstances |
|
|
} |
|
|
} |
|
|
function acquirelocalinstances(selected){ |
|
|
|
|
|
var chessinstances = utils.assign(require(path.normalize(selected.root + '/chessinstances.js'))); |
|
|
|
|
|
return chessinstances |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var noprerequisites = { |
|
|
var noprerequisites = { |
|
|
add : true, 'set-url' : true, 'repo-relocate' : true |
|
|
add : true, 'set-url' : true, 'repo-relocate' : true |
|
|
, remote : true |
|
|
, remote : true |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return detectInstance().then((detectedInstance)=>{ |
|
|
return detectInstance().then((detectedInstance)=>{ |
|
|
|
|
|
|
|
|
processedArgs._[1] ? clioverrides.instanceName = processedArgs._[1]: null; |
|
|
|
|
|
processedArgs.node_env ? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) || processedArgs.node_env |
|
|
|
|
|
: (process.env.NODE_ENV && process.env.NODE_ENV.trim()) ? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()): null; |
|
|
|
|
|
|
|
|
|
|
|
clioverrides.reconfirm = processedArgs.reconfirm |
|
|
|
|
|
|
|
|
|
|
|
selectedinstance = Object.assign(detectedInstance, clioverrides); |
|
|
|
|
|
|
|
|
selectedinstance = Object.assign(detectedInstance || {}, clioverrides); |
|
|
var todo = Promise.resolve(true); |
|
|
var todo = Promise.resolve(true); |
|
|
var promptkeys = { 'instanceName' : processedArgs._[1] } |
|
|
|
|
|
|
|
|
var promptkeys = { 'instanceName' : clioverrides.instanceName, 'node_env' : clioverrides.node_env } |
|
|
|
|
|
|
|
|
if(clioverrides.reconfirm) { |
|
|
if(clioverrides.reconfirm) { |
|
|
var reconfirm = { |
|
|
var reconfirm = { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// No local instances config found. We use a default initialized instance available in selectedinstance |
|
|
// No local instances config found. We use a default initialized instance available in selectedinstance |
|
|
// Confirm those that were not supplied as user choices in runtime args and proceed to reattempt. |
|
|
// Confirm those that were not supplied as user choices in runtime args and proceed to reattempt. |
|
|
if(promptkeys[k] && selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined && selectedinstance[k] === undefined |
|
|
|
|
|
|
|
|
// PB : TODO -- selectedinstance === __default check to prompt everything... |
|
|
|
|
|
if( (promptkeys[k] !== undefined && promptkeys[k] !== null) && selectedinstance[k] !== promptkeys[k] |
|
|
|
|
|
|| (promptkeys[k] === undefined || promptkeys[k] === null) && (selectedinstance[k] === undefined || selectedinstance[k] === null) |
|
|
|| reconfirm[k]) { |
|
|
|| reconfirm[k]) { |
|
|
prompts.push(async ()=>{ |
|
|
prompts.push(async ()=>{ |
|
|
// PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked. |
|
|
// PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (e) { |
|
|
catch (e) { |
|
|
console.error(e) // Missing chessinstances is not an error... |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PB : TODO -- verbose mode warning.. console.warn(e) // Missing chessinstances is not an error... |
|
|
initinstances(selectedinstance) |
|
|
initinstances(selectedinstance) |
|
|
|
|
|
|
|
|
var instanceNameChoices = new Set(Object.keys( chessinstances) ) |
|
|
var instanceNameChoices = new Set(Object.keys( chessinstances) ) |
|
|
|
|
|
|
|
|
var choices = { |
|
|
var choices = { |
|
|
'instanceName' : Array.from(instanceNameChoices) |
|
|
'instanceName' : Array.from(instanceNameChoices) |
|
|
, 'reposerver' : selectedinstance['reposervers'] |
|
|
, 'reposerver' : selectedinstance['reposervers'] |
|
|
|
|
|
, 'instanceType' : ['development', 'production'] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts) |
|
|
Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts) |