UNPKG

894 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const manifest_file_1 = require("@anycli/manifest-file");
4class Manifest extends manifest_file_1.default {
5 constructor(file) {
6 super(['@anycli/plugins', file].join(':'), file);
7 this.writeOptions = { spaces: 2 };
8 }
9 async list() {
10 return (await this.get('plugins')) || {};
11 }
12 async add(name, tag) {
13 this.debug(`adding ${name}@${tag}`);
14 const plugins = await this.list();
15 plugins[name] = { tag };
16 await this.set(['plugins', plugins]);
17 }
18 async remove(name) {
19 this.debug(`removing ${name}`);
20 const plugins = await this.list();
21 if (!plugins[name])
22 return this.debug('not found in manifest');
23 delete plugins[name];
24 await this.set(['plugins', plugins]);
25 }
26}
27exports.default = Manifest;