UNPKG

@wmfs/tymly

Version:

A framework for building and sharing workflows in Node.js

76 lines (64 loc) 1.99 kB
const path = require('path') const discoverBlueprintDirs = require('./discover-blueprint-dirs') const extractRefProperties = require('./extract-ref-properties') const buildPaths = require('./build-paths') const processExclusions = require('./process-exclusions') const tymlyLoader = require('./tymly-loader') function load (options) { options.messages.heading('Loading') const plugins = loadPlugins(options) const blueprints = loadBlueprints(plugins, options) return { pluginPaths: plugins.paths, pluginComponents: plugins.components, blueprintPaths: blueprints.paths, blueprintComponents: blueprints.components, blueprintRefs: blueprints.tymlyRefs, blueprintRefProperties: blueprints.refProperties } } // load function loadPlugins (options) { const paths = buildPaths( path.resolve(__dirname, './../../plugin'), options.pluginPaths ) const { components } = tymlyLoader({ sourcePaths: paths, processRefProperties: false, messages: options.messages, suffix: 'components', sourceLabel: 'plugins', expectModule: true, excludeBaseNames: processExclusions(options.excludePlugins) }) return { paths, components } } // loadPlugins function loadBlueprints (plugins, options) { const paths = buildPaths( discoverBlueprintDirs(plugins.paths, options.messages), options.blueprintPaths ) const { components, tymlyRefs, refProperties } = tymlyLoader( { sourcePaths: paths, messages: options.messages, expectModule: false, sourceLabel: 'blueprints', expectedMetaFilename: 'blueprint.json', mandatoryMetaKeys: ['name', 'version', 'namespace'], refProperties: extractRefProperties(plugins.components), pluginComponents: plugins.components, excludeBaseNames: processExclusions(options.excludeBlueprints) } ) return { paths, components, tymlyRefs, refProperties } } // loadBlueprints module.exports = load