@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
  var __importDefault = (this && this.__importDefault) || function (mod) {
24
15
  return (mod && mod.__esModule) ? mod : { "default": mod };
25
16
  };
@@ -40,11 +31,9 @@ const AclMap = {
40
31
  ADMINWRITE: (0, i18n_1.t)('所有用户可读,仅管理员可写'),
41
32
  ADMINONLY: (0, i18n_1.t)('仅管理员可读写')
42
33
  };
43
- function getStorageService(envId) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const { storage } = yield (0, utils_1.getMangerService)(envId);
46
- return storage;
47
- });
34
+ async function getStorageService(envId) {
35
+ const { storage } = await (0, utils_1.getMangerService)(envId);
36
+ return storage;
48
37
  }
49
38
  function checkCloudPath(cloudPath) {
50
39
  if ((cloudPath === null || cloudPath === void 0 ? void 0 : cloudPath[0]) === '/') {
@@ -71,82 +60,80 @@ let UploadCommand = class UploadCommand extends common_1.Command {
71
60
  desc: (0, i18n_1.t)('上传文件/文件夹')
72
61
  };
73
62
  }
74
- execute(envId, params, options, log) {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- const localPath = params === null || params === void 0 ? void 0 : params[0];
77
- const cloudPath = params === null || params === void 0 ? void 0 : params[1];
78
- const retryCount = options === null || options === void 0 ? void 0 : options.times;
79
- const retryInterval = options === null || options === void 0 ? void 0 : options.interval;
80
- const resolveLocalPath = path_1.default.resolve(localPath);
81
- if (!(0, utils_1.checkFullAccess)(resolveLocalPath)) {
82
- throw new error_1.CloudBaseError((0, i18n_1.t)('文件未找到!'));
83
- }
84
- if (retryCount > 10) {
85
- throw new error_1.CloudBaseError((0, i18n_1.t)('上传重试次数为 0-10 次之间'));
86
- }
87
- const loading = (0, utils_1.loadingFactory)();
88
- loading.start((0, i18n_1.t)('准备上传中...'));
89
- const storageService = yield getStorageService(envId);
90
- const isDir = fs_1.default.statSync(resolveLocalPath).isDirectory();
91
- let totalFiles = 0;
92
- if (isDir) {
93
- let files = yield storageService.walkLocalDir(resolveLocalPath);
94
- files = files.filter((item) => !(0, utils_1.isDirectory)(item));
95
- totalFiles = files.length;
96
- }
97
- const onProgress = (0, utils_1.createUploadProgressBar)(() => {
98
- !isDir && log.success((0, i18n_1.t)('上传文件成功!'));
99
- }, () => {
100
- loading.stop();
101
- });
102
- const successFiles = [];
103
- const failedFiles = [];
104
- if (isDir) {
105
- yield storageService.uploadDirectory({
106
- localPath: resolveLocalPath,
107
- cloudPath,
108
- onProgress,
109
- onFileFinish: (...args) => {
110
- const error = args[0];
111
- const fileInfo = args[2];
112
- if (error) {
113
- failedFiles.push(fileInfo.Key);
114
- }
115
- else {
116
- successFiles.push(fileInfo.Key);
117
- }
118
- },
119
- retryCount: retryCount || 1,
120
- retryInterval,
121
- parallel: 20
122
- });
123
- log.success((0, i18n_1.t)('文件共计 {{count}} 个', { count: totalFiles }));
124
- log.success((0, i18n_1.t)('文件上传成功 {{count}} 个', { count: successFiles.length }));
125
- if (totalFiles <= 50) {
126
- (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
127
- }
128
- log.error((0, i18n_1.t)('文件上传失败 {{count}} 个', { count: failedFiles.length }));
129
- if (failedFiles.length) {
130
- if (totalFiles <= 50) {
131
- (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
63
+ async execute(envId, params, options, log) {
64
+ const localPath = params === null || params === void 0 ? void 0 : params[0];
65
+ const cloudPath = params === null || params === void 0 ? void 0 : params[1];
66
+ const retryCount = options === null || options === void 0 ? void 0 : options.times;
67
+ const retryInterval = options === null || options === void 0 ? void 0 : options.interval;
68
+ const resolveLocalPath = path_1.default.resolve(localPath);
69
+ if (!(0, utils_1.checkFullAccess)(resolveLocalPath)) {
70
+ throw new error_1.CloudBaseError((0, i18n_1.t)('文件未找到!'));
71
+ }
72
+ if (retryCount > 10) {
73
+ throw new error_1.CloudBaseError((0, i18n_1.t)('上传重试次数为 0-10 次之间'));
74
+ }
75
+ const loading = (0, utils_1.loadingFactory)();
76
+ loading.start((0, i18n_1.t)('准备上传中...'));
77
+ const storageService = await getStorageService(envId);
78
+ const isDir = fs_1.default.statSync(resolveLocalPath).isDirectory();
79
+ let totalFiles = 0;
80
+ if (isDir) {
81
+ let files = await storageService.walkLocalDir(resolveLocalPath);
82
+ files = files.filter((item) => !(0, utils_1.isDirectory)(item));
83
+ totalFiles = files.length;
84
+ }
85
+ const onProgress = (0, utils_1.createUploadProgressBar)(() => {
86
+ !isDir && log.success((0, i18n_1.t)('上传文件成功!'));
87
+ }, () => {
88
+ loading.stop();
89
+ });
90
+ const successFiles = [];
91
+ const failedFiles = [];
92
+ if (isDir) {
93
+ await storageService.uploadDirectory({
94
+ localPath: resolveLocalPath,
95
+ cloudPath,
96
+ onProgress,
97
+ onFileFinish: (...args) => {
98
+ const error = args[0];
99
+ const fileInfo = args[2];
100
+ if (error) {
101
+ failedFiles.push(fileInfo.Key);
132
102
  }
133
103
  else {
134
- const errorLogPath = path_1.default.resolve('./cloudbase-error.log');
135
- log.error((0, i18n_1.t)('上传失败文件:'));
136
- console.log(errorLogPath);
137
- fs_1.default.writeFileSync(errorLogPath, failedFiles.join('\n'));
104
+ successFiles.push(fileInfo.Key);
138
105
  }
139
- }
106
+ },
107
+ retryCount: retryCount || 1,
108
+ retryInterval,
109
+ parallel: 20
110
+ });
111
+ log.success((0, i18n_1.t)('文件共计 {{count}} 个', { count: totalFiles }));
112
+ log.success((0, i18n_1.t)('文件上传成功 {{count}} 个', { count: successFiles.length }));
113
+ if (totalFiles <= 50) {
114
+ (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
140
115
  }
141
- else {
142
- const assignCloudPath = cloudPath || path_1.default.parse(resolveLocalPath).base;
143
- yield storageService.uploadFile({
144
- localPath: resolveLocalPath,
145
- cloudPath: assignCloudPath,
146
- onProgress
147
- });
116
+ log.error((0, i18n_1.t)('文件上传失败 {{count}} 个', { count: failedFiles.length }));
117
+ if (failedFiles.length) {
118
+ if (totalFiles <= 50) {
119
+ (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
120
+ }
121
+ else {
122
+ const errorLogPath = path_1.default.resolve('./cloudbase-error.log');
123
+ log.error((0, i18n_1.t)('上传失败文件:'));
124
+ console.log(errorLogPath);
125
+ fs_1.default.writeFileSync(errorLogPath, failedFiles.join('\n'));
126
+ }
148
127
  }
149
- });
128
+ }
129
+ else {
130
+ const assignCloudPath = cloudPath || path_1.default.parse(resolveLocalPath).base;
131
+ await storageService.uploadFile({
132
+ localPath: resolveLocalPath,
133
+ cloudPath: assignCloudPath,
134
+ onProgress
135
+ });
136
+ }
150
137
  }
151
138
  };
152
139
  __decorate([
@@ -182,34 +169,32 @@ let DownloadCommand = class DownloadCommand extends common_1.Command {
182
169
  desc: (0, i18n_1.t)('下载文件/文件夹,文件夹需指定 --dir 选项')
183
170
  };
184
171
  }
185
- execute(envId, options, params) {
186
- return __awaiter(this, void 0, void 0, function* () {
187
- const cloudPath = params === null || params === void 0 ? void 0 : params[0];
188
- const localPath = params === null || params === void 0 ? void 0 : params[1];
189
- const storageService = yield getStorageService(envId);
190
- const resolveLocalPath = path_1.default.resolve(localPath);
191
- const { dir } = options;
192
- const fileText = dir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
193
- if (dir && !(0, utils_1.checkFullAccess)(resolveLocalPath)) {
194
- throw new error_1.CloudBaseError((0, i18n_1.t)('存储文件夹不存在!'));
195
- }
196
- const loading = (0, utils_1.loadingFactory)();
197
- loading.start((0, i18n_1.t)('下载{{type}}中', { type: fileText }));
198
- if (dir) {
199
- yield storageService.downloadDirectory({
200
- localPath: resolveLocalPath,
201
- cloudPath,
202
- parallel: 20
203
- });
204
- }
205
- else {
206
- yield storageService.downloadFile({
207
- cloudPath,
208
- localPath: resolveLocalPath
209
- });
210
- }
211
- loading.succeed((0, i18n_1.t)('下载{{type}}成功!', { type: fileText }));
212
- });
172
+ async execute(envId, options, params) {
173
+ const cloudPath = params === null || params === void 0 ? void 0 : params[0];
174
+ const localPath = params === null || params === void 0 ? void 0 : params[1];
175
+ const storageService = await getStorageService(envId);
176
+ const resolveLocalPath = path_1.default.resolve(localPath);
177
+ const { dir } = options;
178
+ const fileText = dir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
179
+ if (dir && !(0, utils_1.checkFullAccess)(resolveLocalPath)) {
180
+ throw new error_1.CloudBaseError((0, i18n_1.t)('存储文件夹不存在!'));
181
+ }
182
+ const loading = (0, utils_1.loadingFactory)();
183
+ loading.start((0, i18n_1.t)('下载{{type}}中', { type: fileText }));
184
+ if (dir) {
185
+ await storageService.downloadDirectory({
186
+ localPath: resolveLocalPath,
187
+ cloudPath,
188
+ parallel: 20
189
+ });
190
+ }
191
+ else {
192
+ await storageService.downloadFile({
193
+ cloudPath,
194
+ localPath: resolveLocalPath
195
+ });
196
+ }
197
+ loading.succeed((0, i18n_1.t)('下载{{type}}成功!', { type: fileText }));
213
198
  }
214
199
  };
215
200
  __decorate([
@@ -244,37 +229,35 @@ let DeleteFileCommand = class DeleteFileCommand extends common_1.Command {
244
229
  desc: (0, i18n_1.t)('删除文件/文件夹,文件夹需指定 --dir 选项')
245
230
  };
246
231
  }
247
- execute(envId, options, params) {
248
- return __awaiter(this, void 0, void 0, function* () {
249
- let isDir = options.dir;
250
- const cloudPath = params === null || params === void 0 ? void 0 : params[0];
251
- const loading = (0, utils_1.loadingFactory)();
252
- const storageService = yield getStorageService(envId);
253
- if (!cloudPath) {
254
- const { confirm } = yield inquirer_1.default.prompt({
255
- type: 'confirm',
256
- name: 'confirm',
257
- message: (0, i18n_1.t)('指定云端路径为空,将会删除所有文件,是否继续'),
258
- default: false
259
- });
260
- if (!confirm) {
261
- throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
262
- }
263
- isDir = true;
264
- }
265
- if (cloudPath === '/') {
266
- isDir = true;
267
- }
268
- const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
269
- loading.start((0, i18n_1.t)('删除{{type}}中', { type: fileText }));
270
- if (isDir) {
271
- yield storageService.deleteDirectory(cloudPath);
272
- }
273
- else {
274
- yield storageService.deleteFile([cloudPath]);
232
+ async execute(envId, options, params) {
233
+ let isDir = options.dir;
234
+ const cloudPath = params === null || params === void 0 ? void 0 : params[0];
235
+ const loading = (0, utils_1.loadingFactory)();
236
+ const storageService = await getStorageService(envId);
237
+ if (!cloudPath) {
238
+ const { confirm } = await inquirer_1.default.prompt({
239
+ type: 'confirm',
240
+ name: 'confirm',
241
+ message: (0, i18n_1.t)('指定云端路径为空,将会删除所有文件,是否继续'),
242
+ default: false
243
+ });
244
+ if (!confirm) {
245
+ throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
275
246
  }
276
- loading.succeed((0, i18n_1.t)('删除{{type}}成功!', { type: fileText }));
277
- });
247
+ isDir = true;
248
+ }
249
+ if (cloudPath === '/') {
250
+ isDir = true;
251
+ }
252
+ const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
253
+ loading.start((0, i18n_1.t)('删除{{type}}中', { type: fileText }));
254
+ if (isDir) {
255
+ await storageService.deleteDirectory(cloudPath);
256
+ }
257
+ else {
258
+ await storageService.deleteFile([cloudPath]);
259
+ }
260
+ loading.succeed((0, i18n_1.t)('删除{{type}}成功!', { type: fileText }));
278
261
  }
279
262
  };
280
263
  __decorate([
@@ -305,27 +288,25 @@ let StorageListCommand = class StorageListCommand extends common_1.Command {
305
288
  desc: (0, i18n_1.t)('获取文件存储的文件列表,不指定路径时获取全部文件列表')
306
289
  };
307
290
  }
308
- execute(envId, params) {
309
- return __awaiter(this, void 0, void 0, function* () {
310
- const cloudPath = params === null || params === void 0 ? void 0 : params[0];
311
- const storageService = yield getStorageService(envId);
312
- const loading = (0, utils_1.loadingFactory)();
313
- loading.start((0, i18n_1.t)('获取文件列表中...'));
314
- const list = yield storageService.listDirectoryFiles(cloudPath);
315
- loading.stop();
316
- const head = [(0, i18n_1.t)('序号'), 'Key', 'LastModified', 'ETag', 'Size(KB)'];
317
- const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
318
- const tableData = list
319
- .filter(notDir)
320
- .map((item, index) => [
321
- index + 1,
322
- item.Key,
323
- (0, utils_1.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss'),
324
- item.ETag,
325
- String((0, utils_1.formateFileSize)(item.Size, 'KB'))
326
- ]);
327
- (0, utils_1.printHorizontalTable)(head, tableData);
328
- });
291
+ async execute(envId, params) {
292
+ const cloudPath = params === null || params === void 0 ? void 0 : params[0];
293
+ const storageService = await getStorageService(envId);
294
+ const loading = (0, utils_1.loadingFactory)();
295
+ loading.start((0, i18n_1.t)('获取文件列表中...'));
296
+ const list = await storageService.listDirectoryFiles(cloudPath);
297
+ loading.stop();
298
+ const head = [(0, i18n_1.t)('序号'), 'Key', 'LastModified', 'ETag', 'Size(KB)'];
299
+ const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
300
+ const tableData = list
301
+ .filter(notDir)
302
+ .map((item, index) => [
303
+ index + 1,
304
+ item.Key,
305
+ (0, utils_1.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss'),
306
+ item.ETag,
307
+ String((0, utils_1.formateFileSize)(item.Size, 'KB'))
308
+ ]);
309
+ (0, utils_1.printHorizontalTable)(head, tableData);
329
310
  }
330
311
  };
331
312
  __decorate([
@@ -355,14 +336,12 @@ let GetUrlCommand = class GetUrlCommand extends common_1.Command {
355
336
  desc: (0, i18n_1.t)('获取文件临时访问地址')
356
337
  };
357
338
  }
358
- execute(envId, params, log) {
359
- return __awaiter(this, void 0, void 0, function* () {
360
- const cloudPath = params === null || params === void 0 ? void 0 : params[0];
361
- const storageService = yield getStorageService(envId);
362
- const fileList = yield storageService.getTemporaryUrl([cloudPath]);
363
- const { url } = fileList[0];
364
- log.success((0, i18n_1.t)('文件临时访问地址:{{url}}', { url }));
365
- });
339
+ async execute(envId, params, log) {
340
+ const cloudPath = params === null || params === void 0 ? void 0 : params[0];
341
+ const storageService = await getStorageService(envId);
342
+ const fileList = await storageService.getTemporaryUrl([cloudPath]);
343
+ const { url } = fileList[0];
344
+ log.success((0, i18n_1.t)('文件临时访问地址:{{url}}', { url }));
366
345
  }
367
346
  };
368
347
  __decorate([
@@ -393,20 +372,18 @@ let StorageDetailCommand = class StorageDetailCommand extends common_1.Command {
393
372
  desc: (0, i18n_1.t)('获取文件信息')
394
373
  };
395
374
  }
396
- execute(envId, params) {
397
- return __awaiter(this, void 0, void 0, function* () {
398
- const cloudPath = params === null || params === void 0 ? void 0 : params[0];
399
- const storageService = yield getStorageService(envId);
400
- const fileInfo = yield storageService.getFileInfo(cloudPath);
401
- const date = (0, utils_1.formatDate)(fileInfo.Date, 'yyyy-MM-dd hh:mm:ss');
402
- const logInfo = (0, i18n_1.t)('文件大小:{{size}}\n文件类型:{{type}}\n修改日期:{{date}}\nETag:{{etag}}', {
403
- size: fileInfo.Size,
404
- type: fileInfo.Type,
405
- date,
406
- etag: fileInfo.ETag
407
- });
408
- console.log(logInfo);
375
+ async execute(envId, params) {
376
+ const cloudPath = params === null || params === void 0 ? void 0 : params[0];
377
+ const storageService = await getStorageService(envId);
378
+ const fileInfo = await storageService.getFileInfo(cloudPath);
379
+ const date = (0, utils_1.formatDate)(fileInfo.Date, 'yyyy-MM-dd hh:mm:ss');
380
+ const logInfo = (0, i18n_1.t)('文件大小:{{size}}\n文件类型:{{type}}\n修改日期:{{date}}\nETag:{{etag}}', {
381
+ size: fileInfo.Size,
382
+ type: fileInfo.Type,
383
+ date,
384
+ etag: fileInfo.ETag
409
385
  });
386
+ console.log(logInfo);
410
387
  }
411
388
  };
412
389
  __decorate([
@@ -436,12 +413,10 @@ let GetAclCommand = class GetAclCommand extends common_1.Command {
436
413
  desc: (0, i18n_1.t)('获取文件存储权限信息')
437
414
  };
438
415
  }
439
- execute(envId) {
440
- return __awaiter(this, void 0, void 0, function* () {
441
- const storageService = yield getStorageService(envId);
442
- const acl = yield storageService.getStorageAcl();
443
- console.log((0, i18n_1.t)('当前权限【{{acl}}】', { acl: AclMap[acl] }));
444
- });
416
+ async execute(envId) {
417
+ const storageService = await getStorageService(envId);
418
+ const acl = await storageService.getStorageAcl();
419
+ console.log((0, i18n_1.t)('当前权限【{{acl}}】', { acl: AclMap[acl] }));
445
420
  }
446
421
  };
447
422
  __decorate([
@@ -470,35 +445,33 @@ let setAclCommand = class setAclCommand extends common_1.Command {
470
445
  desc: (0, i18n_1.t)('设置文件存储权限信息')
471
446
  };
472
447
  }
473
- execute(envId, log) {
474
- return __awaiter(this, void 0, void 0, function* () {
475
- const storageService = yield getStorageService(envId);
476
- const { acl } = yield inquirer_1.default.prompt({
477
- type: 'list',
478
- name: 'acl',
479
- message: (0, i18n_1.t)('选择权限'),
480
- choices: [
481
- {
482
- name: (0, i18n_1.t)('所有用户可读,仅创建者和管理员可写'),
483
- value: 'READONLY'
484
- },
485
- {
486
- name: (0, i18n_1.t)('仅创建者及管理员可读写'),
487
- value: 'PRIVATE'
488
- },
489
- {
490
- name: (0, i18n_1.t)('所有用户可读,仅管理员可写'),
491
- value: 'ADMINWRITE'
492
- },
493
- {
494
- name: (0, i18n_1.t)('仅管理员可读写'),
495
- value: 'ADMINONLY'
496
- }
497
- ]
498
- });
499
- yield storageService.setStorageAcl(acl);
500
- log.success((0, i18n_1.t)('设置存储权限成功!'));
448
+ async execute(envId, log) {
449
+ const storageService = await getStorageService(envId);
450
+ const { acl } = await inquirer_1.default.prompt({
451
+ type: 'list',
452
+ name: 'acl',
453
+ message: (0, i18n_1.t)('选择权限'),
454
+ choices: [
455
+ {
456
+ name: (0, i18n_1.t)('所有用户可读,仅创建者和管理员可写'),
457
+ value: 'READONLY'
458
+ },
459
+ {
460
+ name: (0, i18n_1.t)('仅创建者及管理员可读写'),
461
+ value: 'PRIVATE'
462
+ },
463
+ {
464
+ name: (0, i18n_1.t)('所有用户可读,仅管理员可写'),
465
+ value: 'ADMINWRITE'
466
+ },
467
+ {
468
+ name: (0, i18n_1.t)('仅管理员可读写'),
469
+ value: 'ADMINONLY'
470
+ }
471
+ ]
501
472
  });
473
+ await storageService.setStorageAcl(acl);
474
+ log.success((0, i18n_1.t)('设置存储权限成功!'));
502
475
  }
503
476
  };
504
477
  __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.DeleteThirdAttach = void 0;
25
16
  const common_1 = require("../common");
@@ -47,25 +38,23 @@ class DeleteThirdAttach extends common_1.Command {
47
38
  requiredEnvId: false
48
39
  };
49
40
  }
50
- execute(options) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const { source, thirdAppId } = options;
53
- let typeFlag;
54
- if (source === 'qq') {
55
- typeFlag = 1;
56
- }
57
- if (!typeFlag) {
58
- throw new Error((0, i18n_1.t)('请指定对应的source'));
59
- }
60
- const loading = (0, utils_1.loadingFactory)();
61
- loading.start((0, i18n_1.t)('数据加载中...'));
62
- const data = yield (0, third_1.deleteThirdPartAttach)({
63
- TypeFlag: typeFlag,
64
- ThirdPartAppid: thirdAppId
65
- });
66
- loading.stop();
67
- console.log(data);
41
+ async execute(options) {
42
+ const { source, thirdAppId } = options;
43
+ let typeFlag;
44
+ if (source === 'qq') {
45
+ typeFlag = 1;
46
+ }
47
+ if (!typeFlag) {
48
+ throw new Error((0, i18n_1.t)('请指定对应的source'));
49
+ }
50
+ const loading = (0, utils_1.loadingFactory)();
51
+ loading.start((0, i18n_1.t)('数据加载中...'));
52
+ const data = await (0, third_1.deleteThirdPartAttach)({
53
+ TypeFlag: typeFlag,
54
+ ThirdPartAppid: thirdAppId
68
55
  });
56
+ loading.stop();
57
+ console.log(data);
69
58
  }
70
59
  }
71
60
  __decorate([