-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
124 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const _ = require('lodash'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
module.exports = async lando => { | ||
// load in legacy inits | ||
await require('./lando-load-legacy-inits')(lando); | ||
|
||
// build the cache | ||
return lando.Promise.resolve(lando.config.plugins) | ||
// Make sure the tasks dir exists | ||
.filter(plugin => fs.existsSync(plugin.tasks)) | ||
// Get a list off full js files that exist in that dir | ||
.map(plugin => _(fs.readdirSync(plugin.tasks)) | ||
.map(file => path.join(plugin.tasks, file)) | ||
.filter(path => _.endsWith(path, '.js')) | ||
.value(), | ||
) | ||
// Loadem and loggem | ||
.then(tasks => _.flatten(tasks)) | ||
.each(file => { | ||
lando.tasks.push({...require(file)(lando, {}), file}); | ||
lando.log.debug('autoloaded global task %s', path.basename(file, '.js')); | ||
}) | ||
// Reset the task cache | ||
.then(() => { | ||
lando.cache.set('_.tasks.cache', JSON.stringify(lando.tasks), {persist: true}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
const _ = require('lodash'); | ||
const fs = require('fs'); | ||
const glob = require('glob'); | ||
const path = require('path'); | ||
|
||
// Helper to get init config | ||
const getLegacyInitConfig = dirs => _(dirs) | ||
.filter(dir => fs.existsSync(dir)) | ||
.flatMap(dir => glob.sync(path.join(dir, '*', 'init.js'))) | ||
.map(file => require(file)) | ||
.value(); | ||
|
||
// Helper to get init config | ||
const getInitConfig = dirs => _(dirs) | ||
.filter(dir => fs.existsSync(dir)) | ||
.flatMap(dir => fs.readdirSync(dir).map(file => path.join(dir, file))) | ||
.map(file => require(file)) | ||
.value(); | ||
|
||
// Helper to get init source config | ||
const getInitSourceConfig = dirs => _(dirs) | ||
.filter(dir => fs.existsSync(dir)) | ||
.flatMap(dir => glob.sync(path.join(dir, '*.js'))) | ||
.map(file => require(file)) | ||
.flatMap(source => source.sources) | ||
.value(); | ||
|
||
module.exports = async lando => { | ||
const legacyInits = getLegacyInitConfig(_.map(lando.config.plugins, 'recipes')); | ||
const inits = getInitConfig(_.map(lando.config.plugins, 'inits')); | ||
|
||
lando.config.inits = _.sortBy(_.map(_.merge( | ||
{}, | ||
_.fromPairs(_.map(legacyInits, init => ([init.name, init]))), | ||
_.fromPairs(_.map(inits, init => ([init.name, init]))), | ||
), init => init), 'name'); | ||
|
||
// Load in config frmo sources | ||
const sources = getInitSourceConfig(_.map(lando.config.plugins, 'sources')); | ||
const initSources = _(lando.config.inits) | ||
.filter(init => _.has(init, 'sources')) | ||
.flatMap(init => init.sources) | ||
.value(); | ||
|
||
lando.config.sources = _.sortBy(sources.concat(initSources), 'label'); | ||
|
||
// And finally the recipes | ||
lando.config.recipes = _.sortBy(_.map(lando.config.inits, init => init.name), 'name'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters