// Helper to get tokens const getTokens = (home, tokens = []) => _(utils.sortTokens(utils.getTerminusTokens(home), tokens)) .map(token => ({name: token.email, value: token.token})) .thru(tokens => tokens.concat([{name: 'add or refresh a token', value: 'more'}])) .value()
/* * Helper to locate the "closest" platform yaml */ const traverseUp = (startFrom = process.cwd()) => { return _(_.range(path.dirname(startFrom).split(path.sep).length)) .map(end => _.dropRight(path.dirname(startFrom).split(path.sep), end).join(path.sep)) .unshift(startFrom) .dropRight() .value(); }
_(fs.readdirSync(baseDir, {withFileTypes: true})) .filter(dirent => dirent.isDirectory()) .map(dirent => dirent.name) .concat('.') .map(directory => path.resolve(baseDir, directory, '.platform.app.yaml')) .filter(file => fs.existsSync(file)) .map(file => ({data: yamlPlatform.load(fs.readFileSync(file)), file})) .map(data => ({name: data.data.name, file: data.file, dir: path.dirname(data.file)})) .value()
constructor(id, info = {}, ...sources) { this.id = id; this.info = info; this.data = _(sources).map(source => _.merge({}, source, {version: '3.6'})).value(); }
// Helper to get init config const getInitConfig = dirs => _(dirs) .filter(dir => fs.existsSync(dir)) .flatMap(dir => glob.sync(path.join(dir, '*', 'init.js'))) .map(file => require(file)) .value()
_(services) // Break apart platform type into typ and version .map(service => _.merge({}, service, getPlatformServiceType(service))) // Filter out services that are not supported yet .filter(service => getLandoServiceType(service.type) !== false) // Merge in other needed lando things .map(service => _.merge({}, getLandoService(service), {runConfig: _.find(runConfig, {service: service.name})})) // Finally map to an object .map(service => ([service.name, service])) .fromPairs() .value()
_(options) .keys() .sortBy() .map(key => [key, options[key]]) .fromPairs() .value()
/* * Helper to get passthru options */ const handlePassthruOpts = (options = {}, answers = {}) => _(options) .map((value, key) => _.merge({}, {name: key}, value)) .filter(value => value.passthrough === true && !_.isNil(answers[value.name])) .map(value => `--${value.name}=${answers[value.name]}`) .value()
/* * Helper to find containers that serve */ const getOtherServingContainers = services => _(services) .filter(service => service.type === 'lagoon-varnish') .map('name') .value()
// Helper to get tokens const getTokens = (home, tokens = []) => _(utils.sortTokens(utils.getPlatformshTokens(home), tokens)) .map(token => ({name: token.email, value: token.token})) .thru(tokens => tokens.concat([{name: 'add or refresh a token', value: 'more'}])) .value()