UNPKG

@tuzki/cli

Version:

🐇 lowcode-cli is an efficient cli tool for Rabbitpre plugin component secondary development. ❤️

157 lines (156 loc) 4.63 kB
/* * api init project * * @Author: xu.jin * @Date: 2023-08-15 19:21:16 * * Copyright © 2014-2023 Rabbitpre.com. All Rights Reserved. */ 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()); }); }; import Logger from '@tuzki/scaffold-logger'; import { get } from '../utils/request.js'; import { getApiPrefix } from './common.js'; const logger = Logger.get('cli:apis:init-project'); /** * 获取模块类型列表 * * @export * @return {*} {Promise<ProjectType[]>} */ export const getModuleTypes = () => __awaiter(void 0, void 0, void 0, function* () { try { const apiPrefix = getApiPrefix(); const typeList = yield get(`${apiPrefix}/getType`); return typeList; } catch (err) { logger.error('请求获取模块类型列表失败:', err); process.exit(1); } }); /** * 获取模块列表 * * @export * @param {ProjectType} type 模块类型 * @return {*} {Promise<Module[]>} 模块列表 */ export const getModuleList = (type) => __awaiter(void 0, void 0, void 0, function* () { try { const apiPrefix = getApiPrefix(); const moduleList = yield get(`${apiPrefix}/findList`, { type }); return moduleList; } catch (err) { logger.error('请求获取模块列表失败:', err); process.exit(1); } }); /** * 下载模块源码 * * @export * @param {string} id 模块 id * @param {ProjectType} type 模块类型 * @return {*} */ export const downloadModuleCode = (query) => __awaiter(void 0, void 0, void 0, function* () { try { const apiPrefix = getApiPrefix(); const moduleCode = yield get(`${apiPrefix}/downloadCode`, query, { customOptions: { buffer: true, }, }); return moduleCode; } catch (err) { logger.error('请求下载模块源码失败:', err); process.exit(1); } }); /** * 获取模块模型 * * @export * @param {string} id 模块 id * @param {ProjectType} type 模块类型 * @return {*} */ export const getModuleModel = (query) => __awaiter(void 0, void 0, void 0, function* () { try { const apiPrefix = getApiPrefix(); const model = yield get(`${apiPrefix}/getModel`, query); return model; } catch (err) { logger.error('请求获取模块模型数据失败:', err); process.exit(1); } }); /** * 获取模块实现 * * @export * @param {string} id 模块 id * @param {ProjectType} type 模块类型 * @return {*} */ export const getModuleImplement = (query) => __awaiter(void 0, void 0, void 0, function* () { try { const apiPrefix = getApiPrefix(); const model = yield get(`${apiPrefix}/getImplement`, query); return model; } catch (err) { logger.error('请求获取模块实现数据失败:', err); process.exit(1); } }); /** * 获取所有开发版本列表 * * @export * @param {string} id 模块 id * @param {ProjectType} type 模块类型 * @return {*} */ export const findDevVersionList = (id, type) => __awaiter(void 0, void 0, void 0, function* () { try { const apiPrefix = getApiPrefix(); const query = { id, type }; const versions = yield get(`${apiPrefix}/findDevVersionList`, query); return versions; } catch (err) { logger.error('请求获取开发版本列表失败:', err); process.exit(1); } }); /** * 检查当前版本是否已上线 * * @export * @param {string} versionId 当前版本id * @param {ProjectType} type 类型 * @return {*} */ export const checkVersionOnline = (query) => __awaiter(void 0, void 0, void 0, function* () { try { const apiPrefix = getApiPrefix(); const isRelease = yield get(`${apiPrefix}/checkVersionOnline`, query); return isRelease; } catch (err) { logger.error('请求检查当前版本是否已上线:', err); process.exit(1); } });