@cloudbase/cli 2.10.0-beta.0 → 2.11.0-beta.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 (205) hide show
  1. package/lib/auth/login.js +51 -65
  2. package/lib/auth/logout.js +3 -14
  3. package/lib/commands/account/login.js +136 -149
  4. package/lib/commands/account/logout.js +3 -14
  5. package/lib/commands/ag/base.js +203 -0
  6. package/lib/commands/ag/create.js +301 -0
  7. package/lib/commands/ag/debug/index.html +699 -0
  8. package/lib/commands/ag/delete.js +200 -0
  9. package/lib/commands/ag/deploy.js +185 -0
  10. package/lib/commands/ag/detail.js +113 -0
  11. package/lib/commands/ag/index.js +22 -0
  12. package/lib/commands/ag/list.js +155 -0
  13. package/lib/commands/ag/run.js +644 -0
  14. package/lib/commands/ai/index.js +76 -95
  15. package/lib/commands/cloudfunction/base.js +182 -203
  16. package/lib/commands/cloudrun/base.js +578 -603
  17. package/lib/commands/common.js +48 -63
  18. package/lib/commands/config/delete.js +16 -27
  19. package/lib/commands/config/get.js +13 -24
  20. package/lib/commands/config/list.js +16 -27
  21. package/lib/commands/config/set.js +33 -44
  22. package/lib/commands/db/base.js +221 -240
  23. package/lib/commands/env/base.js +36 -49
  24. package/lib/commands/env/domain.js +79 -94
  25. package/lib/commands/env/login.js +120 -135
  26. package/lib/commands/framework/index.js +32 -49
  27. package/lib/commands/fun/base.js +223 -244
  28. package/lib/commands/functions/alias/getRoute.js +33 -44
  29. package/lib/commands/functions/alias/setRoute.js +36 -47
  30. package/lib/commands/functions/code-download.js +43 -54
  31. package/lib/commands/functions/code-update.js +23 -34
  32. package/lib/commands/functions/concurrency/delete.js +11 -22
  33. package/lib/commands/functions/concurrency/list.js +20 -31
  34. package/lib/commands/functions/concurrency/set.js +13 -24
  35. package/lib/commands/functions/config-update.js +30 -41
  36. package/lib/commands/functions/copy.js +12 -23
  37. package/lib/commands/functions/delete.js +30 -41
  38. package/lib/commands/functions/deploy.js +184 -202
  39. package/lib/commands/functions/detail.js +23 -34
  40. package/lib/commands/functions/invoke.js +69 -75
  41. package/lib/commands/functions/layer/bind.js +102 -105
  42. package/lib/commands/functions/layer/create.js +29 -35
  43. package/lib/commands/functions/layer/delete.js +42 -48
  44. package/lib/commands/functions/layer/download.js +52 -58
  45. package/lib/commands/functions/layer/list.js +44 -50
  46. package/lib/commands/functions/layer/sort.js +39 -45
  47. package/lib/commands/functions/list.js +25 -36
  48. package/lib/commands/functions/log.js +65 -73
  49. package/lib/commands/functions/run.js +118 -116
  50. package/lib/commands/functions/trigger-create.js +32 -43
  51. package/lib/commands/functions/trigger-delete.js +50 -61
  52. package/lib/commands/functions/version/list.js +29 -40
  53. package/lib/commands/functions/version/publish.js +11 -22
  54. package/lib/commands/gateway/create.js +50 -61
  55. package/lib/commands/gateway/delete.js +38 -49
  56. package/lib/commands/gateway/domain.js +65 -80
  57. package/lib/commands/gateway/list.js +31 -42
  58. package/lib/commands/gateway/switch.js +48 -61
  59. package/lib/commands/helpers/init.js +226 -249
  60. package/lib/commands/helpers/new.js +35 -46
  61. package/lib/commands/helpers/open.js +22 -33
  62. package/lib/commands/hosting/hosting.js +157 -178
  63. package/lib/commands/index.js +1 -0
  64. package/lib/commands/lowcode/app.js +114 -144
  65. package/lib/commands/lowcode/comps.js +136 -127
  66. package/lib/commands/lowcode/utils.js +11 -22
  67. package/lib/commands/pull/pull.js +33 -46
  68. package/lib/commands/run/delete.js +35 -46
  69. package/lib/commands/run/image/delete.js +32 -39
  70. package/lib/commands/run/image/download.js +26 -33
  71. package/lib/commands/run/image/list.js +41 -48
  72. package/lib/commands/run/image/upload.js +26 -33
  73. package/lib/commands/run/list.js +32 -43
  74. package/lib/commands/run/service/config.js +17 -28
  75. package/lib/commands/run/service/deploy.js +15 -26
  76. package/lib/commands/run/service/list.js +48 -59
  77. package/lib/commands/run/service/update.js +7 -18
  78. package/lib/commands/run/standalonegateway/create.js +35 -42
  79. package/lib/commands/run/standalonegateway/destroy.js +23 -30
  80. package/lib/commands/run/standalonegateway/list.js +19 -26
  81. package/lib/commands/run/standalonegateway/package.js +31 -38
  82. package/lib/commands/run/standalonegateway/turn.js +27 -34
  83. package/lib/commands/run/version/create.js +198 -205
  84. package/lib/commands/run/version/delete.js +31 -38
  85. package/lib/commands/run/version/list.js +42 -49
  86. package/lib/commands/run/version/modify.js +27 -34
  87. package/lib/commands/run/version/update.js +201 -208
  88. package/lib/commands/runf/base.js +216 -237
  89. package/lib/commands/self-update.js +59 -72
  90. package/lib/commands/smart.js +66 -79
  91. package/lib/commands/storage/storage.js +192 -219
  92. package/lib/commands/third/thirdAttach.js +16 -27
  93. package/lib/commands/utils.js +119 -149
  94. package/lib/db/index.js +48 -67
  95. package/lib/decorators/captureError.js +10 -21
  96. package/lib/decorators/guard.js +11 -22
  97. package/lib/decorators/injectParams.js +29 -40
  98. package/lib/decorators/params/common.js +5 -2
  99. package/lib/decorators/params/index.js +3 -12
  100. package/lib/env/domain.js +13 -28
  101. package/lib/env/index.js +25 -44
  102. package/lib/env/login.js +30 -45
  103. package/lib/function/alias.js +31 -44
  104. package/lib/function/base.js +187 -215
  105. package/lib/function/code.js +8 -19
  106. package/lib/function/concurrency.js +43 -58
  107. package/lib/function/create.js +43 -53
  108. package/lib/function/delete.js +22 -35
  109. package/lib/function/layer/attach.js +33 -46
  110. package/lib/function/layer/create.js +34 -45
  111. package/lib/function/layer/delete.js +5 -16
  112. package/lib/function/layer/download.js +11 -22
  113. package/lib/function/layer/list.js +12 -25
  114. package/lib/function/layer/sort.js +6 -17
  115. package/lib/function/trigger.js +65 -82
  116. package/lib/function/update.js +24 -32
  117. package/lib/function/version.js +29 -42
  118. package/lib/function/vpc.js +12 -25
  119. package/lib/gateway/index.js +77 -104
  120. package/lib/hosting.js +157 -188
  121. package/lib/run/delete.js +3 -12
  122. package/lib/run/image/build.js +6 -15
  123. package/lib/run/image/delete.js +3 -12
  124. package/lib/run/image/info.js +3 -12
  125. package/lib/run/image/list.js +6 -15
  126. package/lib/run/list.js +19 -30
  127. package/lib/run/repo.js +6 -15
  128. package/lib/run/service/common.js +160 -173
  129. package/lib/run/service/config.js +44 -57
  130. package/lib/run/service/deployPackage.js +33 -44
  131. package/lib/run/service/list.js +8 -14
  132. package/lib/run/service/showLogs.js +69 -90
  133. package/lib/run/service/update.js +50 -63
  134. package/lib/run/standalonegateway/create.js +3 -12
  135. package/lib/run/standalonegateway/destroy.js +3 -12
  136. package/lib/run/standalonegateway/list.js +3 -12
  137. package/lib/run/standalonegateway/package/list.js +3 -12
  138. package/lib/run/standalonegateway/turn/off.js +3 -12
  139. package/lib/run/standalonegateway/turn/on.js +3 -12
  140. package/lib/run/version/create.js +41 -31
  141. package/lib/run/version/delete.js +3 -12
  142. package/lib/run/version/list.js +3 -12
  143. package/lib/run/version/modify.js +3 -12
  144. package/lib/run/version/repo.js +6 -15
  145. package/lib/run/version/update.js +37 -26
  146. package/lib/storage.js +62 -93
  147. package/lib/third/index.js +6 -17
  148. package/lib/utils/ai/banner.js +49 -60
  149. package/lib/utils/ai/claudeWindows.js +2 -2
  150. package/lib/utils/ai/config.js +169 -206
  151. package/lib/utils/ai/ensureFiles.js +6 -17
  152. package/lib/utils/ai/env.js +16 -27
  153. package/lib/utils/ai/envLocalManager.js +35 -52
  154. package/lib/utils/ai/router.js +927 -1005
  155. package/lib/utils/ai/setup.js +527 -563
  156. package/lib/utils/auth.js +3 -14
  157. package/lib/utils/checkTcbrEnv.js +20 -31
  158. package/lib/utils/cli-table.js +6 -1
  159. package/lib/utils/config.js +4 -13
  160. package/lib/utils/dts.js +98 -113
  161. package/lib/utils/env.js +154 -175
  162. package/lib/utils/function-packer.js +29 -42
  163. package/lib/utils/log.js +10 -21
  164. package/lib/utils/mcp-config-modifier.js +105 -120
  165. package/lib/utils/net/cloud-api-request.js +15 -23
  166. package/lib/utils/net/credential.js +26 -39
  167. package/lib/utils/net/http-request.js +63 -80
  168. package/lib/utils/net/manager-service.js +22 -35
  169. package/lib/utils/notice.js +16 -27
  170. package/lib/utils/output/loading.js +3 -12
  171. package/lib/utils/parallel.js +32 -43
  172. package/lib/utils/platform/mac.js +4 -15
  173. package/lib/utils/platform/port.js +4 -15
  174. package/lib/utils/prompt/select.js +6 -15
  175. package/lib/utils/report.js +28 -33
  176. package/lib/utils/reporter/agree.js +11 -22
  177. package/lib/utils/reporter/download.js +17 -28
  178. package/lib/utils/reporter/usage.js +12 -23
  179. package/lib/utils/store/auth.js +17 -30
  180. package/lib/utils/store/config.js +11 -25
  181. package/lib/utils/store/db.js +17 -36
  182. package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
  183. package/lib/utils/template-manager.js +215 -242
  184. package/lib/utils/template.js +81 -96
  185. package/lib/utils/tools/common.js +45 -56
  186. package/lib/utils/tools/time.js +5 -16
  187. package/lib/utils/url.js +10 -4
  188. package/package.json +2 -2
  189. package/specs/ag-command/design.md +421 -0
  190. package/specs/ag-command/doc.md +204 -0
  191. package/specs/ag-command/requirements.md +173 -0
  192. package/specs/ag-command/summary.md +174 -0
  193. package/specs/ag-command/tasks.md +197 -0
  194. package/specs/ag-command/usage-guide.md +420 -0
  195. package/tsconfig.json +1 -1
  196. package/types/commands/ag/base.d.ts +44 -0
  197. package/types/commands/ag/create.d.ts +25 -0
  198. package/types/commands/ag/delete.d.ts +32 -0
  199. package/types/commands/ag/deploy.d.ts +31 -0
  200. package/types/commands/ag/detail.d.ts +28 -0
  201. package/types/commands/ag/index.d.ts +6 -0
  202. package/types/commands/ag/list.d.ts +35 -0
  203. package/types/commands/ag/run.d.ts +52 -0
  204. package/types/commands/cloudrun/base.d.ts +10 -0
  205. package/types/commands/index.d.ts +1 -0
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
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
14
  Object.defineProperty(exports, "__esModule", { value: true });
24
15
  exports.CreateService = void 0;
25
16
  const enquirer_1 = require("enquirer");
@@ -54,61 +45,59 @@ let CreateService = class CreateService extends common_1.Command {
54
45
  desc: (0, i18n_1.t)('创建 HTTP 访问服务')
55
46
  };
56
47
  }
57
- execute(envId, options) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const functionsService = yield (0, function_1.getFunctionService)(envId);
60
- let { function: functionName, servicePath } = options;
61
- const loading = (0, utils_1.loadingFactory)();
62
- if (!servicePath || !functionName) {
63
- loading.start((0, i18n_1.t)('数据加载中...'));
64
- const functions = yield functionsService.listFunctions(100, 0);
65
- loading.stop();
66
- if (!functions.length) {
67
- throw new error_1.CloudBaseError((0, i18n_1.t)('当前环境下不存在可用的云函数,请先创建云函数!'));
68
- }
69
- let { name } = yield (0, enquirer_1.prompt)({
70
- type: 'select',
71
- name: 'name',
72
- message: (0, i18n_1.t)('请选择创建HTTP 访问服务的云函数'),
73
- choices: functions.map((item) => item.FunctionName)
74
- });
75
- let { path } = yield (0, enquirer_1.prompt)({
76
- type: 'input',
77
- name: 'path',
78
- message: (0, i18n_1.t)('请输入HTTP 访问服务路径')
79
- });
80
- functionName = name;
81
- servicePath = path;
48
+ async execute(envId, options) {
49
+ const functionsService = await (0, function_1.getFunctionService)(envId);
50
+ let { function: functionName, servicePath } = options;
51
+ const loading = (0, utils_1.loadingFactory)();
52
+ if (!servicePath || !functionName) {
53
+ loading.start((0, i18n_1.t)('数据加载中...'));
54
+ const functions = await functionsService.listFunctions(100, 0);
55
+ loading.stop();
56
+ if (!functions.length) {
57
+ throw new error_1.CloudBaseError((0, i18n_1.t)('当前环境下不存在可用的云函数,请先创建云函数!'));
82
58
  }
83
- (0, validator_1.assertTruthy)(servicePath, (0, i18n_1.t)('请指定需要创建的HTTP 访问服务路径!'));
84
- loading.start((0, i18n_1.t)('[{{functionName}}] HTTP 访问服务创建中...', { functionName }));
85
- servicePath = servicePath[0] === '/' ? servicePath : `/${servicePath}`;
86
- try {
87
- const functionList = yield (0, function_1.listFunction)({
88
- envId,
89
- limit: 100
90
- });
91
- const isExisted = functionList.filter((item) => item.FunctionName === functionName);
92
- if (isExisted.length <= 0) {
93
- throw new error_1.CloudBaseError((0, i18n_1.t)('[{{functionName}}] 云函数不存在!', { functionName }));
94
- }
95
- yield (0, gateway_1.createGateway)({
96
- envId,
97
- path: servicePath,
98
- name: functionName
99
- });
100
- const res = yield (0, gateway_1.queryGatewayDomain)({ envId });
101
- const link = (0, utils_1.genClickableLink)(`https://${res.DefaultDomain}${servicePath}`);
102
- loading.succeed((0, i18n_1.t)('HTTP 访问服务创建成功!\n点击访问> {{link}}', { link }));
59
+ let { name } = await (0, enquirer_1.prompt)({
60
+ type: 'select',
61
+ name: 'name',
62
+ message: (0, i18n_1.t)('请选择创建HTTP 访问服务的云函数'),
63
+ choices: functions.map((item) => item.FunctionName)
64
+ });
65
+ let { path } = await (0, enquirer_1.prompt)({
66
+ type: 'input',
67
+ name: 'path',
68
+ message: (0, i18n_1.t)('请输入HTTP 访问服务路径')
69
+ });
70
+ functionName = name;
71
+ servicePath = path;
72
+ }
73
+ (0, validator_1.assertTruthy)(servicePath, (0, i18n_1.t)('请指定需要创建的HTTP 访问服务路径!'));
74
+ loading.start((0, i18n_1.t)('[{{functionName}}] HTTP 访问服务创建中...', { functionName }));
75
+ servicePath = servicePath[0] === '/' ? servicePath : `/${servicePath}`;
76
+ try {
77
+ const functionList = await (0, function_1.listFunction)({
78
+ envId,
79
+ limit: 100
80
+ });
81
+ const isExisted = functionList.filter((item) => item.FunctionName === functionName);
82
+ if (isExisted.length <= 0) {
83
+ throw new error_1.CloudBaseError((0, i18n_1.t)('[{{functionName}}] 云函数不存在!', { functionName }));
103
84
  }
104
- catch (e) {
105
- loading.stop();
106
- if (e.code === 'InvalidParameter.APICreated') {
107
- throw new error_1.CloudBaseError((0, i18n_1.t)('路径已存在!'));
108
- }
109
- throw e;
85
+ await (0, gateway_1.createGateway)({
86
+ envId,
87
+ path: servicePath,
88
+ name: functionName
89
+ });
90
+ const res = await (0, gateway_1.queryGatewayDomain)({ envId });
91
+ const link = (0, utils_1.genClickableLink)(`https://${res.DefaultDomain}${servicePath}`);
92
+ loading.succeed((0, i18n_1.t)('HTTP 访问服务创建成功!\n点击访问> {{link}}', { link }));
93
+ }
94
+ catch (e) {
95
+ loading.stop();
96
+ if (e.code === 'InvalidParameter.APICreated') {
97
+ throw new error_1.CloudBaseError((0, i18n_1.t)('路径已存在!'));
110
98
  }
111
- });
99
+ throw e;
100
+ }
112
101
  }
113
102
  };
114
103
  __decorate([
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
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
14
  Object.defineProperty(exports, "__esModule", { value: true });
24
15
  exports.DeleteServiceCommand = void 0;
25
16
  const enquirer_1 = require("enquirer");
@@ -55,46 +46,44 @@ let DeleteServiceCommand = class DeleteServiceCommand extends common_1.Command {
55
46
  desc: (0, i18n_1.t)('删除 HTTP 访问服务')
56
47
  };
57
48
  }
58
- execute(envId, options) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- let { servicePath, serviceId, name } = options;
61
- if (!servicePath && !serviceId && (!name || typeof name !== 'string')) {
62
- const { APISet: allServices } = yield (0, gateway_1.queryGateway)({
63
- envId
64
- });
65
- const { selected } = yield (0, enquirer_1.prompt)({
66
- type: 'select',
67
- name: 'selected',
68
- message: (0, i18n_1.t)('请选择需要删除的 Service'),
69
- choices: allServices.map((item) => ({
70
- name: (0, i18n_1.t)('函数名:{{name}}/路径:{{path}}', { name: item.Name, path: item.Path }),
71
- value: item.APIId
72
- })),
73
- result(choices) {
74
- return Object.values(this.map(choices));
75
- }
76
- });
77
- serviceId = selected === null || selected === void 0 ? void 0 : selected[0];
78
- }
79
- if (servicePath) {
80
- servicePath = servicePath[0] === '/' ? servicePath : `/${servicePath}`;
81
- }
82
- const loading = (0, utils_1.loadingFactory)();
83
- loading.start((0, i18n_1.t)('HTTP 访问服务删除中...'));
84
- try {
85
- yield (0, gateway_1.deleteGateway)({
86
- envId,
87
- name,
88
- path: servicePath,
89
- gatewayId: serviceId
90
- });
91
- loading.succeed((0, i18n_1.t)('HTTP 访问服务删除成功!'));
92
- }
93
- catch (e) {
94
- loading.stop();
95
- throw e;
96
- }
97
- });
49
+ async execute(envId, options) {
50
+ let { servicePath, serviceId, name } = options;
51
+ if (!servicePath && !serviceId && (!name || typeof name !== 'string')) {
52
+ const { APISet: allServices } = await (0, gateway_1.queryGateway)({
53
+ envId
54
+ });
55
+ const { selected } = await (0, enquirer_1.prompt)({
56
+ type: 'select',
57
+ name: 'selected',
58
+ message: (0, i18n_1.t)('请选择需要删除的 Service'),
59
+ choices: allServices.map((item) => ({
60
+ name: (0, i18n_1.t)('函数名:{{name}}/路径:{{path}}', { name: item.Name, path: item.Path }),
61
+ value: item.APIId
62
+ })),
63
+ result(choices) {
64
+ return Object.values(this.map(choices));
65
+ }
66
+ });
67
+ serviceId = selected === null || selected === void 0 ? void 0 : selected[0];
68
+ }
69
+ if (servicePath) {
70
+ servicePath = servicePath[0] === '/' ? servicePath : `/${servicePath}`;
71
+ }
72
+ const loading = (0, utils_1.loadingFactory)();
73
+ loading.start((0, i18n_1.t)('HTTP 访问服务删除中...'));
74
+ try {
75
+ await (0, gateway_1.deleteGateway)({
76
+ envId,
77
+ name,
78
+ path: servicePath,
79
+ gatewayId: serviceId
80
+ });
81
+ loading.succeed((0, i18n_1.t)('HTTP 访问服务删除成功!'));
82
+ }
83
+ catch (e) {
84
+ loading.stop();
85
+ throw e;
86
+ }
98
87
  }
99
88
  };
100
89
  __decorate([
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
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
14
  Object.defineProperty(exports, "__esModule", { value: true });
24
15
  exports.UnbindCustomDomainCommand = exports.GetCustomDomainsCommand = exports.BindCustomDomainCommand = void 0;
25
16
  const common_1 = require("../common");
@@ -51,27 +42,25 @@ class BindCustomDomainCommand extends common_1.Command {
51
42
  desc: (0, i18n_1.t)('绑定自定义HTTP 访问服务域名')
52
43
  };
53
44
  }
54
- execute(envId, params) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const domain = params === null || params === void 0 ? void 0 : params[0];
57
- console.log(domain);
58
- if (!domain) {
59
- throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要绑定的HTTP 访问服务域名!'));
60
- }
61
- const loading = (0, utils_1.loadingFactory)();
62
- loading.start((0, i18n_1.t)('HTTP 访问服务域名 [{{domain}}] 绑定中...', { domain }));
63
- try {
64
- yield (0, gateway_1.bindGatewayDomain)({
65
- envId,
66
- domain
67
- });
68
- loading.succeed((0, i18n_1.t)('HTTP 访问服务域名[{{domain}}] 绑定成功!', { domain }));
69
- }
70
- catch (e) {
71
- loading.stop();
72
- throw e;
73
- }
74
- });
45
+ async execute(envId, params) {
46
+ const domain = params === null || params === void 0 ? void 0 : params[0];
47
+ console.log(domain);
48
+ if (!domain) {
49
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要绑定的HTTP 访问服务域名!'));
50
+ }
51
+ const loading = (0, utils_1.loadingFactory)();
52
+ loading.start((0, i18n_1.t)('HTTP 访问服务域名 [{{domain}}] 绑定中...', { domain }));
53
+ try {
54
+ await (0, gateway_1.bindGatewayDomain)({
55
+ envId,
56
+ domain
57
+ });
58
+ loading.succeed((0, i18n_1.t)('HTTP 访问服务域名[{{domain}}] 绑定成功!', { domain }));
59
+ }
60
+ catch (e) {
61
+ loading.stop();
62
+ throw e;
63
+ }
75
64
  }
76
65
  }
77
66
  __decorate([
@@ -103,38 +92,36 @@ let GetCustomDomainsCommand = class GetCustomDomainsCommand extends common_1.Com
103
92
  desc: (0, i18n_1.t)('查询 HTTP 访问服务自定义域名')
104
93
  };
105
94
  }
106
- execute(envId, options, log) {
95
+ async execute(envId, options, log) {
107
96
  var _a;
108
- return __awaiter(this, void 0, void 0, function* () {
109
- const { domain: domainName } = options;
110
- if (!envId && !domainName) {
111
- throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要查询的环境 ID 或HTTP 访问服务域名!'));
112
- }
113
- const loading = (0, utils_1.loadingFactory)();
114
- loading.start((0, i18n_1.t)('查询HTTP 访问服务域名中...'));
115
- try {
116
- const res = yield (0, gateway_1.queryGatewayDomain)({
117
- envId,
118
- domain: domainName
119
- });
120
- loading.succeed((0, i18n_1.t)('查询HTTP 访问服务域名成功!'));
121
- if (!((_a = res === null || res === void 0 ? void 0 : res.ServiceSet) === null || _a === void 0 ? void 0 : _a.length)) {
122
- log.info((0, i18n_1.t)('HTTP 访问服务域名为空!'));
123
- return;
124
- }
125
- const head = [(0, i18n_1.t)('域名'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('创建时间')];
126
- const tableData = res.ServiceSet.map((item) => [
127
- item.Domain,
128
- SERVICE_STATUS_MAP[item.Status],
129
- (0, utils_1.formatDate)(item.OpenTime * 1000, 'yyyy-MM-dd hh:mm:ss')
130
- ]);
131
- (0, utils_1.printHorizontalTable)(head, tableData);
132
- }
133
- catch (e) {
134
- loading.stop();
135
- throw e;
97
+ const { domain: domainName } = options;
98
+ if (!envId && !domainName) {
99
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要查询的环境 ID 或HTTP 访问服务域名!'));
100
+ }
101
+ const loading = (0, utils_1.loadingFactory)();
102
+ loading.start((0, i18n_1.t)('查询HTTP 访问服务域名中...'));
103
+ try {
104
+ const res = await (0, gateway_1.queryGatewayDomain)({
105
+ envId,
106
+ domain: domainName
107
+ });
108
+ loading.succeed((0, i18n_1.t)('查询HTTP 访问服务域名成功!'));
109
+ if (!((_a = res === null || res === void 0 ? void 0 : res.ServiceSet) === null || _a === void 0 ? void 0 : _a.length)) {
110
+ log.info((0, i18n_1.t)('HTTP 访问服务域名为空!'));
111
+ return;
136
112
  }
137
- });
113
+ const head = [(0, i18n_1.t)('域名'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('创建时间')];
114
+ const tableData = res.ServiceSet.map((item) => [
115
+ item.Domain,
116
+ SERVICE_STATUS_MAP[item.Status],
117
+ (0, utils_1.formatDate)(item.OpenTime * 1000, 'yyyy-MM-dd hh:mm:ss')
118
+ ]);
119
+ (0, utils_1.printHorizontalTable)(head, tableData);
120
+ }
121
+ catch (e) {
122
+ loading.stop();
123
+ throw e;
124
+ }
138
125
  }
139
126
  };
140
127
  __decorate([
@@ -166,26 +153,24 @@ let UnbindCustomDomainCommand = class UnbindCustomDomainCommand extends common_1
166
153
  desc: (0, i18n_1.t)('解绑自定义HTTP 访问服务域名')
167
154
  };
168
155
  }
169
- execute(envId, params) {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- const domain = params === null || params === void 0 ? void 0 : params[0];
172
- if (!domain) {
173
- throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要解绑的HTTP 访问服务域名!'));
174
- }
175
- const loading = (0, utils_1.loadingFactory)();
176
- loading.start((0, i18n_1.t)('HTTP Service域名 [{{domain}}] 解绑中...', { domain }));
177
- try {
178
- yield (0, gateway_1.unbindGatewayDomain)({
179
- envId,
180
- domain
181
- });
182
- loading.succeed((0, i18n_1.t)('HTTP Service域名 [{{domain}}] 解绑成功!', { domain }));
183
- }
184
- catch (e) {
185
- loading.stop();
186
- throw e;
187
- }
188
- });
156
+ async execute(envId, params) {
157
+ const domain = params === null || params === void 0 ? void 0 : params[0];
158
+ if (!domain) {
159
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要解绑的HTTP 访问服务域名!'));
160
+ }
161
+ const loading = (0, utils_1.loadingFactory)();
162
+ loading.start((0, i18n_1.t)('HTTP Service域名 [{{domain}}] 解绑中...', { domain }));
163
+ try {
164
+ await (0, gateway_1.unbindGatewayDomain)({
165
+ envId,
166
+ domain
167
+ });
168
+ loading.succeed((0, i18n_1.t)('HTTP Service域名 [{{domain}}] 解绑成功!', { domain }));
169
+ }
170
+ catch (e) {
171
+ loading.stop();
172
+ throw e;
173
+ }
189
174
  }
190
175
  };
191
176
  __decorate([
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
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
14
  Object.defineProperty(exports, "__esModule", { value: true });
24
15
  exports.ListServiceCommand = void 0;
25
16
  const common_1 = require("../common");
@@ -55,41 +46,39 @@ let ListServiceCommand = class ListServiceCommand extends common_1.Command {
55
46
  desc: (0, i18n_1.t)('获取 HTTP 访问服务列表')
56
47
  };
57
48
  }
58
- execute(envId, options, log) {
49
+ async execute(envId, options, log) {
59
50
  var _a;
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const { domain: domainName, servicePath, serviceId } = options;
62
- if (!envId && !domainName) {
63
- throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要查询的环境 ID 或HTTP 访问服务自定义域名!'));
64
- }
65
- const loading = (0, utils_1.loadingFactory)();
66
- loading.start((0, i18n_1.t)('查询HTTP 访问服务中...'));
67
- try {
68
- const res = yield (0, gateway_1.queryGateway)({
69
- envId,
70
- domain: domainName,
71
- path: servicePath,
72
- gatewayId: serviceId
73
- });
74
- loading.stop();
75
- if (((_a = res === null || res === void 0 ? void 0 : res.APISet) === null || _a === void 0 ? void 0 : _a.length) === 0) {
76
- log.info((0, i18n_1.t)('HTTP 访问服务为空'));
77
- return;
78
- }
79
- const head = [(0, i18n_1.t)('触发路径'), (0, i18n_1.t)('关联资源'), (0, i18n_1.t)('触发类型'), (0, i18n_1.t)('创建时间')];
80
- const tableData = res.APISet.map((item) => [
81
- item.Path,
82
- item.Name,
83
- item.Type === 1 ? (0, i18n_1.t)('云函数') : (0, i18n_1.t)('云托管'),
84
- (0, utils_1.formatDate)(item.CreateTime * 1000, 'yyyy-MM-dd hh:mm:ss')
85
- ]);
86
- (0, utils_1.printHorizontalTable)(head, tableData);
87
- }
88
- catch (e) {
89
- loading.stop();
90
- throw e;
51
+ const { domain: domainName, servicePath, serviceId } = options;
52
+ if (!envId && !domainName) {
53
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要查询的环境 ID 或HTTP 访问服务自定义域名!'));
54
+ }
55
+ const loading = (0, utils_1.loadingFactory)();
56
+ loading.start((0, i18n_1.t)('查询HTTP 访问服务中...'));
57
+ try {
58
+ const res = await (0, gateway_1.queryGateway)({
59
+ envId,
60
+ domain: domainName,
61
+ path: servicePath,
62
+ gatewayId: serviceId
63
+ });
64
+ loading.stop();
65
+ if (((_a = res === null || res === void 0 ? void 0 : res.APISet) === null || _a === void 0 ? void 0 : _a.length) === 0) {
66
+ log.info((0, i18n_1.t)('HTTP 访问服务为空'));
67
+ return;
91
68
  }
92
- });
69
+ const head = [(0, i18n_1.t)('触发路径'), (0, i18n_1.t)('关联资源'), (0, i18n_1.t)('触发类型'), (0, i18n_1.t)('创建时间')];
70
+ const tableData = res.APISet.map((item) => [
71
+ item.Path,
72
+ item.Name,
73
+ item.Type === 1 ? (0, i18n_1.t)('云函数') : (0, i18n_1.t)('云托管'),
74
+ (0, utils_1.formatDate)(item.CreateTime * 1000, 'yyyy-MM-dd hh:mm:ss')
75
+ ]);
76
+ (0, utils_1.printHorizontalTable)(head, tableData);
77
+ }
78
+ catch (e) {
79
+ loading.stop();
80
+ throw e;
81
+ }
93
82
  }
94
83
  };
95
84
  __decorate([
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
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
14
  Object.defineProperty(exports, "__esModule", { value: true });
24
15
  exports.ServiceAuthSwitch = exports.ServiceSwitchCommand = void 0;
25
16
  const enquirer_1 = require("enquirer");
@@ -43,34 +34,32 @@ let ServiceSwitchCommand = class ServiceSwitchCommand extends common_1.Command {
43
34
  desc: (0, i18n_1.t)('开启/关闭HTTP 访问服务')
44
35
  };
45
36
  }
46
- execute(envId) {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- const loading = (0, utils_1.loadingFactory)();
49
- loading.start((0, i18n_1.t)('数据加载中...'));
50
- const { EnableService } = yield (0, gateway_1.getHttpServicePrivilege)({ envId });
51
- const status = EnableService ? (0, i18n_1.t)('已开启') : (0, i18n_1.t)('已关闭');
52
- loading.stop();
53
- const { enable } = yield (0, enquirer_1.prompt)({
54
- type: 'select',
55
- name: 'enable',
56
- message: (0, i18n_1.t)('开启/关闭HTTP 访问服务(当前状态:{{status}})', { status }),
57
- choices: [(0, i18n_1.t)('开启'), (0, i18n_1.t)('关闭')]
58
- });
59
- try {
60
- const loadingText = enable ? (0, i18n_1.t)('HTTP 访问服务开启中') : (0, i18n_1.t)('HTTP 访问服务关闭中');
61
- loading.start(loadingText);
62
- yield (0, gateway_1.switchHttpService)({
63
- envId,
64
- enable: enable === (0, i18n_1.t)('开启')
65
- });
66
- const successText = enable ? (0, i18n_1.t)('HTTP 访问服务开启成功!') : (0, i18n_1.t)('HTTP 访问服务关闭成功!');
67
- loading.succeed(successText);
68
- }
69
- catch (e) {
70
- loading.stop();
71
- throw e;
72
- }
37
+ async execute(envId) {
38
+ const loading = (0, utils_1.loadingFactory)();
39
+ loading.start((0, i18n_1.t)('数据加载中...'));
40
+ const { EnableService } = await (0, gateway_1.getHttpServicePrivilege)({ envId });
41
+ const status = EnableService ? (0, i18n_1.t)('已开启') : (0, i18n_1.t)('已关闭');
42
+ loading.stop();
43
+ const { enable } = await (0, enquirer_1.prompt)({
44
+ type: 'select',
45
+ name: 'enable',
46
+ message: (0, i18n_1.t)('开启/关闭HTTP 访问服务(当前状态:{{status}})', { status }),
47
+ choices: [(0, i18n_1.t)('开启'), (0, i18n_1.t)('关闭')]
73
48
  });
49
+ try {
50
+ const loadingText = enable ? (0, i18n_1.t)('HTTP 访问服务开启中') : (0, i18n_1.t)('HTTP 访问服务关闭中');
51
+ loading.start(loadingText);
52
+ await (0, gateway_1.switchHttpService)({
53
+ envId,
54
+ enable: enable === (0, i18n_1.t)('开启')
55
+ });
56
+ const successText = enable ? (0, i18n_1.t)('HTTP 访问服务开启成功!') : (0, i18n_1.t)('HTTP 访问服务关闭成功!');
57
+ loading.succeed(successText);
58
+ }
59
+ catch (e) {
60
+ loading.stop();
61
+ throw e;
62
+ }
74
63
  }
75
64
  };
76
65
  __decorate([
@@ -103,32 +92,30 @@ let ServiceAuthSwitch = class ServiceAuthSwitch extends common_1.Command {
103
92
  desc: (0, i18n_1.t)('开启/关闭HTTP 访问服务访问鉴权')
104
93
  };
105
94
  }
106
- execute(envId) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- const loading = (0, utils_1.loadingFactory)();
109
- loading.start((0, i18n_1.t)('数据加载中...'));
110
- const { EnableAuth } = yield (0, gateway_1.getHttpServicePrivilege)({ envId });
111
- const status = EnableAuth ? (0, i18n_1.t)('已开启') : (0, i18n_1.t)('已关闭');
112
- loading.stop();
113
- const { enable } = yield (0, enquirer_1.prompt)({
114
- type: 'select',
115
- name: 'enable',
116
- message: (0, i18n_1.t)('开启/关闭HTTP 访问服务访问鉴权(当前状态:{{status}})', { status }),
117
- choices: [(0, i18n_1.t)('开启'), (0, i18n_1.t)('关闭')]
118
- });
119
- try {
120
- loading.start((0, i18n_1.t)('HTTP 访问服务访问鉴权{{enable}}中', { enable }));
121
- yield (0, gateway_1.switchHttpServiceAuth)({
122
- envId,
123
- enable: enable === (0, i18n_1.t)('开启')
124
- });
125
- loading.succeed((0, i18n_1.t)('HTTP 访问服务访问鉴权{{enable}}成功!', { enable }));
126
- }
127
- catch (e) {
128
- loading.stop();
129
- throw e;
130
- }
95
+ async execute(envId) {
96
+ const loading = (0, utils_1.loadingFactory)();
97
+ loading.start((0, i18n_1.t)('数据加载中...'));
98
+ const { EnableAuth } = await (0, gateway_1.getHttpServicePrivilege)({ envId });
99
+ const status = EnableAuth ? (0, i18n_1.t)('已开启') : (0, i18n_1.t)('已关闭');
100
+ loading.stop();
101
+ const { enable } = await (0, enquirer_1.prompt)({
102
+ type: 'select',
103
+ name: 'enable',
104
+ message: (0, i18n_1.t)('开启/关闭HTTP 访问服务访问鉴权(当前状态:{{status}})', { status }),
105
+ choices: [(0, i18n_1.t)('开启'), (0, i18n_1.t)('关闭')]
131
106
  });
107
+ try {
108
+ loading.start((0, i18n_1.t)('HTTP 访问服务访问鉴权{{enable}}中', { enable }));
109
+ await (0, gateway_1.switchHttpServiceAuth)({
110
+ envId,
111
+ enable: enable === (0, i18n_1.t)('开启')
112
+ });
113
+ loading.succeed((0, i18n_1.t)('HTTP 访问服务访问鉴权{{enable}}成功!', { enable }));
114
+ }
115
+ catch (e) {
116
+ loading.stop();
117
+ throw e;
118
+ }
132
119
  }
133
120
  };
134
121
  __decorate([