UNPKG

kdesign-ui

Version:

kd is from company of klx, it provide quickly genarator company inner business front structure

47 lines (46 loc) 1.9 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var commander_1 = tslib_1.__importDefault(require("commander")); var chalk_1 = tslib_1.__importDefault(require("chalk")); var log_1 = require("../utils/log"); var version = require('../../package.json').engines.node; var checkVersion = require('../utils').checkVersion; var interfaceLog = new log_1.InterfaceLog('file', 'error', false); // 检查版本 checkVersion(version); // 注册命令 commander_1.default .version(require('../../package.json').version) .usage('<command> [options]'); commander_1.default .command('init <page-type>') .description('创建新项目结构,可以选择前台consumer或者后台admin') .option('-t, --type <pagetype>', '结构类型参数') .action(function (name, cmd) { if (name === 'consumer') { console.log(chalk_1.default.red('开发中,敬请期待...')); return; } var options = cmd; require('../lib/init')(name, options); }); commander_1.default .command('interface') .description('根据模块编码生成前端接口调用结构') .option('-c, --code <code>', '模块编码') .option('-dp, --dataPath <path>', '下载地址') .option('-p, --proxy <url>', '代理获取数据地址') .action(function (action, options) { var code = action.code, dataPath = action.dataPath, proxy = action.proxy; if (!code || !dataPath || !proxy) { interfaceLog.error('code、dataPath、proxy为必传项'); return; } proxy = proxy.replace(/%26/, '&'); Promise.resolve().then(function () { return tslib_1.__importStar(require('../lib/interface')); }).then(function (res) { res['default'](code, proxy, dataPath); }); }); commander_1.default.parse(process.argv);