UNPKG

@feflow/cli

Version:
682 lines 30.9 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; 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()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CacheController = exports.LOAD_ALL = exports.LOAD_UNIVERSAL_PLUGIN = exports.LOAD_DEVKIT = exports.LOAD_PLUGIN = exports.CommandType = void 0; /* eslint-disable no-loop-func */ var fs_1 = __importDefault(require("fs")); var path_1 = __importDefault(require("path")); var osenv_1 = __importDefault(require("osenv")); var lodash_1 = __importDefault(require("lodash")); var load_universal_plugin_1 = require("../plugin/load-universal-plugin"); var logger_1 = __importDefault(require("../logger")); var yaml_1 = require("../../shared/yaml"); var constant_1 = require("../../shared/constant"); var load_plugins_1 = require("../plugin/load-plugins"); var internalPlugins = { devtool: '@feflow/feflow-plugin-devtool', }; var CommandType; (function (CommandType) { CommandType["NATIVE_TYPE"] = "native"; CommandType["PLUGIN_TYPE"] = "plugin"; CommandType["INTERNAL_PLUGIN_TYPE"] = "devtool"; CommandType["UNIVERSAL_PLUGIN_TYPE"] = "universal"; CommandType["UNKNOWN_TYPE"] = "unknown"; })(CommandType = exports.CommandType || (exports.CommandType = {})); exports.LOAD_PLUGIN = 1 << 0; exports.LOAD_DEVKIT = 1 << 1; exports.LOAD_UNIVERSAL_PLUGIN = 1 << 2; exports.LOAD_ALL = exports.LOAD_PLUGIN | exports.LOAD_DEVKIT | exports.LOAD_UNIVERSAL_PLUGIN; var TargetPlugin = /** @class */ (function () { function TargetPlugin(type, path, pkg) { this.type = type; this.path = path; this.pkg = pkg; } return TargetPlugin; }()); var NativePlugin = /** @class */ (function (_super) { __extends(NativePlugin, _super); function NativePlugin() { return _super !== null && _super.apply(this, arguments) || this; } return NativePlugin; }(TargetPlugin)); var TargetUniversalPlugin = /** @class */ (function () { function TargetUniversalPlugin(type, version, pkg) { this.type = type; this.version = version; this.pkg = pkg; } return TargetUniversalPlugin; }()); var CacheController = /** @class */ (function () { function CacheController(ctx) { this.lastCommand = ''; this.lastVersion = ''; this.lastStore = {}; this.subCommandMap = {}; this.subCommandMapWithVersion = { commands: [] }; this.cacheVersion = '1.0.0'; this.pickOrder = [ CommandType.PLUGIN_TYPE, CommandType.UNIVERSAL_PLUGIN_TYPE, CommandType.NATIVE_TYPE, CommandType.INTERNAL_PLUGIN_TYPE, ]; this.ctx = ctx; this.root = path_1.default.join(osenv_1.default.home(), constant_1.FEFLOW_ROOT); this.cacheFilePath = path_1.default.join(this.root, constant_1.CACHE_FILE); this.cache = this.getCache(); if (this.cache) { var isCacheExpired = this.cache.version !== this.cacheVersion; if (isCacheExpired) { this.ctx.logger.debug('fef cache is expired, clear invalid cache.'); this.cache = { version: this.cacheVersion, }; this.writeCache(); } } else { this.ctx.logger.debug('fef cache is empty.'); } } CacheController.prototype.registerSubCommand = function (type, store, pluginName, version) { var e_1, _a; if (pluginName === void 0) { pluginName = CommandType.NATIVE_TYPE; } if (version === void 0) { version = 'latest'; } var newCommands = lodash_1.default.difference(Object.keys(store), Object.keys(this.lastStore)); if (!!this.lastCommand) { if (type === CommandType.PLUGIN_TYPE) { // 命令相同的场景,插件提供方变化后,依然可以探测到是新命令 var commonCommands = Object.keys(store).filter(function (item) { return !newCommands.includes(item); }); try { for (var commonCommands_1 = __values(commonCommands), commonCommands_1_1 = commonCommands_1.next(); !commonCommands_1_1.done; commonCommands_1_1 = commonCommands_1.next()) { var common = commonCommands_1_1.value; if (!this.lastStore[common]) continue; if (store[common].pluginName !== this.lastStore[common].pluginName) { newCommands.push(common); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (commonCommands_1_1 && !commonCommands_1_1.done && (_a = commonCommands_1.return)) _a.call(commonCommands_1); } finally { if (e_1) throw e_1.error; } } this.subCommandMap[this.lastCommand] = newCommands; } else { if (!this.subCommandMapWithVersion[this.lastCommand]) { this.subCommandMapWithVersion[this.lastCommand] = { commands: [ { name: newCommands[0], version: this.lastVersion, }, ], }; } else { this.subCommandMapWithVersion[this.lastCommand].commands.push({ name: newCommands[0], version: this.lastVersion, }); } } } this.lastVersion = version; this.lastCommand = pluginName; this.lastStore = Object.assign({}, store); }; CacheController.prototype.initCacheFile = function () { this.cache = { commandPickerMap: this.getAllCommandPickerMap(), version: this.cacheVersion, }; this.writeCache(); }; CacheController.prototype.writeCache = function (filePath) { if (filePath === void 0) { filePath = this.cacheFilePath; } (0, yaml_1.safeDump)(this.cache, filePath); }; CacheController.prototype.updateCache = function (type) { var _a; if (!((_a = this.cache) === null || _a === void 0 ? void 0 : _a.commandPickerMap)) { this.initCacheFile(); return; } if (type === CommandType.PLUGIN_TYPE) { this.cache.commandPickerMap[type] = this.getPluginMap(); } else if (type === CommandType.UNIVERSAL_PLUGIN_TYPE) { this.cache.commandPickerMap[type] = this.getUniversalMap(); } this.writeCache(); this.lastStore = {}; this.lastCommand = ''; }; CacheController.prototype.getAllCommandPickerMap = function () { var commandPickerMap = {}; commandPickerMap[CommandType.NATIVE_TYPE] = this.getNativeMap(); commandPickerMap[CommandType.PLUGIN_TYPE] = this.getPluginMap(); commandPickerMap[CommandType.INTERNAL_PLUGIN_TYPE] = this.getInternalPluginMap(); commandPickerMap[CommandType.UNIVERSAL_PLUGIN_TYPE] = this.getUniversalMap(); return commandPickerMap; }; CacheController.prototype.getNativeMap = function () { var nativePath = path_1.default.join(__dirname, '../native'); var nativeMap = {}; fs_1.default.readdirSync(nativePath) .filter(function (file) { return file.endsWith('.js'); }) .forEach(function (file) { var command = file.split('.')[0]; // 通过缓存路径的方式并不是一个值得主张的方案,例如在我们使用webpack构建单文件时这个机制会成为束缚 // 缓存绝对路径更不提倡,当客户端node切换不同版本时,绝对路径将导致异常 // 此处将其变更为相对路径,暂时解决版本切换的问题 // 另外值得讨论的是,cache逻辑本身不应该阻塞正常业务流程,但目前cache带来的问题反而比主逻辑还多,这是很不健康的现象 nativeMap[command] = { commands: [ { name: command, }, ], path: file, type: CommandType.NATIVE_TYPE, }; }); return nativeMap; }; CacheController.prototype.getInternalPluginMap = function () { var e_2, _a; var devtool = {}; try { for (var _b = __values(Object.keys(internalPlugins)), _c = _b.next(); !_c.done; _c = _b.next()) { var command = _c.value; devtool[command] = { path: internalPlugins[command], type: CommandType.INTERNAL_PLUGIN_TYPE, commands: [{ name: 'devtool' }], }; } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } return devtool; }; CacheController.prototype.getPluginMap = function () { var e_3, _a; var _b; var plugin = {}; var _c = __read((0, load_plugins_1.getPluginsList)(this.ctx), 2), err = _c[0], pluginList = _c[1]; var home = path_1.default.join(osenv_1.default.home(), constant_1.FEFLOW_ROOT); if (!Object.keys(this.subCommandMap).length) { return plugin; } if (!err) { try { for (var pluginList_1 = __values(pluginList), pluginList_1_1 = pluginList_1.next(); !pluginList_1_1.done; pluginList_1_1 = pluginList_1.next()) { var pluginNpm = pluginList_1_1.value; var pluginPath = path_1.default.join(home, 'node_modules', pluginNpm); // TODO // read plugin command from the key which from its package.json plugin[pluginNpm] = { type: CommandType.PLUGIN_TYPE, commands: (_b = this.subCommandMap[pluginNpm]) === null || _b === void 0 ? void 0 : _b.map(function (cmd) { return ({ name: cmd, }); }), path: pluginPath, }; } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (pluginList_1_1 && !pluginList_1_1.done && (_a = pluginList_1.return)) _a.call(pluginList_1); } finally { if (e_3) throw e_3.error; } } } else { this.ctx.logger.debug('picker load plugin failed', err); } return plugin; }; CacheController.prototype.getUniversalMap = function () { var e_4, _a; var universalPlugin = {}; try { for (var _b = __values(Object.keys(this.subCommandMapWithVersion)), _c = _b.next(); !_c.done; _c = _b.next()) { var pkg = _c.value; if (!pkg) continue; var plugin = this.subCommandMapWithVersion[pkg]; universalPlugin[pkg] = __assign(__assign({}, plugin), { type: CommandType.UNIVERSAL_PLUGIN_TYPE }); } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_4) throw e_4.error; } } return universalPlugin; }; CacheController.prototype.getCache = function () { var cacheFilePath = this.cacheFilePath; try { return (0, yaml_1.parseYaml)(cacheFilePath); } catch (error) { this.ctx.logger.error("parse ".concat(constant_1.CACHE_FILE, " error: "), error); } }; CacheController.prototype.removeCache = function (name) { var e_5, _a, e_6, _b; if (!this.cache) return; var _c = this.cache.commandPickerMap, commandPickerMap = _c === void 0 ? {} : _c; var targetPath = { type: '', plugin: '' }; try { for (var _d = __values(this.pickOrder), _e = _d.next(); !_e.done; _e = _d.next()) { var type = _e.value; var pluginsInType = commandPickerMap[type]; if (!pluginsInType) continue; try { for (var _f = (e_6 = void 0, __values(Object.keys(pluginsInType))), _g = _f.next(); !_g.done; _g = _f.next()) { var plugin = _g.value; if (name === plugin) { targetPath = { type: type, plugin: plugin, }; } } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { if (_g && !_g.done && (_b = _f.return)) _b.call(_f); } finally { if (e_6) throw e_6.error; } } if (targetPath.type) { break; } } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (_e && !_e.done && (_a = _d.return)) _a.call(_d); } finally { if (e_5) throw e_5.error; } } if (targetPath.type && targetPath.plugin && this.cache.commandPickerMap) { delete this.cache.commandPickerMap[targetPath.type][targetPath.plugin]; this.writeCache(); } }; // 获取命令的缓存目录 CacheController.prototype.getCommandPath = function (cmd) { var e_7, _a, e_8, _b; var _c; var target = new TargetUniversalPlugin(CommandType.UNKNOWN_TYPE, '', ''); if (!((_c = this.cache) === null || _c === void 0 ? void 0 : _c.commandPickerMap)) return target; var commandPickerMap = this.cache.commandPickerMap; var cmdList = []; try { for (var _d = __values(this.pickOrder), _e = _d.next(); !_e.done; _e = _d.next()) { var type = _e.value; var pluginsInType = commandPickerMap[type]; if (!pluginsInType) continue; var _loop_1 = function (plugin) { var _h = pluginsInType[plugin], commands = _h.commands, path_2 = _h.path, type_1 = _h.type; commands === null || commands === void 0 ? void 0 : commands.forEach(function (_a) { var name = _a.name, cmdPath = _a.path, version = _a.version; if (cmd === name) { if (type_1 === CommandType.UNIVERSAL_PLUGIN_TYPE) { target = new TargetUniversalPlugin(type_1, version, plugin); } else if (type_1 === CommandType.NATIVE_TYPE) { target = new NativePlugin(type_1, (cmdPath || path_2), CommandType.NATIVE_TYPE); } else { target = new TargetPlugin(type_1, (cmdPath || path_2), plugin); } cmdList.push(lodash_1.default.cloneDeep(target)); } }); }; try { for (var _f = (e_8 = void 0, __values(Object.keys(pluginsInType))), _g = _f.next(); !_g.done; _g = _f.next()) { var plugin = _g.value; _loop_1(plugin); } } catch (e_8_1) { e_8 = { error: e_8_1 }; } finally { try { if (_g && !_g.done && (_b = _f.return)) _b.call(_f); } finally { if (e_8) throw e_8.error; } } } } catch (e_7_1) { e_7 = { error: e_7_1 }; } finally { try { if (_e && !_e.done && (_a = _d.return)) _a.call(_d); } finally { if (e_7) throw e_7.error; } } var args = this.ctx.args; if (cmdList.length >= 2) { if (!args.pick) { this.ctx.logger.debug("\n \u5F53\u524D\u547D\u4EE4(".concat(cmd, ")\u51FA\u73B0\u51B2\u7A81, \u5982\u679C\u5982\u679C\u60F3\u8981\u6267\u884C\u5176\u4ED6\u63D2\u4EF6\uFF0C\u8BF7\u4F7F\u7528--pick\u53C2\u6570\u6307\u660E\n \u4F8B\u5982: fef doctor --pick native \u6216\u8005 fef doctor --pick @tencent/feflow-plugin-raft")); } else { cmdList = cmdList.filter(function (_a) { var pkg = _a.pkg; return pkg === args.pick; }); } } return cmdList[0]; }; return CacheController; }()); exports.CacheController = CacheController; var CommandPicker = /** @class */ (function () { function CommandPicker(ctx, cmd) { if (cmd === void 0) { cmd = 'help'; } this.supportType = [ CommandType.NATIVE_TYPE, CommandType.PLUGIN_TYPE, CommandType.UNIVERSAL_PLUGIN_TYPE, CommandType.INTERNAL_PLUGIN_TYPE, ]; this.homeRunCmd = ['help', 'list']; this.root = ctx.root; this.ctx = ctx; this.cmd = cmd; this.isHelp = cmd === 'help' || ctx.args.h || ctx.args.help; this.cacheController = new CacheController(ctx); } CommandPicker.prototype.loadHelp = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.cmd = 'help'; return [4 /*yield*/, this.pickCommand()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }; CommandPicker.prototype.isAvailable = function () { var targetCommand = this.cacheController.getCommandPath(this.cmd) || {}; var type = targetCommand.type; if (type === CommandType.UNIVERSAL_PLUGIN_TYPE) { var _a = targetCommand, version = _a.version, pkg = _a.pkg; var pkgPath = path_1.default.join(this.ctx.universalModules, "".concat(pkg, "@").concat(version)); var pathExists = fs_1.default.existsSync(pkgPath); return !this.isHelp && pathExists && !!version; } if (type === CommandType.PLUGIN_TYPE) { var path_3 = targetCommand.path; var pathExists = fs_1.default.existsSync(path_3); var isCacheType = this.supportType.includes(type); return !this.isHelp && pathExists && isCacheType; } if (type === CommandType.NATIVE_TYPE) { if (!this.homeRunCmd.includes(this.cmd)) { return true; } } return false; }; CommandPicker.prototype.checkCommand = function () { var _a; return __awaiter(this, void 0, void 0, function () { var cmdInfo; return __generator(this, function (_b) { switch (_b.label) { case 0: cmdInfo = (_a = this.ctx) === null || _a === void 0 ? void 0 : _a.commander.get(this.cmd); if (!!cmdInfo) return [3 /*break*/, 2]; return [4 /*yield*/, this.loadHelp()]; case 1: _b.sent(); _b.label = 2; case 2: return [2 /*return*/]; } }); }); }; CommandPicker.prototype.getCommandSource = function (path) { var reg = /node_modules\/(.*)/; var _a = __read(reg.exec(path) || [], 2), commandSource = _a[1]; return commandSource; }; CommandPicker.prototype.pickCommand = function () { var _a, _b; return __awaiter(this, void 0, void 0, function () { var targetCommand, type, pluginLogger, _c, version, pkg, error_1, commandPath, commandSource, commandEntry, error_2; return __generator(this, function (_d) { switch (_d.label) { case 0: targetCommand = this.cacheController.getCommandPath(this.cmd) || {}; type = targetCommand.type; pluginLogger = (0, logger_1.default)({ debug: Boolean(this.ctx.args.debug), silent: Boolean(this.ctx.args.silent), name: targetCommand.pkg, }); this.ctx.logger.debug('pick command type: ', type); if (!this.supportType.includes(type)) { return [2 /*return*/, this.ctx.logger.warn("this kind of command is not supported in command picker: ".concat(type))]; } if (!(type === CommandType.UNIVERSAL_PLUGIN_TYPE)) return [3 /*break*/, 5]; _c = targetCommand, version = _c.version, pkg = _c.pkg; _d.label = 1; case 1: _d.trys.push([1, 3, , 4]); return [4 /*yield*/, (0, load_universal_plugin_1.execPlugin)(Object.assign({}, this.ctx, { logger: pluginLogger }), pkg, version)]; case 2: _d.sent(); return [3 /*break*/, 4]; case 3: error_1 = _d.sent(); this.ctx.fefError.printError({ error: error_1, }); return [3 /*break*/, 4]; case 4: return [3 /*break*/, 10]; case 5: commandPath = ''; if (targetCommand instanceof TargetPlugin) { commandPath = targetCommand.path; } // native命令跟node版本挂钩,需要解析到具体node版本下路径 if (type === 'native') { // 兼容原来的绝对路径形式 if (path_1.default.isAbsolute(commandPath)) { commandPath = path_1.default.basename(commandPath); } commandPath = path_1.default.join(__dirname, '../native', commandPath); } commandSource = this.getCommandSource(commandPath) || CommandType.NATIVE_TYPE; this.ctx.logger.debug('pick command path: ', commandPath); this.ctx.logger.debug('pick command source: ', commandSource); _d.label = 6; case 6: _d.trys.push([6, 9, , 10]); (_b = (_a = this.ctx) === null || _a === void 0 ? void 0 : _a.reporter) === null || _b === void 0 ? void 0 : _b.setCommandSource(commandSource); return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require(commandPath)); })]; case 7: commandEntry = _d.sent(); return [4 /*yield*/, commandEntry.default(Object.assign({}, this.ctx, { logger: pluginLogger }))]; case 8: _d.sent(); return [3 /*break*/, 10]; case 9: error_2 = _d.sent(); this.ctx.fefError.printError({ error: error_2, }); return [3 /*break*/, 10]; case 10: return [2 /*return*/]; } }); }); }; CommandPicker.prototype.getCmdInfo = function () { var targetCommand = this.cacheController.getCommandPath(this.cmd) || {}; var type = targetCommand.type; var cmdInfo = { type: type, path: '', }; if (type === CommandType.PLUGIN_TYPE) { cmdInfo.path = targetCommand.path; } else if (type === CommandType.UNIVERSAL_PLUGIN_TYPE) { var _a = targetCommand, pkg = _a.pkg, version = _a.version; cmdInfo.path = path_1.default.join(this.ctx.root, constant_1.UNIVERSAL_MODULES, "".concat(pkg, "@").concat(version)); } else { cmdInfo.path = this.ctx.root; } return cmdInfo; }; return CommandPicker; }()); exports.default = CommandPicker; //# sourceMappingURL=index.js.map