@cloudbase/cli 1.9.9 → 1.10.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.
Files changed (61) hide show
  1. package/lib/commands/common.js +3 -9
  2. package/lib/commands/functions/alias/getRoute.js +98 -0
  3. package/lib/commands/functions/alias/index.js +14 -0
  4. package/lib/commands/functions/alias/setRoute.js +100 -0
  5. package/lib/commands/functions/concurrency/delete.js +70 -0
  6. package/lib/commands/functions/concurrency/index.js +15 -0
  7. package/lib/commands/functions/concurrency/list.js +81 -0
  8. package/lib/commands/functions/concurrency/set.js +72 -0
  9. package/lib/commands/functions/index.js +3 -0
  10. package/lib/commands/functions/list.js +2 -8
  11. package/lib/commands/functions/version/index.js +14 -0
  12. package/lib/commands/functions/version/list.js +96 -0
  13. package/lib/commands/functions/version/publish.js +70 -0
  14. package/lib/commands/lowcode/comps.js +4 -115
  15. package/lib/commands/storage/storage.js +5 -20
  16. package/lib/constant.js +23 -1
  17. package/lib/function/alias.js +53 -0
  18. package/lib/function/concurrency.js +69 -0
  19. package/lib/function/index.js +3 -0
  20. package/lib/function/version.js +51 -0
  21. package/lib/storage.js +2 -5
  22. package/package.json +3 -3
  23. package/src/commands/functions/alias/getRoute.ts +76 -0
  24. package/src/commands/functions/alias/index.ts +2 -0
  25. package/src/commands/functions/alias/setRoute.ts +82 -0
  26. package/src/commands/functions/concurrency/delete.ts +45 -0
  27. package/src/commands/functions/concurrency/index.ts +3 -0
  28. package/src/commands/functions/concurrency/list.ts +58 -0
  29. package/src/commands/functions/concurrency/set.ts +47 -0
  30. package/src/commands/functions/index.ts +3 -0
  31. package/src/commands/functions/list.ts +1 -8
  32. package/src/commands/functions/version/index.ts +2 -0
  33. package/src/commands/functions/version/list.ts +73 -0
  34. package/src/commands/functions/version/publish.ts +43 -0
  35. package/src/constant.ts +24 -0
  36. package/src/function/alias.ts +43 -0
  37. package/src/function/concurrency.ts +57 -0
  38. package/src/function/index.ts +4 -1
  39. package/src/function/version.ts +39 -0
  40. package/src/types.ts +95 -0
  41. package/types/commands/common.d.ts +0 -1
  42. package/types/commands/functions/alias/getRoute.d.ts +13 -0
  43. package/types/commands/functions/alias/index.d.ts +2 -0
  44. package/types/commands/functions/alias/setRoute.d.ts +13 -0
  45. package/types/commands/functions/concurrency/delete.d.ts +13 -0
  46. package/types/commands/functions/concurrency/index.d.ts +3 -0
  47. package/types/commands/functions/concurrency/list.d.ts +13 -0
  48. package/types/commands/functions/concurrency/set.d.ts +13 -0
  49. package/types/commands/functions/index.d.ts +3 -0
  50. package/types/commands/functions/version/index.d.ts +2 -0
  51. package/types/commands/functions/version/list.d.ts +13 -0
  52. package/types/commands/functions/version/publish.d.ts +13 -0
  53. package/types/commands/lowcode/comps.d.ts +3 -26
  54. package/types/commands/storage/storage.d.ts +1 -1
  55. package/types/constant.d.ts +16 -0
  56. package/types/function/alias.d.ts +3 -0
  57. package/types/function/concurrency.d.ts +4 -0
  58. package/types/function/index.d.ts +3 -0
  59. package/types/function/version.d.ts +3 -0
  60. package/types/storage.d.ts +0 -3
  61. package/types/types.d.ts +82 -0
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
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
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.PublishFunctionVersion = void 0;
25
+ const common_1 = require("../../common");
26
+ const utils_1 = require("../../../utils");
27
+ const function_1 = require("../../../function");
28
+ const decorators_1 = require("../../../decorators");
29
+ let PublishFunctionVersion = class PublishFunctionVersion extends common_1.Command {
30
+ get options() {
31
+ return {
32
+ cmd: 'fn',
33
+ childCmd: 'publish-version <name> [description]',
34
+ options: [
35
+ {
36
+ flags: '-e, --envId <envId>',
37
+ desc: '环境 Id'
38
+ }
39
+ ],
40
+ desc: '发布函数新版本'
41
+ };
42
+ }
43
+ execute(ctx, params) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const name = params === null || params === void 0 ? void 0 : params[0];
46
+ const description = params === null || params === void 0 ? void 0 : params[1];
47
+ const { envId } = ctx;
48
+ const loading = (0, utils_1.loadingFactory)();
49
+ loading.start(`发布函数 [${name}] 新版本中...`);
50
+ yield (0, function_1.publishVersion)({
51
+ envId,
52
+ functionName: name,
53
+ description
54
+ });
55
+ loading.succeed(`发布函数 [${name}] 新版本成功!`);
56
+ });
57
+ }
58
+ };
59
+ __decorate([
60
+ (0, decorators_1.InjectParams)(),
61
+ __param(0, (0, decorators_1.CmdContext)()),
62
+ __param(1, (0, decorators_1.ArgsParams)()),
63
+ __metadata("design:type", Function),
64
+ __metadata("design:paramtypes", [Object, Object]),
65
+ __metadata("design:returntype", Promise)
66
+ ], PublishFunctionVersion.prototype, "execute", null);
67
+ PublishFunctionVersion = __decorate([
68
+ (0, common_1.ICommand)()
69
+ ], PublishFunctionVersion);
70
+ exports.PublishFunctionVersion = PublishFunctionVersion;
@@ -1,29 +1,10 @@
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
- });
14
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
5
  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;
18
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
19
7
  };
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
- };
27
8
  var __metadata = (this && this.__metadata) || function (k, v) {
28
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
29
10
  };
@@ -43,7 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
43
24
  return (mod && mod.__esModule) ? mod : { "default": mod };
44
25
  };
45
26
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.LowCodePublishVersionComps = exports.LowCodePublishComps = exports.LowCodeDebugComps = exports.LowCodeBuildComps = exports.LowCodeCreateComps = void 0;
27
+ exports.LowCodePublishComps = exports.LowCodeDebugComps = exports.LowCodeBuildComps = exports.LowCodeCreateComps = void 0;
47
28
  const lodash_1 = __importDefault(require("lodash"));
48
29
  const path_1 = __importDefault(require("path"));
49
30
  const common_1 = require("../common");
@@ -57,7 +38,6 @@ const child_process_1 = require("child_process");
57
38
  const enquirer_1 = require("enquirer");
58
39
  const fs_extra_1 = __importDefault(require("fs-extra"));
59
40
  const util_1 = require("util");
60
- const semver = __importStar(require("semver"));
61
41
  const cloudService = utils_1.CloudApiService.getInstance('lowcode');
62
42
  const DEFAULE_TEMPLATE_PATH = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcc/template.zip';
63
43
  let LowCodeCreateComps = class LowCodeCreateComps extends common_1.Command {
@@ -222,22 +202,17 @@ let LowCodePublishComps = class LowCodePublishComps extends common_1.Command {
222
202
  {
223
203
  flags: '--verbose',
224
204
  desc: '是否打印详细日志'
225
- },
226
- {
227
- flags: '--admin',
228
- desc: '是否使用admin接口',
229
- hideHelp: true
230
205
  }
231
206
  ],
232
207
  desc: '发布组件库',
233
208
  requiredEnvId: false
234
209
  };
235
210
  }
236
- execute(ctx, log, options) {
211
+ execute(ctx, log) {
237
212
  return __awaiter(this, void 0, void 0, function* () {
238
213
  const config = ctx.config.lowcodeCustomComponents;
239
214
  if (config) {
240
- yield (0, lowcode_cli_1.gracePublishComps)(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: Boolean(options.admin) }));
215
+ yield (0, lowcode_cli_1.gracePublishComps)(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log }));
241
216
  log.success('组件库 - 已同步到云端,请到低码控制台发布该组件库!');
242
217
  return;
243
218
  }
@@ -267,100 +242,14 @@ __decorate([
267
242
  (0, decorators_1.InjectParams)(),
268
243
  __param(0, (0, decorators_1.CmdContext)()),
269
244
  __param(1, (0, decorators_1.Log)()),
270
- __param(2, (0, decorators_1.ArgsOptions)()),
271
245
  __metadata("design:type", Function),
272
- __metadata("design:paramtypes", [Object, decorators_1.Logger, Object]),
246
+ __metadata("design:paramtypes", [Object, decorators_1.Logger]),
273
247
  __metadata("design:returntype", Promise)
274
248
  ], LowCodePublishComps.prototype, "execute", null);
275
249
  LowCodePublishComps = __decorate([
276
250
  (0, common_1.ICommand)()
277
251
  ], LowCodePublishComps);
278
252
  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;
364
253
  function _download(compsPath, compsName) {
365
254
  return __awaiter(this, void 0, void 0, function* () {
366
255
  yield (0, utils_1.execWithLoading)(() => __awaiter(this, void 0, void 0, function* () {
@@ -60,29 +60,19 @@ 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'
68
63
  }
69
64
  ],
70
65
  desc: '上传文件/文件夹'
71
66
  };
72
67
  }
73
- execute(envId, params, options, log) {
68
+ execute(envId, params, log) {
74
69
  return __awaiter(this, void 0, void 0, function* () {
75
70
  const localPath = params === null || params === void 0 ? void 0 : params[0];
76
71
  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;
79
72
  const resolveLocalPath = path_1.default.resolve(localPath);
80
73
  if (!(0, utils_1.checkFullAccess)(resolveLocalPath)) {
81
74
  throw new error_1.CloudBaseError('文件未找到!');
82
75
  }
83
- if (retryCount > 10) {
84
- throw new error_1.CloudBaseError('上传重试次数为 0-10 次之间');
85
- }
86
76
  const loading = (0, utils_1.loadingFactory)();
87
77
  loading.start('准备上传中...');
88
78
  const storageService = yield getStorageService(envId);
@@ -114,10 +104,7 @@ let UploadCommand = class UploadCommand extends common_1.Command {
114
104
  else {
115
105
  successFiles.push(fileInfo.Key);
116
106
  }
117
- },
118
- retryCount: retryCount || 1,
119
- retryInterval,
120
- parallel: 20
107
+ }
121
108
  });
122
109
  log.success(`文件共计 ${totalFiles} 个`);
123
110
  log.success(`文件上传成功 ${successFiles.length} 个`);
@@ -152,10 +139,9 @@ __decorate([
152
139
  (0, decorators_1.InjectParams)(),
153
140
  __param(0, (0, decorators_1.EnvId)()),
154
141
  __param(1, (0, decorators_1.ArgsParams)()),
155
- __param(2, (0, decorators_1.ArgsOptions)()),
156
- __param(3, (0, decorators_1.Log)()),
142
+ __param(2, (0, decorators_1.Log)()),
157
143
  __metadata("design:type", Function),
158
- __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
144
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
159
145
  __metadata("design:returntype", Promise)
160
146
  ], UploadCommand.prototype, "execute", null);
161
147
  UploadCommand = __decorate([
@@ -197,8 +183,7 @@ let DownloadCommand = class DownloadCommand extends common_1.Command {
197
183
  if (dir) {
198
184
  yield storageService.downloadDirectory({
199
185
  localPath: resolveLocalPath,
200
- cloudPath,
201
- parallel: 20
186
+ cloudPath
202
187
  });
203
188
  }
204
189
  else {
package/lib/constant.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ALL_COMMANDS = exports.STATUS_TEXT = exports.REQUEST_TIMEOUT = exports.DefaultCloudBaseConfig = exports.DefaultFunctionDeployConfig = exports.ConfigItems = void 0;
3
+ exports.ConcurrencyTaskStatus = exports.StatusMap = exports.ALL_COMMANDS = exports.STATUS_TEXT = exports.REQUEST_TIMEOUT = exports.DefaultCloudBaseConfig = exports.DefaultFunctionDeployConfig = exports.ConfigItems = void 0;
4
4
  class ConfigItems {
5
5
  }
6
6
  exports.ConfigItems = ConfigItems;
@@ -51,6 +51,12 @@ exports.ALL_COMMANDS = [
51
51
  'fn trigger create',
52
52
  'fn trigger delete',
53
53
  'fn invoke',
54
+ 'fn publish-version',
55
+ 'fn list-function-versions',
56
+ 'fn put-provisioned-concurrency',
57
+ 'fn get-provisioned-concurrency',
58
+ 'fn delete-provisioned-concurrency',
59
+ 'fn config-route',
54
60
  'functions run',
55
61
  'storage upload',
56
62
  'storage download',
@@ -77,3 +83,19 @@ exports.ALL_COMMANDS = [
77
83
  'run standalonegateway turn on',
78
84
  'run standalonegateway turn off',
79
85
  ];
86
+ exports.StatusMap = {
87
+ Active: '部署完成',
88
+ Creating: '创建中',
89
+ CreateFailed: '创建失败',
90
+ Updating: '更新中',
91
+ UpdateFailed: '更新失败',
92
+ Publishing: '函数版本发布中',
93
+ PublishFailed: '函数版本发布失败',
94
+ Deleting: '函数删除中',
95
+ DeleteFailed: '函数删除失败'
96
+ };
97
+ exports.ConcurrencyTaskStatus = {
98
+ Done: '已完成',
99
+ InProgress: '进行中',
100
+ Failed: '失败'
101
+ };
@@ -0,0 +1,53 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getFunctionAliasConfig = exports.setFunctionAliasConfig = void 0;
13
+ const error_1 = require("../error");
14
+ const base_1 = require("./base");
15
+ function setFunctionAliasConfig(options) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const { envId, functionName, name, functionVersion, description, routingConfig } = options;
18
+ const scfService = yield (0, base_1.getFunctionService)(envId);
19
+ try {
20
+ yield scfService.updateFunctionAliasConfig({
21
+ functionName,
22
+ name,
23
+ functionVersion,
24
+ description,
25
+ routingConfig
26
+ });
27
+ }
28
+ catch (e) {
29
+ throw new error_1.CloudBaseError(`[${functionName}] 设置函数流量配置失败: ${e.message}`, {
30
+ code: e.code
31
+ });
32
+ }
33
+ });
34
+ }
35
+ exports.setFunctionAliasConfig = setFunctionAliasConfig;
36
+ function getFunctionAliasConfig(options) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const { envId, functionName, name } = options;
39
+ const scfService = yield (0, base_1.getFunctionService)(envId);
40
+ try {
41
+ return scfService.getFunctionAlias({
42
+ functionName,
43
+ name
44
+ });
45
+ }
46
+ catch (e) {
47
+ throw new error_1.CloudBaseError(`[${functionName}] 查询函数别名配置失败: ${e.message}`, {
48
+ code: e.code
49
+ });
50
+ }
51
+ });
52
+ }
53
+ exports.getFunctionAliasConfig = getFunctionAliasConfig;
@@ -0,0 +1,69 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.deleteProvisionedConcurrencyConfig = exports.getProvisionedConcurrencyConfig = exports.setProvisionedConcurrencyConfig = void 0;
13
+ const error_1 = require("../error");
14
+ const base_1 = require("./base");
15
+ function setProvisionedConcurrencyConfig(options) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const { envId, functionName, qualifier, versionProvisionedConcurrencyNum } = options;
18
+ const scfService = yield (0, base_1.getFunctionService)(envId);
19
+ try {
20
+ yield scfService.setProvisionedConcurrencyConfig({
21
+ functionName,
22
+ qualifier,
23
+ versionProvisionedConcurrencyNum
24
+ });
25
+ }
26
+ catch (e) {
27
+ throw new error_1.CloudBaseError(`[${functionName}] 设置函数预置并发失败: ${e.message}`, {
28
+ code: e.code
29
+ });
30
+ }
31
+ });
32
+ }
33
+ exports.setProvisionedConcurrencyConfig = setProvisionedConcurrencyConfig;
34
+ function getProvisionedConcurrencyConfig(options) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const { envId, functionName, qualifier } = options;
37
+ const scfService = yield (0, base_1.getFunctionService)(envId);
38
+ try {
39
+ return scfService.getProvisionedConcurrencyConfig({
40
+ functionName,
41
+ qualifier,
42
+ });
43
+ }
44
+ catch (e) {
45
+ throw new error_1.CloudBaseError(`[${functionName}] 查看函数预置并发信息失败: ${e.message}`, {
46
+ code: e.code
47
+ });
48
+ }
49
+ });
50
+ }
51
+ exports.getProvisionedConcurrencyConfig = getProvisionedConcurrencyConfig;
52
+ function deleteProvisionedConcurrencyConfig(options) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const { envId, functionName, qualifier } = options;
55
+ const scfService = yield (0, base_1.getFunctionService)(envId);
56
+ try {
57
+ yield scfService.deleteProvisionedConcurrencyConfig({
58
+ functionName,
59
+ qualifier
60
+ });
61
+ }
62
+ catch (e) {
63
+ throw new error_1.CloudBaseError(`[${functionName}] 删除函数预置并发失败: ${e.message}`, {
64
+ code: e.code
65
+ });
66
+ }
67
+ });
68
+ }
69
+ exports.deleteProvisionedConcurrencyConfig = deleteProvisionedConcurrencyConfig;
@@ -18,3 +18,6 @@ __exportStar(require("./delete"), exports);
18
18
  __exportStar(require("./update"), exports);
19
19
  __exportStar(require("./layer"), exports);
20
20
  __exportStar(require("./vpc"), exports);
21
+ __exportStar(require("./version"), exports);
22
+ __exportStar(require("./concurrency"), exports);
23
+ __exportStar(require("./alias"), exports);
@@ -0,0 +1,51 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.listFunctionVersions = exports.publishVersion = void 0;
13
+ const error_1 = require("../error");
14
+ const base_1 = require("./base");
15
+ function publishVersion(options) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const { envId, functionName, description = '' } = options;
18
+ const scfService = yield (0, base_1.getFunctionService)(envId);
19
+ try {
20
+ yield scfService.publishVersion({
21
+ functionName,
22
+ description
23
+ });
24
+ }
25
+ catch (e) {
26
+ throw new error_1.CloudBaseError(`[${functionName}] 函数发布新版本失败: ${e.message}`, {
27
+ code: e.code
28
+ });
29
+ }
30
+ });
31
+ }
32
+ exports.publishVersion = publishVersion;
33
+ function listFunctionVersions(options) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const { envId, functionName, offset = 0, limit = 20 } = options;
36
+ const scfService = yield (0, base_1.getFunctionService)(envId);
37
+ try {
38
+ return scfService.listVersionByFunction({
39
+ functionName,
40
+ offset,
41
+ limit
42
+ });
43
+ }
44
+ catch (e) {
45
+ throw new error_1.CloudBaseError(`[${functionName}] 查看寒函数版本列表失败: ${e.message}`, {
46
+ code: e.code
47
+ });
48
+ }
49
+ });
50
+ }
51
+ exports.listFunctionVersions = listFunctionVersions;
package/lib/storage.js CHANGED
@@ -25,14 +25,11 @@ 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, retryInterval, parallel, retryCount } = options;
28
+ const { envId, localPath, cloudPath } = options;
29
29
  const storageService = yield (0, utils_1.getStorageService)(envId);
30
30
  return storageService.uploadDirectory({
31
31
  localPath,
32
- cloudPath,
33
- retryInterval,
34
- retryCount,
35
- parallel
32
+ cloudPath
36
33
  });
37
34
  });
38
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "1.9.9",
3
+ "version": "1.10.0",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -26,8 +26,8 @@
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.1",
30
- "@cloudbase/manager-node": "3.11.1-beta",
29
+ "@cloudbase/lowcode-cli": "^0.12.2",
30
+ "@cloudbase/manager-node": "3.12.0",
31
31
  "@cloudbase/toolbox": "^0.7.2",
32
32
  "@sentry/node": "^5.10.2",
33
33
  "address": "^1.1.2",
@@ -0,0 +1,76 @@
1
+
2
+ import { Command, ICommand } from '../../common'
3
+ import { loadingFactory, printHorizontalTable } from '../../../utils'
4
+ import { getFunctionAliasConfig } from '../../../function'
5
+ import { InjectParams, CmdContext, ArgsParams, ArgsOptions } from '../../../decorators'
6
+
7
+
8
+ function parseRoutingConfigValue(expression: string) {
9
+ const commaIndex = expression.indexOf(',')
10
+ const valueExpression = expression.substring(commaIndex + 1, expression.length - 1)
11
+ return valueExpression
12
+ }
13
+
14
+ @ICommand()
15
+ export class getFunctionRoutingConfig extends Command {
16
+ get options() {
17
+ return {
18
+ cmd: 'fn',
19
+ childCmd: 'get-route <name>',
20
+ options: [
21
+ {
22
+ flags: '-e, --envId <envId>',
23
+ desc: '环境 Id'
24
+ }
25
+ ],
26
+ desc: '查看函数版本流量配置'
27
+ }
28
+ }
29
+
30
+ @InjectParams()
31
+ async execute(@CmdContext() ctx, @ArgsParams() params) {
32
+ const name = params?.[0]
33
+
34
+ const {
35
+ envId
36
+ } = ctx
37
+
38
+ const loading = loadingFactory()
39
+ loading.start(`查询函数 [${name}] 版本流量配置中...`)
40
+
41
+ const aliasRes = await getFunctionAliasConfig({
42
+ envId,
43
+ functionName: name,
44
+ name: '$DEFAULT'
45
+ })
46
+
47
+ const routingConfig = aliasRes?.RoutingConfig?.AddtionVersionMatchs
48
+ let finalConfig = []
49
+ if (routingConfig.length === 1) {
50
+ finalConfig.push({
51
+ version: routingConfig[0].Version,
52
+ value: parseRoutingConfigValue(routingConfig[0].Expression)
53
+ })
54
+ } else if (routingConfig.length === 2) {
55
+ finalConfig.push({
56
+ version: routingConfig[0].Version,
57
+ value: parseRoutingConfigValue(routingConfig[0].Expression)
58
+ }, {
59
+ version: routingConfig[1].Version,
60
+ value: 100 - Number(parseRoutingConfigValue(routingConfig[0].Expression))
61
+ })
62
+ }
63
+
64
+ loading.stop()
65
+
66
+ const head: string[] = ['版本', '流量比例']
67
+
68
+ const tableData = finalConfig.map((item) => [
69
+ item.version,
70
+ item.value
71
+ ])
72
+
73
+ printHorizontalTable(head, tableData)
74
+
75
+ }
76
+ }
@@ -0,0 +1,2 @@
1
+ export * from './setRoute'
2
+ export * from './getRoute'