semo-plugin-plugin
Version:
A semo plugin to provide plugin management.
45 lines (44 loc) • 2.12 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handler = exports.builder = exports.aliases = exports.desc = exports.command = exports.disabled = void 0;
const core_1 = require("@semo/core");
exports.disabled = false; // Set to true to disable this command temporarily
exports.command = 'uninstall <plugin...>';
exports.desc = 'Uninstall plugins';
exports.aliases = 'un';
// export const middleware = (argv) => {}
const builder = function (yargs) {
yargs.option('scope', { default: '', describe: 'Set plugin npm scope' });
yargs.option('local', {
default: false,
describe: 'Uninstall plugin from local directory, otherwise uninstall from global directory',
});
// yargs.commandDir('install')
};
exports.builder = builder;
const handler = function (argv) {
return __awaiter(this, void 0, void 0, function* () {
const scriptName = argv.scriptName || 'semo';
argv.plugin = core_1.Utils._.castArray(argv.plugin);
argv.plugin = argv.plugin.map(plugin => {
if (plugin.indexOf(`${scriptName}-plugin-`) === -1) {
plugin = `${scriptName}-plugin-${plugin}`;
}
if (argv.scope) {
plugin = `@${argv.scope}/${plugin}`;
}
return plugin;
});
core_1.Utils.uninstallPackage(argv.plugin, 'home-plugin-cache', true);
});
};
exports.handler = handler;