@cloudbase/cli 2.9.9 → 2.9.10
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 +95 -98
- 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 +25 -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 +7 -1
- 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 +10 -3
- package/types/commands/cloudrun/base.d.ts +1 -0
- 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
package/bin/cloudbase.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const chalk = require('chalk')
|
|
3
|
+
const { t } = require('../lib/i18n')
|
|
3
4
|
|
|
4
|
-
console.log(chalk.bold.yellowBright('\n',
|
|
5
|
+
console.log(chalk.bold.yellowBright('\n', t('Tip: cloudbase 命令可以简写为 tcb')), '\n')
|
|
5
6
|
|
|
6
7
|
require('./tcb').main()
|
package/bin/tcb.js
CHANGED
|
@@ -24,15 +24,18 @@ const { getProxy } = require('../lib/utils/net')
|
|
|
24
24
|
const { getCloudBaseConfig, getPrivateSettings } = require('../lib/utils/config')
|
|
25
25
|
const { registerCommands } = require('../lib')
|
|
26
26
|
const { beaconAction } = require('../lib/utils/report')
|
|
27
|
+
const { t } = require('../lib/i18n')
|
|
27
28
|
|
|
28
|
-
const regionSupported = ['ap-shanghai', 'ap-beijing', 'ap-guangzhou']
|
|
29
|
+
const regionSupported = ['ap-shanghai', 'ap-beijing', 'ap-guangzhou', 'ap-singapore']
|
|
29
30
|
const regionSupportedMap = {
|
|
30
|
-
'ap-shanghai': '上海',
|
|
31
|
-
'ap-beijing': '北京',
|
|
32
|
-
'ap-guangzhou': '广州',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
'ap-shanghai': t('上海'),
|
|
32
|
+
'ap-beijing': t('北京'),
|
|
33
|
+
'ap-guangzhou': t('广州'),
|
|
34
|
+
'ap-singapore': t('新加坡'),
|
|
35
|
+
sh: t('上海'),
|
|
36
|
+
bj: t('北京'),
|
|
37
|
+
gz: t('广州'),
|
|
38
|
+
sg: t('新加坡')
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
async function main() {
|
|
@@ -49,7 +52,10 @@ async function main() {
|
|
|
49
52
|
if (NODE_MIN_VERSION > currentMajorVersion) {
|
|
50
53
|
console.error(
|
|
51
54
|
chalk.bold.red(
|
|
52
|
-
|
|
55
|
+
t('当前 Node.js 版本为 v{{current}}。请升级到至少 v{{min}} 版本。', {
|
|
56
|
+
current: currentMajorVersion,
|
|
57
|
+
min: NODE_MIN_VERSION
|
|
58
|
+
})
|
|
53
59
|
)
|
|
54
60
|
)
|
|
55
61
|
process.exit(1)
|
|
@@ -58,13 +64,13 @@ async function main() {
|
|
|
58
64
|
|
|
59
65
|
// 输出版本信息
|
|
60
66
|
console.log(chalk.gray(`CloudBase CLI ${pkg.version}`))
|
|
61
|
-
console.log(chalk.gray('试试 tcb ai 命令,开启 AI 全栈开发体验'))
|
|
67
|
+
console.log(chalk.gray(t('试试 tcb ai 命令,开启 AI 全栈开发体验')))
|
|
62
68
|
|
|
63
69
|
const yargsParsedResult = yargsParser(process.argv.slice(2))
|
|
64
70
|
const config = await getCloudBaseConfig(yargsParsedResult.configFile)
|
|
65
71
|
const privateSettings = getPrivateSettings(config)
|
|
66
72
|
if (privateSettings) {
|
|
67
|
-
console.log(chalk.gray(
|
|
73
|
+
console.log(chalk.gray(t('检测到私有化配置')))
|
|
68
74
|
if (privateSettings.endpoints && privateSettings.endpoints.cliApi) {
|
|
69
75
|
// 初始化 lowcode 服务cliapi入口
|
|
70
76
|
process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL = privateSettings.endpoints.cliApi
|
|
@@ -75,10 +81,10 @@ async function main() {
|
|
|
75
81
|
|
|
76
82
|
// 设置 options 选项
|
|
77
83
|
program.storeOptionsAsProperties(false)
|
|
78
|
-
program.option('--verbose', '打印出内部运行信息')
|
|
79
|
-
program.option('--mode <mode>', '指定加载 env 文件的环境')
|
|
80
|
-
program.option('--config-file <path>', '设置配置文件,默认为 cloudbaserc.json')
|
|
81
|
-
program.option('-r, --region <region>', '指定环境地域')
|
|
84
|
+
program.option('--verbose', t('打印出内部运行信息'))
|
|
85
|
+
program.option('--mode <mode>', t('指定加载 env 文件的环境'))
|
|
86
|
+
program.option('--config-file <path>', t('设置配置文件,默认为 cloudbaserc.json'))
|
|
87
|
+
program.option('-r, --region <region>', t('指定环境地域'))
|
|
82
88
|
|
|
83
89
|
if (!privateSettings) {
|
|
84
90
|
// HACK: 隐藏自动生成的 help 信息
|
|
@@ -91,7 +97,7 @@ async function main() {
|
|
|
91
97
|
program.version(
|
|
92
98
|
`\nCLI: ${pkg.version}`,
|
|
93
99
|
'-v, --version',
|
|
94
|
-
'输出当前 CloudBase CLI 版本'
|
|
100
|
+
t('输出当前 CloudBase CLI 版本')
|
|
95
101
|
)
|
|
96
102
|
}
|
|
97
103
|
|
|
@@ -102,14 +108,14 @@ async function main() {
|
|
|
102
108
|
return
|
|
103
109
|
}
|
|
104
110
|
const cmd = args.join(' ')
|
|
105
|
-
console.log(chalk.bold.red('Error: ') +
|
|
111
|
+
console.log(chalk.bold.red('Error: ') + t('{{cmd}} 不是有效的命令', { cmd }))
|
|
106
112
|
didYouMean.threshold = 0.5
|
|
107
113
|
didYouMean.caseSensitive = false
|
|
108
114
|
const suggest = didYouMean(cmd, ALL_COMMANDS)
|
|
109
115
|
if (suggest) {
|
|
110
|
-
console.log(chalk.bold(
|
|
116
|
+
console.log(chalk.bold(t('\n您是不是想使用命令:tcb {{suggest}}\n', { suggest })))
|
|
111
117
|
}
|
|
112
|
-
console.log(
|
|
118
|
+
console.log(t('💡使用 {{helpCmd}} 查看所有命令', { helpCmd: chalk.bold('tcb -h') }))
|
|
113
119
|
})
|
|
114
120
|
|
|
115
121
|
// 没有使用命令
|
|
@@ -140,7 +146,7 @@ async function main() {
|
|
|
140
146
|
program.parse(processArgv)
|
|
141
147
|
} catch (e) {
|
|
142
148
|
const errMsg = `${logSymbols.error} ${
|
|
143
|
-
e.message || '参数异常,请检查您是否使用了正确的命令!'
|
|
149
|
+
e.message || t('参数异常,请检查您是否使用了正确的命令!')
|
|
144
150
|
}`
|
|
145
151
|
console.log(errMsg)
|
|
146
152
|
}
|
|
@@ -179,9 +185,10 @@ async function main() {
|
|
|
179
185
|
const regionSpecified =
|
|
180
186
|
processArgv.indexOf('-r') !== -1 || processArgv.indexOf('--region') !== -1
|
|
181
187
|
const region = yargsParsedResult.r || yargsParsedResult.region
|
|
182
|
-
const multiRegionErrMsg =
|
|
183
|
-
regionSupportedMap[region] || '上海'
|
|
184
|
-
|
|
188
|
+
const multiRegionErrMsg = t('\n此环境可能不属于当前账号,或为非{{region}}地域环境,如需切换地域请追加参数(例:-r gz),请检查环境归属,参考多地域使用方法:{{url}}', {
|
|
189
|
+
region: regionSupportedMap[region] || t('上海'),
|
|
190
|
+
url: 'https://docs.cloudbase.net/cli-v1/region.html'
|
|
191
|
+
})
|
|
185
192
|
if (!regionSpecified) {
|
|
186
193
|
// 从 -e 参数、--envId 参数和配置文件中获取环境 id
|
|
187
194
|
const envId = yargsParsedResult.e || yargsParsedResult.envId || config.envId
|
|
@@ -194,7 +201,7 @@ async function main() {
|
|
|
194
201
|
const prompt = new Confirm({
|
|
195
202
|
type: 'confirm',
|
|
196
203
|
name: 'confirm',
|
|
197
|
-
message:
|
|
204
|
+
message: t('该环境可能属于 {{region}} 地域,是否切换地域并重新执行命令?', { region: regionSupportedMap[predictRegion] }),
|
|
198
205
|
initial: 'Y'
|
|
199
206
|
})
|
|
200
207
|
const confirm = await prompt.run()
|
|
@@ -209,7 +216,7 @@ async function main() {
|
|
|
209
216
|
// 重新执行命令
|
|
210
217
|
const newArgvStr = processArgv.slice(2).join(' ')
|
|
211
218
|
console.log(
|
|
212
|
-
`\n${chalk.yellow.bold('正在重新执行命令:')} tcb ${newArgvStr}\n`
|
|
219
|
+
`\n${chalk.yellow.bold(t('正在重新执行命令:'))} tcb ${newArgvStr}\n`
|
|
213
220
|
)
|
|
214
221
|
await execa('tcb', processArgv.slice(2), {
|
|
215
222
|
stdio: 'inherit'
|
|
@@ -276,7 +283,7 @@ async function main() {
|
|
|
276
283
|
}
|
|
277
284
|
const credential = await getCredentialWithoutCheck()
|
|
278
285
|
if (!credential) {
|
|
279
|
-
throw new Error('无有效身份信息,请使用 cloudbase login 登录')
|
|
286
|
+
throw new Error(t('无有效身份信息,请使用 cloudbase login 登录'))
|
|
280
287
|
}
|
|
281
288
|
commonCredential = credential
|
|
282
289
|
return {
|
|
@@ -312,9 +319,9 @@ async function main() {
|
|
|
312
319
|
})
|
|
313
320
|
|
|
314
321
|
if (notifier.update) {
|
|
315
|
-
console.log('
|
|
316
|
-
console.log('当前版本:' + notifier.update.current)
|
|
317
|
-
console.log('请参考升级文档:https://docs.cloudbase.net/cli-v1/install\n
|
|
322
|
+
console.log(`\n${t('发现新版本:')} ` + notifier.update.latest)
|
|
323
|
+
console.log(`${t('当前版本:')} ` + notifier.update.current)
|
|
324
|
+
console.log(`${t('请参考升级文档:')} https://docs.cloudbase.net/cli-v1/install\n`)
|
|
318
325
|
}
|
|
319
326
|
}
|
|
320
327
|
|
package/lib/auth/login.js
CHANGED
|
@@ -17,43 +17,51 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
17
17
|
const utils_1 = require("../utils");
|
|
18
18
|
const decorators_1 = require("../decorators");
|
|
19
19
|
const env_1 = require("../env");
|
|
20
|
+
const i18n_1 = require("../i18n");
|
|
20
21
|
const log = new decorators_1.Logger();
|
|
21
22
|
const LoginRes = {
|
|
22
23
|
SUCCESS: {
|
|
23
24
|
code: 'SUCCESS',
|
|
24
|
-
msg: '登录成功!'
|
|
25
|
+
msg: (0, i18n_1.t)('登录成功!')
|
|
25
26
|
},
|
|
26
27
|
INVALID_TOKEN: {
|
|
27
28
|
code: 'INVALID_TOKEN',
|
|
28
|
-
msg: '无效的身份信息!'
|
|
29
|
+
msg: (0, i18n_1.t)('无效的身份信息!')
|
|
29
30
|
},
|
|
30
31
|
CHECK_LOGIN_FAILED: {
|
|
31
32
|
code: 'CHECK_LOGIN_FAILED',
|
|
32
|
-
msg: '检查登录态失败'
|
|
33
|
+
msg: (0, i18n_1.t)('检查登录态失败')
|
|
33
34
|
},
|
|
34
35
|
INVALID_PARAM(msg) {
|
|
35
36
|
return {
|
|
36
37
|
code: 'INVALID_PARAM',
|
|
37
|
-
msg:
|
|
38
|
+
msg: (0, i18n_1.t)('参数无效:{{msg}}', { msg })
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
42
|
function loginByWebAuth() {
|
|
42
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
44
|
try {
|
|
44
|
-
const credential = yield utils_1.authSupevisor.loginByWebAuth(
|
|
45
|
+
const credential = yield utils_1.authSupevisor.loginByWebAuth({
|
|
46
|
+
getAuthUrl: (rawUrl) => {
|
|
47
|
+
if ((0, i18n_1.isIntl)()) {
|
|
48
|
+
return rawUrl.replace('https://tcb.cloud.tencent.com/dev', utils_1.EUrl.DevPlatform);
|
|
49
|
+
}
|
|
50
|
+
return rawUrl;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
45
53
|
if (lodash_1.default.isEmpty(credential)) {
|
|
46
54
|
return LoginRes.INVALID_TOKEN;
|
|
47
55
|
}
|
|
48
56
|
return Object.assign({ credential }, LoginRes.SUCCESS);
|
|
49
57
|
}
|
|
50
58
|
catch (error) {
|
|
51
|
-
console.error('Web 授权登录失败,可能是环境兼容性问题');
|
|
52
|
-
console.error('建议使用密钥登录:tcb login --key');
|
|
53
|
-
console.error('详细说明请参考:https://docs.cloudbase.net/cli-v1/login#%E8%85%BE%E8%AE%AF%E4%BA%91-%E4%BA%91%E5%BC%80%E5%8F%91%E6%8E%A7%E5%88%B6%E5%8F%B0%E6%8E%88%E6%9D%83');
|
|
59
|
+
console.error((0, i18n_1.t)('Web 授权登录失败,可能是环境兼容性问题'));
|
|
60
|
+
console.error((0, i18n_1.t)('建议使用密钥登录:tcb login --key'));
|
|
61
|
+
console.error((0, i18n_1.t)('详细说明请参考:{{url}}', { url: 'https://docs.cloudbase.net/cli-v1/login#%E8%85%BE%E8%AE%AF%E4%BA%91-%E4%BA%91%E5%BC%80%E5%8F%91%E6%8E%A7%E5%88%B6%E5%8F%B0%E6%8E%88%E6%9D%83' }));
|
|
54
62
|
return {
|
|
55
63
|
code: 'WEB_AUTH_FAILED',
|
|
56
|
-
msg: 'Web 授权登录失败,请使用密钥登录:tcb login --key',
|
|
64
|
+
msg: (0, i18n_1.t)('Web 授权登录失败,请使用密钥登录:tcb login --key'),
|
|
57
65
|
error: error.message
|
|
58
66
|
};
|
|
59
67
|
}
|
|
@@ -63,7 +71,7 @@ exports.loginByWebAuth = loginByWebAuth;
|
|
|
63
71
|
function loginWithKey(secretId, secretKey, token) {
|
|
64
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
73
|
if (!secretId || !secretKey) {
|
|
66
|
-
return LoginRes.INVALID_PARAM('SecretID 或 SecretKey 不能为空');
|
|
74
|
+
return LoginRes.INVALID_PARAM((0, i18n_1.t)('SecretID 或 SecretKey 不能为空'));
|
|
67
75
|
}
|
|
68
76
|
const credential = yield utils_1.authSupevisor.loginByApiSecret(secretId, secretKey, token);
|
|
69
77
|
if (lodash_1.default.isEmpty(credential)) {
|
|
@@ -85,10 +93,10 @@ function checkLogin() {
|
|
|
85
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
94
|
const credential = yield (0, utils_1.checkAndGetCredential)();
|
|
87
95
|
if (lodash_1.default.isEmpty(credential)) {
|
|
88
|
-
log.info('你还没有登录,请在控制台中授权登录');
|
|
96
|
+
log.info((0, i18n_1.t)('你还没有登录,请在控制台中授权登录'));
|
|
89
97
|
const res = yield (0, utils_1.execWithLoading)(() => login(), {
|
|
90
|
-
startTip: '请在浏览器中打开的授权页面进行授权...',
|
|
91
|
-
successTip: '授权登录成功!'
|
|
98
|
+
startTip: (0, i18n_1.t)('请在浏览器中打开的授权页面进行授权...'),
|
|
99
|
+
successTip: (0, i18n_1.t)('授权登录成功!')
|
|
92
100
|
});
|
|
93
101
|
const envId = (_a = res === null || res === void 0 ? void 0 : res.credential) === null || _a === void 0 ? void 0 : _a.envId;
|
|
94
102
|
if (envId) {
|
|
@@ -33,19 +33,20 @@ const auth_1 = require("../../auth");
|
|
|
33
33
|
const env_1 = require("../../env");
|
|
34
34
|
const error_1 = require("../../error");
|
|
35
35
|
const decorators_1 = require("../../decorators");
|
|
36
|
+
const i18n_1 = require("../../i18n");
|
|
36
37
|
const utils_1 = require("../../utils");
|
|
37
38
|
function printSuggestion() {
|
|
38
|
-
const tips =
|
|
39
|
+
const tips = `${(0, i18n_1.t)('可使用下面命令继续操作:')}
|
|
39
40
|
|
|
40
|
-
${chalk_1.default.gray('–')} 一键开启 AI 开发体验
|
|
41
|
+
${chalk_1.default.gray('–')} ${(0, i18n_1.t)('一键开启 AI 开发体验')}
|
|
41
42
|
|
|
42
43
|
${chalk_1.default.cyan('$ tcb ai')}
|
|
43
44
|
|
|
44
|
-
${chalk_1.default.gray('–')} 查看命令使用介绍
|
|
45
|
+
${chalk_1.default.gray('–')} ${(0, i18n_1.t)('查看命令使用介绍')}
|
|
45
46
|
|
|
46
47
|
${chalk_1.default.cyan('$ tcb -h')}
|
|
47
48
|
|
|
48
|
-
Tips:可以使用简写命令 tcb 代替 cloudbase`;
|
|
49
|
+
${(0, i18n_1.t)('Tips:可以使用简写命令 tcb 代替 cloudbase')}`;
|
|
49
50
|
console.log(tips);
|
|
50
51
|
}
|
|
51
52
|
function askForCollectDataConfirm() {
|
|
@@ -56,7 +57,7 @@ function askForCollectDataConfirm() {
|
|
|
56
57
|
const { confirm } = yield inquirer_1.default.prompt({
|
|
57
58
|
type: 'confirm',
|
|
58
59
|
name: 'confirm',
|
|
59
|
-
message: '是否同意 Cloudbase CLI 收集您的使用数据以改进产品?',
|
|
60
|
+
message: (0, i18n_1.t)('是否同意 Cloudbase CLI 收集您的使用数据以改进产品?'),
|
|
60
61
|
default: true
|
|
61
62
|
});
|
|
62
63
|
if (confirm) {
|
|
@@ -72,22 +73,22 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
72
73
|
options: [
|
|
73
74
|
{
|
|
74
75
|
flags: '-k, --key',
|
|
75
|
-
desc: '使用永久密钥登录'
|
|
76
|
+
desc: (0, i18n_1.t)('使用永久密钥登录')
|
|
76
77
|
},
|
|
77
78
|
{
|
|
78
79
|
flags: '--apiKeyId <apiKeyId>',
|
|
79
|
-
desc: '腾讯云 API 秘钥 Id'
|
|
80
|
+
desc: (0, i18n_1.t)('腾讯云 API 秘钥 Id')
|
|
80
81
|
},
|
|
81
82
|
{
|
|
82
83
|
flags: '--apiKey <apiKey>',
|
|
83
|
-
desc: '腾讯云 API 秘钥 Key'
|
|
84
|
+
desc: (0, i18n_1.t)('腾讯云 API 秘钥 Key')
|
|
84
85
|
},
|
|
85
86
|
{
|
|
86
87
|
flags: '--token [token]',
|
|
87
|
-
desc: '腾讯云 API 临时秘钥 Token'
|
|
88
|
+
desc: (0, i18n_1.t)('腾讯云 API 临时秘钥 Token')
|
|
88
89
|
}
|
|
89
90
|
],
|
|
90
|
-
desc: '登录腾讯云账号',
|
|
91
|
+
desc: (0, i18n_1.t)('登录腾讯云账号'),
|
|
91
92
|
requiredEnvId: false,
|
|
92
93
|
withoutAuth: true
|
|
93
94
|
};
|
|
@@ -97,17 +98,17 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
97
98
|
log.verbose(options);
|
|
98
99
|
const { apiKeyId, apiKey, token } = options;
|
|
99
100
|
const loading = (0, utils_1.loadingFactory)();
|
|
100
|
-
loading.start('检验登录状态');
|
|
101
|
+
loading.start((0, i18n_1.t)('检验登录状态'));
|
|
101
102
|
const credential = yield (0, utils_1.checkAndGetCredential)();
|
|
102
103
|
if (!lodash_1.default.isEmpty(credential)) {
|
|
103
|
-
loading.succeed('您已登录,无需再次登录!');
|
|
104
|
+
loading.succeed((0, i18n_1.t)('您已登录,无需再次登录!'));
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
107
|
else {
|
|
107
108
|
loading.stop();
|
|
108
109
|
}
|
|
109
110
|
if (apiKey && apiKeyId) {
|
|
110
|
-
loading.start('正在验证腾讯云密钥...');
|
|
111
|
+
loading.start((0, i18n_1.t)('正在验证腾讯云密钥...'));
|
|
111
112
|
const res = yield (0, auth_1.login)({
|
|
112
113
|
token,
|
|
113
114
|
key: true,
|
|
@@ -115,96 +116,96 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
115
116
|
secretId: apiKeyId
|
|
116
117
|
});
|
|
117
118
|
if (res.code === 'SUCCESS') {
|
|
118
|
-
loading.succeed('登录成功!');
|
|
119
|
+
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
119
120
|
printSuggestion();
|
|
120
121
|
}
|
|
121
122
|
else {
|
|
122
|
-
loading.fail('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!');
|
|
123
|
+
loading.fail((0, i18n_1.t)('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!'));
|
|
123
124
|
return process.exit(1);
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
else if (options.key) {
|
|
127
|
-
const clickableLink = (0, utils_1.genClickableLink)(
|
|
128
|
-
console.log(
|
|
128
|
+
const clickableLink = (0, utils_1.genClickableLink)(`${utils_1.EUrl.Console}/cam/capi`);
|
|
129
|
+
console.log((0, i18n_1.t)('您可以访问 {{link}} 获取 API 秘钥', { link: clickableLink }));
|
|
129
130
|
const { secretId } = yield inquirer_1.default.prompt({
|
|
130
131
|
type: 'input',
|
|
131
132
|
name: 'secretId',
|
|
132
|
-
message: '请输入腾讯云 SecretID:'
|
|
133
|
+
message: (0, i18n_1.t)('请输入腾讯云 SecretID:')
|
|
133
134
|
});
|
|
134
135
|
const { secretKey } = yield inquirer_1.default.prompt({
|
|
135
136
|
type: 'input',
|
|
136
137
|
name: 'secretKey',
|
|
137
|
-
message: '请输入腾讯云 SecretKey:'
|
|
138
|
+
message: (0, i18n_1.t)('请输入腾讯云 SecretKey:')
|
|
138
139
|
});
|
|
139
140
|
if (!secretId || !secretKey) {
|
|
140
|
-
throw new error_1.CloudBaseError('SecretID 或 SecretKey 不能为空');
|
|
141
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('SecretID 或 SecretKey 不能为空'));
|
|
141
142
|
}
|
|
142
|
-
loading.start('正在验证腾讯云密钥...');
|
|
143
|
+
loading.start((0, i18n_1.t)('正在验证腾讯云密钥...'));
|
|
143
144
|
const res = yield (0, auth_1.login)({
|
|
144
145
|
key: true,
|
|
145
146
|
secretId,
|
|
146
147
|
secretKey
|
|
147
148
|
});
|
|
148
149
|
if (res.code === 'SUCCESS') {
|
|
149
|
-
loading.succeed('登录成功!');
|
|
150
|
+
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
150
151
|
yield askForCollectDataConfirm();
|
|
151
152
|
printSuggestion();
|
|
152
153
|
}
|
|
153
154
|
else {
|
|
154
|
-
loading.fail('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!');
|
|
155
|
+
loading.fail((0, i18n_1.t)('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!'));
|
|
155
156
|
return process.exit(1);
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
else {
|
|
159
|
-
loading.start('请在浏览器中打开的授权页面进行授权...');
|
|
160
|
+
loading.start((0, i18n_1.t)('请在浏览器中打开的授权页面进行授权...'));
|
|
160
161
|
const res = yield (0, auth_1.login)();
|
|
161
162
|
if (res.code === 'SUCCESS') {
|
|
162
|
-
loading.succeed('登录成功!');
|
|
163
|
+
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
163
164
|
yield askForCollectDataConfirm();
|
|
164
165
|
printSuggestion();
|
|
165
166
|
}
|
|
166
167
|
else if (res.code === 'WEB_AUTH_FAILED') {
|
|
167
|
-
loading.fail('Web 授权登录失败');
|
|
168
|
-
console.log(chalk_1.default.yellow('⚠️ 检测到环境兼容性问题'));
|
|
169
|
-
console.log(chalk_1.default.cyan('建议使用密钥登录:'));
|
|
170
|
-
console.log(chalk_1.default.cyan('tcb login --key'));
|
|
171
|
-
console.log(chalk_1.default.gray('详细说明请参考:https://docs.cloudbase.net/cli-v1/login#%E8%85%BE%E8%AE%AF%E4%BA%91-%E4%BA%91%E5%BC%80%E5%8F%91%E6%8E%A7%E5%88%B6%E5%8F%B0%E6%8E%88%E6%9D%83'));
|
|
168
|
+
loading.fail((0, i18n_1.t)('Web 授权登录失败'));
|
|
169
|
+
console.log(chalk_1.default.yellow((0, i18n_1.t)('⚠️ 检测到环境兼容性问题')));
|
|
170
|
+
console.log(chalk_1.default.cyan((0, i18n_1.t)('建议使用密钥登录:')));
|
|
171
|
+
console.log(chalk_1.default.cyan((0, i18n_1.t)('tcb login --key')));
|
|
172
|
+
console.log(chalk_1.default.gray((0, i18n_1.t)('详细说明请参考:{{url}}', { url: 'https://docs.cloudbase.net/cli-v1/login#%E8%85%BE%E8%AE%AF%E4%BA%91-%E4%BA%91%E5%BC%80%E5%8F%91%E6%8E%A7%E5%88%B6%E5%8F%B0%E6%8E%88%E6%9D%83' })));
|
|
172
173
|
console.log('');
|
|
173
174
|
const { useKey } = yield inquirer_1.default.prompt({
|
|
174
175
|
type: 'confirm',
|
|
175
176
|
name: 'useKey',
|
|
176
|
-
message: '是否切换到密钥登录模式?',
|
|
177
|
+
message: (0, i18n_1.t)('是否切换到密钥登录模式?'),
|
|
177
178
|
default: true
|
|
178
179
|
});
|
|
179
180
|
if (useKey) {
|
|
180
181
|
const clickableLink = (0, utils_1.genClickableLink)('https://console.cloud.tencent.com/cam/capi');
|
|
181
|
-
console.log(
|
|
182
|
+
console.log((0, i18n_1.t)('您可以访问 {{link}} 获取 API 秘钥', { link: clickableLink }));
|
|
182
183
|
const { secretId } = yield inquirer_1.default.prompt({
|
|
183
184
|
type: 'input',
|
|
184
185
|
name: 'secretId',
|
|
185
|
-
message: '请输入腾讯云 SecretID:'
|
|
186
|
+
message: (0, i18n_1.t)('请输入腾讯云 SecretID:')
|
|
186
187
|
});
|
|
187
188
|
const { secretKey } = yield inquirer_1.default.prompt({
|
|
188
189
|
type: 'input',
|
|
189
190
|
name: 'secretKey',
|
|
190
|
-
message: '请输入腾讯云 SecretKey:'
|
|
191
|
+
message: (0, i18n_1.t)('请输入腾讯云 SecretKey:')
|
|
191
192
|
});
|
|
192
193
|
if (!secretId || !secretKey) {
|
|
193
|
-
throw new error_1.CloudBaseError('SecretID 或 SecretKey 不能为空');
|
|
194
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('SecretID 或 SecretKey 不能为空'));
|
|
194
195
|
}
|
|
195
|
-
loading.start('正在验证腾讯云密钥...');
|
|
196
|
+
loading.start((0, i18n_1.t)('正在验证腾讯云密钥...'));
|
|
196
197
|
const keyRes = yield (0, auth_1.login)({
|
|
197
198
|
key: true,
|
|
198
199
|
secretId,
|
|
199
200
|
secretKey
|
|
200
201
|
});
|
|
201
202
|
if (keyRes.code === 'SUCCESS') {
|
|
202
|
-
loading.succeed('登录成功!');
|
|
203
|
+
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
203
204
|
yield askForCollectDataConfirm();
|
|
204
205
|
printSuggestion();
|
|
205
206
|
}
|
|
206
207
|
else {
|
|
207
|
-
loading.fail('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!');
|
|
208
|
+
loading.fail((0, i18n_1.t)('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!'));
|
|
208
209
|
return process.exit(1);
|
|
209
210
|
}
|
|
210
211
|
}
|
|
@@ -214,20 +215,20 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
214
215
|
}
|
|
215
216
|
else {
|
|
216
217
|
loading.fail(res.msg);
|
|
217
|
-
console.log('Web 授权登录失败,秘钥校验失败!');
|
|
218
|
+
console.log((0, i18n_1.t)('Web 授权登录失败,秘钥校验失败!'));
|
|
218
219
|
return process.exit(1);
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
|
-
const consoleUrl =
|
|
222
|
+
const consoleUrl = `${utils_1.EUrl.TcbConsole}/env/index?action=CreateEnv&from=cli`;
|
|
222
223
|
try {
|
|
223
224
|
const envs = yield (0, env_1.listEnvs)();
|
|
224
225
|
if (!envs.length) {
|
|
225
|
-
log.warn(
|
|
226
|
+
log.warn((0, i18n_1.t)('您还没有可用的环境,请前往控制台 {{link}} 创建环境', { link: (0, utils_1.genClickableLink)(consoleUrl) }));
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
catch (e) {
|
|
229
230
|
if (e.code === 'ResourceNotFound.UserNotExists') {
|
|
230
|
-
log.error(
|
|
231
|
+
log.error((0, i18n_1.t)('您还没有可用的环境,请前往控制台 {{link}} 创建环境', { link: (0, utils_1.genClickableLink)(consoleUrl) }));
|
|
231
232
|
}
|
|
232
233
|
else {
|
|
233
234
|
console.error(e);
|
|
@@ -25,12 +25,13 @@ exports.LogoutCommand = void 0;
|
|
|
25
25
|
const common_1 = require("../common");
|
|
26
26
|
const auth_1 = require("../../auth");
|
|
27
27
|
const decorators_1 = require("../../decorators");
|
|
28
|
+
const i18n_1 = require("../../i18n");
|
|
28
29
|
let LogoutCommand = class LogoutCommand extends common_1.Command {
|
|
29
30
|
get options() {
|
|
30
31
|
return {
|
|
31
32
|
cmd: 'logout',
|
|
32
33
|
options: [],
|
|
33
|
-
desc: '登出腾讯云账号',
|
|
34
|
+
desc: (0, i18n_1.t)('登出腾讯云账号'),
|
|
34
35
|
requiredEnvId: false,
|
|
35
36
|
withoutAuth: true
|
|
36
37
|
};
|
|
@@ -38,7 +39,7 @@ let LogoutCommand = class LogoutCommand extends common_1.Command {
|
|
|
38
39
|
execute(log) {
|
|
39
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
41
|
yield (0, auth_1.logout)();
|
|
41
|
-
log.success('注销登录成功!');
|
|
42
|
+
log.success((0, i18n_1.t)('注销登录成功!'));
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
};
|
package/lib/commands/ai/index.js
CHANGED
|
@@ -32,6 +32,7 @@ const report_1 = require("../../utils/report");
|
|
|
32
32
|
const error_1 = require("../../error");
|
|
33
33
|
const banner_1 = require("../../utils/ai/banner");
|
|
34
34
|
const ensureFiles_1 = require("../../utils/ai/ensureFiles");
|
|
35
|
+
const i18n_1 = require("../../i18n");
|
|
35
36
|
let AICommand = class AICommand extends common_1.Command {
|
|
36
37
|
get options() {
|
|
37
38
|
return {
|
|
@@ -39,34 +40,34 @@ let AICommand = class AICommand extends common_1.Command {
|
|
|
39
40
|
options: [
|
|
40
41
|
{
|
|
41
42
|
flags: '-a, --agent <agent>',
|
|
42
|
-
desc: 'AI CLI 工具 (claude, qwen, codex, aider, codebuddy)'
|
|
43
|
+
desc: (0, i18n_1.t)('AI CLI 工具 (claude, qwen, codex, aider, codebuddy)')
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
46
|
flags: '-e, --envId <envId>',
|
|
46
|
-
desc: '云开发环境 ID'
|
|
47
|
+
desc: (0, i18n_1.t)('云开发环境 ID')
|
|
47
48
|
},
|
|
48
49
|
{
|
|
49
50
|
flags: '--template <template>',
|
|
50
|
-
desc: '指定模板类型 (miniprogram, react, vue, uniapp, rules)'
|
|
51
|
+
desc: (0, i18n_1.t)('指定模板类型 (miniprogram, react, vue, uniapp, rules)')
|
|
51
52
|
},
|
|
52
53
|
{
|
|
53
54
|
flags: '--setup',
|
|
54
|
-
desc: '运行配置向导'
|
|
55
|
+
desc: (0, i18n_1.t)('运行配置向导')
|
|
55
56
|
},
|
|
56
57
|
{
|
|
57
58
|
flags: '--config',
|
|
58
|
-
desc: '显示配置信息'
|
|
59
|
+
desc: (0, i18n_1.t)('显示配置信息')
|
|
59
60
|
},
|
|
60
61
|
{
|
|
61
62
|
flags: '--reset',
|
|
62
|
-
desc: '重置配置'
|
|
63
|
+
desc: (0, i18n_1.t)('重置配置')
|
|
63
64
|
},
|
|
64
65
|
{
|
|
65
66
|
flags: '--template <template>',
|
|
66
|
-
desc: '指定模板类型 (miniprogram, react, vue, uniapp, rules)'
|
|
67
|
+
desc: (0, i18n_1.t)('指定模板类型 (miniprogram, react, vue, uniapp, rules)')
|
|
67
68
|
}
|
|
68
69
|
],
|
|
69
|
-
desc: 'CloudBase AI ToolKit CLI - 快速启动和配置主流 AI 编程工具\n\n示例:\n tcb ai -a claude -- --continue\n tcb ai -a codebuddy -- mcp list\n\n说明:-- 后的参数会直接传递给目标 AI CLI。',
|
|
70
|
+
desc: (0, i18n_1.t)('CloudBase AI ToolKit CLI - 快速启动和配置主流 AI 编程工具\n\n示例:\n tcb ai -a claude -- --continue\n tcb ai -a codebuddy -- mcp list\n\n说明:-- 后的参数会直接传递给目标 AI CLI。'),
|
|
70
71
|
requiredEnvId: false,
|
|
71
72
|
withoutAuth: true,
|
|
72
73
|
allowUnknownOption: true
|
|
@@ -116,10 +117,10 @@ let AICommand = class AICommand extends common_1.Command {
|
|
|
116
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
118
|
try {
|
|
118
119
|
yield configManager.resetConfig();
|
|
119
|
-
log.info('✅ AI 配置已重置');
|
|
120
|
+
log.info((0, i18n_1.t)('✅ AI 配置已重置'));
|
|
120
121
|
}
|
|
121
122
|
catch (error) {
|
|
122
|
-
throw new error_1.CloudBaseError('重置配置失败', { original: error });
|
|
123
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('重置配置失败'), { original: error });
|
|
123
124
|
}
|
|
124
125
|
});
|
|
125
126
|
}
|
|
@@ -127,7 +128,7 @@ let AICommand = class AICommand extends common_1.Command {
|
|
|
127
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
129
|
try {
|
|
129
130
|
const aiConfig = yield configManager.loadConfig();
|
|
130
|
-
log.info('当前 AI 配置:');
|
|
131
|
+
log.info((0, i18n_1.t)('当前 AI 配置:'));
|
|
131
132
|
log.info(JSON.stringify(aiConfig, null, 2));
|
|
132
133
|
}
|
|
133
134
|
catch (error) {
|
|
@@ -135,7 +136,7 @@ let AICommand = class AICommand extends common_1.Command {
|
|
|
135
136
|
log.error(error.message);
|
|
136
137
|
}
|
|
137
138
|
else {
|
|
138
|
-
throw new error_1.CloudBaseError('读取配置失败', { original: error });
|
|
139
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('读取配置失败'), { original: error });
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
});
|