@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.
- 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
|
};
|
|
@@ -49,32 +40,30 @@ let OpenLinkCommand = class OpenLinkCommand extends common_1.Command {
|
|
|
49
40
|
withoutAuth: true
|
|
50
41
|
};
|
|
51
42
|
}
|
|
52
|
-
execute(params) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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)('文件')],
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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([
|
package/lib/commands/index.js
CHANGED