UNPKG

@tuzki/cli

Version:

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

59 lines (58 loc) 2.48 kB
/* * Update Command * * @Author: xu.jin * @Date: 2022-12-13 14:34:46 * * Copyright © 2014-2022 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()); }); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import Logger from '@tuzki/scaffold-logger'; import { COMMAND } from '@tuzki/scaffold-types'; import chalk from 'chalk'; import path from 'path'; import commandService from '../create-service.js'; import getBuiltInPlugins from '../plugins.js'; import { checkLogin, getRootDir } from '../utils/common.js'; const logger = Logger.get('cli:commands:update'); export const update = (commandArgs) => __awaiter(void 0, void 0, void 0, function* () { const { rootDir } = commandArgs, resetArgs = __rest(commandArgs, ["rootDir"]); const { cicd } = resetArgs; // 检查登录 !cicd && checkLogin(); const dirPath = path.join(rootDir || process.cwd()); const rootPath = getRootDir(dirPath); logger.log(`Preparing to update the project at ${chalk.cyan.underline(rootPath)}`); logger.logEmptyLine(); try { yield commandService({ rootDir }).run({ command: COMMAND.UPDATE_PROJECT, rootDir: rootPath, commandArgs: Object.assign({}, resetArgs), getBuiltInPlugins, }); } catch (err) { logger.error('更新模块代码失败:', err); process.exit(1); } });