UNPKG

@szzbmy/lowcode-cli

Version:

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

58 lines (57 loc) 1.89 kB
#!/usr/bin/env node "use strict"; /* * lowcode-cli 主程序入口 * @Author: Jiyu Shao * @Date: 2021-08-12 10:25:07 * @Last Modified by: chubiao Ni * @Last Modified time: 2022-02-14 16:54:18 */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const meow_1 = __importDefault(require("meow")); const update_checker_1 = require("./utils/update-checker"); const commands_1 = __importDefault(require("./commands")); const help_message_1 = require("./constants/help-message"); const config_1 = require("./config"); const logger_1 = require("./utils/logger"); // 执行初始化命令行逻辑 const init = async () => { // 配置CLI参数和标志解析规则 const cli = (0, meow_1.default)({ help: help_message_1.GLOBAL_HELP_MESSAGE, autoHelp: false, autoVersion: false, allowUnknownFlags: false, flags: { // 全局配置 version: { type: 'boolean', alias: 'v' }, help: { type: 'boolean', alias: 'h' }, env: { type: 'string' }, logLevel: { type: 'string' }, // 调试模式下的选项 pure: { type: 'boolean' }, }, }); // 获取用户传的参数, 并进行处理 const { input } = cli; const { flags } = cli; // 设置日志级别 (0, logger_1.injectLogLevel)(flags.logLevel); // 注入当前环境变量 await (0, config_1.injectConfigEnv)(flags.env); if (flags.version) { await (0, update_checker_1.checkUpdate)(); cli.showVersion(); return; } if (flags.help || input.length === 0) { await (0, update_checker_1.checkUpdate)(); cli.showHelp(); return; } (0, commands_1.default)(cli); }; init();