| @@ -294,7 +294,7 @@ var performPull = (repo, branch, repoowner, errHandler) => { | |||
| }) | |||
| .catch((e) => { | |||
| e.repo = repo; | |||
| if(errHandler) return errHandler(e) | |||
| if(errHandler) throw errHandler(e) | |||
| if (__isElevated) { | |||
| fs.writeFileSync('run.log', ', ' + JSON.stringify(e), { 'flag': 'a+' }) | |||
| } | |||
| @@ -338,7 +338,7 @@ var performPull = (repo, branch, repoowner, errHandler) => { | |||
| }) | |||
| .catch(e => { | |||
| e.repo = repo; | |||
| if(errHandler) return errHandler(e) | |||
| if(errHandler) throw errHandler(e) | |||
| if (__isElevated) { | |||
| fs.writeFileSync('run.log', ', ' + JSON.stringify(e), { 'flag': 'a+' }) | |||
| } | |||
| @@ -2246,11 +2246,13 @@ var configs = (function(){ | |||
| clusterNodeInstance(selected) { var clusternodename = 'node01' | |||
| return __acquireConfig(selected, selected.username, clusternodename | |||
| , selected.instanceName + '-config-' + selected.node_env + `-${clusternodename}` | |||
| , function(e){ console.info('Customized node level config not found. This is not an Error. Will attempt with owner level config.') } | |||
| , function(e){ console.info('Customized node level config not found. This is not an Error. Will attempt with owner level config.'); | |||
| return e; } | |||
| ) | |||
| } | |||
| , ownerInstnace(selected) { return __acquireConfig(selected, selected.username, null, null | |||
| , function(e){ console.info('Customized user level config not found. This is not an Error. Will attempt global common instance config.') } | |||
| , function(e){ console.info('Customized user level config not found. This is not an Error. Will attempt global common instance config.'); | |||
| return e } | |||
| ) | |||
| } | |||
| // PB : TODO -- Use the ORG level instance before falling back to common Instance coz common instance may not exist for certain orgs. | |||
| @@ -2261,8 +2263,13 @@ var configs = (function(){ | |||
| } | |||
| })() | |||
| var eNotImplemented = function(){ | |||
| console.error('Not yet implemented') | |||
| process.exit() | |||
| } | |||
| var acquireConfig = function(slections){ | |||
| var configPriority = [ 'clusterNodeInstance', 'ownerInstnace', 'commonInstance', 'genericChess' ] | |||
| var configPriority = [ 'clusterNodeInstance', 'ownerInstnace', 'commonInstance', 'genericChessInstance' ] | |||
| return any(configPriority.map(cfg => { return function() { return configs[cfg](slections) } } ), true, true) | |||
| } | |||
| @@ -2284,25 +2291,26 @@ var __acquireConfig = function (selected, owner, clusternodename, configrepo, er | |||
| } | |||
| else process.exit() | |||
| }) | |||
| console.error() | |||
| } | |||
| if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${owner}/${configrepo}.git/' not found`))){ | |||
| return cli.prompt( ['(i) install new instance with this name locally' | |||
| , '(f) fork a new instance for yourself' | |||
| , '(c) customize your personal instance for this node' | |||
| , '(o) fork a new instance for your organization' // prompt organization name... | |||
| , '(c) create a custom personal instance for this node' // prompt hostname as nodename | |||
| , '(p) create a custom personal instance' | |||
| , '(e) exit'] | |||
| , 'Config for instance not found. Would you like to with this name ? (y/n) ', 'y' ).then(propValue => { | |||
| , 'Config for instance not found. Would you like to ', 'e' ).then(propValue => { | |||
| if(propValue === 'y') { | |||
| return createLocalChessInsance() | |||
| } | |||
| if(propValue === 'i') return eNotImplemented() // return createLocalChessInsance(selectedinstance) | |||
| if(propValue === 'f') return eNotImplemented() // return createChessInstance(selectedinstance) | |||
| // if(propValue === 'o') createChessInstance(selectedinstance, orgname) | |||
| else process.exit() | |||
| }) | |||
| } | |||
| console.warn(e) | |||
| console.warn('Config acquisition failed.') | |||
| throw e; //('Config acquisition failed.') | |||
| } | |||
| var successHandler = () => { | |||
| @@ -2326,8 +2334,14 @@ var __acquireConfig = function (selected, owner, clusternodename, configrepo, er | |||
| ENV.NODE_ENV = selectedinstance.node_env; | |||
| } | |||
| return performPull(configrepo, null, owner, errHandler || ((e)=>{ throw e })).then( successHandler ) | |||
| .catch( errorHandler ) | |||
| return performPull(configrepo, null, owner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler ) | |||
| .catch( (e)=>{ | |||
| // if(e){ | |||
| if(Promise.resolve(e) === e) return e; | |||
| console.error(e) | |||
| throw e; // Not a hard error but we need this for bcontinueonfailure | |||
| // } | |||
| }) | |||
| } | |||
| var launchpath = path.normalize(process.cwd()) | |||
| @@ -3062,9 +3076,9 @@ var promptkeys = { | |||
| function createChessInstance( cfg ){ | |||
| return createInstance(cfg) | |||
| var inst = {}; | |||
| var __new = Object.assign({}, __default, cfg) | |||
| inst[cfg.node_env] = __new; return inst; | |||
| // var inst = {}; | |||
| // var __new = Object.assign({}, __default, cfg) | |||
| // inst[cfg.node_env] = __new; return inst; | |||
| } | |||
| var choices = { | |||