@cloudbase/cli 1.10.0 → 1.12.2-alpha.0
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.
- package/bin/tcb.js +1 -1
- package/lib/commands/common.js +9 -3
- package/lib/commands/lowcode/comps.js +115 -4
- package/lib/commands/storage/storage.js +20 -5
- package/lib/storage.js +5 -2
- package/package.json +11 -4
- package/tsconfig.json +1 -0
- package/types/commands/common.d.ts +1 -0
- package/types/commands/lowcode/comps.d.ts +26 -3
- package/types/commands/storage/storage.d.ts +1 -1
- package/types/storage.d.ts +3 -0
package/bin/tcb.js
CHANGED
package/lib/commands/common.js
CHANGED
|
@@ -111,9 +111,15 @@ class Command extends events_1.EventEmitter {
|
|
|
111
111
|
}
|
|
112
112
|
createProgram(instance, deprecate, newCmd) {
|
|
113
113
|
const { cmd, desc, options, requiredEnvId = true, withoutAuth = false } = this.options;
|
|
114
|
-
instance.storeOptionsAsProperties(false)
|
|
114
|
+
instance.storeOptionsAsProperties(false);
|
|
115
115
|
options.forEach((option) => {
|
|
116
|
-
|
|
116
|
+
const { hideHelp } = option;
|
|
117
|
+
if (hideHelp) {
|
|
118
|
+
instance.addOption(new commander_1.Option(option.flags, option.desc).hideHelp());
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
instance.option(option.flags, option.desc);
|
|
122
|
+
}
|
|
117
123
|
});
|
|
118
124
|
instance.description(desc);
|
|
119
125
|
instance.action((...args) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -136,7 +142,7 @@ class Command extends events_1.EventEmitter {
|
|
|
136
142
|
params,
|
|
137
143
|
options: cmdOptions
|
|
138
144
|
};
|
|
139
|
-
this.emit('preHandle', ctx, args);
|
|
145
|
+
this.emit('preHandle', ctx, args.slice(0, -1));
|
|
140
146
|
yield this.preHandle();
|
|
141
147
|
if (deprecate) {
|
|
142
148
|
console.log(chalk_1.default.bold.yellowBright('\n', `⚠️ 此命令将被废弃,请使用新的命令 tcb ${newCmd} 代替`), '\n');
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
2
14
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
17
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
18
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
19
|
};
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
8
27
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
28
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
29
|
};
|
|
@@ -24,7 +43,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
43
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
44
|
};
|
|
26
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.LowCodePublishComps = exports.LowCodeDebugComps = exports.LowCodeBuildComps = exports.LowCodeCreateComps = void 0;
|
|
46
|
+
exports.LowCodePublishVersionComps = exports.LowCodePublishComps = exports.LowCodeDebugComps = exports.LowCodeBuildComps = exports.LowCodeCreateComps = void 0;
|
|
28
47
|
const lodash_1 = __importDefault(require("lodash"));
|
|
29
48
|
const path_1 = __importDefault(require("path"));
|
|
30
49
|
const common_1 = require("../common");
|
|
@@ -38,6 +57,7 @@ const child_process_1 = require("child_process");
|
|
|
38
57
|
const enquirer_1 = require("enquirer");
|
|
39
58
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
40
59
|
const util_1 = require("util");
|
|
60
|
+
const semver = __importStar(require("semver"));
|
|
41
61
|
const cloudService = utils_1.CloudApiService.getInstance('lowcode');
|
|
42
62
|
const DEFAULE_TEMPLATE_PATH = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcc/template.zip';
|
|
43
63
|
let LowCodeCreateComps = class LowCodeCreateComps extends common_1.Command {
|
|
@@ -202,17 +222,22 @@ let LowCodePublishComps = class LowCodePublishComps extends common_1.Command {
|
|
|
202
222
|
{
|
|
203
223
|
flags: '--verbose',
|
|
204
224
|
desc: '是否打印详细日志'
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
flags: '--admin',
|
|
228
|
+
desc: '是否使用admin接口',
|
|
229
|
+
hideHelp: true
|
|
205
230
|
}
|
|
206
231
|
],
|
|
207
232
|
desc: '发布组件库',
|
|
208
233
|
requiredEnvId: false
|
|
209
234
|
};
|
|
210
235
|
}
|
|
211
|
-
execute(ctx, log) {
|
|
236
|
+
execute(ctx, log, options) {
|
|
212
237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
213
238
|
const config = ctx.config.lowcodeCustomComponents;
|
|
214
239
|
if (config) {
|
|
215
|
-
yield (0, lowcode_cli_1.gracePublishComps)(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log }));
|
|
240
|
+
yield (0, lowcode_cli_1.gracePublishComps)(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: Boolean(options.admin) }));
|
|
216
241
|
log.success('组件库 - 已同步到云端,请到低码控制台发布该组件库!');
|
|
217
242
|
return;
|
|
218
243
|
}
|
|
@@ -242,14 +267,100 @@ __decorate([
|
|
|
242
267
|
(0, decorators_1.InjectParams)(),
|
|
243
268
|
__param(0, (0, decorators_1.CmdContext)()),
|
|
244
269
|
__param(1, (0, decorators_1.Log)()),
|
|
270
|
+
__param(2, (0, decorators_1.ArgsOptions)()),
|
|
245
271
|
__metadata("design:type", Function),
|
|
246
|
-
__metadata("design:paramtypes", [Object, decorators_1.Logger]),
|
|
272
|
+
__metadata("design:paramtypes", [Object, decorators_1.Logger, Object]),
|
|
247
273
|
__metadata("design:returntype", Promise)
|
|
248
274
|
], LowCodePublishComps.prototype, "execute", null);
|
|
249
275
|
LowCodePublishComps = __decorate([
|
|
250
276
|
(0, common_1.ICommand)()
|
|
251
277
|
], LowCodePublishComps);
|
|
252
278
|
exports.LowCodePublishComps = LowCodePublishComps;
|
|
279
|
+
let LowCodePublishVersionComps = class LowCodePublishVersionComps extends common_1.Command {
|
|
280
|
+
get options() {
|
|
281
|
+
return {
|
|
282
|
+
cmd: 'lowcode',
|
|
283
|
+
childCmd: 'publishVersion',
|
|
284
|
+
options: [
|
|
285
|
+
{
|
|
286
|
+
flags: '--verbose',
|
|
287
|
+
desc: '是否打印详细日志'
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
flags: '--comment <comment>',
|
|
291
|
+
desc: '版本备注',
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
flags: '--tag <version>',
|
|
295
|
+
desc: '版本号'
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
flags: '--admin',
|
|
299
|
+
desc: '是否使用admin接口',
|
|
300
|
+
hideHelp: true
|
|
301
|
+
}
|
|
302
|
+
],
|
|
303
|
+
desc: '发布组件库版本',
|
|
304
|
+
requiredEnvId: false
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
execute(ctx, options, log) {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
+
const { tag, comment, admin } = options;
|
|
310
|
+
if (!comment) {
|
|
311
|
+
log.error('请使用 --comment 填写版本注释');
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (!tag) {
|
|
315
|
+
log.error('请使用 --tag 填写符合semver的版本号');
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (!semver.valid(tag)) {
|
|
319
|
+
log.error('组件库版本不符合semver标准');
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const config = ctx.config.lowcodeCustomComponents;
|
|
323
|
+
if (!config) {
|
|
324
|
+
log.error('组件库 - 请添加组件库配置到cloudbaserc.json 以使用该命令');
|
|
325
|
+
}
|
|
326
|
+
const res = yield (0, lowcode_cli_1.publishVersion)(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: options.admin }), comment, tag);
|
|
327
|
+
if (res.data.code === 200) {
|
|
328
|
+
log.success('组件库 - 已发布新版本!');
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (res.data.code === 100) {
|
|
332
|
+
log.error('组件库 - 无待发布版本');
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (res.data.code === 201) {
|
|
336
|
+
log.error('组件库 - comment 重复, 请使用有意义的comment');
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
if (res.data.msg) {
|
|
341
|
+
log.error(`组件库 - ${res.data.msg} RequestId: ${res.requestId}`);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
log.error('组件库 - 未知错误');
|
|
345
|
+
}
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
__decorate([
|
|
352
|
+
(0, decorators_1.InjectParams)(),
|
|
353
|
+
__param(0, (0, decorators_1.CmdContext)()),
|
|
354
|
+
__param(1, (0, decorators_1.ArgsOptions)()),
|
|
355
|
+
__param(2, (0, decorators_1.Log)()),
|
|
356
|
+
__metadata("design:type", Function),
|
|
357
|
+
__metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
|
|
358
|
+
__metadata("design:returntype", Promise)
|
|
359
|
+
], LowCodePublishVersionComps.prototype, "execute", null);
|
|
360
|
+
LowCodePublishVersionComps = __decorate([
|
|
361
|
+
(0, common_1.ICommand)()
|
|
362
|
+
], LowCodePublishVersionComps);
|
|
363
|
+
exports.LowCodePublishVersionComps = LowCodePublishVersionComps;
|
|
253
364
|
function _download(compsPath, compsName) {
|
|
254
365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
255
366
|
yield (0, utils_1.execWithLoading)(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -60,19 +60,29 @@ let UploadCommand = class UploadCommand extends common_1.Command {
|
|
|
60
60
|
{
|
|
61
61
|
flags: '-e, --envId <envId>',
|
|
62
62
|
desc: '环境 Id'
|
|
63
|
+
},
|
|
64
|
+
{ flags: '--times <times>', desc: '设置上传重试次数,默认值为 1' },
|
|
65
|
+
{
|
|
66
|
+
flags: '--interval <interval>',
|
|
67
|
+
desc: '设置上传失败时,重试时间间隔(毫秒),默认值为 500'
|
|
63
68
|
}
|
|
64
69
|
],
|
|
65
70
|
desc: '上传文件/文件夹'
|
|
66
71
|
};
|
|
67
72
|
}
|
|
68
|
-
execute(envId, params, log) {
|
|
73
|
+
execute(envId, params, options, log) {
|
|
69
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
75
|
const localPath = params === null || params === void 0 ? void 0 : params[0];
|
|
71
76
|
const cloudPath = params === null || params === void 0 ? void 0 : params[1];
|
|
77
|
+
const retryCount = options === null || options === void 0 ? void 0 : options.times;
|
|
78
|
+
const retryInterval = options === null || options === void 0 ? void 0 : options.interval;
|
|
72
79
|
const resolveLocalPath = path_1.default.resolve(localPath);
|
|
73
80
|
if (!(0, utils_1.checkFullAccess)(resolveLocalPath)) {
|
|
74
81
|
throw new error_1.CloudBaseError('文件未找到!');
|
|
75
82
|
}
|
|
83
|
+
if (retryCount > 10) {
|
|
84
|
+
throw new error_1.CloudBaseError('上传重试次数为 0-10 次之间');
|
|
85
|
+
}
|
|
76
86
|
const loading = (0, utils_1.loadingFactory)();
|
|
77
87
|
loading.start('准备上传中...');
|
|
78
88
|
const storageService = yield getStorageService(envId);
|
|
@@ -104,7 +114,10 @@ let UploadCommand = class UploadCommand extends common_1.Command {
|
|
|
104
114
|
else {
|
|
105
115
|
successFiles.push(fileInfo.Key);
|
|
106
116
|
}
|
|
107
|
-
}
|
|
117
|
+
},
|
|
118
|
+
retryCount: retryCount || 1,
|
|
119
|
+
retryInterval,
|
|
120
|
+
parallel: 20
|
|
108
121
|
});
|
|
109
122
|
log.success(`文件共计 ${totalFiles} 个`);
|
|
110
123
|
log.success(`文件上传成功 ${successFiles.length} 个`);
|
|
@@ -139,9 +152,10 @@ __decorate([
|
|
|
139
152
|
(0, decorators_1.InjectParams)(),
|
|
140
153
|
__param(0, (0, decorators_1.EnvId)()),
|
|
141
154
|
__param(1, (0, decorators_1.ArgsParams)()),
|
|
142
|
-
__param(2, (0, decorators_1.
|
|
155
|
+
__param(2, (0, decorators_1.ArgsOptions)()),
|
|
156
|
+
__param(3, (0, decorators_1.Log)()),
|
|
143
157
|
__metadata("design:type", Function),
|
|
144
|
-
__metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
|
|
158
|
+
__metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
|
|
145
159
|
__metadata("design:returntype", Promise)
|
|
146
160
|
], UploadCommand.prototype, "execute", null);
|
|
147
161
|
UploadCommand = __decorate([
|
|
@@ -183,7 +197,8 @@ let DownloadCommand = class DownloadCommand extends common_1.Command {
|
|
|
183
197
|
if (dir) {
|
|
184
198
|
yield storageService.downloadDirectory({
|
|
185
199
|
localPath: resolveLocalPath,
|
|
186
|
-
cloudPath
|
|
200
|
+
cloudPath,
|
|
201
|
+
parallel: 20
|
|
187
202
|
});
|
|
188
203
|
}
|
|
189
204
|
else {
|
package/lib/storage.js
CHANGED
|
@@ -25,11 +25,14 @@ function uploadFile(options) {
|
|
|
25
25
|
exports.uploadFile = uploadFile;
|
|
26
26
|
function uploadDirectory(options) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const { envId, localPath, cloudPath } = options;
|
|
28
|
+
const { envId, localPath, cloudPath, retryInterval, parallel, retryCount } = options;
|
|
29
29
|
const storageService = yield (0, utils_1.getStorageService)(envId);
|
|
30
30
|
return storageService.uploadDirectory({
|
|
31
31
|
localPath,
|
|
32
|
-
cloudPath
|
|
32
|
+
cloudPath,
|
|
33
|
+
retryInterval,
|
|
34
|
+
retryCount,
|
|
35
|
+
parallel
|
|
33
36
|
});
|
|
34
37
|
});
|
|
35
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.2-alpha.0",
|
|
4
4
|
"description": "cli tool for cloudbase",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"test": "jest --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000",
|
|
12
12
|
"tsc": "tsc",
|
|
13
13
|
"pkg": "pkg ./bin/cloudbase.js --out-path ./pkg",
|
|
14
|
-
"postinstall": "node ./post-install.js || exit 0"
|
|
14
|
+
"postinstall": "node ./post-install.js || exit 0",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
15
16
|
},
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|
|
@@ -21,13 +22,18 @@
|
|
|
21
22
|
"tcb": "bin/tcb.js",
|
|
22
23
|
"cloudbase": "bin/cloudbase.js"
|
|
23
24
|
},
|
|
25
|
+
"husky": {
|
|
26
|
+
"hooks": {
|
|
27
|
+
"pre-commit": "npm run build && git add ."
|
|
28
|
+
}
|
|
29
|
+
},
|
|
24
30
|
"author": "cwuyiqing@gmail.com",
|
|
25
31
|
"license": "ISC",
|
|
26
32
|
"dependencies": {
|
|
27
33
|
"@cloudbase/cloud-api": "^0.4.0",
|
|
28
34
|
"@cloudbase/framework-core": "^1.6.1",
|
|
29
|
-
"@cloudbase/lowcode-cli": "^0.12.
|
|
30
|
-
"@cloudbase/manager-node": "3.12.0",
|
|
35
|
+
"@cloudbase/lowcode-cli": "^0.12.3",
|
|
36
|
+
"@cloudbase/manager-node": "^3.12.0",
|
|
31
37
|
"@cloudbase/toolbox": "^0.7.2",
|
|
32
38
|
"@sentry/node": "^5.10.2",
|
|
33
39
|
"address": "^1.1.2",
|
|
@@ -67,6 +73,7 @@
|
|
|
67
73
|
"@types/lodash": "^4.14.149",
|
|
68
74
|
"@types/node": "^12.12.38",
|
|
69
75
|
"@types/node-fetch": "^2.5.4",
|
|
76
|
+
"@types/react": "^17.0.37",
|
|
70
77
|
"@types/semver": "^7.3.9",
|
|
71
78
|
"@types/webpack-dev-server": "^3.11.1",
|
|
72
79
|
"@typescript-eslint/eslint-plugin": "^4.8.1",
|
package/tsconfig.json
CHANGED
|
@@ -43,12 +43,35 @@ export declare class LowCodePublishComps extends Command {
|
|
|
43
43
|
get options(): {
|
|
44
44
|
cmd: string;
|
|
45
45
|
childCmd: string;
|
|
46
|
-
options: {
|
|
46
|
+
options: ({
|
|
47
47
|
flags: string;
|
|
48
48
|
desc: string;
|
|
49
|
-
|
|
49
|
+
hideHelp?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
flags: string;
|
|
52
|
+
desc: string;
|
|
53
|
+
hideHelp: boolean;
|
|
54
|
+
})[];
|
|
55
|
+
desc: string;
|
|
56
|
+
requiredEnvId: boolean;
|
|
57
|
+
};
|
|
58
|
+
execute(ctx: any, log: Logger, options: any): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
export declare class LowCodePublishVersionComps extends Command {
|
|
61
|
+
get options(): {
|
|
62
|
+
cmd: string;
|
|
63
|
+
childCmd: string;
|
|
64
|
+
options: ({
|
|
65
|
+
flags: string;
|
|
66
|
+
desc: string;
|
|
67
|
+
hideHelp?: undefined;
|
|
68
|
+
} | {
|
|
69
|
+
flags: string;
|
|
70
|
+
desc: string;
|
|
71
|
+
hideHelp: boolean;
|
|
72
|
+
})[];
|
|
50
73
|
desc: string;
|
|
51
74
|
requiredEnvId: boolean;
|
|
52
75
|
};
|
|
53
|
-
execute(ctx: any, log?: Logger): Promise<void>;
|
|
76
|
+
execute(ctx: any, options: any, log?: Logger): Promise<void>;
|
|
54
77
|
}
|
|
@@ -11,7 +11,7 @@ export declare class UploadCommand extends Command {
|
|
|
11
11
|
}[];
|
|
12
12
|
desc: string;
|
|
13
13
|
};
|
|
14
|
-
execute(envId: any, params: any, log: Logger): Promise<void>;
|
|
14
|
+
execute(envId: any, params: any, options: any, log: Logger): Promise<void>;
|
|
15
15
|
}
|
|
16
16
|
export declare class DownloadCommand extends Command {
|
|
17
17
|
get options(): {
|