UNPKG

1.59 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const command_1 = require("@oclif/command");
4const Config = require("@oclif/config");
5const fs = require("fs-extra");
6const path = require("path");
7class Manifest extends command_1.Command {
8 async run() {
9 try {
10 fs.unlinkSync('oclif.manifest.json');
11 }
12 catch (_a) { }
13 const { args } = this.parse(Manifest);
14 const root = path.resolve(args.path);
15 let plugin = new Config.Plugin({ root, type: 'core', ignoreManifest: true, errorOnManifestCreate: true });
16 if (!plugin)
17 throw new Error('plugin not found');
18 await plugin.load();
19 if (!plugin.valid) {
20 const p = require.resolve('@oclif/plugin-legacy', { paths: [process.cwd()] });
21 const { PluginLegacy } = require(p);
22 delete plugin.name;
23 plugin = new PluginLegacy(this.config, plugin);
24 await plugin.load();
25 }
26 if (process.env.OCLIF_NEXT_VERSION) {
27 plugin.manifest.version = process.env.OCLIF_NEXT_VERSION;
28 }
29 const dotfile = plugin.pjson.files.find((f) => f.endsWith('.oclif.manifest.json'));
30 const file = path.join(plugin.root, `${dotfile ? '.' : ''}oclif.manifest.json`);
31 fs.writeFileSync(file, JSON.stringify(plugin.manifest));
32 this.log(`wrote manifest to ${file}`);
33 }
34}
35exports.default = Manifest;
36Manifest.description = 'generates plugin manifest json';
37Manifest.args = [
38 { name: 'path', description: 'path to plugin', default: '.' },
39];