@vendure/cli
Version:
A modern, headless ecommerce framework
26 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolvePluginFromOptions = resolvePluginFromOptions;
const ast_utils_1 = require("../utilities/ast-utils");
const vendure_plugin_ref_1 = require("./vendure-plugin-ref");
function resolvePluginFromOptions(project, options) {
let plugin = options.providedPlugin;
if (!plugin && options.pluginName) {
const pluginClasses = (0, ast_utils_1.getPluginClasses)(project);
const foundPlugin = pluginClasses.find(p => p.getName() === options.pluginName);
if (!foundPlugin) {
const availablePlugins = pluginClasses.map(p => p.getName()).filter(Boolean);
throw new Error(`Plugin "${options.pluginName}" not found. Available plugins:\n` +
availablePlugins.map(name => ` - ${name}`).join('\n'));
}
plugin = new vendure_plugin_ref_1.VendurePluginRef(foundPlugin);
}
if (options.isNonInteractive && !plugin) {
throw new Error('Plugin must be specified when running in non-interactive mode');
}
return {
plugin,
shouldPromptForSelection: !plugin && !options.isNonInteractive,
};
}
//# sourceMappingURL=plugin-resolution.js.map