youzanyun-devtool-worker
Version:
- web - ws - proxy
261 lines (260 loc) • 9.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const path_1 = tslib_1.__importDefault(require("path"));
const spring4js_nodejs_1 = require("spring4js-nodejs");
let ProjectService = class ProjectService {
async getCompletedProjectById(id) {
const localProject = await this.projectDao.getDataById(id);
let result = { appId: 0 };
if (localProject && localProject.proName) {
let container = global.container;
let applicationService = await container.getServiceInstance("applicationService");
const res = await applicationService.getAppDetail(localProject.proName);
result = res.appDetail;
}
return result;
}
async getProjectById(id) {
let project = await this.projectDao.getDataById(id);
return project;
}
async getProjectList(params = {}) {
const result = await this.projectDao.getDataWithCondition(params);
return result;
}
async getProjectsByProName(params) {
const result = await this.projectDao.getDataWithCondition(params);
return result;
}
async saveProject(params) {
const isDesignPlatform = await fs_extra_1.default.pathExists(path_1.default.resolve(params.proPath, "ecloud-tpl-version.json"));
const isNodeJs = await fs_extra_1.default.pathExists(path_1.default.resolve(params.proPath, "package.json"));
const isJava = await fs_extra_1.default.pathExists(path_1.default.resolve(params.proPath, "pom.xml"));
const isPhp = await fs_extra_1.default.pathExists(path_1.default.resolve(params.proPath, "composer.json"));
params.isDesignPlatform = isDesignPlatform;
params.isNodeJs = isNodeJs;
params.isJava = isJava;
params.isPhp = isPhp;
return await this.projectDao.save(params);
}
async deleteProject(id) {
return await this.projectDao.delete(id);
}
async checkProjectStatus(proPath) {
const isClean = await this.gitService.checkGitRepoClean(proPath);
return isClean;
}
async getSideBarNavigatorList({ projectId, workbenchId, }) {
let project = await this.getProjectById(projectId);
if (project.isDesignPlatform) {
return [
{
icon: "bulb",
title: "设计平台定制",
key: "design-platform",
actionType: "openMenuView",
param: {
customType: "design-platform",
},
},
];
}
else {
return [
{
icon: "apartment",
title: "扩展点调试",
key: "bep",
actionType: "openUrl",
param: {
hasNavigator: true,
commands: ["close-all-mock"],
url: `/html/extension-point?projectId=${projectId}&workbenchId=${workbenchId}&type=bep`,
},
},
{
icon: "mail",
title: "消息推送调试",
key: "mep",
actionType: "openUrl",
param: {
hasNavigator: true,
commands: ["close-all-mock"],
url: `/html/extension-point?projectId=${projectId}&workbenchId=${workbenchId}&type=mep`,
},
},
{
icon: "html5",
title: "H5页面开发",
key: "h5-extension",
children: [
{
icon: "",
title: "微商城h5",
key: "wsc-h5",
actionType: "openMenuView",
param: {
customType: "wsc-h5",
},
},
{
icon: "",
title: "美业h5",
key: "beauty-h5",
actionType: "openMenuView",
param: {
customType: "beauty-h5",
},
},
],
},
{
icon: "shopping",
title: "小程序开发",
key: "mp",
children: [
{
icon: "",
title: "微商城小程序",
key: "wsc",
actionType: "openMenuView",
param: {
hasNavigator: false,
customType: "wsc-mp",
},
},
{
icon: "",
title: "零售小程序",
key: "retail",
actionType: "openMenuView",
param: {
customType: "retail-mp",
},
},
{
icon: "",
title: "美业小程序",
key: "beauty",
actionType: "openMenuView",
param: {
customType: "beauty-mp",
},
},
],
},
{
icon: "desktop",
title: "PC页面开发",
key: "pc-extension",
children: [
{
icon: "",
title: "微商城pc",
key: "wsc-pc",
actionType: "openMenuView",
param: {
customType: "wsc-pc",
},
},
{
icon: "",
title: "美业pc",
key: "beauty-pc",
actionType: "openMenuView",
param: {
customType: "beauty-pc",
},
},
],
},
{
icon: "api",
title: "API调试",
key: "api",
actionType: "openUrl",
param: {
hasNavigator: false,
url: `https://diy.youzanyun.com/custom/dev-tool/page?projectId=${projectId}`,
},
},
{
icon: "tool",
title: "常用工具",
key: "tools",
actionType: "openUrl",
param: {
hasNavigator: false,
url: `/html/common-tool?projectId=${projectId}`,
},
},
{
icon: "html5",
fontIcon: "icon-qianrushiyingyong",
title: "嵌入式应用开发",
key: "built-in-app",
actionType: "openMenuView",
param: {
customType: "wsc-build-in-app",
},
},
];
}
}
async getCustomTypeList(projectId) {
let project = await this.getProjectById(projectId);
let customTypeList = [];
if (project.isDesignPlatform) {
customTypeList = [
{
text: "设计平台定制",
value: "design-platform",
},
];
}
else {
customTypeList = [
{
text: "h5页面定制",
value: "h5-extension",
},
{
text: "微商城小程序",
value: "wsc-mp",
},
{
text: "PC定制",
value: "wsc-pc",
},
{
text: "零售小程序",
value: "retail-mp",
},
{
text: "美业小程序",
value: "beauty-mp",
},
{
text: "功能调试",
value: "backend-helper",
},
];
}
return customTypeList;
}
};
tslib_1.__decorate([
spring4js_nodejs_1.Resource()
], ProjectService.prototype, "configService", void 0);
tslib_1.__decorate([
spring4js_nodejs_1.Resource()
], ProjectService.prototype, "gitService", void 0);
tslib_1.__decorate([
spring4js_nodejs_1.Resource()
], ProjectService.prototype, "projectDao", void 0);
ProjectService = tslib_1.__decorate([
spring4js_nodejs_1.Service()
], ProjectService);
exports.default = ProjectService;