@gmcb/cli 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export default function (...args: any[]): Promise<void>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const utils_1 = require("../utils");
5
+ async function default_1(...args) {
6
+ const opts = args[0];
7
+ let commands = ['cross-env NODE_ENV=development'];
8
+ const bin = (0, utils_1.getBinPath)(opts.compiler);
9
+ if (opts.compiler === 'uni') {
10
+ commands = [...commands, bin, 'dev', '-p', opts.platform];
11
+ }
12
+ else {
13
+ commands = [...commands, bin, 'dev'];
14
+ }
15
+ const command = commands.join(' ');
16
+ (0, utils_1.spawnSync)(command);
17
+ }
@@ -0,0 +1 @@
1
+ export default function (...args: any[]): Promise<void>;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = default_1;
7
+ const fs_1 = require("fs");
8
+ const path_1 = require("path");
9
+ const inquirer_1 = __importDefault(require("inquirer"));
10
+ const utils_1 = require("../utils");
11
+ const build_1 = __importDefault(require("./build"));
12
+ async function default_1(...args) {
13
+ const { start } = await inquirer_1.default.prompt({
14
+ type: 'confirm',
15
+ message: '您当前正在执行发布操作,是否继续?',
16
+ name: 'start',
17
+ default: true,
18
+ });
19
+ if (!start) {
20
+ process.exit(1);
21
+ }
22
+ const { update } = await inquirer_1.default.prompt({
23
+ type: 'confirm',
24
+ message: '是否已更新版本号?',
25
+ name: 'update',
26
+ default: true,
27
+ });
28
+ if (!update) {
29
+ process.exit(1);
30
+ }
31
+ const prompt = await inquirer_1.default.prompt([
32
+ {
33
+ type: 'confirm',
34
+ message: '是否需要安装依赖?',
35
+ name: 'install',
36
+ default: true,
37
+ },
38
+ {
39
+ type: 'confirm',
40
+ message: '是否确定执行发布?',
41
+ name: 'publish',
42
+ default: true,
43
+ },
44
+ ]);
45
+ if (!prompt.publish) {
46
+ process.exit(1);
47
+ }
48
+ if (prompt.install) {
49
+ (0, utils_1.spawnSync)('npm install');
50
+ }
51
+ if (!(0, fs_1.existsSync)((0, path_1.join)(utils_1.COMMAND_PATH, 'node_modules/@gmcb/publish'))) {
52
+ utils_1.log.error('缺少必要的依赖,请执行“npm i @gmcb/publish -D”安装依赖!');
53
+ }
54
+ const cmds = await (0, build_1.default)(...args);
55
+ const commands = cmds.slice(0, 3);
56
+ if (!commands[2].startsWith('BUILD_ENV')) {
57
+ commands[2] = 'BUILD_ENV=';
58
+ }
59
+ if (!['dev', 'sit', 'uat', 'pre', 'prod'].includes(commands[2].split('=')[1])) {
60
+ utils_1.log.error('没有检测到需要发布的环境,无法完成上传,请切换到dev/sit/uat/pre/master分支再次执行脚本,或者您可以选择手动上传!');
61
+ }
62
+ commands.push('node');
63
+ const opts = args[0];
64
+ const scriptPath = (0, path_1.join)(utils_1.COMMAND_PATH, 'node_modules/@gmcb/publish/lib');
65
+ if (opts.platform?.startsWith('mp')) {
66
+ commands.push((0, path_1.join)(scriptPath, opts.platform));
67
+ }
68
+ else if (opts.platform?.startsWith('app')) {
69
+ if (opts.wgt) {
70
+ commands.push((0, path_1.join)(scriptPath, 'app-wgt'));
71
+ }
72
+ else if (opts.zip) {
73
+ commands.push((0, path_1.join)(scriptPath, 'app-zip'));
74
+ }
75
+ }
76
+ if (commands[commands.length - 1] !== 'node') {
77
+ (0, utils_1.spawnSync)(commands.join(' '));
78
+ }
79
+ }
package/lib/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/lib/bin.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commander_1 = __importDefault(require("commander"));
8
+ const package_json_1 = __importDefault(require("../package.json"));
9
+ const create_1 = __importDefault(require("./actions/create"));
10
+ const dev_1 = __importDefault(require("./actions/dev"));
11
+ const build_1 = __importDefault(require("./actions/build"));
12
+ const publish_1 = __importDefault(require("./actions/publish"));
13
+ const config_1 = __importDefault(require("./actions/config"));
14
+ const copy_1 = __importDefault(require("./actions/copy"));
15
+ const commands_1 = require("./commands");
16
+ const utils_1 = require("./utils");
17
+ const program = new commander_1.default.Command();
18
+ program
19
+ .name(utils_1.BIN_NAME)
20
+ .version(package_json_1.default.version, ...commands_1.version)
21
+ .usage('<command> [options]');
22
+ program
23
+ .command('create <project-name>')
24
+ .description('创建项目框架')
25
+ .option(...commands_1.template)
26
+ .action(create_1.default);
27
+ program
28
+ .command('dev')
29
+ .description('应用程序开发')
30
+ .option(...commands_1.platform)
31
+ .option(...commands_1.compiler)
32
+ .action(dev_1.default);
33
+ program
34
+ .command('build')
35
+ .description('应用程序构建')
36
+ .option(...commands_1.platform)
37
+ .option(...commands_1.compiler)
38
+ .option(...commands_1.branch)
39
+ .option(...commands_1.source)
40
+ .option(...commands_1.custom)
41
+ .option(...commands_1.wgt)
42
+ .option(...commands_1.res)
43
+ .option(...commands_1.env)
44
+ .option(...commands_1.project)
45
+ .option(...commands_1.zip)
46
+ .option(...commands_1.win)
47
+ .option(...commands_1.mac)
48
+ .option(...commands_1.linux)
49
+ .action(build_1.default);
50
+ program
51
+ .command('copy')
52
+ .description('复制资源到指定目录中')
53
+ .option(...commands_1.ignore)
54
+ .option(...commands_1.source)
55
+ .option(...commands_1.dest)
56
+ .option(...commands_1.clean)
57
+ .option(...commands_1.link)
58
+ .action(copy_1.default);
59
+ program
60
+ .command('publish')
61
+ .description('应用程序发布')
62
+ .option(...commands_1.platform)
63
+ .option(...commands_1.compiler)
64
+ .option(...commands_1.branch)
65
+ .option(...commands_1.source)
66
+ .option(...commands_1.wgt)
67
+ .option(...commands_1.res)
68
+ .option(...commands_1.env)
69
+ .option(...commands_1.project)
70
+ .option(...commands_1.zip)
71
+ .option(...commands_1.win)
72
+ .option(...commands_1.mac)
73
+ .option(...commands_1.linux)
74
+ .action(publish_1.default);
75
+ program
76
+ .command('config [name]')
77
+ .description('环境变量配置')
78
+ .option(...commands_1.hbuilderxCli)
79
+ .option(...commands_1.weixinCli)
80
+ .option(...commands_1.alipayCli)
81
+ .option(...commands_1.branch)
82
+ .action(config_1.default);
83
+ program.parse();
@@ -0,0 +1,2 @@
1
+ export * from './option';
2
+ export * from './platform';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./option"), exports);
18
+ __exportStar(require("./platform"), exports);
@@ -0,0 +1,47 @@
1
+ import { PLATFORM_OPTIONS, COMPILER_OPTIONS } from '../utils';
2
+ export declare const version: readonly ["-v, --version", "输出版本号"];
3
+ export declare const template: readonly ["-t, --template <template-name>", "模版仓库名称"];
4
+ export declare const platform: readonly ["-p, --platform <platform-name>", "编译平台,默认h5", "h5"];
5
+ export declare const project: readonly ["-P, --project <project-name>", "HbuilderX工作台中的项目名称"];
6
+ export declare const compiler: readonly ["-c, --compiler <compiler-name>", "构建工具,默认uni", "uni"];
7
+ export declare const env: readonly ["-e, --env <env-name>", "构建环境,可选如dev/sit/uat/prod等,默认prod", "prod"];
8
+ export declare const branch: readonly ["-b, --branch [branch-name]", "Git分支名称,仅在该分支下执行命令"];
9
+ export declare const source: readonly ["-s, --source <source-path>", "资源路径"];
10
+ export declare const dest: readonly ["-d, --dest <dest-path>", "目标路径"];
11
+ export declare const ignore: readonly ["--ignore [files]", "忽略需要复制的文件或者文件夹,英文逗号分隔"];
12
+ export declare const clean: readonly ["--clean", "复制文件前是否清除资源"];
13
+ export declare const name: readonly ["--name <name>", "应用资源名称"];
14
+ export declare const path: readonly ["--path <path>", "应用资源路径"];
15
+ export declare const link: readonly ["--link", "是否使用软链接"];
16
+ export declare const win: readonly ["--win", "是否构建Windows应用"];
17
+ export declare const mac: readonly ["--mac", "是否构建MacOS应用"];
18
+ export declare const linux: readonly ["--linux", "是否构建Linux应用"];
19
+ export declare const zip: readonly ["--zip", "是否构建桌面应用热更新资源"];
20
+ export declare const custom: readonly ["--custom", "是否构建自定义基座"];
21
+ export declare const wgt: readonly ["--wgt", "是否构建移动应用热更新资源"];
22
+ export declare const res: readonly ["--res", "是否构建移动应用本地资源"];
23
+ export declare const hbuilderxCli: readonly ["--cli.hbuilderx <cli-path>", "HbuilderX Cli路径"];
24
+ export declare const weixinCli: readonly ["--cli.weixin <cli-path>", "微信开发者工具 Cli路径"];
25
+ export declare const alipayCli: readonly ["--cli.alipay <cli-path>", "支付宝开发者工具 Cli路径"];
26
+ export interface Options {
27
+ template?: string;
28
+ branch?: string | boolean;
29
+ platform?: (typeof PLATFORM_OPTIONS)[number];
30
+ compiler?: (typeof COMPILER_OPTIONS)[number];
31
+ project?: string;
32
+ env?: string;
33
+ wgt?: boolean;
34
+ custom?: boolean;
35
+ res?: boolean;
36
+ ignore?: string;
37
+ clean: boolean;
38
+ source?: string;
39
+ dest?: string;
40
+ name?: string;
41
+ path?: string;
42
+ link?: boolean;
43
+ zip: boolean;
44
+ win: boolean;
45
+ mac: boolean;
46
+ linux: boolean;
47
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alipayCli = exports.weixinCli = exports.hbuilderxCli = exports.res = exports.wgt = exports.custom = exports.zip = exports.linux = exports.mac = exports.win = exports.link = exports.path = exports.name = exports.clean = exports.ignore = exports.dest = exports.source = exports.branch = exports.env = exports.compiler = exports.project = exports.platform = exports.template = exports.version = void 0;
4
+ exports.version = ['-v, --version', '输出版本号'];
5
+ exports.template = ['-t, --template <template-name>', '模版仓库名称'];
6
+ exports.platform = ['-p, --platform <platform-name>', '编译平台,默认h5', 'h5'];
7
+ exports.project = ['-P, --project <project-name>', 'HbuilderX工作台中的项目名称'];
8
+ exports.compiler = ['-c, --compiler <compiler-name>', '构建工具,默认uni', 'uni'];
9
+ exports.env = ['-e, --env <env-name>', '构建环境,可选如dev/sit/uat/prod等,默认prod', 'prod'];
10
+ exports.branch = ['-b, --branch [branch-name]', 'Git分支名称,仅在该分支下执行命令'];
11
+ exports.source = ['-s, --source <source-path>', '资源路径'];
12
+ exports.dest = ['-d, --dest <dest-path>', '目标路径'];
13
+ exports.ignore = ['--ignore [files]', '忽略需要复制的文件或者文件夹,英文逗号分隔'];
14
+ exports.clean = ['--clean', '复制文件前是否清除资源'];
15
+ exports.name = ['--name <name>', '应用资源名称'];
16
+ exports.path = ['--path <path>', '应用资源路径'];
17
+ exports.link = ['--link', '是否使用软链接'];
18
+ exports.win = ['--win', '是否构建Windows应用'];
19
+ exports.mac = ['--mac', '是否构建MacOS应用'];
20
+ exports.linux = ['--linux', '是否构建Linux应用'];
21
+ exports.zip = ['--zip', '是否构建桌面应用热更新资源'];
22
+ exports.custom = ['--custom', '是否构建自定义基座'];
23
+ exports.wgt = ['--wgt', '是否构建移动应用热更新资源'];
24
+ exports.res = ['--res', '是否构建移动应用本地资源'];
25
+ exports.hbuilderxCli = ['--cli.hbuilderx <cli-path>', 'HbuilderX Cli路径'];
26
+ exports.weixinCli = ['--cli.weixin <cli-path>', '微信开发者工具 Cli路径'];
27
+ exports.alipayCli = ['--cli.alipay <cli-path>', '支付宝开发者工具 Cli路径'];
@@ -0,0 +1,13 @@
1
+ import type { Options } from './option';
2
+ export declare const app: (opts: Options) => {
3
+ common: any[];
4
+ android: any[];
5
+ ios: any[];
6
+ wgt: any[];
7
+ };
8
+ export declare const mp: () => {
9
+ common: any[];
10
+ weixin: any[];
11
+ alipay: any[];
12
+ };
13
+ export declare const h5: () => any[];
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.h5 = exports.mp = exports.app = void 0;
4
+ const path_1 = require("path");
5
+ const utils_1 = require("../utils");
6
+ const config_1 = require("../actions/config");
7
+ const config = (0, config_1.getLocalConfig)();
8
+ const app = (opts) => {
9
+ const { android: _android, ios: _ios, wgt: _wgt, custom, ...rest } = config?.app ?? {};
10
+ if (opts.custom) {
11
+ rest['iscustom'] = true;
12
+ }
13
+ const commonCommand = (0, utils_1.objectToCommand)(rest);
14
+ const androidCommand = (0, utils_1.objectToCommand)({
15
+ android: Object.assign({}, _android, rest['iscustom'] ? custom?.android : {}),
16
+ });
17
+ const iosCommand = (0, utils_1.objectToCommand)({
18
+ ios: Object.assign({}, _ios, rest['iscustom'] ? custom?.ios : {}),
19
+ });
20
+ const wgtCommand = (0, utils_1.objectToCommand)(_wgt);
21
+ if (androidCommand['--android.certfile']) {
22
+ androidCommand['--android.certfile'] = (0, path_1.resolve)(androidCommand['--android.certfile']);
23
+ }
24
+ if (iosCommand['--ios.profile']) {
25
+ iosCommand['--ios.profile'] = (0, path_1.resolve)(iosCommand['--ios.profile']);
26
+ }
27
+ if (iosCommand['--ios.certfile']) {
28
+ iosCommand['--ios.certfile'] = (0, path_1.resolve)(iosCommand['--ios.certfile']);
29
+ }
30
+ if (wgtCommand['--path']) {
31
+ wgtCommand['--path'] = (0, path_1.resolve)(wgtCommand['--path']);
32
+ }
33
+ const common = (0, utils_1.filterToArray)(commonCommand);
34
+ const android = (0, utils_1.filterToArray)(androidCommand);
35
+ const ios = (0, utils_1.filterToArray)(iosCommand);
36
+ const wgt = (0, utils_1.filterToArray)(wgtCommand);
37
+ return {
38
+ common,
39
+ android,
40
+ ios,
41
+ wgt,
42
+ };
43
+ };
44
+ exports.app = app;
45
+ const mp = () => {
46
+ const { weixin: _weixin, alipay: _alipay, ...rest } = config?.mp ?? {};
47
+ const commonCommand = (0, utils_1.objectToCommand)(rest);
48
+ const weixinCommand = (0, utils_1.objectToCommand)(_weixin);
49
+ const alipayCommand = (0, utils_1.objectToCommand)(_alipay);
50
+ if (weixinCommand['--privatekey']) {
51
+ weixinCommand['--privatekey'] = (0, path_1.resolve)(weixinCommand['--privatekey']);
52
+ }
53
+ if (alipayCommand['--privatekey']) {
54
+ alipayCommand['--privatekey'] = (0, path_1.resolve)(alipayCommand['--privatekey']);
55
+ }
56
+ const common = (0, utils_1.filterToArray)(commonCommand);
57
+ const weixin = (0, utils_1.filterToArray)(weixinCommand);
58
+ const alipay = (0, utils_1.filterToArray)(alipayCommand);
59
+ return {
60
+ common,
61
+ weixin,
62
+ alipay,
63
+ };
64
+ };
65
+ exports.mp = mp;
66
+ const h5 = () => {
67
+ const command = (0, utils_1.objectToCommand)(config?.h5);
68
+ return (0, utils_1.filterToArray)(command);
69
+ };
70
+ exports.h5 = h5;
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { getLocalConfig } from './actions/config';
package/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLocalConfig = void 0;
4
+ var config_1 = require("./actions/config");
5
+ Object.defineProperty(exports, "getLocalConfig", { enumerable: true, get: function () { return config_1.getLocalConfig; } });
@@ -0,0 +1,17 @@
1
+ import HOME_PATH from 'user-home';
2
+ export declare const BIN_NAME: string;
3
+ export declare const PLATFORM: NodeJS.Platform;
4
+ export declare const IS_MAC: boolean;
5
+ export declare const IS_WIN: boolean;
6
+ export declare const CONFIG_PATH: string;
7
+ export declare const COMMAND_PATH: string;
8
+ export declare const PACKAGE_PATH: string;
9
+ export declare const LOCAL_CONFIG_PATH: string;
10
+ export declare const BUILD_ENV_PATH: string;
11
+ export declare const HAS_SRC: boolean;
12
+ export declare const SRC_PATH: string;
13
+ export declare const DIST_PATH: string;
14
+ export declare const MAINFEST_PATH: string;
15
+ export { HOME_PATH };
16
+ export declare const PLATFORM_OPTIONS: readonly ["h5", "mp-alipay", "mp-baidu", "mp-jd", "mp-kuaishou", "mp-qq", "mp-toutiao", "mp-weixin", "app", "app-ios", "app-android", "app-harmony", "windows", "macos", "linux"];
17
+ export declare const COMPILER_OPTIONS: readonly ["vite", "uni", "electron-vite"];
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.COMPILER_OPTIONS = exports.PLATFORM_OPTIONS = exports.HOME_PATH = exports.MAINFEST_PATH = exports.DIST_PATH = exports.SRC_PATH = exports.HAS_SRC = exports.BUILD_ENV_PATH = exports.LOCAL_CONFIG_PATH = exports.PACKAGE_PATH = exports.COMMAND_PATH = exports.CONFIG_PATH = exports.IS_WIN = exports.IS_MAC = exports.PLATFORM = exports.BIN_NAME = void 0;
7
+ const path_1 = require("path");
8
+ const os_1 = __importDefault(require("os"));
9
+ const fs_1 = require("fs");
10
+ const user_home_1 = __importDefault(require("user-home"));
11
+ exports.HOME_PATH = user_home_1.default;
12
+ const package_json_1 = require("../../package.json");
13
+ exports.BIN_NAME = Object.keys(package_json_1.bin)[0];
14
+ exports.PLATFORM = os_1.default.platform();
15
+ exports.IS_MAC = exports.PLATFORM === 'darwin';
16
+ exports.IS_WIN = exports.PLATFORM === 'win32';
17
+ exports.CONFIG_PATH = (0, path_1.join)(user_home_1.default, 'uni.build.json');
18
+ exports.COMMAND_PATH = process.cwd();
19
+ exports.PACKAGE_PATH = (0, path_1.join)(exports.COMMAND_PATH, 'package.json');
20
+ exports.LOCAL_CONFIG_PATH = (0, path_1.join)(exports.COMMAND_PATH, 'uni.build.json');
21
+ exports.BUILD_ENV_PATH = (0, path_1.join)(exports.COMMAND_PATH, 'buildenv');
22
+ exports.HAS_SRC = (0, fs_1.existsSync)((0, path_1.join)(exports.COMMAND_PATH, 'src'));
23
+ exports.SRC_PATH = (0, path_1.join)(exports.COMMAND_PATH, exports.HAS_SRC ? 'src' : '');
24
+ exports.DIST_PATH = (0, path_1.join)(exports.COMMAND_PATH, exports.HAS_SRC ? 'unpackage' : '', 'dist');
25
+ exports.MAINFEST_PATH = (0, path_1.join)(exports.SRC_PATH, 'manifest.json');
26
+ exports.PLATFORM_OPTIONS = [
27
+ 'h5',
28
+ 'mp-alipay',
29
+ 'mp-baidu',
30
+ 'mp-jd',
31
+ 'mp-kuaishou',
32
+ 'mp-qq',
33
+ 'mp-toutiao',
34
+ 'mp-weixin',
35
+ 'app',
36
+ 'app-ios',
37
+ 'app-android',
38
+ 'app-harmony',
39
+ 'windows',
40
+ 'macos',
41
+ 'linux',
42
+ ];
43
+ exports.COMPILER_OPTIONS = ['vite', 'uni', 'electron-vite'];
@@ -0,0 +1,4 @@
1
+ export declare function objectToCommand(obj?: Record<string, any>): {};
2
+ export declare function filterToArray(obj?: Record<string, any>): any[];
3
+ export declare function spawnSync(command?: string): import("child_process").SpawnSyncReturns<Buffer>;
4
+ export declare function getBinPath(name: string): string;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.objectToCommand = objectToCommand;
7
+ exports.filterToArray = filterToArray;
8
+ exports.spawnSync = spawnSync;
9
+ exports.getBinPath = getBinPath;
10
+ const fs_1 = require("fs");
11
+ const path_1 = require("path");
12
+ const cross_spawn_1 = __importDefault(require("cross-spawn"));
13
+ const flat_1 = require("flat");
14
+ const const_1 = require("./const");
15
+ function objectToCommand(obj = {}) {
16
+ const object = (0, flat_1.flatten)(obj);
17
+ const res = {};
18
+ Object.keys(object).forEach((key) => {
19
+ res[`--${key}`] = typeof object[key] === 'object' ? JSON.stringify(object[key]) : object[key];
20
+ });
21
+ return res;
22
+ }
23
+ function filterToArray(obj = {}) {
24
+ const array = [];
25
+ Object.keys(obj).forEach((key) => {
26
+ const value = obj[key];
27
+ if (value != null && value !== false && value !== 'false') {
28
+ array.push(`${key} ${value}`);
29
+ }
30
+ });
31
+ return array;
32
+ }
33
+ function spawnSync(command = '') {
34
+ console.log(command);
35
+ return cross_spawn_1.default.sync(command, { stdio: 'inherit', shell: true });
36
+ }
37
+ function getBinPath(name) {
38
+ const path = (0, path_1.join)(const_1.COMMAND_PATH, 'node_modules/.bin', name);
39
+ if ((0, fs_1.existsSync)(path)) {
40
+ return path;
41
+ }
42
+ return name;
43
+ }
@@ -0,0 +1,3 @@
1
+ export * from './const';
2
+ export * from './function';
3
+ export * as log from './log';
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.log = void 0;
30
+ __exportStar(require("./const"), exports);
31
+ __exportStar(require("./function"), exports);
32
+ exports.log = __importStar(require("./log"));
@@ -0,0 +1,3 @@
1
+ export declare function warning(msg: string): void;
2
+ export declare function error(msg: string): void;
3
+ export declare function success(msg: string): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.warning = warning;
7
+ exports.error = error;
8
+ exports.success = success;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ function warning(msg) {
11
+ if (msg) {
12
+ console.log(chalk_1.default.yellowBright(`Warning:${msg}`));
13
+ }
14
+ }
15
+ function error(msg) {
16
+ if (msg) {
17
+ console.log(chalk_1.default.redBright(`Error:${msg}`));
18
+ process.exit(1);
19
+ }
20
+ }
21
+ function success(msg) {
22
+ if (msg) {
23
+ console.log(chalk_1.default.greenBright(`Success:${msg}`));
24
+ }
25
+ }
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@gmcb/cli",
3
+ "version": "0.1.8",
4
+ "description": "工茂草本前端命令行工具",
5
+ "author": "yinjiazeng@163.com",
6
+ "license": "MIT",
7
+ "main": "lib/index.js",
8
+ "bin": {
9
+ "gmcb": "lib/bin.js"
10
+ },
11
+ "homepage": "https://git.keeprisk.cn/gmcb/front-end/tree/master/packages/cli",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "scripts": {
16
+ "tsc": "vue-tsc",
17
+ "tsc:dev": "vue-tsc --watch"
18
+ },
19
+ "keywords": [
20
+ "gmcb",
21
+ "cli"
22
+ ],
23
+ "files": [
24
+ "lib",
25
+ "schema.json",
26
+ "CHANGELOG.md",
27
+ "README.md"
28
+ ],
29
+ "dependencies": {
30
+ "adm-zip": "^0.5.16",
31
+ "chalk": "^4.1.2",
32
+ "commander": "^12.1.0",
33
+ "cross-env": "^7.0.3",
34
+ "cross-spawn": "^7.0.6",
35
+ "delay": "^5.0.0",
36
+ "download": "^8.0.0",
37
+ "flat": "^5.0.2",
38
+ "fs-extra": "^10.1.0",
39
+ "inquirer": "^8.2.6",
40
+ "lodash": "^4.17.21",
41
+ "ora": "^5.4.1",
42
+ "rimraf": "^3.0.2",
43
+ "simple-git": "^3.27.0",
44
+ "strip-json-comments": "^3.1.1",
45
+ "user-home": "^3.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/adm-zip": "^0.5.7",
49
+ "@types/cross-spawn": "^6.0.6",
50
+ "@types/download": "^8.0.5",
51
+ "@types/flat": "^5.0.5",
52
+ "@types/fs-extra": "^11.0.4",
53
+ "@types/inquirer": "^9.0.7",
54
+ "@types/rimraf": "^4.0.5",
55
+ "@types/user-home": "^2.0.2"
56
+ }
57
+ }