UNPKG

@anycli/dev-cli

Version:
40 lines (39 loc) 1.49 kB
"use strict"; // tslint:disable no-implicit-dependencies Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = require("@anycli/command"); const Config = require("@anycli/config"); const fs = require("fs"); const path = require("path"); class Manifest extends command_1.Command { async run() { try { fs.unlinkSync('.anycli.manifest.json'); } catch (_a) { } const { args } = this.parse(Manifest); const root = path.resolve(args.path); let plugin = new Config.Plugin({ root, type: 'core', ignoreManifest: true }); await plugin.load(); if (!plugin) throw new Error('plugin not found'); if (!plugin.valid) { // @ts-ignore let p = require.resolve('@anycli/plugin-legacy', { paths: [process.cwd()] }); const { PluginLegacy } = require(p); delete plugin.name; plugin = new PluginLegacy(this.config, plugin); } if (process.env.ANYCLI_NEXT_VERSION) { plugin.manifest.version = process.env.ANYCLI_NEXT_VERSION; } const file = path.join(plugin.root, '.anycli.manifest.json'); fs.writeFileSync(file, JSON.stringify(plugin.manifest)); this.log(`wrote manifest to ${file}`); } } Manifest.description = 'generates plugin manifest json'; Manifest.args = [ { name: 'path', description: 'path to plugin', default: '.' } ]; exports.default = Manifest;