@cloudbase/cli 1.9.7 → 1.9.9

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.
@@ -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).passCommandToAction(false);
114
+ instance.storeOptionsAsProperties(false);
115
115
  options.forEach((option) => {
116
- instance.option(option.flags, option.desc);
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.Log)()),
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.9.7",
3
+ "version": "1.9.9",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -26,15 +26,15 @@
26
26
  "dependencies": {
27
27
  "@cloudbase/cloud-api": "^0.4.0",
28
28
  "@cloudbase/framework-core": "^1.6.1",
29
- "@cloudbase/lowcode-cli": "^0.12.0",
30
- "@cloudbase/manager-node": "^3.9.0",
29
+ "@cloudbase/lowcode-cli": "^0.12.1",
30
+ "@cloudbase/manager-node": "3.11.1-beta",
31
31
  "@cloudbase/toolbox": "^0.7.2",
32
32
  "@sentry/node": "^5.10.2",
33
33
  "address": "^1.1.2",
34
34
  "axios": "^0.21.1",
35
35
  "chalk": "^2.4.2",
36
36
  "cli-table3": "^0.5.1",
37
- "commander": "^6.1.0",
37
+ "commander": "7",
38
38
  "del": "^5.1.0",
39
39
  "didyoumean": "^1.2.1",
40
40
  "enquirer": "^2.3.6",
@@ -53,6 +53,7 @@
53
53
  "progress": "^2.0.3",
54
54
  "query-string": "^6.8.1",
55
55
  "reflect-metadata": "^0.1.13",
56
+ "semver": "^7.3.5",
56
57
  "tar-fs": "^2.0.1",
57
58
  "terminal-link": "^2.1.1",
58
59
  "unzipper": "^0.10.10",
@@ -66,6 +67,7 @@
66
67
  "@types/lodash": "^4.14.149",
67
68
  "@types/node": "^12.12.38",
68
69
  "@types/node-fetch": "^2.5.4",
70
+ "@types/semver": "^7.3.9",
69
71
  "@types/webpack-dev-server": "^3.11.1",
70
72
  "@typescript-eslint/eslint-plugin": "^4.8.1",
71
73
  "@typescript-eslint/parser": "^4.8.1",
@@ -1,7 +1,7 @@
1
1
  import chalk from 'chalk'
2
2
  import * as Sentry from '@sentry/node'
3
3
  import { EventEmitter } from 'events'
4
- import { program, Command as Commander } from 'commander'
4
+ import { program, Command as Commander, Option } from 'commander'
5
5
  import { CloudBaseError } from '../error'
6
6
  import { ICommandContext } from '../types'
7
7
  import {
@@ -16,6 +16,7 @@ import {
16
16
  interface ICommandOption {
17
17
  flags: string
18
18
  desc: string
19
+ hideHelp?: boolean
19
20
  }
20
21
 
21
22
  export interface ICommandOptions {
@@ -87,6 +88,7 @@ export abstract class Command extends EventEmitter {
87
88
  } else {
88
89
  // 新命令或原有的旧命令格式
89
90
  instance = program.command(cmd) as Commander
91
+ // @ts-expect-error 这里是用来自定义commander fallback 帮助信息
90
92
  instance._helpDescription = '输出帮助信息'
91
93
  instance.addHelpCommand('help [command]', '查看命令帮助信息')
92
94
  cmdMap.set(cmd, instance)
@@ -110,6 +112,7 @@ export abstract class Command extends EventEmitter {
110
112
  instance = cmdMap.get(cmdKey)
111
113
  } else {
112
114
  instance = instance.command(cmdName) as Commander
115
+ // @ts-expect-error 这里是用来自定义commander fallback 帮助信息
113
116
  instance._helpDescription = '查看命令帮助信息'
114
117
  desc && instance.description(desc)
115
118
  cmdMap.set(cmdKey, instance)
@@ -137,11 +140,16 @@ export abstract class Command extends EventEmitter {
137
140
 
138
141
  private createProgram(instance: Commander, deprecate: boolean, newCmd?: string) {
139
142
  const { cmd, desc, options, requiredEnvId = true, withoutAuth = false } = this.options
140
-
141
- instance.storeOptionsAsProperties(false).passCommandToAction(false)
142
-
143
+ instance.storeOptionsAsProperties(false)
143
144
  options.forEach((option) => {
144
- instance.option(option.flags, option.desc)
145
+
146
+ const { hideHelp } = option
147
+ if(hideHelp) {
148
+ instance.addOption(new Option(option.flags, option.desc).hideHelp())
149
+ } else {
150
+ instance.option(option.flags, option.desc)
151
+ }
152
+
145
153
  })
146
154
 
147
155
  instance.description(desc)
@@ -178,7 +186,7 @@ export abstract class Command extends EventEmitter {
178
186
  }
179
187
 
180
188
  // 处理前
181
- this.emit('preHandle', ctx, args)
189
+ this.emit('preHandle', ctx, args.slice(0, -1))
182
190
  await this.preHandle()
183
191
 
184
192
  // 废弃警告
@@ -14,11 +14,13 @@ import {
14
14
  graceDebugComps,
15
15
  gracePublishComps,
16
16
  IPublishCompsInfo,
17
+ publishVersion
17
18
  } from '@cloudbase/lowcode-cli'
18
19
  import { exec } from 'child_process'
19
20
  import { prompt } from 'enquirer'
20
21
  import fse from 'fs-extra'
21
22
  import { promisify } from 'util'
23
+ import * as semver from 'semver'
22
24
 
23
25
  const cloudService = CloudApiService.getInstance('lowcode')
24
26
  const DEFAULE_TEMPLATE_PATH = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcc/template.zip'
@@ -176,6 +178,11 @@ export class LowCodePublishComps extends Command {
176
178
  {
177
179
  flags: '--verbose',
178
180
  desc: '是否打印详细日志'
181
+ },
182
+ {
183
+ flags: '--admin',
184
+ desc: '是否使用admin接口',
185
+ hideHelp: true
179
186
  }
180
187
  ],
181
188
  desc: '发布组件库',
@@ -184,14 +191,16 @@ export class LowCodePublishComps extends Command {
184
191
  }
185
192
 
186
193
  @InjectParams()
187
- async execute(@CmdContext() ctx, @Log() log?: Logger) {
194
+ async execute(@CmdContext() ctx, @Log() log: Logger, @ArgsOptions() options: any) {
188
195
  // 有RC配置, 使用新接口
196
+
189
197
  const config = ctx.config.lowcodeCustomComponents
190
198
  if (config) {
191
199
  await gracePublishComps({
192
200
  ...config,
193
201
  context: config.context || process.cwd(),
194
- logger: log
202
+ logger: log,
203
+ isAdmin: Boolean(options.admin)
195
204
  })
196
205
  log.success('组件库 - 已同步到云端,请到低码控制台发布该组件库!')
197
206
  return
@@ -224,6 +233,86 @@ export class LowCodePublishComps extends Command {
224
233
  }
225
234
  }
226
235
 
236
+ @ICommand()
237
+ export class LowCodePublishVersionComps extends Command {
238
+ get options() {
239
+ return {
240
+ cmd: 'lowcode',
241
+ childCmd: 'publishVersion',
242
+ options: [
243
+ {
244
+ flags: '--verbose',
245
+ desc: '是否打印详细日志'
246
+ },
247
+ {
248
+ flags: '--comment <comment>',
249
+ desc: '版本备注',
250
+ },
251
+ {
252
+ flags: '--tag <version>',
253
+ desc: '版本号'
254
+ },
255
+ {
256
+ flags: '--admin',
257
+ desc: '是否使用admin接口',
258
+ hideHelp: true
259
+ }
260
+ ],
261
+ desc: '发布组件库版本',
262
+ requiredEnvId: false
263
+ }
264
+ }
265
+
266
+ @InjectParams()
267
+ async execute(@CmdContext() ctx, @ArgsOptions() options, @Log() log?: Logger) {
268
+ // 有RC配置, 使用新接口
269
+ const {tag, comment, admin} = options
270
+ if(!comment) {
271
+ log.error('请使用 --comment 填写版本注释')
272
+ return
273
+ }
274
+ if(!tag) {
275
+ log.error('请使用 --tag 填写符合semver的版本号')
276
+ return
277
+ }
278
+ if(!semver.valid(tag)) {
279
+ log.error('组件库版本不符合semver标准')
280
+ return
281
+ }
282
+ const config = ctx.config.lowcodeCustomComponents
283
+
284
+ if(!config) {
285
+ log.error('组件库 - 请添加组件库配置到cloudbaserc.json 以使用该命令')
286
+ }
287
+
288
+ const res = await publishVersion({
289
+ ...config,
290
+ context: config.context || process.cwd(),
291
+ logger: log,
292
+ isAdmin: options.admin
293
+ }, comment, tag)
294
+ if(res.data.code === 200) {
295
+ log.success('组件库 - 已发布新版本!')
296
+ return
297
+ }
298
+ if (res.data.code === 100) {
299
+ log.error('组件库 - 无待发布版本')
300
+ return
301
+ }
302
+ if (res.data.code === 201) {
303
+ log.error('组件库 - comment 重复, 请使用有意义的comment')
304
+ return
305
+ } else {
306
+ if(res.data.msg) {
307
+ log.error(`组件库 - ${res.data.msg} RequestId: ${res.requestId}`)
308
+ } else {
309
+ log.error('组件库 - 未知错误')
310
+ }
311
+ return
312
+ }
313
+ }
314
+ }
315
+
227
316
  async function _download(compsPath, compsName) {
228
317
  await execWithLoading(
229
318
  async () => {
@@ -48,6 +48,11 @@ export class UploadCommand extends Command {
48
48
  {
49
49
  flags: '-e, --envId <envId>',
50
50
  desc: '环境 Id'
51
+ },
52
+ { flags: '--times <times>', desc: '设置上传重试次数,默认值为 1' },
53
+ {
54
+ flags: '--interval <interval>',
55
+ desc: '设置上传失败时,重试时间间隔(毫秒),默认值为 500'
51
56
  }
52
57
  ],
53
58
  desc: '上传文件/文件夹'
@@ -55,13 +60,23 @@ export class UploadCommand extends Command {
55
60
  }
56
61
 
57
62
  @InjectParams()
58
- async execute(@EnvId() envId, @ArgsParams() params, @Log() log: Logger) {
63
+ async execute(
64
+ @EnvId() envId,
65
+ @ArgsParams() params,
66
+ @ArgsOptions() options,
67
+ @Log() log: Logger
68
+ ) {
59
69
  const localPath = params?.[0]
60
70
  const cloudPath = params?.[1]
71
+ const retryCount = options?.times
72
+ const retryInterval = options?.interval
61
73
  const resolveLocalPath = path.resolve(localPath)
62
74
  if (!checkFullAccess(resolveLocalPath)) {
63
75
  throw new CloudBaseError('文件未找到!')
64
76
  }
77
+ if (retryCount > 10) {
78
+ throw new CloudBaseError('上传重试次数为 0-10 次之间')
79
+ }
65
80
 
66
81
  const loading = loadingFactory()
67
82
  loading.start('准备上传中...')
@@ -88,7 +103,6 @@ export class UploadCommand extends Command {
88
103
 
89
104
  const successFiles = []
90
105
  const failedFiles = []
91
-
92
106
  if (isDir) {
93
107
  await storageService.uploadDirectory({
94
108
  localPath: resolveLocalPath,
@@ -102,7 +116,10 @@ export class UploadCommand extends Command {
102
116
  } else {
103
117
  successFiles.push(fileInfo.Key)
104
118
  }
105
- }
119
+ },
120
+ retryCount: retryCount || 1,
121
+ retryInterval,
122
+ parallel: 20
106
123
  })
107
124
 
108
125
  log.success(`文件共计 ${totalFiles} 个`)
@@ -184,7 +201,8 @@ export class DownloadCommand extends Command {
184
201
  if (dir) {
185
202
  await storageService.downloadDirectory({
186
203
  localPath: resolveLocalPath,
187
- cloudPath
204
+ cloudPath,
205
+ parallel: 20
188
206
  })
189
207
  } else {
190
208
  await storageService.downloadFile({
package/src/storage.ts CHANGED
@@ -5,6 +5,9 @@ interface IStorageOptions {
5
5
  envId: string
6
6
  localPath: string
7
7
  cloudPath: string
8
+ parallel?: number
9
+ retryCount?: number
10
+ retryInterval?: number
8
11
  }
9
12
 
10
13
  interface IStorageCloudOptions {
@@ -23,11 +26,14 @@ export async function uploadFile(options: IStorageOptions) {
23
26
  }
24
27
 
25
28
  export async function uploadDirectory(options: IStorageOptions) {
26
- const { envId, localPath, cloudPath } = options
29
+ const { envId, localPath, cloudPath, retryInterval, parallel, retryCount } = options
27
30
  const storageService = await getStorageService(envId)
28
31
  return storageService.uploadDirectory({
29
32
  localPath,
30
- cloudPath
33
+ cloudPath,
34
+ retryInterval,
35
+ retryCount,
36
+ parallel
31
37
  })
32
38
  }
33
39
 
@@ -4,6 +4,7 @@ import { ICommandContext } from '../types';
4
4
  interface ICommandOption {
5
5
  flags: string;
6
6
  desc: string;
7
+ hideHelp?: boolean;
7
8
  }
8
9
  export interface ICommandOptions {
9
10
  deprecateCmd?: string;
@@ -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(): {
@@ -3,6 +3,9 @@ interface IStorageOptions {
3
3
  envId: string;
4
4
  localPath: string;
5
5
  cloudPath: string;
6
+ parallel?: number;
7
+ retryCount?: number;
8
+ retryInterval?: number;
6
9
  }
7
10
  interface IStorageCloudOptions {
8
11
  envId: string;
@@ -1,30 +0,0 @@
1
- {
2
- // See https://go.microsoft.com/fwlink/?LinkId=733558
3
- // for thedocumentation about the tasks.json format
4
- "version": "2.0.0",
5
- "command": "tsc",
6
- //-p 指定目录;-w watch,检测文件改变自动编译
7
- "args": [
8
- "-p",
9
- ".",
10
- "-w"
11
- ],
12
- "problemMatcher": "$tsc",
13
- "tasks": [
14
- {
15
- "label": "tsc",
16
- "type": "shell",
17
- "command": "tsc",
18
- "args": [
19
- "-p",
20
- ".",
21
- "-w"
22
- ],
23
- "problemMatcher": "$tsc",
24
- "group": {
25
- "_id": "build",
26
- "isDefault": false
27
- }
28
- }
29
- ]
30
- }
@@ -1,11 +0,0 @@
1
- {
2
- // See https://go.microsoft.com/fwlink/?LinkId=733558
3
- // for thedocumentation about the tasks.json format
4
- "version": "0.1.0",
5
- "command": "tsc",
6
- "isShellCommand": true,
7
- //-p 指定目录;-w watch,检测文件改变自动编译
8
- "args": ["-p", ".","-w"],
9
- "showOutput": "always",
10
- "problemMatcher": "$tsc"
11
- }