@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.
- package/lib/auth/login.js +51 -65
- package/lib/auth/logout.js +3 -14
- package/lib/commands/account/login.js +136 -149
- package/lib/commands/account/logout.js +3 -14
- package/lib/commands/ag/base.js +203 -0
- package/lib/commands/ag/create.js +301 -0
- package/lib/commands/ag/debug/index.html +699 -0
- package/lib/commands/ag/delete.js +200 -0
- package/lib/commands/ag/deploy.js +185 -0
- package/lib/commands/ag/detail.js +113 -0
- package/lib/commands/ag/index.js +22 -0
- package/lib/commands/ag/list.js +155 -0
- package/lib/commands/ag/run.js +644 -0
- package/lib/commands/ai/index.js +76 -95
- package/lib/commands/cloudfunction/base.js +182 -203
- package/lib/commands/cloudrun/base.js +578 -603
- package/lib/commands/common.js +48 -63
- package/lib/commands/config/delete.js +16 -27
- package/lib/commands/config/get.js +13 -24
- package/lib/commands/config/list.js +16 -27
- package/lib/commands/config/set.js +33 -44
- package/lib/commands/db/base.js +221 -240
- package/lib/commands/env/base.js +36 -49
- package/lib/commands/env/domain.js +79 -94
- package/lib/commands/env/login.js +120 -135
- package/lib/commands/framework/index.js +32 -49
- package/lib/commands/fun/base.js +223 -244
- package/lib/commands/functions/alias/getRoute.js +33 -44
- package/lib/commands/functions/alias/setRoute.js +36 -47
- package/lib/commands/functions/code-download.js +43 -54
- package/lib/commands/functions/code-update.js +23 -34
- package/lib/commands/functions/concurrency/delete.js +11 -22
- package/lib/commands/functions/concurrency/list.js +20 -31
- package/lib/commands/functions/concurrency/set.js +13 -24
- package/lib/commands/functions/config-update.js +30 -41
- package/lib/commands/functions/copy.js +12 -23
- package/lib/commands/functions/delete.js +30 -41
- package/lib/commands/functions/deploy.js +184 -202
- package/lib/commands/functions/detail.js +23 -34
- package/lib/commands/functions/invoke.js +69 -75
- package/lib/commands/functions/layer/bind.js +102 -105
- package/lib/commands/functions/layer/create.js +29 -35
- package/lib/commands/functions/layer/delete.js +42 -48
- package/lib/commands/functions/layer/download.js +52 -58
- package/lib/commands/functions/layer/list.js +44 -50
- package/lib/commands/functions/layer/sort.js +39 -45
- package/lib/commands/functions/list.js +25 -36
- package/lib/commands/functions/log.js +65 -73
- package/lib/commands/functions/run.js +118 -116
- package/lib/commands/functions/trigger-create.js +32 -43
- package/lib/commands/functions/trigger-delete.js +50 -61
- package/lib/commands/functions/version/list.js +29 -40
- package/lib/commands/functions/version/publish.js +11 -22
- package/lib/commands/gateway/create.js +50 -61
- package/lib/commands/gateway/delete.js +38 -49
- package/lib/commands/gateway/domain.js +65 -80
- package/lib/commands/gateway/list.js +31 -42
- package/lib/commands/gateway/switch.js +48 -61
- package/lib/commands/helpers/init.js +226 -249
- package/lib/commands/helpers/new.js +35 -46
- package/lib/commands/helpers/open.js +22 -33
- package/lib/commands/hosting/hosting.js +157 -178
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/app.js +114 -144
- package/lib/commands/lowcode/comps.js +136 -127
- package/lib/commands/lowcode/utils.js +11 -22
- package/lib/commands/pull/pull.js +33 -46
- package/lib/commands/run/delete.js +35 -46
- package/lib/commands/run/image/delete.js +32 -39
- package/lib/commands/run/image/download.js +26 -33
- package/lib/commands/run/image/list.js +41 -48
- package/lib/commands/run/image/upload.js +26 -33
- package/lib/commands/run/list.js +32 -43
- package/lib/commands/run/service/config.js +17 -28
- package/lib/commands/run/service/deploy.js +15 -26
- package/lib/commands/run/service/list.js +48 -59
- package/lib/commands/run/service/update.js +7 -18
- package/lib/commands/run/standalonegateway/create.js +35 -42
- package/lib/commands/run/standalonegateway/destroy.js +23 -30
- package/lib/commands/run/standalonegateway/list.js +19 -26
- package/lib/commands/run/standalonegateway/package.js +31 -38
- package/lib/commands/run/standalonegateway/turn.js +27 -34
- package/lib/commands/run/version/create.js +198 -205
- package/lib/commands/run/version/delete.js +31 -38
- package/lib/commands/run/version/list.js +42 -49
- package/lib/commands/run/version/modify.js +27 -34
- package/lib/commands/run/version/update.js +201 -208
- package/lib/commands/runf/base.js +216 -237
- package/lib/commands/self-update.js +59 -72
- package/lib/commands/smart.js +66 -79
- package/lib/commands/storage/storage.js +192 -219
- package/lib/commands/third/thirdAttach.js +16 -27
- package/lib/commands/utils.js +119 -149
- package/lib/db/index.js +48 -67
- package/lib/decorators/captureError.js +10 -21
- package/lib/decorators/guard.js +11 -22
- package/lib/decorators/injectParams.js +29 -40
- package/lib/decorators/params/common.js +5 -2
- package/lib/decorators/params/index.js +3 -12
- package/lib/env/domain.js +13 -28
- package/lib/env/index.js +25 -44
- package/lib/env/login.js +30 -45
- package/lib/function/alias.js +31 -44
- package/lib/function/base.js +187 -215
- package/lib/function/code.js +8 -19
- package/lib/function/concurrency.js +43 -58
- package/lib/function/create.js +43 -53
- package/lib/function/delete.js +22 -35
- package/lib/function/layer/attach.js +33 -46
- package/lib/function/layer/create.js +34 -45
- package/lib/function/layer/delete.js +5 -16
- package/lib/function/layer/download.js +11 -22
- package/lib/function/layer/list.js +12 -25
- package/lib/function/layer/sort.js +6 -17
- package/lib/function/trigger.js +65 -82
- package/lib/function/update.js +24 -32
- package/lib/function/version.js +29 -42
- package/lib/function/vpc.js +12 -25
- package/lib/gateway/index.js +77 -104
- package/lib/hosting.js +157 -188
- package/lib/run/delete.js +3 -12
- package/lib/run/image/build.js +6 -15
- package/lib/run/image/delete.js +3 -12
- package/lib/run/image/info.js +3 -12
- package/lib/run/image/list.js +6 -15
- package/lib/run/list.js +19 -30
- package/lib/run/repo.js +6 -15
- package/lib/run/service/common.js +160 -173
- package/lib/run/service/config.js +44 -57
- package/lib/run/service/deployPackage.js +33 -44
- package/lib/run/service/list.js +8 -14
- package/lib/run/service/showLogs.js +69 -90
- package/lib/run/service/update.js +50 -63
- package/lib/run/standalonegateway/create.js +3 -12
- package/lib/run/standalonegateway/destroy.js +3 -12
- package/lib/run/standalonegateway/list.js +3 -12
- package/lib/run/standalonegateway/package/list.js +3 -12
- package/lib/run/standalonegateway/turn/off.js +3 -12
- package/lib/run/standalonegateway/turn/on.js +3 -12
- package/lib/run/version/create.js +41 -31
- package/lib/run/version/delete.js +3 -12
- package/lib/run/version/list.js +3 -12
- package/lib/run/version/modify.js +3 -12
- package/lib/run/version/repo.js +6 -15
- package/lib/run/version/update.js +37 -26
- package/lib/storage.js +62 -93
- package/lib/third/index.js +6 -17
- package/lib/utils/ai/banner.js +49 -60
- package/lib/utils/ai/claudeWindows.js +2 -2
- package/lib/utils/ai/config.js +169 -206
- package/lib/utils/ai/ensureFiles.js +6 -17
- package/lib/utils/ai/env.js +16 -27
- package/lib/utils/ai/envLocalManager.js +35 -52
- package/lib/utils/ai/router.js +927 -1005
- package/lib/utils/ai/setup.js +527 -563
- package/lib/utils/auth.js +3 -14
- package/lib/utils/checkTcbrEnv.js +20 -31
- package/lib/utils/cli-table.js +6 -1
- package/lib/utils/config.js +4 -13
- package/lib/utils/dts.js +98 -113
- package/lib/utils/env.js +154 -175
- package/lib/utils/function-packer.js +29 -42
- package/lib/utils/log.js +10 -21
- package/lib/utils/mcp-config-modifier.js +105 -120
- package/lib/utils/net/cloud-api-request.js +15 -23
- package/lib/utils/net/credential.js +26 -39
- package/lib/utils/net/http-request.js +63 -80
- package/lib/utils/net/manager-service.js +22 -35
- package/lib/utils/notice.js +16 -27
- package/lib/utils/output/loading.js +3 -12
- package/lib/utils/parallel.js +32 -43
- package/lib/utils/platform/mac.js +4 -15
- package/lib/utils/platform/port.js +4 -15
- package/lib/utils/prompt/select.js +6 -15
- package/lib/utils/report.js +28 -33
- package/lib/utils/reporter/agree.js +11 -22
- package/lib/utils/reporter/download.js +17 -28
- package/lib/utils/reporter/usage.js +12 -23
- package/lib/utils/store/auth.js +17 -30
- package/lib/utils/store/config.js +11 -25
- package/lib/utils/store/db.js +17 -36
- package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
- package/lib/utils/template-manager.js +215 -242
- package/lib/utils/template.js +81 -96
- package/lib/utils/tools/common.js +45 -56
- package/lib/utils/tools/time.js +5 -16
- package/lib/utils/url.js +10 -4
- package/package.json +2 -2
- package/specs/ag-command/design.md +421 -0
- package/specs/ag-command/doc.md +204 -0
- package/specs/ag-command/requirements.md +173 -0
- package/specs/ag-command/summary.md +174 -0
- package/specs/ag-command/tasks.md +197 -0
- package/specs/ag-command/usage-guide.md +420 -0
- package/tsconfig.json +1 -1
- package/types/commands/ag/base.d.ts +44 -0
- package/types/commands/ag/create.d.ts +25 -0
- package/types/commands/ag/delete.d.ts +32 -0
- package/types/commands/ag/deploy.d.ts +31 -0
- package/types/commands/ag/detail.d.ts +28 -0
- package/types/commands/ag/index.d.ts +6 -0
- package/types/commands/ag/list.d.ts +35 -0
- package/types/commands/ag/run.d.ts +52 -0
- package/types/commands/cloudrun/base.d.ts +10 -0
- 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
|
-
|
|
45
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
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
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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
|
-
|
|
441
|
-
|
|
442
|
-
|
|
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
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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([
|