@itera-web/cli 1.1.54

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.
Files changed (61) hide show
  1. package/README.md +56 -0
  2. package/bin/index.js +18 -0
  3. package/dist/commands/app/app-obs.d.ts +14 -0
  4. package/dist/commands/app/app-obs.js +243 -0
  5. package/dist/commands/app/up.d.ts +11 -0
  6. package/dist/commands/app/up.js +103 -0
  7. package/dist/commands/web/buildapp.d.ts +10 -0
  8. package/dist/commands/web/buildapp.js +106 -0
  9. package/dist/commands/web/git.d.ts +3 -0
  10. package/dist/commands/web/git.js +57 -0
  11. package/dist/commands/web/init.d.ts +4 -0
  12. package/dist/commands/web/init.js +129 -0
  13. package/dist/commands/web/packageapp.d.ts +5 -0
  14. package/dist/commands/web/packageapp.js +98 -0
  15. package/dist/commands/web/publish.d.ts +10 -0
  16. package/dist/commands/web/publish.js +104 -0
  17. package/dist/commands/web/pullprojects.d.ts +5 -0
  18. package/dist/commands/web/pullprojects.js +108 -0
  19. package/dist/commands/web/startapp.d.ts +5 -0
  20. package/dist/commands/web/startapp.js +98 -0
  21. package/dist/commands/web/updateprojects.d.ts +17 -0
  22. package/dist/commands/web/updateprojects.js +220 -0
  23. package/dist/config/util.d.ts +14 -0
  24. package/dist/config/util.js +88 -0
  25. package/dist/config/webpack.buildpackage.d.ts +1 -0
  26. package/dist/config/webpack.buildpackage.js +63 -0
  27. package/dist/config/webpack.common.d.ts +1 -0
  28. package/dist/config/webpack.common.js +178 -0
  29. package/dist/config/webpack.dev.d.ts +1 -0
  30. package/dist/config/webpack.dev.js +27 -0
  31. package/dist/config/webpack.pro.d.ts +1 -0
  32. package/dist/config/webpack.pro.js +43 -0
  33. package/dist/plugins/app.exe +0 -0
  34. package/dist/plugins/sortSrciptTag.d.ts +1 -0
  35. package/dist/plugins/sortSrciptTag.js +75 -0
  36. package/dist/plugins/webSocketServer.d.ts +4 -0
  37. package/dist/plugins/webSocketServer.js +53 -0
  38. package/dist/public/git.d.ts +1 -0
  39. package/dist/public/git.js +375 -0
  40. package/dist/public/hook.d.ts +18 -0
  41. package/dist/public/hook.js +93 -0
  42. package/dist/public/log.d.ts +8 -0
  43. package/dist/public/log.js +58 -0
  44. package/dist/public/public.d.ts +19 -0
  45. package/dist/public/public.js +425 -0
  46. package/dist/public/sign.d.ts +2 -0
  47. package/dist/public/sign.js +148 -0
  48. package/dist/public/smartMerge.d.ts +3 -0
  49. package/dist/public/smartMerge.js +31 -0
  50. package/dist/public/update-version.d.ts +2 -0
  51. package/dist/public/update-version.js +130 -0
  52. package/dist/public/upload-obs.d.ts +1 -0
  53. package/dist/public/upload-obs.js +242 -0
  54. package/dist/public/upload-web.d.ts +1 -0
  55. package/dist/public/upload-web.js +154 -0
  56. package/dist/store/index.d.ts +2 -0
  57. package/dist/store/index.js +65 -0
  58. package/dist/store/types.d.ts +53 -0
  59. package/dist/store/types.js +2 -0
  60. package/package.json +110 -0
  61. package/tsconfig.json +30 -0
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ `qgtools` 自定义CLI 用于构建 WEB (React) 和 Electron 应用
2
+
3
+ 支持构建`React TS公共组件`、`项目的本地调试`、`打包发布`
4
+
5
+ - 1.1.54 => `itera-cli update-projects` 多任务并发部署可视化选择 UI可拖拽
6
+ - 1.1.42 => 排序插件优化 main.js 和 react.js
7
+ - 1.1.40 => `itera-cli build --split` 设置打包分析端口号
8
+ - 1.1.38 => `itera-cli update-projects` 添加是否并行执行命令
9
+ - 1.1.36 => `itera-cli git` 取消 `itera-cli publish` 的 git 操作 新增单独命令 `itera-cli git`
10
+ - 1.1.34 => `itera-cli pull-projects` 批量拉取项目 (使用和 `[update-projects]` 同一个配置文件,只获取项目路径)
11
+ - 1.1.31 => `itera-cli update-projects` 批量更新项目依赖 (配置文件内定义多个项目和对应的需要执行的执行命令)
12
+ - 1.1.26 => `itera-cli publish` 完善 git 拉取流程、冲突检测 和 检测文件改动
13
+ - 1.1.22 => `itera-cli publish` 添加 --del 参数
14
+
15
+
16
+ - 1.1.21 => scss 内 `url()` 引入 public 图片兼容: `url('#{$img-prefix}/bg.png')`
17
+ - 1.1.16 => 多个 Appid 打包问题修复
18
+ - 1.1.8 => 添加 `Electron` 开始打包、打包结束 Hooks
19
+ - 1.1.7 => 添加 script 标签 倒序自定义插件
20
+ - 1.1.5 => 添加 `git` 上传类型
21
+ - 1.1.4 => 强化整体功能
22
+
23
+ 基于 `yargs` 扩展命令行 `itera-cli -h` 实现Web调试构建发布,Electron 开发全流程自动化,多项目自动化部署。
24
+
25
+
26
+ 包含:
27
+ (1) CSSModule
28
+
29
+ (2) SCSS
30
+
31
+ (3) SVG雪碧图loader
32
+
33
+ (4) 静态资源处理
34
+
35
+ (5) 其他资源处理
36
+
37
+ (6) @别名
38
+
39
+ (7) PostCSS (tailwindcss)
40
+
41
+ (8) Babel (JS、TS)
42
+
43
+ (9) CSS压缩,JS压缩,处理debugger、console、注释处理
44
+
45
+ (10) 分割包等等。
46
+
47
+ 目前雏形已经构建完毕
48
+
49
+ 1.开启本地调试 `itera-cli serve`
50
+
51
+ 2.构建项目包 `itera-cli build`
52
+
53
+ 3.构建TS公共组件库 `itera-cli package`
54
+
55
+
56
+ [使用参考文档](http://60.205.203.200:8084/)
package/bin/index.js ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path');
4
+ const yargs = require('yargs');
5
+
6
+ const { hideBin } = require('yargs/helpers');
7
+
8
+ yargs(hideBin(process.argv))
9
+ .scriptName('itera-cli')
10
+ .usage('$0 <command> [options]')
11
+ .commandDir(path.join(__dirname, '../dist/commands/web'))
12
+ .commandDir(path.join(__dirname, '../dist/commands/app'))
13
+ .help()
14
+ .alias('h', 'help')
15
+ .version()
16
+ .alias('v', 'version')
17
+ .demandCommand(1, '请至少输入一个命令')
18
+ .parse();
@@ -0,0 +1,14 @@
1
+ import { Arguments, CommandBuilder } from 'yargs';
2
+ export declare const command = "app-obs";
3
+ export declare const describe = "\u53D1\u5E03\u8F6F\u4EF6";
4
+ export interface AppObsArgs extends Arguments {
5
+ 'update-version': boolean;
6
+ backpack: boolean;
7
+ serve: boolean;
8
+ nobuild: boolean;
9
+ autoupload: boolean;
10
+ autoupdate: boolean;
11
+ sign: boolean;
12
+ }
13
+ export declare const builder: CommandBuilder<{}, AppObsArgs>;
14
+ export declare const handler: (argv: AppObsArgs) => Promise<void>;
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ var _a, _b, _c, _d, _e, _f;
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
53
+ var child_process_1 = require("child_process");
54
+ var fs_1 = __importDefault(require("fs"));
55
+ var fs_extra_1 = __importDefault(require("fs-extra"));
56
+ var path_1 = __importDefault(require("path"));
57
+ var store_1 = require("../../store");
58
+ var git_1 = require("../../public/git");
59
+ var hook_1 = require("../../public/hook");
60
+ var log_1 = require("../../public/log");
61
+ var public_1 = require("../../public/public");
62
+ var sign_1 = require("../../public/sign");
63
+ var update_version_1 = require("../../public/update-version");
64
+ (0, child_process_1.execSync)('chcp 65001');
65
+ var rootPath = (_a = store_1.mainData.runtimePath) !== null && _a !== void 0 ? _a : '';
66
+ var coreAppPath = (_b = store_1.mainData.updateConfig.configPath.coreAppPath) !== null && _b !== void 0 ? _b : '';
67
+ var coreProPath = (_c = store_1.mainData.updateConfig.configPath.coreProPath) !== null && _c !== void 0 ? _c : '';
68
+ var destPatchZipFile = (_d = store_1.mainData.updateConfig.configPath.destPatchZipFile) !== null && _d !== void 0 ? _d : '';
69
+ var destPatchFile = (_e = store_1.mainData.updateConfig.configPath.destPatchFile) !== null && _e !== void 0 ? _e : '';
70
+ var newDir = (_f = store_1.mainData.updateConfig.configPath.newDir) !== null && _f !== void 0 ? _f : '';
71
+ var env = Object.assign({}, process.env, {
72
+ PATH: rootPath + ';' + process.env.PATH,
73
+ npm_config_prefix: 'C:\\Program Files\\nodejs\\npm',
74
+ });
75
+ exports.command = 'app-obs';
76
+ exports.describe = '发布软件';
77
+ var builder = function (yargs) {
78
+ return yargs
79
+ .option('update-version', {
80
+ describe: '上传版本配置文件',
81
+ type: 'boolean',
82
+ default: false,
83
+ })
84
+ .option('backpack', {
85
+ describe: '直接打包',
86
+ type: 'boolean',
87
+ default: false,
88
+ })
89
+ .option('serve', {
90
+ describe: '本地调试',
91
+ type: 'boolean',
92
+ default: false,
93
+ })
94
+ .option('nobuild', {
95
+ describe: '跳过构建',
96
+ type: 'boolean',
97
+ default: false,
98
+ })
99
+ .option('autoupload', {
100
+ describe: '自动上传',
101
+ type: 'boolean',
102
+ default: false,
103
+ })
104
+ .option('autoupdate', {
105
+ describe: '自动更新',
106
+ type: 'boolean',
107
+ default: false,
108
+ })
109
+ .option('sign', {
110
+ describe: '是否签名',
111
+ type: 'boolean',
112
+ default: false,
113
+ });
114
+ };
115
+ exports.builder = builder;
116
+ var handler = function (argv) { return __awaiter(void 0, void 0, void 0, function () {
117
+ var updateConfig, _i, _a, item, beforeStart, _b, _c, item, packageCmd, batPath, buildPath, err_1;
118
+ var _d, _e, _f;
119
+ return __generator(this, function (_g) {
120
+ switch (_g.label) {
121
+ case 0: return [4, (0, public_1.loadUserConfig)(hook_1.hook)];
122
+ case 1:
123
+ _g.sent();
124
+ return [4, (0, public_1.onCheckIteraCliVersion)()];
125
+ case 2:
126
+ _g.sent();
127
+ updateConfig = store_1.mainData.updateConfig;
128
+ _g.label = 3;
129
+ case 3:
130
+ _g.trys.push([3, 22, , 23]);
131
+ (0, public_1.ensurePathsExist)(updateConfig.configPath);
132
+ if (!argv['update-version']) return [3, 5];
133
+ (0, public_1.onSetLatest)(true);
134
+ return [4, (0, update_version_1.onUpdateLatestOBS)(argv)];
135
+ case 4:
136
+ _g.sent();
137
+ return [2];
138
+ case 5:
139
+ if (!argv.backpack) return [3, 10];
140
+ _i = 0, _a = updateConfig.agentsInfo;
141
+ _g.label = 6;
142
+ case 6:
143
+ if (!(_i < _a.length)) return [3, 9];
144
+ item = _a[_i];
145
+ return [4, (0, public_1.onSeePackage)(item, false)];
146
+ case 7:
147
+ _g.sent();
148
+ _g.label = 8;
149
+ case 8:
150
+ _i++;
151
+ return [3, 6];
152
+ case 9: return [2];
153
+ case 10:
154
+ if (argv.serve) {
155
+ fs_extra_1.default.copySync(coreAppPath, coreProPath);
156
+ return [2];
157
+ }
158
+ return [4, hook_1.hook.call('beforeStart', { cwd: process.cwd() })];
159
+ case 11:
160
+ beforeStart = (_g.sent()).beforeStart;
161
+ if (!beforeStart)
162
+ return [2];
163
+ (0, public_1.onSetLatest)(false);
164
+ (0, public_1.fsUnLinkSync)(__spreadArray([
165
+ coreProPath,
166
+ newDir,
167
+ destPatchZipFile,
168
+ destPatchFile,
169
+ updateConfig.configPath.buildPath
170
+ ], Object.values(updateConfig.deletePath || {}), true));
171
+ if (!(0, public_1.zipMainJS)(coreAppPath)) {
172
+ log_1.Console.error('!!!压缩 main.js 主进程代码失败!');
173
+ return [2];
174
+ }
175
+ if (!(0, public_1.zipMainJS)(coreAppPath)) {
176
+ log_1.Console.error('!!!压缩 main.js 主进程代码失败!');
177
+ return [2];
178
+ }
179
+ log_1.Console.success('源码 压缩、混淆完毕');
180
+ if (!argv.nobuild) {
181
+ log_1.Console.cyan('正在执行 WEB 构建');
182
+ (0, child_process_1.execSync)('itera-cli build', { env: env });
183
+ }
184
+ if (fs_1.default.existsSync(newDir))
185
+ fs_extra_1.default.removeSync(newDir);
186
+ if (fs_1.default.existsSync(destPatchFile))
187
+ fs_extra_1.default.removeSync(destPatchFile);
188
+ fs_1.default.mkdirSync(newDir);
189
+ fs_1.default.mkdirSync(destPatchFile);
190
+ fs_1.default.mkdirSync("".concat(destPatchFile, "/resources"));
191
+ _b = 0, _c = updateConfig.agentsInfo;
192
+ _g.label = 12;
193
+ case 12:
194
+ if (!(_b < _c.length)) return [3, 18];
195
+ item = _c[_b];
196
+ fs_1.default.writeFileSync(path_1.default.join((_d = updateConfig.configPath.batPath) !== null && _d !== void 0 ? _d : '', 'agent'), String(item.agent_id), 'utf8');
197
+ packageCmd = updateConfig.commend['package'];
198
+ if (!packageCmd) {
199
+ throw new Error('打包命令未发现 [updateConfig.commend.package]');
200
+ }
201
+ log_1.Console.cyan("\u6B63\u5728\u6267\u884C ".concat(packageCmd, " \u6253\u5305"));
202
+ (0, child_process_1.execSync)(packageCmd, { env: env });
203
+ log_1.Console.cyan('复制更新文件到软件根目录');
204
+ batPath = (_e = updateConfig.configPath.batPath) !== null && _e !== void 0 ? _e : '';
205
+ buildPath = (_f = updateConfig.configPath.buildPath) !== null && _f !== void 0 ? _f : '';
206
+ fs_extra_1.default.copySync(batPath, path_1.default.join(buildPath, "".concat(item.path, "-win32-ia32")), {
207
+ overwrite: true,
208
+ errorOnExist: false,
209
+ });
210
+ if (!argv.sign) return [3, 14];
211
+ return [4, (0, sign_1.BatchSign)()];
212
+ case 13:
213
+ _g.sent();
214
+ return [3, 15];
215
+ case 14:
216
+ log_1.Console.warn('已跳过批量签名');
217
+ _g.label = 15;
218
+ case 15: return [4, (0, public_1.onSeePackage)(item, argv.sign)];
219
+ case 16:
220
+ _g.sent();
221
+ _g.label = 17;
222
+ case 17:
223
+ _b++;
224
+ return [3, 12];
225
+ case 18: return [4, (0, git_1.performGitOperations)()];
226
+ case 19:
227
+ _g.sent();
228
+ return [4, (0, public_1.onSetElectronDir)(argv)];
229
+ case 20:
230
+ _g.sent();
231
+ return [4, hook_1.hook.call('afterEnd', { cwd: process.cwd() })];
232
+ case 21:
233
+ _g.sent();
234
+ return [3, 23];
235
+ case 22:
236
+ err_1 = _g.sent();
237
+ log_1.Console.error(err_1);
238
+ return [3, 23];
239
+ case 23: return [2];
240
+ }
241
+ });
242
+ }); };
243
+ exports.handler = handler;
@@ -0,0 +1,11 @@
1
+ import { Arguments, CommandBuilder } from 'yargs';
2
+ interface UpObsArgs extends Arguments {
3
+ web: boolean;
4
+ upload: boolean;
5
+ autoupload: boolean;
6
+ }
7
+ export declare const command = "up-obs";
8
+ export declare const describe = "\u4E0A\u4F20\u8F6F\u4EF6\u76F8\u5173\u6587\u4EF6";
9
+ export declare const builder: CommandBuilder<{}, UpObsArgs>;
10
+ export declare const handler: (argv: UpObsArgs) => Promise<void>;
11
+ export {};
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
43
+ var path_1 = __importDefault(require("path"));
44
+ var store_1 = require("../../store");
45
+ var log_1 = require("../../public/log");
46
+ var public_1 = require("../../public/public");
47
+ var upload_obs_1 = require("../../public/upload-obs");
48
+ var upload_web_1 = require("../../public/upload-web");
49
+ var distPath = path_1.default.join(store_1.mainData.runtimePath, 'dist');
50
+ exports.command = 'up-obs';
51
+ exports.describe = '上传软件相关文件';
52
+ var builder = function (yargs) {
53
+ return yargs
54
+ .option('web', {
55
+ describe: '上传web文件至FTP服务器',
56
+ type: 'boolean',
57
+ default: false,
58
+ })
59
+ .option('upload', {
60
+ describe: '上传更新文件至OBS',
61
+ type: 'boolean',
62
+ default: false,
63
+ })
64
+ .option('autoupload', {
65
+ describe: '自动上传文件',
66
+ type: 'boolean',
67
+ default: false,
68
+ });
69
+ };
70
+ exports.builder = builder;
71
+ var handler = function (argv) { return __awaiter(void 0, void 0, void 0, function () {
72
+ var obs;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0: return [4, (0, public_1.onCheckIteraCliVersion)()];
76
+ case 1:
77
+ _a.sent();
78
+ if (!argv.web) return [3, 3];
79
+ (0, public_1.fsUnLinkSync)([distPath]);
80
+ return [4, (0, upload_web_1.uploadWeb)()];
81
+ case 2:
82
+ _a.sent();
83
+ return [2];
84
+ case 3:
85
+ if (!argv.upload) return [3, 5];
86
+ if (!store_1.mainData.updateConfig) {
87
+ log_1.Console.error('未发现 update_config 更新信息');
88
+ process.exit(1);
89
+ }
90
+ obs = store_1.mainData.updateConfig.obs;
91
+ if (!obs) {
92
+ log_1.Console.error('updateConfig => obs 信息未发现');
93
+ process.exit(1);
94
+ }
95
+ return [4, (0, upload_obs_1.upload)(argv, true)];
96
+ case 4:
97
+ _a.sent();
98
+ _a.label = 5;
99
+ case 5: return [2];
100
+ }
101
+ });
102
+ }); };
103
+ exports.handler = handler;
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { Arguments, CommandBuilder } from 'yargs';
3
+ interface BuildArgs extends Arguments {
4
+ split: boolean;
5
+ }
6
+ export declare const command = "build";
7
+ export declare const describe = "\u6784\u5EFA\u5E94\u7528";
8
+ export declare const builder: CommandBuilder<{}, BuildArgs>;
9
+ export declare const handler: (argv: BuildArgs) => Promise<void>;
10
+ export {};
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
25
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
30
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ var __importDefault = (this && this.__importDefault) || function (mod) {
51
+ return (mod && mod.__esModule) ? mod : { "default": mod };
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
55
+ var child_process_1 = require("child_process");
56
+ var path_1 = __importDefault(require("path"));
57
+ var util_1 = __importDefault(require("../../config/util"));
58
+ var log_1 = require("../../public/log");
59
+ var public_1 = require("../../public/public");
60
+ var runtimePath = process.cwd();
61
+ var codePath = __dirname;
62
+ function webpackTask(split) {
63
+ log_1.Console.cyan('开始构建项目');
64
+ return new Promise(function (resolve) {
65
+ var command = util_1.default.isWin32() ? 'npx.cmd' : 'npx';
66
+ var args = ['webpack', '--config', path_1.default.join(codePath, '../../config/webpack.pro.js')];
67
+ var babelProcess = (0, child_process_1.spawn)(command, args, {
68
+ cwd: runtimePath,
69
+ env: __assign(__assign({}, process.env), { NODE_ENV: 'production', REAP_PATH: 'pro', SPLIT: String(split) }),
70
+ shell: true,
71
+ });
72
+ babelProcess.stdout.on('data', function (data) {
73
+ log_1.Console.info(data.toString().trim());
74
+ });
75
+ babelProcess.stderr.on('data', function (data) {
76
+ log_1.Console.warn(data.toString().trim());
77
+ });
78
+ babelProcess.on('close', function () {
79
+ resolve();
80
+ });
81
+ });
82
+ }
83
+ exports.command = 'build';
84
+ exports.describe = '构建应用';
85
+ var builder = function (yargs) {
86
+ return yargs.option('split', {
87
+ describe: '是否开启打包分析 / 自定义打包参数',
88
+ type: 'boolean',
89
+ default: false,
90
+ });
91
+ };
92
+ exports.builder = builder;
93
+ var handler = function (argv) { return __awaiter(void 0, void 0, void 0, function () {
94
+ return __generator(this, function (_a) {
95
+ switch (_a.label) {
96
+ case 0: return [4, (0, public_1.onCheckIteraCliVersion)()];
97
+ case 1:
98
+ _a.sent();
99
+ return [4, webpackTask(argv.split)];
100
+ case 2:
101
+ _a.sent();
102
+ return [2];
103
+ }
104
+ });
105
+ }); };
106
+ exports.handler = handler;
@@ -0,0 +1,3 @@
1
+ export declare const command = "git";
2
+ export declare const describe = "\u4E0A\u4F20\u9879\u76EE\u5230 Git";
3
+ export declare const handler: () => Promise<void>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.handler = exports.describe = exports.command = void 0;
40
+ var git_1 = require("../../public/git");
41
+ var public_1 = require("../../public/public");
42
+ exports.command = 'git';
43
+ exports.describe = '上传项目到 Git';
44
+ var handler = function () { return __awaiter(void 0, void 0, void 0, function () {
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4, (0, public_1.onCheckIteraCliVersion)()];
48
+ case 1:
49
+ _a.sent();
50
+ return [4, (0, git_1.performGitOperations)()];
51
+ case 2:
52
+ _a.sent();
53
+ return [2];
54
+ }
55
+ });
56
+ }); };
57
+ exports.handler = handler;
@@ -0,0 +1,4 @@
1
+ export declare const command = "init";
2
+ export declare const describe = "\u521D\u59CB\u5316\u9879\u76EE\u6216\u7EC4\u4EF6";
3
+ export declare const builder: {};
4
+ export declare const handler: () => Promise<void>;