@cloudbase/cli 2.9.9 → 2.9.10-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/bin/cloudbase.js +2 -1
- package/bin/tcb.js +35 -28
- package/lib/auth/login.js +21 -13
- package/lib/commands/account/login.js +43 -42
- package/lib/commands/account/logout.js +3 -2
- package/lib/commands/ai/index.js +13 -12
- package/lib/commands/cloudfunction/base.js +24 -26
- package/lib/commands/cloudrun/base.js +87 -96
- package/lib/commands/common.js +11 -10
- package/lib/commands/config/delete.js +72 -0
- package/lib/commands/config/get.js +69 -0
- package/lib/commands/config/index.js +21 -0
- package/lib/commands/config/interface.js +24 -0
- package/lib/commands/config/list.js +72 -0
- package/lib/commands/config/set.js +89 -0
- package/lib/commands/db/base.js +33 -32
- package/lib/commands/env/base.js +12 -11
- package/lib/commands/env/domain.js +24 -23
- package/lib/commands/env/login.js +31 -30
- package/lib/commands/fun/base.js +37 -36
- package/lib/commands/functions/alias/getRoute.js +5 -4
- package/lib/commands/functions/alias/setRoute.js +7 -6
- package/lib/commands/functions/code-download.js +15 -11
- package/lib/commands/functions/code-update.js +8 -7
- package/lib/commands/functions/concurrency/delete.js +5 -4
- package/lib/commands/functions/concurrency/list.js +6 -5
- package/lib/commands/functions/concurrency/set.js +5 -4
- package/lib/commands/functions/config-update.js +8 -7
- package/lib/commands/functions/copy.js +7 -6
- package/lib/commands/functions/delete.js +8 -7
- package/lib/commands/functions/deploy.js +35 -34
- package/lib/commands/functions/detail.js +32 -31
- package/lib/commands/functions/invoke.js +16 -15
- package/lib/commands/functions/layer/bind.js +26 -25
- package/lib/commands/functions/layer/common.js +2 -1
- package/lib/commands/functions/layer/create.js +7 -6
- package/lib/commands/functions/layer/delete.js +9 -8
- package/lib/commands/functions/layer/download.js +10 -9
- package/lib/commands/functions/layer/list.js +10 -9
- package/lib/commands/functions/layer/sort.js +9 -8
- package/lib/commands/functions/list.js +9 -8
- package/lib/commands/functions/log.js +28 -27
- package/lib/commands/functions/run.js +21 -20
- package/lib/commands/functions/trigger-create.js +9 -8
- package/lib/commands/functions/trigger-delete.js +10 -9
- package/lib/commands/functions/version/list.js +9 -8
- package/lib/commands/functions/version/publish.js +5 -4
- package/lib/commands/gateway/create.js +14 -13
- package/lib/commands/gateway/delete.js +10 -9
- package/lib/commands/gateway/domain.js +25 -24
- package/lib/commands/gateway/list.js +11 -10
- package/lib/commands/gateway/switch.js +22 -19
- package/lib/commands/helpers/init.js +38 -37
- package/lib/commands/helpers/new.js +7 -6
- package/lib/commands/helpers/open.js +7 -6
- package/lib/commands/hosting/hosting.js +45 -44
- package/lib/commands/index.js +1 -0
- package/lib/commands/pull/pull.js +12 -11
- package/lib/commands/run/delete.js +16 -15
- package/lib/commands/run/image/common.js +2 -1
- package/lib/commands/run/image/delete.js +10 -9
- package/lib/commands/run/image/download.js +8 -7
- package/lib/commands/run/image/list.js +11 -10
- package/lib/commands/run/image/upload.js +9 -8
- package/lib/commands/run/list.js +10 -9
- package/lib/commands/run/service/config.js +13 -12
- package/lib/commands/run/service/deploy.js +24 -23
- package/lib/commands/run/service/list.js +10 -9
- package/lib/commands/run/service/update.js +22 -21
- package/lib/commands/run/standalonegateway/common.js +2 -1
- package/lib/commands/run/standalonegateway/create.js +14 -13
- package/lib/commands/run/standalonegateway/destroy.js +9 -8
- package/lib/commands/run/standalonegateway/list.js +7 -6
- package/lib/commands/run/standalonegateway/package.js +7 -6
- package/lib/commands/run/standalonegateway/turn.js +10 -9
- package/lib/commands/run/version/common.js +2 -1
- package/lib/commands/run/version/create.js +41 -40
- package/lib/commands/run/version/delete.js +10 -9
- package/lib/commands/run/version/list.js +13 -12
- package/lib/commands/run/version/modify.js +13 -12
- package/lib/commands/run/version/update.js +57 -54
- package/lib/commands/runf/base.js +42 -40
- package/lib/commands/self-update.js +11 -10
- package/lib/commands/smart.js +5 -4
- package/lib/commands/storage/storage.js +61 -56
- package/lib/commands/third/thirdAttach.js +6 -5
- package/lib/commands/utils.js +8 -5
- package/lib/constant.js +18 -17
- package/lib/decorators/deprecate.js +2 -1
- package/lib/function/alias.js +3 -2
- package/lib/function/base.js +9 -8
- package/lib/function/concurrency.js +4 -3
- package/lib/function/create.js +5 -4
- package/lib/function/delete.js +2 -1
- package/lib/function/layer/attach.js +2 -1
- package/lib/function/layer/create.js +2 -1
- package/lib/function/layer/download.js +2 -1
- package/lib/function/trigger.js +6 -5
- package/lib/function/update.js +3 -2
- package/lib/function/version.js +3 -2
- package/lib/help.js +22 -20
- package/lib/hosting.js +18 -17
- package/lib/i18n/index.js +81 -0
- package/lib/run/service/common.js +14 -13
- package/lib/run/service/config.js +4 -3
- package/lib/run/service/deployPackage.js +6 -5
- package/lib/run/service/showLogs.js +3 -2
- package/lib/run/service/update.js +7 -6
- package/lib/run/standalonegateway/list.js +5 -1
- package/lib/storage.js +2 -1
- package/lib/utils/ai/banner.js +12 -11
- package/lib/utils/ai/claudeWindows.js +5 -3
- package/lib/utils/ai/config.js +3 -2
- package/lib/utils/ai/const.js +4 -3
- package/lib/utils/ai/env.js +3 -2
- package/lib/utils/ai/envLocalManager.js +6 -5
- package/lib/utils/ai/nodeVersion.js +5 -1
- package/lib/utils/ai/router.js +129 -106
- package/lib/utils/ai/setup.js +95 -91
- package/lib/utils/checkTcbrEnv.js +22 -21
- package/lib/utils/cli-table.js +2 -1
- package/lib/utils/commonParamsCheck.js +4 -3
- package/lib/utils/debug-logger.js +2 -1
- package/lib/utils/dts.js +4 -3
- package/lib/utils/env.js +23 -21
- package/lib/utils/fs/index.js +5 -4
- package/lib/utils/function-packer.js +3 -2
- package/lib/utils/index.js +1 -0
- package/lib/utils/mcp-config-modifier.js +18 -17
- package/lib/utils/net/cloud-api-request.js +2 -1
- package/lib/utils/net/credential.js +2 -1
- package/lib/utils/net/http-request.js +2 -1
- package/lib/utils/progress-bar.js +2 -1
- package/lib/utils/prompt/select.js +8 -6
- package/lib/utils/store/auth.js +3 -2
- package/lib/utils/store/config.js +49 -0
- package/lib/utils/store/db.js +5 -0
- package/lib/utils/store/index.js +1 -1
- package/lib/utils/tcbrApi/callTcbrApi.js +2 -1
- package/lib/utils/template-manager.js +37 -36
- package/lib/utils/template.js +10 -9
- package/lib/utils/tools/common.js +3 -2
- package/lib/utils/url.js +19 -0
- package/lib/utils/validator.js +12 -4
- package/locales/README.md +160 -0
- package/locales/i18next-scanner.config.js +206 -0
- package/locales/langs/en.json +1235 -0
- package/locales/langs/zh.json +1235 -0
- package/locales/mapping.json +1235 -0
- package/package.json +9 -2
- package/types/commands/config/delete.d.ts +13 -0
- package/types/commands/config/get.d.ts +13 -0
- package/types/commands/config/index.d.ts +5 -0
- package/types/commands/config/interface.d.ts +17 -0
- package/types/commands/config/list.d.ts +13 -0
- package/types/commands/config/set.d.ts +13 -0
- package/types/commands/index.d.ts +1 -0
- package/types/i18n/index.d.ts +3 -0
- package/types/utils/ai/const.d.ts +1 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/store/config.d.ts +8 -0
- package/types/utils/store/db.d.ts +2 -0
- package/types/utils/store/index.d.ts +1 -1
- package/types/utils/url.d.ts +18 -0
|
@@ -16,6 +16,7 @@ const toolbox_1 = require("@cloudbase/toolbox");
|
|
|
16
16
|
const index_1 = require("./index");
|
|
17
17
|
const __1 = require("..");
|
|
18
18
|
const constant_1 = require("../../constant");
|
|
19
|
+
const i18n_1 = require("../../i18n");
|
|
19
20
|
const tcbService = utils_1.CloudApiService.getInstance('tcb');
|
|
20
21
|
const tcrCloudApiService = new utils_1.CloudApiService('tcr', {}, '2019-09-24');
|
|
21
22
|
const describeCloudRunServerDetail = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -37,7 +38,7 @@ function describeWxCloudBaseRunReleaseOrder(options) {
|
|
|
37
38
|
exports.describeWxCloudBaseRunReleaseOrder = describeWxCloudBaseRunReleaseOrder;
|
|
38
39
|
const convertNumber = (item) => {
|
|
39
40
|
if (isNaN(Number(item))) {
|
|
40
|
-
throw new toolbox_1.CloudBaseError(
|
|
41
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('{{item}} 必须为数字', { item }));
|
|
41
42
|
}
|
|
42
43
|
return Number(item);
|
|
43
44
|
};
|
|
@@ -46,7 +47,7 @@ const extractPolicyDetails = (policyDetails) => {
|
|
|
46
47
|
return policyDetails.split('&').map(condition => {
|
|
47
48
|
let [type, threshold] = [condition.split('=')[0], Number(condition.split('=')[1])];
|
|
48
49
|
if (isNaN(threshold) || !['cpu', 'mem'].includes(type)) {
|
|
49
|
-
throw new toolbox_1.CloudBaseError('请输入合法的缩扩容配置');
|
|
50
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('请输入合法的缩扩容配置'));
|
|
50
51
|
}
|
|
51
52
|
return {
|
|
52
53
|
PolicyType: type,
|
|
@@ -77,19 +78,19 @@ const mergeEnvParams = (curEnvParams, preEnvParams) => {
|
|
|
77
78
|
exports.mergeEnvParams = mergeEnvParams;
|
|
78
79
|
function checkRequiredParams(options) {
|
|
79
80
|
if (!options.envId) {
|
|
80
|
-
throw new toolbox_1.CloudBaseError('请使用 -e 或 --envId 指定环境ID');
|
|
81
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('请使用 -e 或 --envId 指定环境ID'));
|
|
81
82
|
}
|
|
82
83
|
if (!options.serviceName) {
|
|
83
|
-
throw new toolbox_1.CloudBaseError('请使用 -s 或 --serviceName 指定服务名');
|
|
84
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('请使用 -s 或 --serviceName 指定服务名'));
|
|
84
85
|
}
|
|
85
86
|
if (!options.containerPort) {
|
|
86
|
-
throw new toolbox_1.CloudBaseError('请使用 --containerPort 指定监听端口号');
|
|
87
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('请使用 --containerPort 指定监听端口号'));
|
|
87
88
|
}
|
|
88
89
|
if (!options.isCreated && !options.path && !options.custom_image) {
|
|
89
|
-
throw new toolbox_1.CloudBaseError('请使用 --path 指定代码根目录或 --custom_image 指定 TCR 镜像 URL');
|
|
90
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('请使用 --path 指定代码根目录或 --custom_image 指定 TCR 镜像 URL'));
|
|
90
91
|
}
|
|
91
92
|
if (options.isCreated && !options.path && !options.custom_image && !options.library_image && !options.image) {
|
|
92
|
-
throw new toolbox_1.CloudBaseError('请使用 --path 指定代码根目录或 --custom_image 指定 TCR 镜像 URL 或 --library_image 指定线上镜像 tag ');
|
|
93
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('请使用 --path 指定代码根目录或 --custom_image 指定 TCR 镜像 URL 或 --library_image 指定线上镜像 tag '));
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
function tcbrServiceOptions(options, isCreated, defaultOverride, previousServerConfig) {
|
|
@@ -119,7 +120,7 @@ function tcbrServiceOptions(options, isCreated, defaultOverride, previousServerC
|
|
|
119
120
|
minNum
|
|
120
121
|
});
|
|
121
122
|
if (log_type && log_type !== "none") {
|
|
122
|
-
throw new toolbox_1.CloudBaseError('日志类型 log_type 只能为 none,如需自定义日志,请前往控制台配置');
|
|
123
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('日志类型 log_type 只能为 none,如需自定义日志,请前往控制台配置'));
|
|
123
124
|
}
|
|
124
125
|
const defaultLogType = "none";
|
|
125
126
|
const newServiceOptions = {
|
|
@@ -162,8 +163,8 @@ function tcbrServiceOptions(options, isCreated, defaultOverride, previousServerC
|
|
|
162
163
|
if (custom_image) {
|
|
163
164
|
const authorizedTcrInstances = yield getAuthorizedTcrInstance(envId);
|
|
164
165
|
if (!authorizedTcrInstances) {
|
|
165
|
-
const link =
|
|
166
|
-
throw new toolbox_1.CloudBaseError(
|
|
166
|
+
const link = `${utils_1.EUrl.Console}/tcbr/env?/tcbr/env=&envId=${envId}`;
|
|
167
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('您还未授权 tcr 实例,请先到控制台授权:{{link}}', { link: (0, utils_1.genClickableLink)(link) }));
|
|
167
168
|
}
|
|
168
169
|
yield validateTcrImageURL(authorizedTcrInstances, custom_image);
|
|
169
170
|
DeployInfo.ImageUrl = custom_image;
|
|
@@ -176,12 +177,12 @@ function tcbrServiceOptions(options, isCreated, defaultOverride, previousServerC
|
|
|
176
177
|
if (library_image) {
|
|
177
178
|
const imageInfo = imageList.find(({ Tag }) => Tag === library_image);
|
|
178
179
|
if (!imageInfo) {
|
|
179
|
-
throw new toolbox_1.CloudBaseError(
|
|
180
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('镜像 {{image}} 不存在', { image: library_image }));
|
|
180
181
|
}
|
|
181
182
|
DeployInfo.ImageUrl = imageInfo.ImageUrl;
|
|
182
183
|
}
|
|
183
184
|
else {
|
|
184
|
-
throw new toolbox_1.CloudBaseError('暂不支持 --image 参数,请使用 --custom_image 指定 tcr 镜像 URL 或 --library_image 指定线上镜像 tag');
|
|
185
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('暂不支持 --image 参数,请使用 --custom_image 指定 tcr 镜像 URL 或 --library_image 指定线上镜像 tag'));
|
|
185
186
|
}
|
|
186
187
|
}
|
|
187
188
|
}
|
|
@@ -201,7 +202,7 @@ function getAuthorizedTcrInstance(envId) {
|
|
|
201
202
|
exports.getAuthorizedTcrInstance = getAuthorizedTcrInstance;
|
|
202
203
|
function validateTcrImageURL(authorizedTcrInstances, imageUrl) {
|
|
203
204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
const errMsg = '镜像URL解析失败,请检查输入的镜像URL是否正确';
|
|
205
|
+
const errMsg = (0, i18n_1.t)('镜像URL解析失败,请检查输入的镜像URL是否正确');
|
|
205
206
|
try {
|
|
206
207
|
const host = imageUrl.split('/')[0];
|
|
207
208
|
const namespace = imageUrl.split('/')[1];
|
|
@@ -13,14 +13,15 @@ exports.updateCloudRunServerConfig = exports.tcbrServiceConfigOptions = void 0;
|
|
|
13
13
|
const toolbox_1 = require("@cloudbase/toolbox");
|
|
14
14
|
const common_1 = require("./common");
|
|
15
15
|
const utils_1 = require("../../utils");
|
|
16
|
+
const i18n_1 = require("../../i18n");
|
|
16
17
|
function tcbrServiceConfigOptions(options) {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
let { serviceName, envId, cpu, mem, minNum, maxNum, policyDetails, customLogs, envParams, } = options;
|
|
19
20
|
if (!envId) {
|
|
20
|
-
throw new toolbox_1.CloudBaseError('必须使用 -e 或 --envId 指定环境ID');
|
|
21
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('必须使用 -e 或 --envId 指定环境ID'));
|
|
21
22
|
}
|
|
22
23
|
if (!serviceName) {
|
|
23
|
-
throw new toolbox_1.CloudBaseError('必须使用 -s 或 --serviceName 指定服务名');
|
|
24
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('必须使用 -s 或 --serviceName 指定服务名'));
|
|
24
25
|
}
|
|
25
26
|
let { cpuConverted, memConverted, maxNumConverted, minNumConverted } = (0, utils_1.parseOptionalParams)({
|
|
26
27
|
cpu,
|
|
@@ -33,7 +34,7 @@ function tcbrServiceConfigOptions(options) {
|
|
|
33
34
|
serviceName
|
|
34
35
|
});
|
|
35
36
|
if (serviceInfo instanceof Error && serviceInfo['code'] === 'InvalidParameter') {
|
|
36
|
-
throw new toolbox_1.CloudBaseError(
|
|
37
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('服务不存在,请检查服务名是否正确或到控制台 {{link}} 创建服务', { link: (0, utils_1.genClickableLink)(`${utils_1.EUrl.Console}/tcbr`) }));
|
|
37
38
|
}
|
|
38
39
|
const { ServerConfig: previousServerConfig } = serviceInfo.data;
|
|
39
40
|
const newServiceOptions = {
|
|
@@ -40,6 +40,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
40
40
|
const fs = __importStar(require("fs"));
|
|
41
41
|
const __1 = require("..");
|
|
42
42
|
const toolbox_1 = require("@cloudbase/toolbox");
|
|
43
|
+
const i18n_1 = require("../../i18n");
|
|
43
44
|
function packageDeploy(options) {
|
|
44
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
46
|
let { envId, serviceName, filePath, fileToIgnore } = options;
|
|
@@ -52,14 +53,14 @@ function packageDeploy(options) {
|
|
|
52
53
|
const dstPath = path_1.default.join(process.cwd(), zipFile);
|
|
53
54
|
try {
|
|
54
55
|
if (fs.statSync(filePath).isDirectory()) {
|
|
55
|
-
loading.start('正在压缩文件…');
|
|
56
|
+
loading.start((0, i18n_1.t)('正在压缩文件…'));
|
|
56
57
|
yield (0, toolbox_1.zipDir)(filePath, dstPath, fileToIgnore);
|
|
57
|
-
loading.succeed('压缩文件完成');
|
|
58
|
+
loading.succeed((0, i18n_1.t)('压缩文件完成'));
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
catch (error) {
|
|
61
62
|
if (error.code === 'ENOENT') {
|
|
62
|
-
throw new toolbox_1.CloudBaseError('找不到指定文件夹,请检查文件路径是否正确');
|
|
63
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('找不到指定文件夹,请检查文件路径是否正确'));
|
|
63
64
|
}
|
|
64
65
|
else {
|
|
65
66
|
throw new toolbox_1.CloudBaseError(error.message);
|
|
@@ -70,8 +71,8 @@ function packageDeploy(options) {
|
|
|
70
71
|
yield (0, __1.uploadZip)(zipFile, UploadUrl, UploadHeaders[0]);
|
|
71
72
|
return { PackageName, PackageVersion };
|
|
72
73
|
}), {
|
|
73
|
-
startTip: '\n正在上传代码包...',
|
|
74
|
-
failTip: '上传代码包失败,请稍后重试'
|
|
74
|
+
startTip: (0, i18n_1.t)('\n正在上传代码包...'),
|
|
75
|
+
failTip: (0, i18n_1.t)('上传代码包失败,请稍后重试')
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
finally {
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.getLogs = exports.getBuildStatus = void 0;
|
|
16
16
|
const utils_1 = require("../../utils");
|
|
17
17
|
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
const i18n_1 = require("../../i18n");
|
|
18
19
|
function getBuildStatus(envId, serviceName) {
|
|
19
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
21
|
const { data: deployRes } = yield (0, utils_1.callTcbrApi)('DescribeCloudRunDeployRecord', {
|
|
@@ -105,12 +106,12 @@ function showBuildLogs(envId, serviceName, serverVersion = '', offset = 0) {
|
|
|
105
106
|
function getLogs(options) {
|
|
106
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
108
|
const runId = yield getRunId(options.envId, options.serviceName);
|
|
108
|
-
console.log(chalk_1.default.blue(
|
|
109
|
+
console.log(chalk_1.default.blue(`============ ${(0, i18n_1.t)('日志开始')} ===============`));
|
|
109
110
|
yield showProcessLogs(options.envId, runId, options.serviceName);
|
|
110
111
|
if ((yield getBuildStatus(options.envId, options.serviceName)) === 'completed') {
|
|
111
112
|
yield showBuildLogs(options.envId, options.serviceName);
|
|
112
113
|
}
|
|
113
|
-
console.log(chalk_1.default.blue(
|
|
114
|
+
console.log(chalk_1.default.blue(`============ ${(0, i18n_1.t)('日志结束')} ===============`));
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
exports.getLogs = getLogs;
|
|
@@ -19,6 +19,7 @@ const __1 = require("..");
|
|
|
19
19
|
const utils_1 = require("../../utils");
|
|
20
20
|
const common_1 = require("./common");
|
|
21
21
|
const showLogs_1 = require("./showLogs");
|
|
22
|
+
const i18n_1 = require("../../i18n");
|
|
22
23
|
function updateCloudRunServer(serviceConfigOptions) {
|
|
23
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
25
|
try {
|
|
@@ -39,11 +40,11 @@ function updateTcbrService(options) {
|
|
|
39
40
|
serviceName: options.serviceName
|
|
40
41
|
});
|
|
41
42
|
if (serviceDetail === undefined) {
|
|
42
|
-
throw new toolbox_1.CloudBaseError(
|
|
43
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('当前服务不存在,请前往控制台 {{link}} 创建服务', { link: (0, utils_1.genClickableLink)(`${utils_1.EUrl.Console}/tcbr`) }));
|
|
43
44
|
}
|
|
44
45
|
const status = yield (0, showLogs_1.getBuildStatus)(options.envId, options.serviceName);
|
|
45
46
|
if (status === 'pending') {
|
|
46
|
-
throw new toolbox_1.CloudBaseError('服务正在更新部署,请稍后再试,或查看实时部署日志');
|
|
47
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('服务正在更新部署,请稍后再试,或查看实时部署日志'));
|
|
47
48
|
}
|
|
48
49
|
const previousServerConfig = serviceDetail === null || serviceDetail === void 0 ? void 0 : serviceDetail.ServerConfig;
|
|
49
50
|
const newServiceOptions = yield (0, common_1.tcbrServiceOptions)(options, true, true, previousServerConfig);
|
|
@@ -52,7 +53,7 @@ function updateTcbrService(options) {
|
|
|
52
53
|
{
|
|
53
54
|
type: 'confirm',
|
|
54
55
|
name: 'confirm',
|
|
55
|
-
message: '确定要更新服务吗?',
|
|
56
|
+
message: (0, i18n_1.t)('确定要更新服务吗?'),
|
|
56
57
|
}
|
|
57
58
|
]);
|
|
58
59
|
if (!confirm) {
|
|
@@ -61,7 +62,7 @@ function updateTcbrService(options) {
|
|
|
61
62
|
}
|
|
62
63
|
const updateRes = yield updateCloudRunServer(newServiceOptions);
|
|
63
64
|
if (updateRes instanceof Error) {
|
|
64
|
-
throw new toolbox_1.CloudBaseError('当前已有部署发布任务运行中,请稍后再试,或查看实时部署日志');
|
|
65
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('当前已有部署发布任务运行中,请稍后再试,或查看实时部署日志'));
|
|
65
66
|
}
|
|
66
67
|
const taskId = (_a = updateRes.data) === null || _a === void 0 ? void 0 : _a.TaskId;
|
|
67
68
|
if (options.json) {
|
|
@@ -73,10 +74,10 @@ function updateTcbrService(options) {
|
|
|
73
74
|
taskId,
|
|
74
75
|
serviceName: options.serviceName
|
|
75
76
|
});
|
|
76
|
-
console.log(
|
|
77
|
+
console.log((0, i18n_1.t)('本次任务的 TaskID: {{taskId}}', { taskId }));
|
|
77
78
|
}
|
|
78
79
|
else {
|
|
79
|
-
toolbox_1.logger.success('更新服务成功, 本次任务的 TaskID: '
|
|
80
|
+
toolbox_1.logger.success((0, i18n_1.t)('更新服务成功, 本次任务的 TaskID: {{taskId}}', { taskId }));
|
|
80
81
|
}
|
|
81
82
|
});
|
|
82
83
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.listStandalonegateway = void 0;
|
|
13
13
|
const error_1 = require("../../error");
|
|
14
14
|
const utils_1 = require("../../utils");
|
|
15
|
+
const i18n_1 = require("../../i18n");
|
|
15
16
|
const tcbService = utils_1.CloudApiService.getInstance('tcb');
|
|
16
17
|
const listStandalonegateway = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
18
|
const res = yield tcbService.request('DescribeStandaloneGateway', {
|
|
@@ -40,5 +41,8 @@ const listStandalonegateway = (options) => __awaiter(void 0, void 0, void 0, fun
|
|
|
40
41
|
exports.listStandalonegateway = listStandalonegateway;
|
|
41
42
|
const beautifySubnetList = (list) => list.join('\n');
|
|
42
43
|
const beautifyServiceList = (list) => list
|
|
43
|
-
.map((item) =>
|
|
44
|
+
.map((item) => (0, i18n_1.t)('服务 {{name}} {{status}}', {
|
|
45
|
+
name: item['ServiceName'],
|
|
46
|
+
status: item['Status'] === 'on' ? (0, i18n_1.t)('开启') : (0, i18n_1.t)('未开启')
|
|
47
|
+
}))
|
|
44
48
|
.join('\n');
|
package/lib/storage.js
CHANGED
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.setAcl = exports.getAcl = exports.detail = exports.getUrl = exports.list = exports.deleteDirectory = exports.deleteFile = exports.downloadDirectory = exports.downloadFile = exports.uploadDirectory = exports.uploadFile = void 0;
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
const error_1 = require("./error");
|
|
15
|
+
const i18n_1 = require("./i18n");
|
|
15
16
|
function uploadFile(options) {
|
|
16
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
const { envId, localPath, cloudPath } = options;
|
|
@@ -115,7 +116,7 @@ function setAcl(options) {
|
|
|
115
116
|
const { envId, acl } = options;
|
|
116
117
|
const validAcl = ['READONLY', 'PRIVATE', 'ADMINWRITE', 'ADMINONLY'];
|
|
117
118
|
if (!validAcl.includes(acl)) {
|
|
118
|
-
throw new error_1.CloudBaseError('非法的权限值,仅支持:READONLY, PRIVATE, ADMINWRITE, ADMINONLY');
|
|
119
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('非法的权限值,仅支持:READONLY, PRIVATE, ADMINWRITE, ADMINONLY'));
|
|
119
120
|
}
|
|
120
121
|
const storageService = yield (0, utils_1.getStorageService)(envId);
|
|
121
122
|
return storageService.setStorageAcl(acl);
|
package/lib/utils/ai/banner.js
CHANGED
|
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
exports.showBanner = void 0;
|
|
39
39
|
const chalk_1 = __importDefault(require("chalk"));
|
|
40
40
|
const output_1 = require("../output");
|
|
41
|
+
const i18n_1 = require("../../i18n");
|
|
41
42
|
function showBanner(log) {
|
|
42
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
44
|
try {
|
|
@@ -65,34 +66,34 @@ AI ToolKit`, {
|
|
|
65
66
|
log.log(data + '\n');
|
|
66
67
|
}
|
|
67
68
|
if (supportsColor) {
|
|
68
|
-
log.log(chalk_1.default.hex('#34495E')('
|
|
69
|
-
log.log(chalk_1.default.hex('#34495E')('
|
|
70
|
-
log.log(chalk_1.default.hex('#34495E')('
|
|
69
|
+
log.log(chalk_1.default.hex('#34495E')(` ${(0, i18n_1.t)('🚀 统一集成各种 AI CLI 工具,内置云开发全栈能力')}`));
|
|
70
|
+
log.log(chalk_1.default.hex('#34495E')(` ${(0, i18n_1.t)('⚡ 生成、部署和托管全栈 Web 应用与小程序、数据库和后端服务')}`));
|
|
71
|
+
log.log(chalk_1.default.hex('#34495E')(` ${(0, i18n_1.t)('🎯 无需运维,极速上线你的创意 💫')}`));
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
|
-
log.log('
|
|
74
|
-
log.log('
|
|
75
|
-
log.log('
|
|
74
|
+
log.log(` ${(0, i18n_1.t)('🚀 统一集成各种 AI CLI 工具,内置云开发全栈能力')}`);
|
|
75
|
+
log.log(` ${(0, i18n_1.t)('⚡ 生成、部署和托管全栈 Web 应用与小程序、数据库和后端服务')}`);
|
|
76
|
+
log.log(` ${(0, i18n_1.t)('🎯 无需运维,极速上线你的创意 💫')}`);
|
|
76
77
|
}
|
|
77
78
|
log.log('');
|
|
78
79
|
log.log('Github:');
|
|
79
80
|
log.log((0, output_1.genClickableLink)('https://github.com/TencentCloudBase/CloudBase-AI-ToolKit'));
|
|
80
81
|
log.log('');
|
|
81
|
-
log.log('使用指引');
|
|
82
|
+
log.log((0, i18n_1.t)('使用指引'));
|
|
82
83
|
log.log((0, output_1.genClickableLink)('https://docs.cloudbase.net/cli-v1/ai/introduce'));
|
|
83
84
|
log.log('');
|
|
84
85
|
}
|
|
85
86
|
catch (e) {
|
|
86
87
|
log.log(chalk_1.default.bold.cyanBright('⛰︎'), chalk_1.default.bold.hex('#FFFFFF')(' CloudBase AI ToolKit CLI'));
|
|
87
88
|
log.log(chalk_1.default.bold.cyanBright(''));
|
|
88
|
-
log.log(chalk_1.default.hex('#34495E')('
|
|
89
|
-
log.log(chalk_1.default.hex('#34495E')('
|
|
90
|
-
log.log(chalk_1.default.hex('#34495E')('
|
|
89
|
+
log.log(chalk_1.default.hex('#34495E')(` ${(0, i18n_1.t)('🚀 统一集成各种 AI CLI 工具,内置云开发全栈能力')}`));
|
|
90
|
+
log.log(chalk_1.default.hex('#34495E')(` ${(0, i18n_1.t)('⚡ 生成、部署和托管全栈 Web 应用与小程序、数据库和后端服务')}`));
|
|
91
|
+
log.log(chalk_1.default.hex('#34495E')(` ${(0, i18n_1.t)('🎯 无需运维,极速上线你的创意 💫')}`));
|
|
91
92
|
log.log('');
|
|
92
93
|
log.log('Github:');
|
|
93
94
|
log.log((0, output_1.genClickableLink)('https://github.com/TencentCloudBase/CloudBase-AI-ToolKit'));
|
|
94
95
|
log.log('');
|
|
95
|
-
log.log('使用指引');
|
|
96
|
+
log.log((0, i18n_1.t)('使用指引'));
|
|
96
97
|
log.log((0, output_1.genClickableLink)('https://docs.cloudbase.net/cli-v1/ai/introduce'));
|
|
97
98
|
log.log('');
|
|
98
99
|
}
|
|
@@ -4,6 +4,7 @@ exports.claudeWindowsCheck = void 0;
|
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const output_1 = require("../output");
|
|
7
|
+
const i18n_1 = require("../../i18n");
|
|
7
8
|
function claudeWindowsCheck(log) {
|
|
8
9
|
const claudeWindowsCheck = checkWindowsClaudeOk();
|
|
9
10
|
if ('error' in claudeWindowsCheck) {
|
|
@@ -19,7 +20,7 @@ function checkWindowsClaudeOk() {
|
|
|
19
20
|
if (pathExistsOnWindows(process.env.CLAUDE_CODE_GIT_BASH_PATH))
|
|
20
21
|
return { success: true };
|
|
21
22
|
return {
|
|
22
|
-
error:
|
|
23
|
+
error: (0, i18n_1.t)('环境变量 CLAUDE_CODE_GIT_BASH_PATH 指定的路径 "{{path}}" 不存在,请检查', { path: process.env.CLAUDE_CODE_GIT_BASH_PATH })
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
let gitExecutablePath = resolveWindowsExecutablePath('git');
|
|
@@ -29,8 +30,9 @@ function checkWindowsClaudeOk() {
|
|
|
29
30
|
return { success: true };
|
|
30
31
|
}
|
|
31
32
|
return {
|
|
32
|
-
error:
|
|
33
|
-
|
|
33
|
+
error: (0, i18n_1.t)('Claude Code 在 Windows 上需要 git-bash (https://git-scm.com/downloads/win)。如果已安装但不在 PATH 中,请设置环境变量 CLAUDE_CODE_GIT_BASH_PATH 指向你的 bash.exe,类似:CLAUDE_CODE_GIT_BASH_PATH=C:\\Program Files\\Git\\bin\\bash.exe\n或者使用 WSL 运行。详情可阅读官方文档 {{link}}', {
|
|
34
|
+
link: (0, output_1.genClickableLink)('https://docs.anthropic.com/zh-CN/docs/claude-code/setup#windows-%E8%AE%BE%E7%BD%AE')
|
|
35
|
+
})
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
function pathExistsOnWindows(targetPath) {
|
package/lib/utils/ai/config.js
CHANGED
|
@@ -18,9 +18,10 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
18
18
|
const envLocalManager_1 = require("./envLocalManager");
|
|
19
19
|
const toolbox_1 = require("@cloudbase/toolbox");
|
|
20
20
|
const const_1 = require("./const");
|
|
21
|
+
const i18n_1 = require("../../i18n");
|
|
21
22
|
exports.CONFIG_NOT_FOUND = 'CONFIG_NOT_FOUND';
|
|
22
23
|
const notFoundError = () => {
|
|
23
|
-
throw new error_1.CloudBaseError('AI 配置未找到,请运行 tcb ai --setup 进行配置', {
|
|
24
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('AI 配置未找到,请运行 tcb ai --setup 进行配置'), {
|
|
24
25
|
code: exports.CONFIG_NOT_FOUND
|
|
25
26
|
});
|
|
26
27
|
};
|
|
@@ -98,7 +99,7 @@ class AIConfigManager {
|
|
|
98
99
|
]);
|
|
99
100
|
}
|
|
100
101
|
catch (error) {
|
|
101
|
-
throw new error_1.CloudBaseError('重置 AI 配置失败,请手动删除 `.env.local`、`cloudbaserc.json` 文件中的 AI 配置部分,或重新运行 tcb ai --setup', { original: error });
|
|
102
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('重置 AI 配置失败,请手动删除 `.env.local`、`cloudbaserc.json` 文件中的 AI 配置部分,或重新运行 tcb ai --setup'), { original: error });
|
|
102
103
|
}
|
|
103
104
|
});
|
|
104
105
|
}
|
package/lib/utils/ai/const.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.LIST_HINT = exports.getBooleanHint = exports.getDefaultModelByBaseUrl =
|
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const v3_1 = __importDefault(require("zod/v3"));
|
|
10
|
+
const i18n_1 = require("../../i18n");
|
|
10
11
|
exports.CONFIG_PATH = path_1.default.join(process.cwd(), 'cloudbaserc.json');
|
|
11
12
|
exports.ENV_LOCAL_PATH = path_1.default.join(process.cwd(), '.env.local');
|
|
12
13
|
exports.CLAUDE_CODE_ROUTER_CONFIG_PATH = path_1.default.join(os_1.default.homedir(), '.claude-code-router', 'config.json');
|
|
@@ -115,7 +116,7 @@ exports.CODEBUDDY = {
|
|
|
115
116
|
])
|
|
116
117
|
};
|
|
117
118
|
exports.NONE = {
|
|
118
|
-
name: '暂不配置',
|
|
119
|
+
name: (0, i18n_1.t)('暂不配置'),
|
|
119
120
|
value: 'none'
|
|
120
121
|
};
|
|
121
122
|
exports.AGENTS = [exports.CLAUDE, exports.CODEBUDDY, exports.QWEN, exports.CODEX, exports.AIDER, exports.CURSOR, exports.NONE];
|
|
@@ -171,7 +172,7 @@ function getDefaultModelByBaseUrl(baseUrl) {
|
|
|
171
172
|
}
|
|
172
173
|
exports.getDefaultModelByBaseUrl = getDefaultModelByBaseUrl;
|
|
173
174
|
function getBooleanHint(defaultValue) {
|
|
174
|
-
return `y
|
|
175
|
+
return `y ${(0, i18n_1.t)('是')} ${defaultValue === true ? `(${(0, i18n_1.t)('留空默认')})` : ''}; n ${(0, i18n_1.t)('否')} ${defaultValue === false ? `(${(0, i18n_1.t)('留空默认')})` : ''}; enter ${(0, i18n_1.t)('确认')}`;
|
|
175
176
|
}
|
|
176
177
|
exports.getBooleanHint = getBooleanHint;
|
|
177
|
-
exports.LIST_HINT = '使用上下键选择,按下 Enter 键确认选项';
|
|
178
|
+
exports.LIST_HINT = (0, i18n_1.t)('使用上下键选择,按下 Enter 键确认选项');
|
package/lib/utils/ai/env.js
CHANGED
|
@@ -14,18 +14,19 @@ const env_1 = require("../../env");
|
|
|
14
14
|
const constants_1 = require("../../commands/constants");
|
|
15
15
|
const utils_1 = require("../../commands/utils");
|
|
16
16
|
const config_1 = require("./config");
|
|
17
|
+
const i18n_1 = require("../../i18n");
|
|
17
18
|
function ensureValidEnv(_envId, log) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
20
|
const envs = yield (0, env_1.listEnvs)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
20
21
|
const validEnv = envs.find((env) => env.EnvId === _envId);
|
|
21
22
|
if (!validEnv) {
|
|
22
|
-
log.error(
|
|
23
|
+
log.error((0, i18n_1.t)('❌ 环境 {{envId}} 与当前账号不匹配,请重新选择', { envId: _envId }));
|
|
23
24
|
const envId = yield (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
24
25
|
new config_1.AIConfigManager().updateEnvId(envId);
|
|
25
26
|
return envId;
|
|
26
27
|
}
|
|
27
28
|
if (validEnv.Status !== constants_1.EnvStatus.NORMAL) {
|
|
28
|
-
log.error(
|
|
29
|
+
log.error((0, i18n_1.t)('❌ 环境 {{envId}} 不可用,请重新选择', { envId: _envId }));
|
|
29
30
|
const envId = yield (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
30
31
|
new config_1.AIConfigManager().updateEnvId(envId);
|
|
31
32
|
return envId;
|
|
@@ -40,6 +40,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
40
40
|
const error_1 = require("../../error");
|
|
41
41
|
const dotenvx = __importStar(require("@dotenvx/dotenvx"));
|
|
42
42
|
const const_1 = require("./const");
|
|
43
|
+
const i18n_1 = require("../../i18n");
|
|
43
44
|
dotenvx.setLogLevel({
|
|
44
45
|
logLevel: 'error'
|
|
45
46
|
});
|
|
@@ -59,7 +60,7 @@ class EnvLocalManager {
|
|
|
59
60
|
yield this.addAIConfigToEnv(aiConfig);
|
|
60
61
|
}
|
|
61
62
|
catch (error) {
|
|
62
|
-
throw new error_1.CloudBaseError(
|
|
63
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('更新 AI 配置失败: {{error}}', { error: error.message }), { original: error });
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
66
|
}
|
|
@@ -75,21 +76,21 @@ class EnvLocalManager {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
catch (error) {
|
|
78
|
-
throw new error_1.CloudBaseError(
|
|
79
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('移除 AI 配置失败: {{error}}', { error: error.message }), { original: error });
|
|
79
80
|
}
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
83
|
validateAIConfig(aiConfig) {
|
|
83
84
|
const errors = [];
|
|
84
85
|
if (!aiConfig.defaultAgent) {
|
|
85
|
-
errors.push('默认 AI 工具不能为空');
|
|
86
|
+
errors.push((0, i18n_1.t)('默认 AI 工具不能为空'));
|
|
86
87
|
}
|
|
87
88
|
Object.entries(aiConfig.agents).forEach(([agentName, config]) => {
|
|
88
89
|
if (!config.apiKey) {
|
|
89
|
-
errors.push(
|
|
90
|
+
errors.push((0, i18n_1.t)('{{agentName}} 必须配置 API Key', { agentName }));
|
|
90
91
|
}
|
|
91
92
|
if (config.baseUrl && !isValidUrl(config.baseUrl)) {
|
|
92
|
-
errors.push(
|
|
93
|
+
errors.push((0, i18n_1.t)('{{agentName}} 的 Base URL 格式不正确', { agentName }));
|
|
93
94
|
}
|
|
94
95
|
});
|
|
95
96
|
return errors;
|
|
@@ -5,10 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ensureNodeVersion = void 0;
|
|
7
7
|
const semver_1 = __importDefault(require("semver"));
|
|
8
|
+
const i18n_1 = require("../../i18n");
|
|
8
9
|
function ensureNodeVersion(version, log) {
|
|
9
10
|
const result = semver_1.default.compare(process.version, version);
|
|
10
11
|
if (result < 0) {
|
|
11
|
-
log.error(
|
|
12
|
+
log.error((0, i18n_1.t)('当前 Node.js 版本为 {{current}}。请升级到至少 {{required}} 版本。', {
|
|
13
|
+
current: process.version,
|
|
14
|
+
required: version
|
|
15
|
+
}));
|
|
12
16
|
process.exit(1);
|
|
13
17
|
}
|
|
14
18
|
}
|