@wocker/ws
Version:
Docker workspace for web projects
88 lines (87 loc) • 3.87 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PluginController = void 0;
const core_1 = require("@wocker/core");
const PluginService_1 = require("../services/PluginService");
let PluginController = class PluginController {
constructor(appConfigService, pluginService) {
this.appConfigService = appConfigService;
this.pluginService = pluginService;
}
async list() {
return this.pluginService.getPluginsTable();
}
async add(names) {
for (const fullName of names) {
const [, name, version] = /^(@?[^@/\s]+(?:\/[^@/\s]+)?)(?:@([^@\s]+))?$/.exec(fullName) || [];
await this.pluginService.install(name, version);
}
}
async remove(names) {
for (const name of names) {
await this.pluginService.uninstall(name);
}
}
async update() {
await this.pluginService.update();
}
getInstalledPlugins() {
return this.appConfigService.plugins.map(pluginRef => pluginRef.name);
}
};
exports.PluginController = PluginController;
__decorate([
(0, core_1.Command)("plugins"),
(0, core_1.Description)("Plugins list"),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], PluginController.prototype, "list", null);
__decorate([
(0, core_1.Command)("plugin:install <...names>"),
(0, core_1.Description)("Install a plugin by specifying its name"),
__param(0, (0, core_1.Param)("names")),
__param(0, (0, core_1.Description)("Names of plugins to install")),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", Promise)
], PluginController.prototype, "add", null);
__decorate([
(0, core_1.Command)("plugin:remove <...names>"),
(0, core_1.Description)("Remove a plugin"),
__param(0, (0, core_1.Param)("names")),
__param(0, (0, core_1.Description)("Names of plugins to remove")),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", Promise)
], PluginController.prototype, "remove", null);
__decorate([
(0, core_1.Command)("plugin:update"),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], PluginController.prototype, "update", null);
__decorate([
(0, core_1.Completion)("names", "plugin:remove <...names>"),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Array)
], PluginController.prototype, "getInstalledPlugins", null);
exports.PluginController = PluginController = __decorate([
(0, core_1.Controller)(),
(0, core_1.Description)("Plugin commands"),
__metadata("design:paramtypes", [core_1.AppConfigService,
PluginService_1.PluginService])
], PluginController);