@cloudbase/cli 2.10.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.UpdateVersion = void 0;
25
16
  const fs_1 = require("fs");
@@ -64,7 +55,9 @@ const describeVersion = (base) => {
64
55
  };
65
56
  let UpdateVersion = class UpdateVersion extends common_1.Command {
66
57
  get options() {
67
- return Object.assign(Object.assign({}, (0, common_2.versionCommonOptions)('update')), { options: [
58
+ return {
59
+ ...(0, common_2.versionCommonOptions)('update'),
60
+ options: [
68
61
  {
69
62
  flags: '-e, --envId <envId>',
70
63
  desc: (0, i18n_1.t)('环境 Id')
@@ -133,210 +126,210 @@ let UpdateVersion = class UpdateVersion extends common_1.Command {
133
126
  flags: '--env <env>',
134
127
  desc: (0, i18n_1.t)('环境变量,格式为xx=a&yy=b,默认为空')
135
128
  }
136
- ], desc: (0, i18n_1.t)('创建云开发环境下云托管服务的版本') });
129
+ ],
130
+ desc: (0, i18n_1.t)('创建云开发环境下云托管服务的版本')
131
+ };
137
132
  }
138
- execute(envId, options) {
139
- return __awaiter(this, void 0, void 0, function* () {
140
- let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, false);
141
- if (envCheckType !== 0) {
142
- (0, utils_1.logEnvCheck)(envId, envCheckType);
143
- return;
144
- }
145
- let { serviceName = '', versionName = '', path: _path = '', repo: _repo = '', image: _image = '', port: _port = '80', flow: _flow = '0', remark: _remark = '', cpu: _cpu = '0.5', mem: _mem = '1', copy: _copy = '0~50', policy: _policy = 'cpu|60', dockerfile: _dockerfile = 'Dockerfile', log: _log = 'stdout', delay: _delay = '2', env: _env = '' } = options;
146
- if (!serviceName || !versionName) {
147
- throw new error_1.CloudBaseError((0, i18n_1.t)('必须输入 serviceName 和 versionName'));
148
- }
149
- let path;
150
- let repositoryType;
151
- let branch;
152
- let codeDetail;
153
- let imageInfo;
154
- let containerPort;
155
- let flowRatio;
156
- let versionRemark;
157
- let cpu;
158
- let mem;
159
- let minNum;
160
- let maxNum;
161
- let policyType;
162
- let policyThreshold;
163
- let customLogs = 'stdout';
164
- let dockerfilePath = 'Dockerfile';
165
- let initialDelaySeconds = 2;
166
- let envParams = '{}';
167
- const uid = (0, utils_1.random)(4);
168
- const loading = (0, utils_1.loadingFactory)();
169
- if (_path) {
170
- path = _path;
171
- if ((0, fs_1.statSync)(path).isDirectory()) {
172
- loading.start((0, i18n_1.t)('正在压缩中'));
173
- yield (0, toolbox_1.zipDir)(path, `./code${uid}.zip`);
174
- loading.succeed((0, i18n_1.t)('压缩完成'));
175
- path = `./code${uid}.zip`;
176
- }
177
- }
178
- else if (_repo) {
179
- const repo = _repo.split('|');
180
- repositoryType = repo[0];
181
- codeDetail.Name.FullName = repo[1];
182
- codeDetail.Name.Name = repo[1].split('/')[1];
183
- branch = repo[2];
184
- }
185
- else if (_image) {
186
- imageInfo = {
187
- ImageUrl: _image
188
- };
189
- }
190
- else {
191
- throw new error_1.CloudBaseError((0, i18n_1.t)('请至少选择一个上传方式'));
192
- }
193
- containerPort = Number(_port);
194
- if (isNaN(containerPort)) {
195
- throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的端口号'));
196
- }
197
- flowRatio = Number(_flow);
198
- if (![100, 0].includes(flowRatio)) {
199
- throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的流量策略'));
200
- }
201
- versionRemark = _remark;
202
- cpu = Number(_cpu);
203
- mem = Number(_mem);
204
- if (isNaN(cpu) || isNaN(mem)) {
205
- throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的cpu和内存规格'));
206
- }
207
- minNum = Number(_copy.split('~')[0]);
208
- maxNum = Number(_copy.split('~')[1]);
209
- if (isNaN(maxNum) || isNaN(minNum)) {
210
- throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的副本个数'));
211
- }
212
- policyType = _policy.split('|')[0];
213
- policyThreshold = Number(_policy.split('|')[1]);
214
- if (!['cpu', 'mem'].includes(policyType) || isNaN(policyThreshold)) {
215
- throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的扩缩容条件'));
133
+ async execute(envId, options) {
134
+ let envCheckType = await (0, utils_1.checkTcbrEnv)(options.envId, false);
135
+ if (envCheckType !== 0) {
136
+ (0, utils_1.logEnvCheck)(envId, envCheckType);
137
+ return;
138
+ }
139
+ let { serviceName = '', versionName = '', path: _path = '', repo: _repo = '', image: _image = '', port: _port = '80', flow: _flow = '0', remark: _remark = '', cpu: _cpu = '0.5', mem: _mem = '1', copy: _copy = '0~50', policy: _policy = 'cpu|60', dockerfile: _dockerfile = 'Dockerfile', log: _log = 'stdout', delay: _delay = '2', env: _env = '' } = options;
140
+ if (!serviceName || !versionName) {
141
+ throw new error_1.CloudBaseError((0, i18n_1.t)('必须输入 serviceName versionName'));
142
+ }
143
+ let path;
144
+ let repositoryType;
145
+ let branch;
146
+ let codeDetail;
147
+ let imageInfo;
148
+ let containerPort;
149
+ let flowRatio;
150
+ let versionRemark;
151
+ let cpu;
152
+ let mem;
153
+ let minNum;
154
+ let maxNum;
155
+ let policyType;
156
+ let policyThreshold;
157
+ let customLogs = 'stdout';
158
+ let dockerfilePath = 'Dockerfile';
159
+ let initialDelaySeconds = 2;
160
+ let envParams = '{}';
161
+ const uid = (0, utils_1.random)(4);
162
+ const loading = (0, utils_1.loadingFactory)();
163
+ if (_path) {
164
+ path = _path;
165
+ if ((0, fs_1.statSync)(path).isDirectory()) {
166
+ loading.start((0, i18n_1.t)('正在压缩中'));
167
+ await (0, toolbox_1.zipDir)(path, `./code${uid}.zip`);
168
+ loading.succeed((0, i18n_1.t)('压缩完成'));
169
+ path = `./code${uid}.zip`;
216
170
  }
217
- dockerfilePath = _dockerfile;
218
- customLogs = _log;
219
- initialDelaySeconds = Number(_delay);
220
- if (isNaN(initialDelaySeconds)) {
221
- throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的延迟时间'));
222
- }
223
- let _envParams = {};
224
- _env.split('&').forEach((item) => {
225
- _envParams[item.split('=')[0]] = item.split('=')[1];
171
+ }
172
+ else if (_repo) {
173
+ const repo = _repo.split('|');
174
+ repositoryType = repo[0];
175
+ codeDetail.Name.FullName = repo[1];
176
+ codeDetail.Name.Name = repo[1].split('/')[1];
177
+ branch = repo[2];
178
+ }
179
+ else if (_image) {
180
+ imageInfo = {
181
+ ImageUrl: _image
182
+ };
183
+ }
184
+ else {
185
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请至少选择一个上传方式'));
186
+ }
187
+ containerPort = Number(_port);
188
+ if (isNaN(containerPort)) {
189
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的端口号'));
190
+ }
191
+ flowRatio = Number(_flow);
192
+ if (![100, 0].includes(flowRatio)) {
193
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的流量策略'));
194
+ }
195
+ versionRemark = _remark;
196
+ cpu = Number(_cpu);
197
+ mem = Number(_mem);
198
+ if (isNaN(cpu) || isNaN(mem)) {
199
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的cpu和内存规格'));
200
+ }
201
+ minNum = Number(_copy.split('~')[0]);
202
+ maxNum = Number(_copy.split('~')[1]);
203
+ if (isNaN(maxNum) || isNaN(minNum)) {
204
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的副本个数'));
205
+ }
206
+ policyType = _policy.split('|')[0];
207
+ policyThreshold = Number(_policy.split('|')[1]);
208
+ if (!['cpu', 'mem'].includes(policyType) || isNaN(policyThreshold)) {
209
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的扩缩容条件'));
210
+ }
211
+ dockerfilePath = _dockerfile;
212
+ customLogs = _log;
213
+ initialDelaySeconds = Number(_delay);
214
+ if (isNaN(initialDelaySeconds)) {
215
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的延迟时间'));
216
+ }
217
+ let _envParams = {};
218
+ _env.split('&').forEach((item) => {
219
+ _envParams[item.split('=')[0]] = item.split('=')[1];
220
+ });
221
+ envParams = JSON.stringify(_envParams);
222
+ loading.start((0, i18n_1.t)('加载中...'));
223
+ let res = '';
224
+ let runId = '';
225
+ if (_path) {
226
+ loading.start((0, i18n_1.t)('正在上传中'));
227
+ let { PackageName, PackageVersion, UploadHeaders, UploadUrl } = await (0, run_1.createBuild)({
228
+ envId,
229
+ serviceName
226
230
  });
227
- envParams = JSON.stringify(_envParams);
228
- loading.start((0, i18n_1.t)('加载中...'));
229
- let res = '';
230
- let runId = '';
231
- if (_path) {
232
- loading.start((0, i18n_1.t)('正在上传中'));
233
- let { PackageName, PackageVersion, UploadHeaders, UploadUrl } = yield (0, run_1.createBuild)({
234
- envId,
235
- serviceName
236
- });
237
- yield (0, run_1.uploadZip)(path, UploadUrl, UploadHeaders[0]);
238
- loading.succeed((0, i18n_1.t)('上传成功'));
239
- if (path === `./code${uid}.zip`) {
240
- loading.start((0, i18n_1.t)('删除本地压缩包'));
241
- (0, fs_1.unlinkSync)(path);
242
- loading.succeed((0, i18n_1.t)('成功删除本地压缩包'));
243
- }
244
- let response = yield (0, run_1.updateVersion)({
245
- envId,
246
- serverName: serviceName,
247
- versionName,
248
- containerPort,
249
- uploadType: 'package',
250
- packageName: PackageName,
251
- packageVersion: PackageVersion,
252
- flowRatio,
253
- versionRemark,
254
- enableUnion: true,
255
- cpu,
256
- mem,
257
- minNum,
258
- maxNum,
259
- policyType,
260
- policyThreshold,
261
- customLogs,
262
- dockerfilePath,
263
- envParams,
264
- initialDelaySeconds
265
- });
266
- res = response.Result;
267
- runId = response.RunId;
231
+ await (0, run_1.uploadZip)(path, UploadUrl, UploadHeaders[0]);
232
+ loading.succeed((0, i18n_1.t)('上传成功'));
233
+ if (path === `./code${uid}.zip`) {
234
+ loading.start((0, i18n_1.t)('删除本地压缩包'));
235
+ (0, fs_1.unlinkSync)(path);
236
+ loading.succeed((0, i18n_1.t)('成功删除本地压缩包'));
268
237
  }
269
- else if (_image) {
270
- let response = yield (0, run_1.updateVersion)({
271
- envId,
272
- serverName: serviceName,
273
- versionName,
274
- containerPort,
275
- uploadType: 'image',
276
- imageInfo,
277
- flowRatio,
278
- versionRemark,
279
- enableUnion: true,
280
- cpu,
281
- mem,
282
- minNum,
283
- maxNum,
284
- policyType,
285
- policyThreshold,
286
- customLogs,
287
- envParams,
288
- initialDelaySeconds
289
- });
290
- res = response.Result;
291
- runId = response.RunId;
292
- }
293
- else {
294
- let response = yield (0, run_1.updateVersion)({
295
- envId,
296
- serverName: serviceName,
297
- versionName,
298
- containerPort,
299
- uploadType: 'repository',
300
- repositoryType,
301
- branch,
302
- codeDetail,
303
- flowRatio,
304
- versionRemark,
305
- enableUnion: true,
306
- cpu,
307
- mem,
308
- minNum,
309
- maxNum,
310
- policyType,
311
- policyThreshold,
312
- customLogs,
313
- dockerfilePath,
314
- envParams,
315
- initialDelaySeconds
316
- });
317
- res = response.Result;
318
- runId = response.RunId;
238
+ let response = await (0, run_1.updateVersion)({
239
+ envId,
240
+ serverName: serviceName,
241
+ versionName,
242
+ containerPort,
243
+ uploadType: 'package',
244
+ packageName: PackageName,
245
+ packageVersion: PackageVersion,
246
+ flowRatio,
247
+ versionRemark,
248
+ enableUnion: true,
249
+ cpu,
250
+ mem,
251
+ minNum,
252
+ maxNum,
253
+ policyType,
254
+ policyThreshold,
255
+ customLogs,
256
+ dockerfilePath,
257
+ envParams,
258
+ initialDelaySeconds
259
+ });
260
+ res = response.Result;
261
+ runId = response.RunId;
262
+ }
263
+ else if (_image) {
264
+ let response = await (0, run_1.updateVersion)({
265
+ envId,
266
+ serverName: serviceName,
267
+ versionName,
268
+ containerPort,
269
+ uploadType: 'image',
270
+ imageInfo,
271
+ flowRatio,
272
+ versionRemark,
273
+ enableUnion: true,
274
+ cpu,
275
+ mem,
276
+ minNum,
277
+ maxNum,
278
+ policyType,
279
+ policyThreshold,
280
+ customLogs,
281
+ envParams,
282
+ initialDelaySeconds
283
+ });
284
+ res = response.Result;
285
+ runId = response.RunId;
286
+ }
287
+ else {
288
+ let response = await (0, run_1.updateVersion)({
289
+ envId,
290
+ serverName: serviceName,
291
+ versionName,
292
+ containerPort,
293
+ uploadType: 'repository',
294
+ repositoryType,
295
+ branch,
296
+ codeDetail,
297
+ flowRatio,
298
+ versionRemark,
299
+ enableUnion: true,
300
+ cpu,
301
+ mem,
302
+ minNum,
303
+ maxNum,
304
+ policyType,
305
+ policyThreshold,
306
+ customLogs,
307
+ dockerfilePath,
308
+ envParams,
309
+ initialDelaySeconds
310
+ });
311
+ res = response.Result;
312
+ runId = response.RunId;
313
+ }
314
+ if (res !== 'succ')
315
+ throw new error_1.CloudBaseError((0, i18n_1.t)('提交构建任务失败'));
316
+ loading.start((0, i18n_1.t)('正在部署中'));
317
+ while (true) {
318
+ let { Percent, Status } = await (0, run_1.basicOperate)({ envId, runId });
319
+ if (Status === 'build_fail') {
320
+ let logs = await (0, run_1.logCreate)({ envId, runId });
321
+ (0, fs_1.writeFileSync)(`./log${runId}`, logs.reduce((res, item) => res + item + '\n', ''));
322
+ throw new error_1.CloudBaseError((0, i18n_1.t)('构建失败,日志写入{{file}}中', { file: `./log${runId}` }));
319
323
  }
320
- if (res !== 'succ')
321
- throw new error_1.CloudBaseError((0, i18n_1.t)('提交构建任务失败'));
322
- loading.start((0, i18n_1.t)('正在部署中'));
323
- while (true) {
324
- let { Percent, Status } = yield (0, run_1.basicOperate)({ envId, runId });
325
- if (Status === 'build_fail') {
326
- let logs = yield (0, run_1.logCreate)({ envId, runId });
327
- (0, fs_1.writeFileSync)(`./log${runId}`, logs.reduce((res, item) => res + item + '\n', ''));
328
- throw new error_1.CloudBaseError((0, i18n_1.t)('构建失败,日志写入{{file}}中', { file: `./log${runId}` }));
329
- }
330
- else if (Status !== 'updating') {
331
- break;
332
- }
333
- loading.start((0, i18n_1.t)('目前构建进度{{percent}}%', { percent: Percent }));
334
- yield new Promise((resolve) => {
335
- setTimeout((_) => resolve('again'), 2000);
336
- });
324
+ else if (Status !== 'updating') {
325
+ break;
337
326
  }
338
- loading.succeed((0, i18n_1.t)('构建成功'));
339
- });
327
+ loading.start((0, i18n_1.t)('目前构建进度{{percent}}%', { percent: Percent }));
328
+ await new Promise((resolve) => {
329
+ setTimeout((_) => resolve('again'), 2000);
330
+ });
331
+ }
332
+ loading.succeed((0, i18n_1.t)('构建成功'));
340
333
  }
341
334
  };
342
335
  __decorate([