UNPKG

youzanyun-devtool-worker

Version:

111 lines (110 loc) 4.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path_1 = tslib_1.__importDefault(require("path")); const spring4js_nodejs_1 = require("spring4js-nodejs"); let BackendHelperService = class BackendHelperService { constructor() { this._dockerShellOut = new spring4js_nodejs_1.Emitter(); this.onDockerShellOut = this._dockerShellOut.registerEvent; } async start() { } async getMenu({ projectId, appName, workbenchId }) { let menuList = [ { title: '扩展点调试', key: '扩展点调试', param: { hasNavigator: true, commands: ["close-all-mock"], contentType: 'webview', url: `/html/extension-point?projectId=${projectId}&workbenchId=${workbenchId}&page=1`, docKey: 'server-debug', } }, { title: '消息推送调试', key: '消息推送调试', param: { hasNavigator: true, commands: ["close-all-mock"], contentType: 'webview', url: `/html/extension-point?projectId=${projectId}&workbenchId=${workbenchId}&page=0`, docKey: 'server-debug', } }, { title: '下载', key: '下载', param: { contentType: 'webview', url: `/html/download?projectId=${projectId}&workbenchId=${workbenchId}`, docKey: 'server-debug', } }, { title: 'isv页面模板', key: 'isv页面模板', param: { contentType: 'webview', url: `/html/isv-page?projectId=${projectId}&workbenchId=${workbenchId}`, docKey: 'default', } }, { title: 'API调试工具', key: 'API调试工具', param: { contentType: 'webview', url: `https://diy.youzanyun.com/custom/dev-tool/page?projectId=${projectId}`, docKey: 'default', } }, { title: '常用工具', key: 'common_tool', param: { contentType: 'webview', url: `/html/common-tool?projectId=${projectId}&workbenchId=${workbenchId}`, docKey: 'common-tool', } } ]; return menuList; } async downloadDocker({ workbenchId, projectId, arg }) { try { let installShell = ''; if (process.platform === 'darwin') { installShell = path_1.default.resolve(this.configService.getWorkerDir(), 'code-tpl/install_docker_server.sh'); await this.executeService.promiseExec(`chmod +x ${installShell}`, {}); } else { installShell = path_1.default.resolve(this.configService.getWorkerDir(), 'code-tpl/docker_install_servers.bat'); } const result = await this.executeService.promiseSpawm(installShell, [arg], {}, { report: (data) => { this._dockerShellOut.fire({ command: 'setDockerShellOut', data }); } }); return result == 0; } catch (error) { return false; } } }; tslib_1.__decorate([ (0, spring4js_nodejs_1.Resource)() ], BackendHelperService.prototype, "configService", void 0); tslib_1.__decorate([ (0, spring4js_nodejs_1.Resource)() ], BackendHelperService.prototype, "executeService", void 0); BackendHelperService = tslib_1.__decorate([ (0, spring4js_nodejs_1.Service)() ], BackendHelperService); exports.default = BackendHelperService;