Comparing version 3.1.1 to 3.2.0
{ | ||
"name": "devlab", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "Node utility for running containerized tasks", | ||
@@ -66,3 +66,3 @@ "keywords": [ | ||
"ora": "^0.3.0", | ||
"redash": "^0.17.0", | ||
"redash": "^0.18.0", | ||
"shortid": "^2.2.6" | ||
@@ -69,0 +69,0 @@ }, |
@@ -84,2 +84,6 @@ const _ = require('redash') | ||
if (!command) throw new Error(`Task '${name}' does not exist.`) | ||
if (_.isType('object', command)) { | ||
if (!command.cmd) throw new Error(`Task '${name}' has no command defined.`) | ||
return command.cmd | ||
} | ||
return command | ||
@@ -86,0 +90,0 @@ }), |
@@ -23,3 +23,3 @@ const _ = require('redash') | ||
getConfig: () => { | ||
const cfg = _.merge(config.load(args.parse().configPath), args.parse()) | ||
const cfg = services.filterEnabled(_.merge(config.load(args.parse().configPath), args.parse())) | ||
return { services: services.get(cfg), primary: command.get(cfg, 'primary', true) } | ||
@@ -26,0 +26,0 @@ }, |
@@ -11,4 +11,36 @@ const _ = require('redash') | ||
/** | ||
* @property {array} All services disabled by instance task | ||
*/ | ||
disabled: [], | ||
/** | ||
* Checks if given task has a 'disable' key, and removes services accordingly | ||
* @param {Object} cfg Instance config object | ||
* @returns {Object} formatted config object | ||
*/ | ||
filterEnabled: (cfg) => { | ||
if (!cfg.run.length) return cfg | ||
const tasks = _.values(_.pick(cfg.run, cfg.tasks)) | ||
const objs = _.filter(_.isType('object'), tasks) | ||
// If any running task doesn't have object config, keep all services | ||
if (objs.length !== tasks.length) return cfg | ||
const svcs = _.chain(t => t.disable === '*' ? _.map(_.keys, cfg.services) : t.disable, objs) | ||
// Track which services are disabled by running tasks | ||
const counts = _.pipe([ | ||
_.groupBy(_.identity), | ||
_.mapValues(_.length) | ||
])(svcs) | ||
// Add service to list if disabled by all running tasks | ||
services.disabled = _.pipe([ | ||
_.toPairs, | ||
_.filter(([key, count]) => _.equals(count, objs.length)), | ||
_.map(_.head) | ||
])(counts) | ||
if (!services.disabled.length) return cfg | ||
// Keep service if name is not in disabled list | ||
cfg.services = _.filter((s) => !_.contains(_.head(_.keys(s)), services.disabled), cfg.services) | ||
return cfg | ||
}, | ||
/** | ||
* Gets all services and returns name, persistence, and arguments | ||
* @param {array} cfg Instance config object | ||
* @param {Object} cfg Instance config object | ||
* @returns {array} Array of services names, persistence and run args | ||
@@ -23,3 +55,3 @@ */ | ||
args: command.get(value, name) | ||
})]), cfg.services), | ||
})]), cfg.services), | ||
/** | ||
@@ -26,0 +58,0 @@ * Runs services and resolves or rejects |
20793
542
+ Addedredash@0.18.0(transitive)
- Removedredash@0.17.0(transitive)
Updatedredash@^0.18.0