@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
  };
@@ -49,32 +40,30 @@ let OpenLinkCommand = class OpenLinkCommand extends common_1.Command {
49
40
  withoutAuth: true
50
41
  };
51
42
  }
52
- execute(params) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- let openLink = null;
55
- const link = params === null || params === void 0 ? void 0 : params[0];
56
- if (link) {
57
- openLink = links.find((item) => item.value === link);
58
- if (!openLink) {
59
- throw new error_1.CloudBaseError((0, i18n_1.t)('{{link}} 链接不存在!', { link }));
60
- }
61
- }
62
- else {
63
- const { selectLink } = yield inquirer_1.default.prompt({
64
- type: 'list',
65
- name: 'selectLink',
66
- message: (0, i18n_1.t)('请选择需要打开的链接'),
67
- choices: links
68
- });
69
- openLink = links.find((item) => item.value === selectLink);
70
- }
43
+ async execute(params) {
44
+ let openLink = null;
45
+ const link = params === null || params === void 0 ? void 0 : params[0];
46
+ if (link) {
47
+ openLink = links.find((item) => item.value === link);
71
48
  if (!openLink) {
72
- throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要打开的链接!'));
49
+ throw new error_1.CloudBaseError((0, i18n_1.t)('{{link}} 链接不存在!', { link }));
73
50
  }
74
- console.log((0, i18n_1.t)('在您的默认浏览器中打开 {{name}} 链接:', { name: openLink.name }));
75
- console.log(chalk_1.default.underline.bold(openLink.url));
76
- (0, open_1.default)(openLink.url);
77
- });
51
+ }
52
+ else {
53
+ const { selectLink } = await inquirer_1.default.prompt({
54
+ type: 'list',
55
+ name: 'selectLink',
56
+ message: (0, i18n_1.t)('请选择需要打开的链接'),
57
+ choices: links
58
+ });
59
+ openLink = links.find((item) => item.value === selectLink);
60
+ }
61
+ if (!openLink) {
62
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要打开的链接!'));
63
+ }
64
+ console.log((0, i18n_1.t)('在您的默认浏览器中打开 {{name}} 链接:', { name: openLink.name }));
65
+ console.log(chalk_1.default.underline.bold(openLink.url));
66
+ (0, open_1.default)(openLink.url);
78
67
  }
79
68
  };
80
69
  __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
  };
@@ -44,11 +35,9 @@ const HostingStatusMap = {
44
35
  create_fail: (0, i18n_1.t)('初始化失败'),
45
36
  destroy_fail: (0, i18n_1.t)('销毁失败')
46
37
  };
47
- function getHostingService(envId) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const { hosting } = yield (0, utils_1.getMangerService)(envId);
50
- return hosting;
51
- });
38
+ async function getHostingService(envId) {
39
+ const { hosting } = await (0, utils_1.getMangerService)(envId);
40
+ return hosting;
52
41
  }
53
42
  let HostingDetail = class HostingDetail extends common_1.Command {
54
43
  get options() {
@@ -65,21 +54,19 @@ let HostingDetail = class HostingDetail extends common_1.Command {
65
54
  desc: (0, i18n_1.t)('查看静态网站服务信息')
66
55
  };
67
56
  }
68
- execute(envId, log) {
57
+ async execute(envId, log) {
69
58
  var _a;
70
- return __awaiter(this, void 0, void 0, function* () {
71
- const res = yield (0, hosting_1.getHostingInfo)({ envId });
72
- const website = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a[0];
73
- if (!website) {
74
- yield (0, hosting_1.initHosting)({ envId });
75
- return;
76
- }
77
- const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
78
- if (website.status !== 'offline') {
79
- log.info((0, i18n_1.t)('静态网站域名:{{link}}', { link }));
80
- }
81
- log.info((0, i18n_1.t)('静态网站状态:【{{status}}】', { status: HostingStatusMap[website.status] }));
82
- });
59
+ const res = await (0, hosting_1.getHostingInfo)({ envId });
60
+ const website = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a[0];
61
+ if (!website) {
62
+ await (0, hosting_1.initHosting)({ envId });
63
+ return;
64
+ }
65
+ const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
66
+ if (website.status !== 'offline') {
67
+ log.info((0, i18n_1.t)('静态网站域名:{{link}}', { link }));
68
+ }
69
+ log.info((0, i18n_1.t)('静态网站状态:【{{status}}】', { status: HostingStatusMap[website.status] }));
83
70
  }
84
71
  };
85
72
  __decorate([
@@ -109,74 +96,72 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
109
96
  desc: (0, i18n_1.t)('部署静态网站文件')
110
97
  };
111
98
  }
112
- execute(envId, params, log) {
99
+ async execute(envId, params, log) {
113
100
  var _a;
114
- return __awaiter(this, void 0, void 0, function* () {
115
- const localPath = (params === null || params === void 0 ? void 0 : params[0]) || '.';
116
- const cloudPath = (params === null || params === void 0 ? void 0 : params[1]) || '';
117
- log.verbose((0, i18n_1.t)('本地目录'), localPath);
118
- const resolveLocalPath = path_1.default.resolve(localPath);
119
- (0, utils_1.checkFullAccess)(resolveLocalPath, true);
120
- const isDir = (0, utils_1.isDirectory)(resolveLocalPath);
121
- const loading = (0, utils_1.loadingFactory)();
122
- loading.start((0, i18n_1.t)('准备上传中...'));
123
- let totalFiles = 0;
124
- if (isDir) {
125
- let files = yield (0, hosting_1.walkLocalDir)(envId, resolveLocalPath);
126
- files = files.filter((item) => !(0, utils_1.isDirectory)(item));
127
- totalFiles = files.length;
128
- }
129
- const onProgress = (0, utils_1.createUploadProgressBar)(() => {
130
- !isDir && log.success((0, i18n_1.t)('文件部署成功!'));
131
- }, () => {
132
- loading.stop();
133
- });
134
- const successFiles = [];
135
- const failedFiles = [];
136
- yield (0, hosting_1.hostingDeploy)({
137
- filePath: resolveLocalPath,
138
- cloudPath,
139
- envId,
140
- isDir,
141
- onProgress,
142
- onFileFinish: (...args) => {
143
- const error = args[0];
144
- const fileInfo = args[2];
145
- if (error) {
146
- failedFiles.push(fileInfo.Key);
147
- }
148
- else {
149
- successFiles.push(fileInfo.Key);
150
- }
101
+ const localPath = (params === null || params === void 0 ? void 0 : params[0]) || '.';
102
+ const cloudPath = (params === null || params === void 0 ? void 0 : params[1]) || '';
103
+ log.verbose((0, i18n_1.t)('本地目录'), localPath);
104
+ const resolveLocalPath = path_1.default.resolve(localPath);
105
+ (0, utils_1.checkFullAccess)(resolveLocalPath, true);
106
+ const isDir = (0, utils_1.isDirectory)(resolveLocalPath);
107
+ const loading = (0, utils_1.loadingFactory)();
108
+ loading.start((0, i18n_1.t)('准备上传中...'));
109
+ let totalFiles = 0;
110
+ if (isDir) {
111
+ let files = await (0, hosting_1.walkLocalDir)(envId, resolveLocalPath);
112
+ files = files.filter((item) => !(0, utils_1.isDirectory)(item));
113
+ totalFiles = files.length;
114
+ }
115
+ const onProgress = (0, utils_1.createUploadProgressBar)(() => {
116
+ !isDir && log.success((0, i18n_1.t)('文件部署成功!'));
117
+ }, () => {
118
+ loading.stop();
119
+ });
120
+ const successFiles = [];
121
+ const failedFiles = [];
122
+ await (0, hosting_1.hostingDeploy)({
123
+ filePath: resolveLocalPath,
124
+ cloudPath,
125
+ envId,
126
+ isDir,
127
+ onProgress,
128
+ onFileFinish: (...args) => {
129
+ const error = args[0];
130
+ const fileInfo = args[2];
131
+ if (error) {
132
+ failedFiles.push(fileInfo.Key);
151
133
  }
152
- });
153
- const info = yield (0, hosting_1.getHostingInfo)({
154
- envId
155
- });
156
- const website = (_a = info === null || info === void 0 ? void 0 : info.data) === null || _a === void 0 ? void 0 : _a[0];
157
- const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
158
- log.success((0, i18n_1.t)('\n部署完成 👉 {{link}}', { link }));
159
- if (isDir) {
160
- log.success((0, i18n_1.t)('文件共计 {{totalFiles}} 个', { totalFiles }));
161
- log.success((0, i18n_1.t)('文件上传成功 {{count}} 个', { count: successFiles.length }));
134
+ else {
135
+ successFiles.push(fileInfo.Key);
136
+ }
137
+ }
138
+ });
139
+ const info = await (0, hosting_1.getHostingInfo)({
140
+ envId
141
+ });
142
+ const website = (_a = info === null || info === void 0 ? void 0 : info.data) === null || _a === void 0 ? void 0 : _a[0];
143
+ const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
144
+ log.success((0, i18n_1.t)('\n部署完成 👉 {{link}}', { link }));
145
+ if (isDir) {
146
+ log.success((0, i18n_1.t)('文件共计 {{totalFiles}} 个', { totalFiles }));
147
+ log.success((0, i18n_1.t)('文件上传成功 {{count}} 个', { count: successFiles.length }));
148
+ if (totalFiles <= 50) {
149
+ (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
150
+ }
151
+ log.error((0, i18n_1.t)('文件上传失败 {{count}} 个', { count: failedFiles.length }));
152
+ if (failedFiles.length) {
162
153
  if (totalFiles <= 50) {
163
- (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
154
+ (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
164
155
  }
165
- log.error((0, i18n_1.t)('文件上传失败 {{count}} 个', { count: failedFiles.length }));
166
- if (failedFiles.length) {
167
- if (totalFiles <= 50) {
168
- (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
169
- }
170
- else {
171
- const errorLogPath = path_1.default.resolve('./cloudbase-error.log');
172
- log.error((0, i18n_1.t)('上传失败文件:'));
173
- console.log(errorLogPath);
174
- fs_1.default.writeFileSync(errorLogPath, failedFiles.join('\n'));
175
- }
176
- throw new error_1.CloudBaseError((0, i18n_1.t)('部分文件上传失败,进程退出'));
156
+ else {
157
+ const errorLogPath = path_1.default.resolve('./cloudbase-error.log');
158
+ log.error((0, i18n_1.t)('上传失败文件:'));
159
+ console.log(errorLogPath);
160
+ fs_1.default.writeFileSync(errorLogPath, failedFiles.join('\n'));
177
161
  }
162
+ throw new error_1.CloudBaseError((0, i18n_1.t)('部分文件上传失败,进程退出'));
178
163
  }
179
- });
164
+ }
180
165
  }
181
166
  };
182
167
  __decorate([
@@ -211,41 +196,39 @@ let HostingDeleteFiles = class HostingDeleteFiles extends common_1.Command {
211
196
  desc: (0, i18n_1.t)('删除静态网站文件/文件夹,文件夹需指定 --dir 选项')
212
197
  };
213
198
  }
214
- execute(envId, options, params) {
215
- return __awaiter(this, void 0, void 0, function* () {
216
- const cloudPath = (params === null || params === void 0 ? void 0 : params[0]) || '';
217
- let isDir = options.dir;
218
- if (!cloudPath) {
219
- const { confirm } = yield inquirer_1.default.prompt({
220
- type: 'confirm',
221
- name: 'confirm',
222
- message: (0, i18n_1.t)('指定云端路径为空,将会删除所有文件,是否继续'),
223
- default: false
224
- });
225
- if (!confirm) {
226
- throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
227
- }
228
- isDir = true;
229
- }
230
- if (cloudPath === '/') {
231
- isDir = true;
232
- }
233
- const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
234
- const loading = (0, utils_1.loadingFactory)();
235
- loading.start((0, i18n_1.t)('删除{{fileText}}中...', { fileText }));
236
- try {
237
- yield (0, hosting_1.hostingDelete)({
238
- envId,
239
- isDir,
240
- cloudPath
241
- });
242
- loading.succeed((0, i18n_1.t)('删除{{fileText}}成功!', { fileText }));
243
- }
244
- catch (e) {
245
- loading.fail((0, i18n_1.t)('删除{{fileText}}失败!', { fileText }));
246
- throw new error_1.CloudBaseError(e.message);
199
+ async execute(envId, options, params) {
200
+ const cloudPath = (params === null || params === void 0 ? void 0 : params[0]) || '';
201
+ let isDir = options.dir;
202
+ if (!cloudPath) {
203
+ const { confirm } = await inquirer_1.default.prompt({
204
+ type: 'confirm',
205
+ name: 'confirm',
206
+ message: (0, i18n_1.t)('指定云端路径为空,将会删除所有文件,是否继续'),
207
+ default: false
208
+ });
209
+ if (!confirm) {
210
+ throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
247
211
  }
248
- });
212
+ isDir = true;
213
+ }
214
+ if (cloudPath === '/') {
215
+ isDir = true;
216
+ }
217
+ const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
218
+ const loading = (0, utils_1.loadingFactory)();
219
+ loading.start((0, i18n_1.t)('删除{{fileText}}中...', { fileText }));
220
+ try {
221
+ await (0, hosting_1.hostingDelete)({
222
+ envId,
223
+ isDir,
224
+ cloudPath
225
+ });
226
+ loading.succeed((0, i18n_1.t)('删除{{fileText}}成功!', { fileText }));
227
+ }
228
+ catch (e) {
229
+ loading.fail((0, i18n_1.t)('删除{{fileText}}失败!', { fileText }));
230
+ throw new error_1.CloudBaseError(e.message);
231
+ }
249
232
  }
250
233
  };
251
234
  __decorate([
@@ -276,33 +259,31 @@ let HostingList = class HostingList extends common_1.Command {
276
259
  desc: (0, i18n_1.t)('展示文件列表')
277
260
  };
278
261
  }
279
- execute(envId) {
280
- return __awaiter(this, void 0, void 0, function* () {
281
- const loading = (0, utils_1.loadingFactory)();
282
- loading.start((0, i18n_1.t)('获取文件列表中...'));
283
- try {
284
- const list = yield (0, hosting_1.hostingList)({
285
- envId
286
- });
287
- loading.stop();
288
- const head = [(0, i18n_1.t)('序号'), (0, i18n_1.t)('Key'), (0, i18n_1.t)('LastModified'), (0, i18n_1.t)('ETag'), (0, i18n_1.t)('Size(KB)')];
289
- const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
290
- const tableData = list
291
- .filter(notDir)
292
- .map((item, index) => [
293
- index + 1,
294
- item.Key,
295
- (0, utils_1.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss'),
296
- item.ETag,
297
- String((0, utils_1.formateFileSize)(item.Size, 'KB'))
298
- ]);
299
- (0, utils_1.printHorizontalTable)(head, tableData);
300
- }
301
- catch (e) {
302
- loading.fail((0, i18n_1.t)('获取文件列表失败!'));
303
- throw new error_1.CloudBaseError(e.message);
304
- }
305
- });
262
+ async execute(envId) {
263
+ const loading = (0, utils_1.loadingFactory)();
264
+ loading.start((0, i18n_1.t)('获取文件列表中...'));
265
+ try {
266
+ const list = await (0, hosting_1.hostingList)({
267
+ envId
268
+ });
269
+ loading.stop();
270
+ const head = [(0, i18n_1.t)('序号'), (0, i18n_1.t)('Key'), (0, i18n_1.t)('LastModified'), (0, i18n_1.t)('ETag'), (0, i18n_1.t)('Size(KB)')];
271
+ const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
272
+ const tableData = list
273
+ .filter(notDir)
274
+ .map((item, index) => [
275
+ index + 1,
276
+ item.Key,
277
+ (0, utils_1.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss'),
278
+ item.ETag,
279
+ String((0, utils_1.formateFileSize)(item.Size, 'KB'))
280
+ ]);
281
+ (0, utils_1.printHorizontalTable)(head, tableData);
282
+ }
283
+ catch (e) {
284
+ loading.fail((0, i18n_1.t)('获取文件列表失败!'));
285
+ throw new error_1.CloudBaseError(e.message);
286
+ }
306
287
  }
307
288
  };
308
289
  __decorate([
@@ -334,33 +315,31 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
334
315
  desc: (0, i18n_1.t)('下载文件/文件夹,文件夹需指定 --dir 选项')
335
316
  };
336
317
  }
337
- execute(envId, options, params) {
338
- return __awaiter(this, void 0, void 0, function* () {
339
- let cloudPath = params === null || params === void 0 ? void 0 : params[0];
340
- const localPath = (params === null || params === void 0 ? void 0 : params[1]) || '.';
341
- const hostingService = yield getHostingService(envId);
342
- const resolveLocalPath = path_1.default.resolve(localPath);
343
- const { dir } = options;
344
- const fileText = dir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
345
- const loading = (0, utils_1.loadingFactory)();
346
- loading.start((0, i18n_1.t)('下载{{fileText}}中', { fileText }));
347
- if (/^\/.+/.test(cloudPath)) {
348
- cloudPath = cloudPath.slice(1);
349
- }
350
- if (dir) {
351
- yield hostingService.downloadDirectory({
352
- cloudPath,
353
- localPath: resolveLocalPath
354
- });
355
- }
356
- else {
357
- yield hostingService.downloadFile({
358
- cloudPath,
359
- localPath: resolveLocalPath
360
- });
361
- }
362
- loading.succeed((0, i18n_1.t)('下载{{fileText}}成功!', { fileText }));
363
- });
318
+ async execute(envId, options, params) {
319
+ let cloudPath = params === null || params === void 0 ? void 0 : params[0];
320
+ const localPath = (params === null || params === void 0 ? void 0 : params[1]) || '.';
321
+ const hostingService = await getHostingService(envId);
322
+ const resolveLocalPath = path_1.default.resolve(localPath);
323
+ const { dir } = options;
324
+ const fileText = dir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
325
+ const loading = (0, utils_1.loadingFactory)();
326
+ loading.start((0, i18n_1.t)('下载{{fileText}}中', { fileText }));
327
+ if (/^\/.+/.test(cloudPath)) {
328
+ cloudPath = cloudPath.slice(1);
329
+ }
330
+ if (dir) {
331
+ await hostingService.downloadDirectory({
332
+ cloudPath,
333
+ localPath: resolveLocalPath
334
+ });
335
+ }
336
+ else {
337
+ await hostingService.downloadFile({
338
+ cloudPath,
339
+ localPath: resolveLocalPath
340
+ });
341
+ }
342
+ loading.succeed((0, i18n_1.t)('下载{{fileText}}成功!', { fileText }));
364
343
  }
365
344
  };
366
345
  __decorate([
@@ -36,3 +36,4 @@ __exportStar(require("./ai"), exports);
36
36
  __exportStar(require("./pull"), exports);
37
37
  __exportStar(require("./self-update"), exports);
38
38
  __exportStar(require("./config"), exports);
39
+ __exportStar(require("./ag"), exports);