@cloudbase/cli 1.12.7-alpha.4 → 2.0.2

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 (120) hide show
  1. package/bin/tcb.js +6 -4
  2. package/lib/commands/run/create.js +6 -1
  3. package/lib/commands/run/delete.js +6 -1
  4. package/lib/commands/run/image/common.js +1 -1
  5. package/lib/commands/run/image/delete.js +5 -0
  6. package/lib/commands/run/image/download.js +5 -0
  7. package/lib/commands/run/image/list.js +5 -0
  8. package/lib/commands/run/image/upload.js +5 -0
  9. package/lib/commands/run/index.js +1 -0
  10. package/lib/commands/run/list.js +7 -1
  11. package/lib/commands/run/service/config.js +112 -0
  12. package/lib/commands/run/service/create.js +140 -0
  13. package/lib/commands/run/service/deploy.js +145 -0
  14. package/lib/commands/run/service/index.js +21 -0
  15. package/lib/commands/run/service/list.js +115 -0
  16. package/lib/commands/run/service/update.js +132 -0
  17. package/lib/commands/run/version/common.js +1 -1
  18. package/lib/commands/run/version/create.js +5 -0
  19. package/lib/commands/run/version/delete.js +5 -0
  20. package/lib/commands/run/version/list.js +5 -0
  21. package/lib/commands/run/version/modify.js +5 -0
  22. package/lib/commands/run/version/update.js +5 -0
  23. package/lib/constant.js +20 -1
  24. package/lib/help.js +40 -38
  25. package/lib/run/index.js +1 -0
  26. package/lib/run/service/common.js +163 -0
  27. package/lib/run/service/config.js +70 -0
  28. package/lib/run/service/create.js +67 -0
  29. package/lib/run/service/deployPackage.js +89 -0
  30. package/lib/run/service/index.js +23 -0
  31. package/lib/run/service/list.js +31 -0
  32. package/lib/run/service/showLogs.js +116 -0
  33. package/lib/run/service/update.js +83 -0
  34. package/lib/utils/checkTcbrEnv.js +74 -0
  35. package/lib/utils/commonParamsCheck.js +48 -0
  36. package/lib/utils/index.js +3 -0
  37. package/lib/utils/net/http-request.js +4 -4
  38. package/lib/utils/tcbrApi/callTcbrApi.js +38 -0
  39. package/lib/utils/tcbrApi/index.js +17 -0
  40. package/lib/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.js +268 -0
  41. package/lib/utils/tcbrApi/tcbr-cloud-api/error.js +17 -0
  42. package/lib/utils/tcbrApi/tcbr-cloud-api/index.js +17 -0
  43. package/lib/utils/tcbrApi/tcbr-cloud-api/request.js +40 -0
  44. package/lib/utils/tcbrApi/tcbr-cloud-api-request.js +61 -0
  45. package/lib/utils/validator.js +32 -1
  46. package/package.json +88 -88
  47. package/src/commands/run/create.ts +9 -2
  48. package/src/commands/run/delete.ts +8 -2
  49. package/src/commands/run/image/common.ts +1 -1
  50. package/src/commands/run/image/delete.ts +8 -1
  51. package/src/commands/run/image/download.ts +7 -1
  52. package/src/commands/run/image/list.ts +7 -2
  53. package/src/commands/run/image/upload.ts +8 -1
  54. package/src/commands/run/index.ts +2 -1
  55. package/src/commands/run/list.ts +11 -3
  56. package/src/commands/run/service/config.ts +81 -0
  57. package/src/commands/run/service/create.ts +118 -0
  58. package/src/commands/run/service/deploy.ts +121 -0
  59. package/src/commands/run/service/index.ts +5 -0
  60. package/src/commands/run/service/list.ts +94 -0
  61. package/src/commands/run/service/update.ts +104 -0
  62. package/src/commands/run/version/common.ts +1 -1
  63. package/src/commands/run/version/create.ts +8 -1
  64. package/src/commands/run/version/delete.ts +8 -2
  65. package/src/commands/run/version/list.ts +7 -1
  66. package/src/commands/run/version/modify.ts +8 -1
  67. package/src/commands/run/version/update.ts +8 -1
  68. package/src/constant.ts +35 -1
  69. package/src/help.ts +50 -48
  70. package/src/run/index.ts +2 -1
  71. package/src/run/service/common.ts +206 -0
  72. package/src/run/service/config.ts +77 -0
  73. package/src/run/service/create.ts +52 -0
  74. package/src/run/service/deployPackage.ts +65 -0
  75. package/src/run/service/index.ts +7 -0
  76. package/src/run/service/list.ts +29 -0
  77. package/src/run/service/showLogs.ts +98 -0
  78. package/src/run/service/update.ts +81 -0
  79. package/src/types.ts +128 -2
  80. package/src/utils/checkTcbrEnv.ts +67 -0
  81. package/src/utils/commonParamsCheck.ts +65 -0
  82. package/src/utils/index.ts +5 -1
  83. package/src/utils/net/http-request.ts +1 -1
  84. package/src/utils/tcbrApi/callTcbrApi.ts +28 -0
  85. package/src/utils/tcbrApi/index.ts +1 -0
  86. package/src/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.ts +363 -0
  87. package/src/utils/tcbrApi/tcbr-cloud-api/error.ts +30 -0
  88. package/src/utils/tcbrApi/tcbr-cloud-api/index.ts +1 -0
  89. package/src/utils/tcbrApi/tcbr-cloud-api/request.ts +28 -0
  90. package/src/utils/tcbrApi/tcbr-cloud-api-request.ts +66 -0
  91. package/src/utils/validator.ts +64 -32
  92. package/types/commands/run/index.d.ts +1 -0
  93. package/types/commands/run/service/config.d.ts +14 -0
  94. package/types/commands/run/service/create.d.ts +13 -0
  95. package/types/commands/run/service/deploy.d.ts +13 -0
  96. package/types/commands/run/service/index.d.ts +5 -0
  97. package/types/commands/run/service/list.d.ts +13 -0
  98. package/types/commands/run/service/update.d.ts +13 -0
  99. package/types/constant.d.ts +18 -0
  100. package/types/run/index.d.ts +1 -0
  101. package/types/run/service/common.d.ts +32 -0
  102. package/types/run/service/config.d.ts +23 -0
  103. package/types/run/service/create.d.ts +7 -0
  104. package/types/run/service/deployPackage.d.ts +11 -0
  105. package/types/run/service/index.d.ts +7 -0
  106. package/types/run/service/list.d.ts +2 -0
  107. package/types/run/service/showLogs.d.ts +2 -0
  108. package/types/run/service/update.d.ts +2 -0
  109. package/types/types.d.ts +116 -2
  110. package/types/utils/checkTcbrEnv.d.ts +3 -0
  111. package/types/utils/commonParamsCheck.d.ts +3 -0
  112. package/types/utils/index.d.ts +3 -0
  113. package/types/utils/tcbrApi/callTcbrApi.d.ts +1 -0
  114. package/types/utils/tcbrApi/index.d.ts +1 -0
  115. package/types/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.d.ts +51 -0
  116. package/types/utils/tcbrApi/tcbr-cloud-api/error.d.ts +20 -0
  117. package/types/utils/tcbrApi/tcbr-cloud-api/index.d.ts +1 -0
  118. package/types/utils/tcbrApi/tcbr-cloud-api/request.d.ts +4 -0
  119. package/types/utils/tcbrApi/tcbr-cloud-api-request.d.ts +9 -0
  120. package/types/utils/validator.d.ts +4 -0
package/bin/tcb.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  const os = require('os')
3
- const yargs = require('yargs')
3
+ const yargsParser = require('yargs-parser')
4
4
  const chalk = require('chalk')
5
5
  const address = require('address')
6
6
  const { program } = require('commander')
@@ -72,8 +72,10 @@ program.option('-r, --region <region>', '指定环境地域')
72
72
 
73
73
  // HACK: 隐藏自动生成的 help 信息
74
74
  program.helpOption(false)
75
+ const isCommandEmpty = yargsParser(process.argv.slice(2))._.length === 0;
76
+
75
77
  // -v 时输出的版本信息,设置时避免影响其他命令使用 -v
76
- if (yargs.argv._.length === 0) {
78
+ if (isCommandEmpty) {
77
79
  program.version(
78
80
  `\nCLI: ${pkg.version}\nFramework: ${frameworkPkg.version}`,
79
81
  '-v, --version',
@@ -99,7 +101,7 @@ program.action((command) => {
99
101
  })
100
102
 
101
103
  // 没有使用命令
102
- if (yargs.argv._.length === 0) {
104
+ if (isCommandEmpty) {
103
105
  if (['-h', '--help'].includes(processArgv[2])) {
104
106
  // 需要隐藏的选项
105
107
  const hideArgs = ['-h', '--help']
@@ -111,7 +113,7 @@ if (yargs.argv._.length === 0) {
111
113
  })
112
114
  const { outputHelpInfo } = require('../lib/help')
113
115
  outputHelpInfo()
114
- } else if (!['-v', '--help'].includes(processArgv[2])) {
116
+ } else if (!['-v', '--version'].includes(processArgv[2])) {
115
117
  // HACK: framework 智能命令
116
118
  const { smartDeploy } = require('../lib')
117
119
  smartDeploy()
@@ -34,7 +34,7 @@ const ZoneMap = {
34
34
  let CreateRun = class CreateRun extends common_1.Command {
35
35
  get options() {
36
36
  return {
37
- cmd: 'run',
37
+ cmd: 'run:deprecated',
38
38
  childCmd: 'create',
39
39
  options: [
40
40
  {
@@ -67,6 +67,11 @@ let CreateRun = class CreateRun extends common_1.Command {
67
67
  }
68
68
  execute(envId, options) {
69
69
  return __awaiter(this, void 0, void 0, function* () {
70
+ let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, false);
71
+ if (envCheckType !== 0) {
72
+ (0, utils_1.logEnvCheck)(envId, envCheckType);
73
+ return;
74
+ }
70
75
  let { name: _name = '', vpc: _vpc = '', repo: _repo = '', log: _log = '', remark: _remark = '', publicAccess: _publicAccess = '' } = options;
71
76
  let name;
72
77
  let remark;
@@ -31,7 +31,7 @@ const utils_1 = require("../../utils");
31
31
  let DeleteRun = class DeleteRun extends common_1.Command {
32
32
  get options() {
33
33
  return {
34
- cmd: 'run',
34
+ cmd: 'run:deprecated',
35
35
  childCmd: 'delete',
36
36
  options: [
37
37
  {
@@ -48,6 +48,11 @@ let DeleteRun = class DeleteRun extends common_1.Command {
48
48
  }
49
49
  execute(envId, options) {
50
50
  return __awaiter(this, void 0, void 0, function* () {
51
+ let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, false);
52
+ if (envCheckType !== 0) {
53
+ (0, utils_1.logEnvCheck)(envId, envCheckType);
54
+ return;
55
+ }
51
56
  let { serviceName = '' } = options;
52
57
  if (serviceName.length === 0) {
53
58
  throw new error_1.CloudBaseError('必须输入服务名');
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.imageCommonOptions = void 0;
4
4
  const imageCommonOptions = (sub) => ({
5
- cmd: 'run',
5
+ cmd: 'run:deprecated',
6
6
  childCmd: {
7
7
  cmd: 'image',
8
8
  desc: '云托管镜像管理'
@@ -47,6 +47,11 @@ let DeleteImage = class DeleteImage extends common_1.Command {
47
47
  }
48
48
  execute(envId, options) {
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
+ let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, false);
51
+ if (envCheckType !== 0) {
52
+ (0, utils_1.logEnvCheck)(envId, envCheckType);
53
+ return;
54
+ }
50
55
  let { serviceName = '', imageTag = '' } = options;
51
56
  if (serviceName.length === 0 || imageTag.length === 0) {
52
57
  throw new error_1.CloudBaseError('必须输入 serviceName 和 imageTag');
@@ -48,6 +48,11 @@ let DownLoadImage = class DownLoadImage extends common_1.Command {
48
48
  }
49
49
  execute(envId, options) {
50
50
  return __awaiter(this, void 0, void 0, function* () {
51
+ let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, false);
52
+ if (envCheckType !== 0) {
53
+ (0, utils_1.logEnvCheck)(envId, envCheckType);
54
+ return;
55
+ }
51
56
  let { serviceName = '', imageTag = '' } = options;
52
57
  if (serviceName.length === 0 || imageTag.length === 0) {
53
58
  throw new error_1.CloudBaseError('必须输入 serviceName 和 imageTag');
@@ -51,6 +51,11 @@ let ListImage = class ListImage extends common_1.Command {
51
51
  }
52
52
  execute(envId, options) {
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
+ let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, false);
55
+ if (envCheckType !== 0) {
56
+ (0, utils_1.logEnvCheck)(envId, envCheckType);
57
+ return;
58
+ }
54
59
  let { limit = 20, offset = 0, serviceName = '' } = options;
55
60
  limit = Number(limit);
56
61
  offset = Number(offset);
@@ -76,6 +76,11 @@ let UploadImage = class UploadImage extends common_1.Command {
76
76
  }
77
77
  execute(envId, options) {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
+ let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, false);
80
+ if (envCheckType !== 0) {
81
+ (0, utils_1.logEnvCheck)(envId, envCheckType);
82
+ return;
83
+ }
79
84
  const { serviceName = '', imageId = '', imageTag = '' } = options;
80
85
  if (serviceName.length === 0 || imageId.length === 0 || imageTag.length === 0) {
81
86
  throw new error_1.CloudBaseError('必须输入 serviceName 和 imageId 和 imageTag');
@@ -20,3 +20,4 @@ __exportStar(require("./version"), exports);
20
20
  __exportStar(require("./delete"), exports);
21
21
  __exportStar(require("./image"), exports);
22
22
  __exportStar(require("./standalonegateway"), exports);
23
+ __exportStar(require("./service"), exports);
@@ -27,13 +27,14 @@ const error_1 = require("../../error");
27
27
  const run_1 = require("../../run");
28
28
  const utils_1 = require("../../utils");
29
29
  const decorators_1 = require("../../decorators");
30
+ const utils_2 = require("../../utils");
30
31
  const StatusMap = {
31
32
  succ: '正常'
32
33
  };
33
34
  let ListRun = class ListRun extends common_1.Command {
34
35
  get options() {
35
36
  return {
36
- cmd: 'run',
37
+ cmd: 'run:deprecated',
37
38
  childCmd: 'list',
38
39
  options: [
39
40
  {
@@ -54,6 +55,11 @@ let ListRun = class ListRun extends common_1.Command {
54
55
  }
55
56
  execute(envId, options) {
56
57
  return __awaiter(this, void 0, void 0, function* () {
58
+ let envCheckType = yield (0, utils_2.checkTcbrEnv)(options.envId, false);
59
+ if (envCheckType !== 0) {
60
+ (0, utils_2.logEnvCheck)(envId, envCheckType);
61
+ return;
62
+ }
57
63
  let { limit = 20, offset = 0 } = options;
58
64
  limit = Number(limit);
59
65
  offset = Number(offset);
@@ -0,0 +1,112 @@
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.ConfigServiceTcbr = void 0;
25
+ const common_1 = require("../../common");
26
+ const decorators_1 = require("../../../decorators");
27
+ const run_1 = require("../../../run");
28
+ const utils_1 = require("../../../utils");
29
+ let ConfigServiceTcbr = class ConfigServiceTcbr extends common_1.Command {
30
+ get options() {
31
+ return {
32
+ cmd: 'run',
33
+ childCmd: 'service:config',
34
+ options: [
35
+ {
36
+ flags: '-e, --envId <envId>',
37
+ desc: '环境 Id,必填'
38
+ },
39
+ {
40
+ flags: '-s, --serviceName <serviceName>',
41
+ desc: '服务名,必填'
42
+ },
43
+ {
44
+ flags: '--cpu <cpu>',
45
+ desc: '单一实例cpu规格,默认0.5'
46
+ },
47
+ {
48
+ flags: '--mem <mem>',
49
+ desc: '单一实例内存规格,默认1'
50
+ },
51
+ {
52
+ flags: '--minNum <minNum>',
53
+ desc: '最小副本数,默认0'
54
+ },
55
+ {
56
+ flags: '--maxNum <maxNum>',
57
+ desc: '最大副本数,默认50,不能大于50'
58
+ },
59
+ {
60
+ flags: '--policyDetails <policyDetails>',
61
+ desc: '扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60'
62
+ },
63
+ {
64
+ flags: '--customLogs <customLogs>',
65
+ desc: '日志采集路径,默认stdout'
66
+ },
67
+ {
68
+ flags: '--envParams <envParams>',
69
+ desc: '环境变量,格式为xx=a&yy=b,默认为空'
70
+ },
71
+ {
72
+ flags: '--json',
73
+ desc: '以 JSON 形式展示结果'
74
+ }
75
+ ],
76
+ desc: '指定环境和服务,更新服务的基础配置'
77
+ };
78
+ }
79
+ execute(options, log) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, true);
82
+ if (envCheckType !== 0) {
83
+ (0, utils_1.logEnvCheck)(options.envId, envCheckType);
84
+ return;
85
+ }
86
+ const newServiceConfig = yield (0, run_1.tcbrServiceConfigOptions)(options);
87
+ const configRes = yield (0, run_1.updateCloudRunServerConfig)({
88
+ envId: options.envId,
89
+ serviceName: options.serviceName,
90
+ ServerBaseConfig: newServiceConfig
91
+ });
92
+ if (options.json) {
93
+ console.log(JSON.stringify(configRes, null, 2));
94
+ }
95
+ else {
96
+ log.success('更新配置信息成功');
97
+ }
98
+ });
99
+ }
100
+ };
101
+ __decorate([
102
+ (0, decorators_1.InjectParams)(),
103
+ __param(0, (0, decorators_1.ArgsOptions)()),
104
+ __param(1, (0, decorators_1.Log)()),
105
+ __metadata("design:type", Function),
106
+ __metadata("design:paramtypes", [Object, decorators_1.Logger]),
107
+ __metadata("design:returntype", Promise)
108
+ ], ConfigServiceTcbr.prototype, "execute", null);
109
+ ConfigServiceTcbr = __decorate([
110
+ (0, common_1.ICommand)()
111
+ ], ConfigServiceTcbr);
112
+ exports.ConfigServiceTcbr = ConfigServiceTcbr;
@@ -0,0 +1,140 @@
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.CreateServiceTcbr = void 0;
25
+ const common_1 = require("../../common");
26
+ const decorators_1 = require("../../../decorators");
27
+ const error_1 = require("../../../error");
28
+ const run_1 = require("../../../run");
29
+ const utils_1 = require("../../../utils");
30
+ let CreateServiceTcbr = class CreateServiceTcbr extends common_1.Command {
31
+ get options() {
32
+ return {
33
+ cmd: 'run',
34
+ childCmd: 'service:create',
35
+ options: [
36
+ {
37
+ flags: '--noConfirm',
38
+ desc: '发布前是否跳过二次确认'
39
+ },
40
+ {
41
+ flags: '--override',
42
+ desc: '缺省的参数是否沿用旧版本配置'
43
+ },
44
+ {
45
+ flags: '-e, --envId <envId>',
46
+ desc: '环境 Id,必填'
47
+ },
48
+ {
49
+ flags: '-s, --serviceName <serviceName>',
50
+ desc: '服务名,必填'
51
+ },
52
+ {
53
+ flags: '--path <path>',
54
+ desc: '本地代码根目录'
55
+ },
56
+ {
57
+ flags: '--cpu <cpu>',
58
+ desc: '单一实例cpu规格,默认0.5'
59
+ },
60
+ {
61
+ flags: '--mem <mem>',
62
+ desc: '单一实例内存规格,默认1'
63
+ },
64
+ {
65
+ flags: '--minNum <minNum>',
66
+ desc: '最小副本数,默认0'
67
+ },
68
+ {
69
+ flags: '--maxNum <maxNum>',
70
+ desc: '最大副本数,默认50,不能大于50'
71
+ },
72
+ {
73
+ flags: '--policyDetails <policyDetails>',
74
+ desc: '扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60'
75
+ },
76
+ {
77
+ flags: '--customLogs <customLogs>',
78
+ desc: '日志采集路径,默认stdout'
79
+ },
80
+ {
81
+ flags: '--envParams <envParams>',
82
+ desc: '环境变量,格式为xx=a&yy=b,默认为空'
83
+ },
84
+ {
85
+ flags: '--containerPort <containerPort>',
86
+ desc: '监听端口,必填'
87
+ },
88
+ {
89
+ flags: '--remark <remark>',
90
+ desc: '版本备注,默认为空'
91
+ },
92
+ {
93
+ flags: '--targetDir <targetDir>',
94
+ desc: '目标目录'
95
+ },
96
+ {
97
+ flags: '--dockerfile <dockerfile>',
98
+ desc: 'Dockerfile文件名,默认为 Dockerfile'
99
+ },
100
+ {
101
+ flags: '--image <image>',
102
+ desc: '镜像标签或ID'
103
+ },
104
+ {
105
+ flags: '--json',
106
+ desc: '以 JSON 形式展示结果'
107
+ }
108
+ ],
109
+ desc: '在指定环境下创建服务'
110
+ };
111
+ }
112
+ execute(options) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, true);
115
+ if (envCheckType !== 0) {
116
+ (0, utils_1.logEnvCheck)(options.envId, envCheckType);
117
+ return;
118
+ }
119
+ const { data: serviceDetail } = yield (0, run_1.describeCloudRunServerDetail)({
120
+ envId: options.envId,
121
+ serviceName: options.serviceName
122
+ });
123
+ if (serviceDetail !== undefined) {
124
+ throw new error_1.CloudBaseError('当前服务已存在,请使用 tcb run service:deploy 更新服务');
125
+ }
126
+ yield (0, run_1.createTcbrService)(options);
127
+ });
128
+ }
129
+ };
130
+ __decorate([
131
+ (0, decorators_1.InjectParams)(),
132
+ __param(0, (0, decorators_1.ArgsOptions)()),
133
+ __metadata("design:type", Function),
134
+ __metadata("design:paramtypes", [Object]),
135
+ __metadata("design:returntype", Promise)
136
+ ], CreateServiceTcbr.prototype, "execute", null);
137
+ CreateServiceTcbr = __decorate([
138
+ (0, common_1.ICommand)()
139
+ ], CreateServiceTcbr);
140
+ exports.CreateServiceTcbr = CreateServiceTcbr;
@@ -0,0 +1,145 @@
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.DeployServiceTcbr = void 0;
25
+ const common_1 = require("../../common");
26
+ const decorators_1 = require("../../../decorators");
27
+ const run_1 = require("../../../run");
28
+ const utils_1 = require("../../../utils");
29
+ let DeployServiceTcbr = class DeployServiceTcbr extends common_1.Command {
30
+ get options() {
31
+ return {
32
+ cmd: 'run',
33
+ childCmd: 'deploy',
34
+ options: [
35
+ {
36
+ flags: '--noConfirm',
37
+ desc: '发布前是否跳过二次确认'
38
+ },
39
+ {
40
+ flags: '--override',
41
+ desc: '缺省的参数是否沿用旧版本配置'
42
+ },
43
+ {
44
+ flags: '-e, --envId <envId>',
45
+ desc: '环境 Id,必填'
46
+ },
47
+ {
48
+ flags: '-s, --serviceName <serviceName>',
49
+ desc: '服务名,必填'
50
+ },
51
+ {
52
+ flags: '--path <path>',
53
+ desc: '本地代码根目录'
54
+ },
55
+ {
56
+ flags: '--cpu <cpu>',
57
+ desc: '单一实例cpu规格,默认0.5'
58
+ },
59
+ {
60
+ flags: '--mem <mem>',
61
+ desc: '单一实例内存规格,默认1'
62
+ },
63
+ {
64
+ flags: '--minNum <minNum>',
65
+ desc: '最小副本数,默认0'
66
+ },
67
+ {
68
+ flags: '--maxNum <maxNum>',
69
+ desc: '最大副本数,默认50,不能大于50'
70
+ },
71
+ {
72
+ flags: '--policyDetails <policyDetails>',
73
+ desc: '扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60'
74
+ },
75
+ {
76
+ flags: '--customLogs <customLogs>',
77
+ desc: '日志采集路径,默认stdout'
78
+ },
79
+ {
80
+ flags: '--envParams <envParams>',
81
+ desc: '环境变量,格式为xx=a&yy=b,默认为空'
82
+ },
83
+ {
84
+ flags: '--containerPort <containerPort>',
85
+ desc: '监听端口,必填'
86
+ },
87
+ {
88
+ flags: '--remark <remark>',
89
+ desc: '版本备注,默认为空'
90
+ },
91
+ {
92
+ flags: '--targetDir <targetDir>',
93
+ desc: '目标目录'
94
+ },
95
+ {
96
+ flags: '--dockerfile <dockerfile>',
97
+ desc: 'Dockerfile文件名,默认为 Dockerfile'
98
+ },
99
+ {
100
+ flags: '--library_image <library_image>',
101
+ desc: '线上镜像仓库的 tag,仅在服务已存在时可用'
102
+ },
103
+ {
104
+ flags: '--image <image>',
105
+ desc: '镜像标签或ID'
106
+ },
107
+ {
108
+ flags: '--json',
109
+ desc: '以 JSON 形式展示结果'
110
+ }
111
+ ],
112
+ desc: '在指定的环境部署服务'
113
+ };
114
+ }
115
+ execute(options) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, true);
118
+ if (envCheckType !== 0) {
119
+ (0, utils_1.logEnvCheck)(options.envId, envCheckType);
120
+ return;
121
+ }
122
+ const { data: serviceDetail } = yield (0, run_1.describeCloudRunServerDetail)({
123
+ envId: options.envId,
124
+ serviceName: options.serviceName
125
+ });
126
+ if (serviceDetail === undefined) {
127
+ yield (0, run_1.createTcbrService)(options);
128
+ }
129
+ else {
130
+ yield (0, run_1.updateTcbrService)(options);
131
+ }
132
+ });
133
+ }
134
+ };
135
+ __decorate([
136
+ (0, decorators_1.InjectParams)(),
137
+ __param(0, (0, decorators_1.ArgsOptions)()),
138
+ __metadata("design:type", Function),
139
+ __metadata("design:paramtypes", [Object]),
140
+ __metadata("design:returntype", Promise)
141
+ ], DeployServiceTcbr.prototype, "execute", null);
142
+ DeployServiceTcbr = __decorate([
143
+ (0, common_1.ICommand)()
144
+ ], DeployServiceTcbr);
145
+ exports.DeployServiceTcbr = DeployServiceTcbr;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./list"), exports);
18
+ __exportStar(require("./create"), exports);
19
+ __exportStar(require("./update"), exports);
20
+ __exportStar(require("./deploy"), exports);
21
+ __exportStar(require("./config"), exports);