@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
  var __importDefault = (this && this.__importDefault) || function (mod) {
24
15
  return (mod && mod.__esModule) ? mod : { "default": mod };
25
16
  };
@@ -51,24 +42,22 @@ let ListAuthDoaminCommand = class ListAuthDoaminCommand extends common_1.Command
51
42
  desc: (0, i18n_1.t)('列出环境的安全域名列表')
52
43
  };
53
44
  }
54
- execute(envId) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const domains = yield (0, env_1.getEnvAuthDomains)({
57
- envId: envId
58
- });
59
- if (domains.length === 0) {
60
- console.log((0, i18n_1.t)('安全域名为空!'));
61
- return;
62
- }
63
- const head = [(0, i18n_1.t)('域名 Id'), (0, i18n_1.t)('域名'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('状态')];
64
- const tableData = domains.map((item) => [
65
- item.Id,
66
- item.Domain,
67
- item.CreateTime,
68
- item.Status === 'ENABLE' ? (0, i18n_1.t)('启用中') : (0, i18n_1.t)('禁用中')
69
- ]);
70
- (0, utils_1.printHorizontalTable)(head, tableData);
45
+ async execute(envId) {
46
+ const domains = await (0, env_1.getEnvAuthDomains)({
47
+ envId: envId
71
48
  });
49
+ if (domains.length === 0) {
50
+ console.log((0, i18n_1.t)('安全域名为空!'));
51
+ return;
52
+ }
53
+ const head = [(0, i18n_1.t)('域名 Id'), (0, i18n_1.t)('域名'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('状态')];
54
+ const tableData = domains.map((item) => [
55
+ item.Id,
56
+ item.Domain,
57
+ item.CreateTime,
58
+ item.Status === 'ENABLE' ? (0, i18n_1.t)('启用中') : (0, i18n_1.t)('禁用中')
59
+ ]);
60
+ (0, utils_1.printHorizontalTable)(head, tableData);
72
61
  }
73
62
  };
74
63
  __decorate([
@@ -101,39 +90,37 @@ let CreateAuthDomainCommand = class CreateAuthDomainCommand extends common_1.Com
101
90
  desc: (0, i18n_1.t)('添加环境安全域名,多个以斜杠 / 分隔')
102
91
  };
103
92
  }
104
- execute(params, envId, log) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- log.verbose(params);
107
- const domain = params === null || params === void 0 ? void 0 : params[0];
108
- const domains = domain.split('/');
109
- const { confirm } = yield inquirer_1.default.prompt({
110
- type: 'confirm',
111
- name: 'confirm',
112
- message: (0, i18n_1.t)('确认添加以下安全域名: {{domains}} ?', { domains }),
113
- default: true
114
- });
115
- if (!confirm) {
116
- throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
117
- }
118
- let envDomains = yield (0, env_1.getEnvAuthDomains)({
119
- envId
120
- });
121
- envDomains = envDomains.map((item) => item.Domain);
122
- const exitDomains = [];
123
- domains.forEach((item) => {
124
- if (envDomains.includes(item)) {
125
- exitDomains.push(item);
126
- }
127
- });
128
- if (exitDomains.length) {
129
- throw new error_1.CloudBaseError((0, i18n_1.t)('域名 [{{domains}}] 已存在!', { domains: exitDomains.join(', ') }));
93
+ async execute(params, envId, log) {
94
+ log.verbose(params);
95
+ const domain = params === null || params === void 0 ? void 0 : params[0];
96
+ const domains = domain.split('/');
97
+ const { confirm } = await inquirer_1.default.prompt({
98
+ type: 'confirm',
99
+ name: 'confirm',
100
+ message: (0, i18n_1.t)('确认添加以下安全域名: {{domains}} ?', { domains }),
101
+ default: true
102
+ });
103
+ if (!confirm) {
104
+ throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
105
+ }
106
+ let envDomains = await (0, env_1.getEnvAuthDomains)({
107
+ envId
108
+ });
109
+ envDomains = envDomains.map((item) => item.Domain);
110
+ const exitDomains = [];
111
+ domains.forEach((item) => {
112
+ if (envDomains.includes(item)) {
113
+ exitDomains.push(item);
130
114
  }
131
- yield (0, env_1.createEnvDomain)({
132
- envId,
133
- domains: domains
134
- });
135
- log.success((0, i18n_1.t)('添加安全域名成功!'));
136
115
  });
116
+ if (exitDomains.length) {
117
+ throw new error_1.CloudBaseError((0, i18n_1.t)('域名 [{{domains}}] 已存在!', { domains: exitDomains.join(', ') }));
118
+ }
119
+ await (0, env_1.createEnvDomain)({
120
+ envId,
121
+ domains: domains
122
+ });
123
+ log.success((0, i18n_1.t)('添加安全域名成功!'));
137
124
  }
138
125
  };
139
126
  __decorate([
@@ -168,44 +155,42 @@ let DeleteAuthDomainCommand = class DeleteAuthDomainCommand extends common_1.Com
168
155
  desc: (0, i18n_1.t)('删除环境的安全域名')
169
156
  };
170
157
  }
171
- execute(envId, log) {
172
- return __awaiter(this, void 0, void 0, function* () {
173
- const loading = (0, utils_1.loadingFactory)();
174
- loading.start((0, i18n_1.t)('拉取环境安全域名中'));
175
- const domains = yield (0, env_1.getEnvAuthDomains)({
176
- envId
177
- });
178
- if (domains.length === 0) {
179
- loading.fail((0, i18n_1.t)('域名安全为空,不能执行删除操作!'));
180
- return;
181
- }
182
- loading.succeed((0, i18n_1.t)('拉取环境安全域名成功!'));
183
- const domainList = domains.map((item) => item.Domain);
184
- const { selectDomains } = yield inquirer_1.default.prompt({
185
- type: 'checkbox',
186
- name: 'selectDomains',
187
- message: (0, i18n_1.t)('请选择需要删除的域名(可多选)>'),
188
- choices: domainList,
189
- default: true
190
- });
191
- const { confirm } = yield inquirer_1.default.prompt({
192
- type: 'confirm',
193
- name: 'confirm',
194
- message: (0, i18n_1.t)('确认删除以下安全域名: {{domains}} ?', { domains: selectDomains }),
195
- default: true
196
- });
197
- if (!confirm) {
198
- throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
199
- }
200
- const domainIds = domains
201
- .filter((item) => selectDomains.includes(item.Domain))
202
- .map((item) => item.Id);
203
- const deleted = yield (0, env_1.deleteEnvDomain)({
204
- domainIds,
205
- envId
206
- });
207
- log.success((0, i18n_1.t)('成功删除了 {{count}} 个域名!', { count: deleted }));
158
+ async execute(envId, log) {
159
+ const loading = (0, utils_1.loadingFactory)();
160
+ loading.start((0, i18n_1.t)('拉取环境安全域名中'));
161
+ const domains = await (0, env_1.getEnvAuthDomains)({
162
+ envId
163
+ });
164
+ if (domains.length === 0) {
165
+ loading.fail((0, i18n_1.t)('域名安全为空,不能执行删除操作!'));
166
+ return;
167
+ }
168
+ loading.succeed((0, i18n_1.t)('拉取环境安全域名成功!'));
169
+ const domainList = domains.map((item) => item.Domain);
170
+ const { selectDomains } = await inquirer_1.default.prompt({
171
+ type: 'checkbox',
172
+ name: 'selectDomains',
173
+ message: (0, i18n_1.t)('请选择需要删除的域名(可多选)>'),
174
+ choices: domainList,
175
+ default: true
176
+ });
177
+ const { confirm } = await inquirer_1.default.prompt({
178
+ type: 'confirm',
179
+ name: 'confirm',
180
+ message: (0, i18n_1.t)('确认删除以下安全域名: {{domains}} ?', { domains: selectDomains }),
181
+ default: true
182
+ });
183
+ if (!confirm) {
184
+ throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
185
+ }
186
+ const domainIds = domains
187
+ .filter((item) => selectDomains.includes(item.Domain))
188
+ .map((item) => item.Id);
189
+ const deleted = await (0, env_1.deleteEnvDomain)({
190
+ domainIds,
191
+ envId
208
192
  });
193
+ log.success((0, i18n_1.t)('成功删除了 {{count}} 个域名!', { count: deleted }));
209
194
  }
210
195
  };
211
196
  __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
  var __importDefault = (this && this.__importDefault) || function (mod) {
24
15
  return (mod && mod.__esModule) ? mod : { "default": mod };
25
16
  };
@@ -56,20 +47,18 @@ let ListLoginCommand = class ListLoginCommand extends common_1.Command {
56
47
  desc: (0, i18n_1.t)('列出环境登录配置')
57
48
  };
58
49
  }
59
- execute(envId) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const configList = yield (0, env_1.getLoginConfigList)({
62
- envId
63
- });
64
- const head = [(0, i18n_1.t)('平台'), (0, i18n_1.t)('平台 Id'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('状态')];
65
- const tableData = configList.map((item) => [
66
- platformMap[item.Platform] ? platformMap[item.Platform] : item.Platform,
67
- item.PlatformId,
68
- item.CreateTime,
69
- item.Status === 'ENABLE' ? (0, i18n_1.t)('启用') : (0, i18n_1.t)('禁用')
70
- ]);
71
- (0, utils_1.printHorizontalTable)(head, tableData);
50
+ async execute(envId) {
51
+ const configList = await (0, env_1.getLoginConfigList)({
52
+ envId
72
53
  });
54
+ const head = [(0, i18n_1.t)('平台'), (0, i18n_1.t)('平台 Id'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('状态')];
55
+ const tableData = configList.map((item) => [
56
+ platformMap[item.Platform] ? platformMap[item.Platform] : item.Platform,
57
+ item.PlatformId,
58
+ item.CreateTime,
59
+ item.Status === 'ENABLE' ? (0, i18n_1.t)('启用') : (0, i18n_1.t)('禁用')
60
+ ]);
61
+ (0, utils_1.printHorizontalTable)(head, tableData);
73
62
  }
74
63
  };
75
64
  __decorate([
@@ -99,70 +88,68 @@ let CreateLoginCommand = class CreateLoginCommand extends common_1.Command {
99
88
  desc: (0, i18n_1.t)('添加环境登录方式配置')
100
89
  };
101
90
  }
102
- execute(envId, log) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- const { platform } = yield inquirer_1.default.prompt([
105
- {
106
- type: 'list',
107
- name: 'platform',
108
- choices: [
109
- {
110
- name: (0, i18n_1.t)('微信公众平台'),
111
- value: 'WECHAT-PUBLIC'
112
- },
113
- {
114
- name: (0, i18n_1.t)('微信开放平台'),
115
- value: 'WECHAT-OPEN'
116
- },
117
- {
118
- name: (0, i18n_1.t)('匿名登录'),
119
- value: 'ANONYMOUS'
120
- }
121
- ],
122
- message: (0, i18n_1.t)('请选择登录方式:'),
123
- default: 'WECHAT-PUBLIC'
124
- }
125
- ]);
126
- let appId;
127
- let appSecret;
128
- if (platform === 'WECHAT-OPEN' || platform === 'WECHAT-PUBLIC') {
129
- const input = yield inquirer_1.default.prompt([
91
+ async execute(envId, log) {
92
+ const { platform } = await inquirer_1.default.prompt([
93
+ {
94
+ type: 'list',
95
+ name: 'platform',
96
+ choices: [
97
+ {
98
+ name: (0, i18n_1.t)('微信公众平台'),
99
+ value: 'WECHAT-PUBLIC'
100
+ },
130
101
  {
131
- type: 'input',
132
- name: 'appId',
133
- message: (0, i18n_1.t)('请输入 AppId:')
102
+ name: (0, i18n_1.t)('微信开放平台'),
103
+ value: 'WECHAT-OPEN'
134
104
  },
135
105
  {
136
- type: 'input',
137
- name: 'appSecret',
138
- message: (0, i18n_1.t)('请输入 AppSecret:')
106
+ name: (0, i18n_1.t)('匿名登录'),
107
+ value: 'ANONYMOUS'
139
108
  }
140
- ]);
141
- appId = input === null || input === void 0 ? void 0 : input.appId;
142
- appSecret = input === null || input === void 0 ? void 0 : input.appSecret;
143
- if (!appId || !appSecret) {
144
- throw new error_1.CloudBaseError((0, i18n_1.t)('appId 和 appSecret 不能为空!'));
145
- }
146
- }
147
- if (platform === 'ANONYMOUS') {
148
- appId = 'anonymous';
149
- appSecret = 'anonymous';
109
+ ],
110
+ message: (0, i18n_1.t)('请选择登录方式:'),
111
+ default: 'WECHAT-PUBLIC'
150
112
  }
151
- try {
152
- yield (0, env_1.createLoginConfig)({
153
- envId,
154
- appId,
155
- appSecret,
156
- platform
157
- });
158
- log.success((0, i18n_1.t)('创建登录方式成功!'));
159
- }
160
- catch (e) {
161
- if (e.code === 'ResourceInUse') {
162
- log.error((0, i18n_1.t)('登录方式已开启'));
113
+ ]);
114
+ let appId;
115
+ let appSecret;
116
+ if (platform === 'WECHAT-OPEN' || platform === 'WECHAT-PUBLIC') {
117
+ const input = await inquirer_1.default.prompt([
118
+ {
119
+ type: 'input',
120
+ name: 'appId',
121
+ message: (0, i18n_1.t)('请输入 AppId:')
122
+ },
123
+ {
124
+ type: 'input',
125
+ name: 'appSecret',
126
+ message: (0, i18n_1.t)('请输入 AppSecret:')
163
127
  }
128
+ ]);
129
+ appId = input === null || input === void 0 ? void 0 : input.appId;
130
+ appSecret = input === null || input === void 0 ? void 0 : input.appSecret;
131
+ if (!appId || !appSecret) {
132
+ throw new error_1.CloudBaseError((0, i18n_1.t)('appId 和 appSecret 不能为空!'));
164
133
  }
165
- });
134
+ }
135
+ if (platform === 'ANONYMOUS') {
136
+ appId = 'anonymous';
137
+ appSecret = 'anonymous';
138
+ }
139
+ try {
140
+ await (0, env_1.createLoginConfig)({
141
+ envId,
142
+ appId,
143
+ appSecret,
144
+ platform
145
+ });
146
+ log.success((0, i18n_1.t)('创建登录方式成功!'));
147
+ }
148
+ catch (e) {
149
+ if (e.code === 'ResourceInUse') {
150
+ log.error((0, i18n_1.t)('登录方式已开启'));
151
+ }
152
+ }
166
153
  }
167
154
  };
168
155
  __decorate([
@@ -193,68 +180,66 @@ let UpdateLogin = class UpdateLogin extends common_1.Command {
193
180
  desc: (0, i18n_1.t)('更新环境登录方式配置')
194
181
  };
195
182
  }
196
- execute(envId, log) {
197
- return __awaiter(this, void 0, void 0, function* () {
198
- const configList = yield (0, env_1.getLoginConfigList)({
199
- envId
200
- });
201
- const configChoices = configList.map((item) => ({
202
- name: `${platformMap[item.Platform]}:${item.PlatformId} [${item.Status === 'ENABLE' ? (0, i18n_1.t)('启用') : (0, i18n_1.t)('禁用')}]`,
203
- value: item,
204
- short: `${platformMap[item.Platform]}:${item.PlatformId}`
205
- }));
206
- const { config, status } = yield inquirer_1.default.prompt([
207
- {
208
- type: 'list',
209
- name: 'config',
210
- choices: configChoices,
211
- message: (0, i18n_1.t)('请选择需要配置的条目:')
212
- },
213
- {
214
- type: 'list',
215
- name: 'status',
216
- choices: [
217
- {
218
- name: (0, i18n_1.t)('启用'),
219
- value: 'ENABLE'
220
- },
221
- {
222
- name: (0, i18n_1.t)('禁用'),
223
- value: 'DISABLE'
224
- }
225
- ],
226
- message: (0, i18n_1.t)('请选择登录方式状态:'),
227
- default: 'ENABLE'
228
- }
229
- ]);
230
- const platform = config.Platform;
231
- let appId;
232
- let appSecret;
233
- if (platform === 'WECHAT-OPEN' || platform === 'WECHAT-PUBLIC') {
234
- const input = yield inquirer_1.default.prompt([
183
+ async execute(envId, log) {
184
+ const configList = await (0, env_1.getLoginConfigList)({
185
+ envId
186
+ });
187
+ const configChoices = configList.map((item) => ({
188
+ name: `${platformMap[item.Platform]}:${item.PlatformId} [${item.Status === 'ENABLE' ? (0, i18n_1.t)('启用') : (0, i18n_1.t)('禁用')}]`,
189
+ value: item,
190
+ short: `${platformMap[item.Platform]}:${item.PlatformId}`
191
+ }));
192
+ const { config, status } = await inquirer_1.default.prompt([
193
+ {
194
+ type: 'list',
195
+ name: 'config',
196
+ choices: configChoices,
197
+ message: (0, i18n_1.t)('请选择需要配置的条目:')
198
+ },
199
+ {
200
+ type: 'list',
201
+ name: 'status',
202
+ choices: [
235
203
  {
236
- type: 'input',
237
- name: 'appId',
238
- message: (0, i18n_1.t)('请输入 AppId(配置状态时可不填):')
204
+ name: (0, i18n_1.t)('启用'),
205
+ value: 'ENABLE'
239
206
  },
240
207
  {
241
- type: 'input',
242
- name: 'appSecret',
243
- message: (0, i18n_1.t)('请输入 AppSecret(配置状态时可不填):')
208
+ name: (0, i18n_1.t)('禁用'),
209
+ value: 'DISABLE'
244
210
  }
245
- ]);
246
- appId = input === null || input === void 0 ? void 0 : input.appId;
247
- appSecret = input === null || input === void 0 ? void 0 : input.appSecret;
211
+ ],
212
+ message: (0, i18n_1.t)('请选择登录方式状态:'),
213
+ default: 'ENABLE'
248
214
  }
249
- yield (0, env_1.updateLoginConfig)({
250
- envId,
251
- configId: config.Id,
252
- appId,
253
- appSecret,
254
- status
255
- });
256
- log.success((0, i18n_1.t)('更新登录方式成功!'));
215
+ ]);
216
+ const platform = config.Platform;
217
+ let appId;
218
+ let appSecret;
219
+ if (platform === 'WECHAT-OPEN' || platform === 'WECHAT-PUBLIC') {
220
+ const input = await inquirer_1.default.prompt([
221
+ {
222
+ type: 'input',
223
+ name: 'appId',
224
+ message: (0, i18n_1.t)('请输入 AppId(配置状态时可不填):')
225
+ },
226
+ {
227
+ type: 'input',
228
+ name: 'appSecret',
229
+ message: (0, i18n_1.t)('请输入 AppSecret(配置状态时可不填):')
230
+ }
231
+ ]);
232
+ appId = input === null || input === void 0 ? void 0 : input.appId;
233
+ appSecret = input === null || input === void 0 ? void 0 : input.appSecret;
234
+ }
235
+ await (0, env_1.updateLoginConfig)({
236
+ envId,
237
+ configId: config.Id,
238
+ appId,
239
+ appSecret,
240
+ status
257
241
  });
242
+ log.success((0, i18n_1.t)('更新登录方式成功!'));
258
243
  }
259
244
  };
260
245
  __decorate([
@@ -34,15 +34,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
34
34
  var __param = (this && this.__param) || function (paramIndex, decorator) {
35
35
  return function (target, key) { decorator(target, key, paramIndex); }
36
36
  };
37
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
38
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
39
- return new (P || (P = Promise))(function (resolve, reject) {
40
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
41
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
42
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
43
- step((generator = generator.apply(thisArg, _arguments || [])).next());
44
- });
45
- };
46
37
  Object.defineProperty(exports, "__esModule", { value: true });
47
38
  exports.FrameworkRun = exports.FrameworkCompile = exports.FrameworkDeploy = void 0;
48
39
  const framework_core_1 = require("@cloudbase/framework-core");
@@ -51,30 +42,28 @@ const decorators_1 = require("../../decorators");
51
42
  const Hosting = __importStar(require("../../hosting"));
52
43
  const Function = __importStar(require("../../function"));
53
44
  const utils_1 = require("../../utils");
54
- function callFramework(ctx, command, module, params) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const { envId, config } = ctx;
57
- const { bumpVersion, versionRemark } = ctx.options;
58
- const loginState = yield utils_1.authSupevisor.getLoginState();
59
- const { token, secretId, secretKey } = loginState;
60
- yield (0, framework_core_1.run)({
61
- projectPath: process.cwd(),
62
- cloudbaseConfig: {
63
- secretId,
64
- secretKey,
65
- token,
66
- envId
67
- },
68
- config,
69
- logLevel: process.argv.includes('--verbose') ? 'debug' : 'info',
70
- resourceProviders: {
71
- hosting: Hosting,
72
- function: Function
73
- },
74
- bumpVersion: Boolean(bumpVersion),
75
- versionRemark
76
- }, command, module, params);
77
- });
45
+ async function callFramework(ctx, command, module, params) {
46
+ const { envId, config } = ctx;
47
+ const { bumpVersion, versionRemark } = ctx.options;
48
+ const loginState = await utils_1.authSupevisor.getLoginState();
49
+ const { token, secretId, secretKey } = loginState;
50
+ await (0, framework_core_1.run)({
51
+ projectPath: process.cwd(),
52
+ cloudbaseConfig: {
53
+ secretId,
54
+ secretKey,
55
+ token,
56
+ envId
57
+ },
58
+ config,
59
+ logLevel: process.argv.includes('--verbose') ? 'debug' : 'info',
60
+ resourceProviders: {
61
+ hosting: Hosting,
62
+ function: Function
63
+ },
64
+ bumpVersion: Boolean(bumpVersion),
65
+ versionRemark
66
+ }, command, module, params);
78
67
  }
79
68
  let FrameworkDeploy = class FrameworkDeploy extends common_1.Command {
80
69
  get options() {
@@ -92,11 +81,9 @@ let FrameworkDeploy = class FrameworkDeploy extends common_1.Command {
92
81
  desc: '云开发 Serverless 应用框架:部署全栈应用'
93
82
  };
94
83
  }
95
- execute(ctx, logger, params) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- const [module] = params || [];
98
- yield callFramework(ctx, 'deploy', module);
99
- });
84
+ async execute(ctx, logger, params) {
85
+ const [module] = params || [];
86
+ await callFramework(ctx, 'deploy', module);
100
87
  }
101
88
  };
102
89
  __decorate([
@@ -133,11 +120,9 @@ let FrameworkCompile = class FrameworkCompile extends common_1.Command {
133
120
  desc: '云开发 Serverless 应用框架:编译应用描述文件'
134
121
  };
135
122
  }
136
- execute(ctx, logger, params) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- const [module] = params || [];
139
- yield callFramework(ctx, 'compile', module);
140
- });
123
+ async execute(ctx, logger, params) {
124
+ const [module] = params || [];
125
+ await callFramework(ctx, 'compile', module);
141
126
  }
142
127
  };
143
128
  __decorate([
@@ -172,12 +157,10 @@ let FrameworkRun = class FrameworkRun extends common_1.Command {
172
157
  desc: '云开发 Serverless 应用框架:执行自定义命令'
173
158
  };
174
159
  }
175
- execute(ctx, logger, params, options) {
176
- return __awaiter(this, void 0, void 0, function* () {
177
- const [command] = params || [];
178
- const { plugin } = options;
179
- yield callFramework(ctx, 'run', plugin, { runCommandKey: command });
180
- });
160
+ async execute(ctx, logger, params, options) {
161
+ const [command] = params || [];
162
+ const { plugin } = options;
163
+ await callFramework(ctx, 'run', plugin, { runCommandKey: command });
181
164
  }
182
165
  };
183
166
  __decorate([