@cloudbase/cli 2.9.8 → 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/cloudbase-cli-2.7.8.tgz +0 -0
- 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 +10 -3
- 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/dist/standalone/ccr.js +0 -78668
- package/dist/standalone/cli.js +0 -626422
package/lib/commands/fun/base.js
CHANGED
|
@@ -35,6 +35,7 @@ const utils_1 = require("../../utils");
|
|
|
35
35
|
const common_1 = require("../common");
|
|
36
36
|
const constants_1 = require("../constants");
|
|
37
37
|
const utils_2 = require("../utils");
|
|
38
|
+
const i18n_1 = require("../../i18n");
|
|
38
39
|
const nodemon = (() => { try {
|
|
39
40
|
return require('nodemon');
|
|
40
41
|
}
|
|
@@ -50,12 +51,12 @@ let FunListCommand = class FunListCommand extends common_1.Command {
|
|
|
50
51
|
options: [
|
|
51
52
|
{
|
|
52
53
|
flags: '-e, --envId <envId>',
|
|
53
|
-
desc: '环境 Id'
|
|
54
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
54
55
|
}
|
|
55
56
|
],
|
|
56
57
|
requiredEnvId: false,
|
|
57
58
|
autoRunLogin: true,
|
|
58
|
-
desc: '查看函数式托管服务列表'
|
|
59
|
+
desc: (0, i18n_1.t)('查看函数式托管服务列表')
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
execute(envId, log) {
|
|
@@ -66,10 +67,10 @@ let FunListCommand = class FunListCommand extends common_1.Command {
|
|
|
66
67
|
envId = yield _selectEnv();
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
|
-
log.info(
|
|
70
|
+
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
70
71
|
}
|
|
71
72
|
try {
|
|
72
|
-
loading.start('获取函数式托管服务列表中…');
|
|
73
|
+
loading.start((0, i18n_1.t)('获取函数式托管服务列表中…'));
|
|
73
74
|
let serverListRes = yield scfService
|
|
74
75
|
.request('DescribeCloudBaseRunServers', {
|
|
75
76
|
EnvId: envId,
|
|
@@ -78,7 +79,7 @@ let FunListCommand = class FunListCommand extends common_1.Command {
|
|
|
78
79
|
})
|
|
79
80
|
.finally(() => loading.stop());
|
|
80
81
|
const serverList = (_a = serverListRes.CloudBaseRunServerSet) === null || _a === void 0 ? void 0 : _a.filter((item) => item.Tag === 'function');
|
|
81
|
-
const head = ['服务名称', '状态', '创建时间', '更新时间'];
|
|
82
|
+
const head = [(0, i18n_1.t)('服务名称'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('更新时间')];
|
|
82
83
|
const tableData = serverList.map((serverItem) => [
|
|
83
84
|
serverItem.ServerName,
|
|
84
85
|
serverItem.Status,
|
|
@@ -88,7 +89,7 @@ let FunListCommand = class FunListCommand extends common_1.Command {
|
|
|
88
89
|
(0, utils_1.printHorizontalTable)(head, tableData);
|
|
89
90
|
}
|
|
90
91
|
catch (e) {
|
|
91
|
-
log.error('获取函数式托管服务列表失败:'
|
|
92
|
+
log.error((0, i18n_1.t)('获取函数式托管服务列表失败:{{message}}', { message: e.message }));
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
}
|
|
@@ -113,32 +114,32 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
|
|
|
113
114
|
options: [
|
|
114
115
|
{
|
|
115
116
|
flags: '-e, --envId <envId>',
|
|
116
|
-
desc: '环境 Id'
|
|
117
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
117
118
|
},
|
|
118
119
|
{
|
|
119
120
|
flags: '-s, --serviceName <serviceName>',
|
|
120
|
-
desc: '服务名称'
|
|
121
|
+
desc: (0, i18n_1.t)('服务名称')
|
|
121
122
|
},
|
|
122
123
|
{
|
|
123
124
|
flags: '--appId <appId>',
|
|
124
|
-
desc: '微信 AppId'
|
|
125
|
+
desc: (0, i18n_1.t)('微信 AppId')
|
|
125
126
|
},
|
|
126
127
|
{
|
|
127
128
|
flags: '--source <source>',
|
|
128
|
-
desc: '目标函数文件所在目录路径。默认为当前路径'
|
|
129
|
+
desc: (0, i18n_1.t)('目标函数文件所在目录路径。默认为当前路径')
|
|
129
130
|
},
|
|
130
131
|
{
|
|
131
132
|
flags: '--includeNodeModules',
|
|
132
|
-
desc: '包含本地 node_modules 目录,默认为 false 不包含'
|
|
133
|
+
desc: (0, i18n_1.t)('包含本地 node_modules 目录,默认为 false 不包含')
|
|
133
134
|
},
|
|
134
135
|
{
|
|
135
136
|
flags: '--functionsConfigFile <functionsConfigFile>',
|
|
136
|
-
desc: '多函数定义配置文件,默认为 ./cloudbase-functions.json'
|
|
137
|
+
desc: (0, i18n_1.t)('多函数定义配置文件,默认为 ./cloudbase-functions.json')
|
|
137
138
|
}
|
|
138
139
|
],
|
|
139
140
|
requiredEnvId: false,
|
|
140
141
|
autoRunLogin: true,
|
|
141
|
-
desc: '部署函数式托管代码'
|
|
142
|
+
desc: (0, i18n_1.t)('部署函数式托管代码')
|
|
142
143
|
};
|
|
143
144
|
}
|
|
144
145
|
execute(envId, log, options) {
|
|
@@ -153,7 +154,7 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
|
|
|
153
154
|
multiFunctionsConfig = (0, functions_framework_1.loadFunctionsConfig)(functionsConfigFile);
|
|
154
155
|
}
|
|
155
156
|
catch (err) {
|
|
156
|
-
log.error(
|
|
157
|
+
log.error((0, i18n_1.t)('多函数定义配置文件 {{functionsConfigFile}} 配置文件有误,请检查', { functionsConfigFile }));
|
|
157
158
|
log.error(err);
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
@@ -162,7 +163,7 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
|
|
|
162
163
|
envId = yield _selectEnv();
|
|
163
164
|
}
|
|
164
165
|
else {
|
|
165
|
-
log.info(
|
|
166
|
+
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
166
167
|
}
|
|
167
168
|
if (!serviceName) {
|
|
168
169
|
let pkgName = '';
|
|
@@ -184,12 +185,12 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
|
|
|
184
185
|
Offset: 0
|
|
185
186
|
});
|
|
186
187
|
if (fetchSvrRes.ServerName && !_isFunRunService(fetchSvrRes.Tag)) {
|
|
187
|
-
log.error(
|
|
188
|
+
log.error((0, i18n_1.t)('{{serviceName}} 服务已存在,但不是一个函数式托管服务,请使用另外的服务名称', { serviceName }));
|
|
188
189
|
return;
|
|
189
190
|
}
|
|
190
191
|
if (!fetchSvrRes.ServerName) {
|
|
191
192
|
try {
|
|
192
|
-
loading.start('正在创建服务…');
|
|
193
|
+
loading.start((0, i18n_1.t)('正在创建服务…'));
|
|
193
194
|
yield scfService.request('EstablishCloudBaseRunServerWx', {
|
|
194
195
|
EnvId: envId,
|
|
195
196
|
ServiceName: serviceName,
|
|
@@ -222,17 +223,17 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
|
|
|
222
223
|
},
|
|
223
224
|
WxBuffer: ''
|
|
224
225
|
});
|
|
225
|
-
loading.succeed('创建服务成功');
|
|
226
|
+
loading.succeed((0, i18n_1.t)('创建服务成功'));
|
|
226
227
|
}
|
|
227
228
|
catch (e) {
|
|
228
229
|
loading.stop();
|
|
229
|
-
log.error('创建服务失败:'
|
|
230
|
+
log.error((0, i18n_1.t)('创建服务失败:{{message}}', { message: e.message }));
|
|
230
231
|
return;
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
let packageName, packageVersion;
|
|
234
235
|
try {
|
|
235
|
-
loading.start('正在上传代码包…');
|
|
236
|
+
loading.start((0, i18n_1.t)('正在上传代码包…'));
|
|
236
237
|
const { PackageName, PackageVersion } = yield (0, run_1.packageDeploy)({
|
|
237
238
|
envId,
|
|
238
239
|
serviceName,
|
|
@@ -245,11 +246,11 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
|
|
|
245
246
|
}
|
|
246
247
|
catch (e) {
|
|
247
248
|
loading.stop();
|
|
248
|
-
log.error('上传代码包失败:'
|
|
249
|
+
log.error((0, i18n_1.t)('上传代码包失败:{{message}}', { message: e.message }));
|
|
249
250
|
return;
|
|
250
251
|
}
|
|
251
252
|
try {
|
|
252
|
-
loading.start('正在创建发布任务…');
|
|
253
|
+
loading.start((0, i18n_1.t)('正在创建发布任务…'));
|
|
253
254
|
yield scfService.request('SubmitServerRelease', {
|
|
254
255
|
EnvId: envId,
|
|
255
256
|
WxAppId: appId,
|
|
@@ -270,11 +271,11 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
|
|
|
270
271
|
},
|
|
271
272
|
VersionRemark: ''
|
|
272
273
|
});
|
|
273
|
-
loading.succeed(
|
|
274
|
+
loading.succeed((0, i18n_1.t)('发布任务创建成功,请前往 https://cloud.weixin.qq.com/cloudrun/service/{{serviceName}} 查看任务详情', { serviceName }));
|
|
274
275
|
}
|
|
275
276
|
catch (e) {
|
|
276
277
|
loading.stop();
|
|
277
|
-
log.error('创建发布任务失败:'
|
|
278
|
+
log.error((0, i18n_1.t)('创建发布任务失败:{{message}}', { message: e.message }));
|
|
278
279
|
}
|
|
279
280
|
});
|
|
280
281
|
}
|
|
@@ -300,31 +301,31 @@ let FunRunCommand = class FunRunCommand extends common_1.Command {
|
|
|
300
301
|
options: [
|
|
301
302
|
{
|
|
302
303
|
flags: '--source <source>',
|
|
303
|
-
desc: '目标函数文件所在目录路径,默认为当前路径'
|
|
304
|
+
desc: (0, i18n_1.t)('目标函数文件所在目录路径,默认为当前路径')
|
|
304
305
|
},
|
|
305
306
|
{
|
|
306
307
|
flags: '--port <port>',
|
|
307
|
-
desc: '监听的端口,默认为 3000'
|
|
308
|
+
desc: (0, i18n_1.t)('监听的端口,默认为 3000')
|
|
308
309
|
},
|
|
309
310
|
{
|
|
310
311
|
flags: '-w, --watch',
|
|
311
|
-
desc: '是否启用热重启模式,如启用,将会在文件变更时自动重启服务,默认为 false'
|
|
312
|
+
desc: (0, i18n_1.t)('是否启用热重启模式,如启用,将会在文件变更时自动重启服务,默认为 false')
|
|
312
313
|
},
|
|
313
314
|
{
|
|
314
315
|
flags: '--dry-run',
|
|
315
|
-
desc: '是否不启动服务,只验证代码可以正常加载,默认为 false'
|
|
316
|
+
desc: (0, i18n_1.t)('是否不启动服务,只验证代码可以正常加载,默认为 false')
|
|
316
317
|
},
|
|
317
318
|
{
|
|
318
319
|
flags: '--logDirname <logDirname>',
|
|
319
|
-
desc: '日志文件目录,默认为 ./logs'
|
|
320
|
+
desc: (0, i18n_1.t)('日志文件目录,默认为 ./logs')
|
|
320
321
|
},
|
|
321
322
|
{
|
|
322
323
|
flags: '--functionsConfigFile <functionsConfigFile>',
|
|
323
|
-
desc: '多函数定义配置文件,默认为 ./cloudbase-functions.json'
|
|
324
|
+
desc: (0, i18n_1.t)('多函数定义配置文件,默认为 ./cloudbase-functions.json')
|
|
324
325
|
}
|
|
325
326
|
],
|
|
326
327
|
requiredEnvId: false,
|
|
327
|
-
desc: '本地运行函数式托管代码'
|
|
328
|
+
desc: (0, i18n_1.t)('本地运行函数式托管代码')
|
|
328
329
|
};
|
|
329
330
|
}
|
|
330
331
|
execute(logger) {
|
|
@@ -335,7 +336,7 @@ let FunRunCommand = class FunRunCommand extends common_1.Command {
|
|
|
335
336
|
if (watchFlag.some((flag) => args.includes(flag))) {
|
|
336
337
|
const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
|
|
337
338
|
if (!nodemon) {
|
|
338
|
-
throw new Error('缺少开发依赖 nodemon,独立发行版已不内置。请在本地开发环境中安装再使用该命令。');
|
|
339
|
+
throw new Error((0, i18n_1.t)('缺少开发依赖 nodemon,独立发行版已不内置。请在本地开发环境中安装再使用该命令。'));
|
|
339
340
|
}
|
|
340
341
|
nodemon({
|
|
341
342
|
script: '',
|
|
@@ -398,10 +399,10 @@ function _inputServiceName(defaultVal = '') {
|
|
|
398
399
|
{
|
|
399
400
|
type: 'input',
|
|
400
401
|
name: 'serviceName',
|
|
401
|
-
message: '请输入服务名称(只能包含数字、小写字母和-,只能以小写字母开头,最多 20字符)',
|
|
402
|
+
message: (0, i18n_1.t)('请输入服务名称(只能包含数字、小写字母和-,只能以小写字母开头,最多 20字符)'),
|
|
402
403
|
default: defaultVal,
|
|
403
404
|
validate: (val) => {
|
|
404
|
-
return /^[a-z][a-z0-9-]{0,19}$/.test(val) ? true : '请输入正确的服务名称';
|
|
405
|
+
return /^[a-z][a-z0-9-]{0,19}$/.test(val) ? true : (0, i18n_1.t)('请输入正确的服务名称');
|
|
405
406
|
}
|
|
406
407
|
}
|
|
407
408
|
];
|
|
@@ -415,8 +416,8 @@ function _inputAppId(defaultVal = '') {
|
|
|
415
416
|
{
|
|
416
417
|
type: 'input',
|
|
417
418
|
name: 'appId',
|
|
418
|
-
message: '请输入微信 AppID',
|
|
419
|
-
validate: (val) => (val ? true : '请输入微信 AppID'),
|
|
419
|
+
message: (0, i18n_1.t)('请输入微信 AppID'),
|
|
420
|
+
validate: (val) => (val ? true : (0, i18n_1.t)('请输入微信 AppID')),
|
|
420
421
|
default: defaultVal
|
|
421
422
|
}
|
|
422
423
|
];
|
|
@@ -26,6 +26,7 @@ const common_1 = require("../../common");
|
|
|
26
26
|
const utils_1 = require("../../../utils");
|
|
27
27
|
const function_1 = require("../../../function");
|
|
28
28
|
const decorators_1 = require("../../../decorators");
|
|
29
|
+
const i18n_1 = require("../../../i18n");
|
|
29
30
|
function parseRoutingConfigValue(expression) {
|
|
30
31
|
const commaIndex = expression.indexOf(',');
|
|
31
32
|
const valueExpression = expression.substring(commaIndex + 1, expression.length - 1);
|
|
@@ -39,10 +40,10 @@ let getFunctionRoutingConfig = class getFunctionRoutingConfig extends common_1.C
|
|
|
39
40
|
options: [
|
|
40
41
|
{
|
|
41
42
|
flags: '-e, --envId <envId>',
|
|
42
|
-
desc: '环境 Id'
|
|
43
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
43
44
|
}
|
|
44
45
|
],
|
|
45
|
-
desc: '查看函数版本流量配置'
|
|
46
|
+
desc: (0, i18n_1.t)('查看函数版本流量配置')
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
execute(ctx, params) {
|
|
@@ -51,7 +52,7 @@ let getFunctionRoutingConfig = class getFunctionRoutingConfig extends common_1.C
|
|
|
51
52
|
const name = params === null || params === void 0 ? void 0 : params[0];
|
|
52
53
|
const { envId } = ctx;
|
|
53
54
|
const loading = (0, utils_1.loadingFactory)();
|
|
54
|
-
loading.start(
|
|
55
|
+
loading.start((0, i18n_1.t)('查询函数 [{{name}}] 版本流量配置中...', { name }));
|
|
55
56
|
const aliasRes = yield (0, function_1.getFunctionAliasConfig)({
|
|
56
57
|
envId,
|
|
57
58
|
functionName: name,
|
|
@@ -75,7 +76,7 @@ let getFunctionRoutingConfig = class getFunctionRoutingConfig extends common_1.C
|
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
loading.stop();
|
|
78
|
-
const head = ['版本', '流量比例'];
|
|
79
|
+
const head = [(0, i18n_1.t)('版本'), (0, i18n_1.t)('流量比例')];
|
|
79
80
|
const tableData = finalConfig.map((item) => [
|
|
80
81
|
item.version,
|
|
81
82
|
item.value
|
|
@@ -27,6 +27,7 @@ const error_1 = require("../../../error");
|
|
|
27
27
|
const utils_1 = require("../../../utils");
|
|
28
28
|
const function_1 = require("../../../function");
|
|
29
29
|
const decorators_1 = require("../../../decorators");
|
|
30
|
+
const i18n_1 = require("../../../i18n");
|
|
30
31
|
let setFunctionRoutingConfig = class setFunctionRoutingConfig extends common_1.Command {
|
|
31
32
|
get options() {
|
|
32
33
|
return {
|
|
@@ -35,10 +36,10 @@ let setFunctionRoutingConfig = class setFunctionRoutingConfig extends common_1.C
|
|
|
35
36
|
options: [
|
|
36
37
|
{
|
|
37
38
|
flags: '-e, --envId <envId>',
|
|
38
|
-
desc: '环境 Id'
|
|
39
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
39
40
|
}
|
|
40
41
|
],
|
|
41
|
-
desc: '设置函数版本流量配置'
|
|
42
|
+
desc: (0, i18n_1.t)('设置函数版本流量配置')
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
execute(ctx, params) {
|
|
@@ -49,16 +50,16 @@ let setFunctionRoutingConfig = class setFunctionRoutingConfig extends common_1.C
|
|
|
49
50
|
const version2 = params === null || params === void 0 ? void 0 : params[3];
|
|
50
51
|
const traffic2 = Number(params === null || params === void 0 ? void 0 : params[4]);
|
|
51
52
|
if ((version2 === undefined && traffic2 !== undefined) || (version2 !== undefined && traffic2 === undefined)) {
|
|
52
|
-
throw new error_1.CloudBaseError('version2 和 traffic2 必须同时设置');
|
|
53
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('version2 和 traffic2 必须同时设置'));
|
|
53
54
|
}
|
|
54
55
|
if (traffic1 !== undefined && traffic2 !== undefined) {
|
|
55
56
|
if (traffic1 + traffic2 !== 100) {
|
|
56
|
-
throw new error_1.CloudBaseError('traffic1 和 traffic2 同时设置时,需保证总和 100');
|
|
57
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('traffic1 和 traffic2 同时设置时,需保证总和 100'));
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
const { envId } = ctx;
|
|
60
61
|
const loading = (0, utils_1.loadingFactory)();
|
|
61
|
-
loading.start(
|
|
62
|
+
loading.start((0, i18n_1.t)('设置函数 [{{name}}] 版本流量配置中...', { name }));
|
|
62
63
|
let routingConfigParams = {
|
|
63
64
|
AddtionVersionMatchs: [{
|
|
64
65
|
Expression: `[0,${traffic1})`,
|
|
@@ -82,7 +83,7 @@ let setFunctionRoutingConfig = class setFunctionRoutingConfig extends common_1.C
|
|
|
82
83
|
functionVersion: '$LATEST',
|
|
83
84
|
routingConfig: routingConfigParams
|
|
84
85
|
});
|
|
85
|
-
loading.succeed(
|
|
86
|
+
loading.succeed((0, i18n_1.t)('设置函数 [{{name}}] 版本流量配置成功!', { name }));
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
};
|
|
@@ -33,28 +33,29 @@ const error_1 = require("../../error");
|
|
|
33
33
|
const decorators_1 = require("../../decorators");
|
|
34
34
|
const function_1 = require("../../function");
|
|
35
35
|
const utils_1 = require("../../utils");
|
|
36
|
+
const i18n_1 = require("../../i18n");
|
|
36
37
|
let CodeDownload = class CodeDownload extends common_1.Command {
|
|
37
38
|
get options() {
|
|
38
39
|
return {
|
|
39
40
|
cmd: 'fn',
|
|
40
41
|
childCmd: {
|
|
41
42
|
cmd: 'code',
|
|
42
|
-
desc: '函数代码管理'
|
|
43
|
+
desc: (0, i18n_1.t)('函数代码管理')
|
|
43
44
|
},
|
|
44
45
|
childSubCmd: 'download <name> [dest]',
|
|
45
46
|
deprecateCmd: 'functions:download <name> [dest]',
|
|
46
47
|
options: [
|
|
47
48
|
{
|
|
48
49
|
flags: '-e, --envId <envId>',
|
|
49
|
-
desc: '环境 Id'
|
|
50
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
50
51
|
},
|
|
51
|
-
{ flags: '-l, --limit <limit>', desc: '返回数据长度,默认值为 20' },
|
|
52
|
+
{ flags: '-l, --limit <limit>', desc: (0, i18n_1.t)('返回数据长度,默认值为 20') },
|
|
52
53
|
{
|
|
53
54
|
flags: '--code-secret <codeSecret>',
|
|
54
|
-
desc: '代码加密的函数的 CodeSecret'
|
|
55
|
+
desc: (0, i18n_1.t)('代码加密的函数的 CodeSecret')
|
|
55
56
|
}
|
|
56
57
|
],
|
|
57
|
-
desc: '下载云函数代码'
|
|
58
|
+
desc: (0, i18n_1.t)('下载云函数代码')
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
execute(ctx, params) {
|
|
@@ -64,7 +65,7 @@ let CodeDownload = class CodeDownload extends common_1.Command {
|
|
|
64
65
|
const name = params === null || params === void 0 ? void 0 : params[0];
|
|
65
66
|
const dest = params === null || params === void 0 ? void 0 : params[1];
|
|
66
67
|
if (!name) {
|
|
67
|
-
throw new error_1.CloudBaseError('请指定云函数名称!');
|
|
68
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
|
|
68
69
|
}
|
|
69
70
|
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
70
71
|
try {
|
|
@@ -72,7 +73,10 @@ let CodeDownload = class CodeDownload extends common_1.Command {
|
|
|
72
73
|
}
|
|
73
74
|
catch (e) {
|
|
74
75
|
if (e.code === 'ResourceNotFound.FunctionName') {
|
|
75
|
-
throw new error_1.CloudBaseError(
|
|
76
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('云函数 [{{name}}] 不存在!\n\n使用 {{command}} 命令查看已部署云函数', {
|
|
77
|
+
name,
|
|
78
|
+
command: (0, utils_1.highlightCommand)('cloudbase functions:list')
|
|
79
|
+
}));
|
|
76
80
|
}
|
|
77
81
|
return;
|
|
78
82
|
}
|
|
@@ -83,25 +87,25 @@ let CodeDownload = class CodeDownload extends common_1.Command {
|
|
|
83
87
|
const { override } = yield inquirer_1.default.prompt({
|
|
84
88
|
type: 'confirm',
|
|
85
89
|
name: 'override',
|
|
86
|
-
message: '函数已经存在,是否覆盖原文件?',
|
|
90
|
+
message: (0, i18n_1.t)('函数已经存在,是否覆盖原文件?'),
|
|
87
91
|
default: false
|
|
88
92
|
});
|
|
89
93
|
if (!override) {
|
|
90
|
-
throw new error_1.CloudBaseError('下载终止!');
|
|
94
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('下载终止!'));
|
|
91
95
|
}
|
|
92
96
|
(0, utils_1.delSync)([destPath]);
|
|
93
97
|
}
|
|
94
98
|
yield fs_extra_1.default.ensureDir(destPath);
|
|
95
99
|
}
|
|
96
100
|
const loading = (0, utils_1.loadingFactory)();
|
|
97
|
-
loading.start('文件下载中...');
|
|
101
|
+
loading.start((0, i18n_1.t)('文件下载中...'));
|
|
98
102
|
yield functionService.downloadFunctionCode({
|
|
99
103
|
envId,
|
|
100
104
|
functionName: name,
|
|
101
105
|
destPath: destPath,
|
|
102
106
|
codeSecret: codeSecret
|
|
103
107
|
});
|
|
104
|
-
loading.succeed(
|
|
108
|
+
loading.succeed((0, i18n_1.t)('[{{name}}] 云函数代码下载成功!', { name }));
|
|
105
109
|
});
|
|
106
110
|
}
|
|
107
111
|
};
|
|
@@ -31,27 +31,28 @@ const error_1 = require("../../error");
|
|
|
31
31
|
const utils_1 = require("../../utils");
|
|
32
32
|
const function_1 = require("../../function");
|
|
33
33
|
const decorators_1 = require("../../decorators");
|
|
34
|
+
const i18n_1 = require("../../i18n");
|
|
34
35
|
let CodeUpdate = class CodeUpdate extends common_1.Command {
|
|
35
36
|
get options() {
|
|
36
37
|
return {
|
|
37
38
|
cmd: 'fn',
|
|
38
39
|
childCmd: {
|
|
39
40
|
cmd: 'code',
|
|
40
|
-
desc: '函数代码管理'
|
|
41
|
+
desc: (0, i18n_1.t)('函数代码管理')
|
|
41
42
|
},
|
|
42
43
|
childSubCmd: 'update <name>',
|
|
43
44
|
deprecateCmd: 'functions:code:update <name>',
|
|
44
45
|
options: [
|
|
45
46
|
{
|
|
46
47
|
flags: '-e, --envId <envId>',
|
|
47
|
-
desc: '环境 Id'
|
|
48
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
48
49
|
},
|
|
49
50
|
{
|
|
50
51
|
flags: '--code-secret <codeSecret>',
|
|
51
|
-
desc: '传入此参数将保护代码,格式为 36 位大小写字母和数字'
|
|
52
|
+
desc: (0, i18n_1.t)('传入此参数将保护代码,格式为 36 位大小写字母和数字')
|
|
52
53
|
}
|
|
53
54
|
],
|
|
54
|
-
desc: '更新云函数代码'
|
|
55
|
+
desc: (0, i18n_1.t)('更新云函数代码')
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
execute(ctx, params) {
|
|
@@ -60,11 +61,11 @@ let CodeUpdate = class CodeUpdate extends common_1.Command {
|
|
|
60
61
|
const { codeSecret } = options;
|
|
61
62
|
const name = params === null || params === void 0 ? void 0 : params[0];
|
|
62
63
|
if (!name) {
|
|
63
|
-
throw new error_1.CloudBaseError('请指定云函数名称!');
|
|
64
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
|
|
64
65
|
}
|
|
65
66
|
const func = config.functions.find((item) => item.name === name) || { name };
|
|
66
67
|
const loading = (0, utils_1.loadingFactory)();
|
|
67
|
-
loading.start(
|
|
68
|
+
loading.start((0, i18n_1.t)('[{{name}}] 函数代码更新中...', { name: func.name }));
|
|
68
69
|
try {
|
|
69
70
|
yield (0, function_1.updateFunctionCode)({
|
|
70
71
|
func,
|
|
@@ -72,7 +73,7 @@ let CodeUpdate = class CodeUpdate extends common_1.Command {
|
|
|
72
73
|
codeSecret,
|
|
73
74
|
functionRootPath: path_1.default.join(process.cwd(), config.functionRoot)
|
|
74
75
|
});
|
|
75
|
-
loading.succeed(
|
|
76
|
+
loading.succeed((0, i18n_1.t)('[{{name}}] 函数代码更新成功!', { name: func.name }));
|
|
76
77
|
}
|
|
77
78
|
catch (e) {
|
|
78
79
|
loading.stop();
|
|
@@ -26,6 +26,7 @@ const common_1 = require("../../common");
|
|
|
26
26
|
const utils_1 = require("../../../utils");
|
|
27
27
|
const function_1 = require("../../../function");
|
|
28
28
|
const decorators_1 = require("../../../decorators");
|
|
29
|
+
const i18n_1 = require("../../../i18n");
|
|
29
30
|
let deleteProvisionedConcurrency = class deleteProvisionedConcurrency extends common_1.Command {
|
|
30
31
|
get options() {
|
|
31
32
|
return {
|
|
@@ -34,10 +35,10 @@ let deleteProvisionedConcurrency = class deleteProvisionedConcurrency extends co
|
|
|
34
35
|
options: [
|
|
35
36
|
{
|
|
36
37
|
flags: '-e, --envId <envId>',
|
|
37
|
-
desc: '环境 Id'
|
|
38
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
38
39
|
}
|
|
39
40
|
],
|
|
40
|
-
desc: '删除函数版本预置并发配置'
|
|
41
|
+
desc: (0, i18n_1.t)('删除函数版本预置并发配置')
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
execute(ctx, params) {
|
|
@@ -46,13 +47,13 @@ let deleteProvisionedConcurrency = class deleteProvisionedConcurrency extends co
|
|
|
46
47
|
const version = params === null || params === void 0 ? void 0 : params[1];
|
|
47
48
|
const { envId } = ctx;
|
|
48
49
|
const loading = (0, utils_1.loadingFactory)();
|
|
49
|
-
loading.start(
|
|
50
|
+
loading.start((0, i18n_1.t)('删除函数 [{{name}}] 预置并发配置中...', { name }));
|
|
50
51
|
yield (0, function_1.deleteProvisionedConcurrencyConfig)({
|
|
51
52
|
envId,
|
|
52
53
|
functionName: name,
|
|
53
54
|
qualifier: version
|
|
54
55
|
});
|
|
55
|
-
loading.succeed(
|
|
56
|
+
loading.succeed((0, i18n_1.t)('删除函数 [{{name}}] 预置并发配置成功!', { name }));
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
};
|
|
@@ -27,6 +27,7 @@ const utils_1 = require("../../../utils");
|
|
|
27
27
|
const function_1 = require("../../../function");
|
|
28
28
|
const decorators_1 = require("../../../decorators");
|
|
29
29
|
const constant_1 = require("../../../constant");
|
|
30
|
+
const i18n_1 = require("../../../i18n");
|
|
30
31
|
let getProvisionedConcurrency = class getProvisionedConcurrency extends common_1.Command {
|
|
31
32
|
get options() {
|
|
32
33
|
return {
|
|
@@ -35,10 +36,10 @@ let getProvisionedConcurrency = class getProvisionedConcurrency extends common_1
|
|
|
35
36
|
options: [
|
|
36
37
|
{
|
|
37
38
|
flags: '-e, --envId <envId>',
|
|
38
|
-
desc: '环境 Id'
|
|
39
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
39
40
|
}
|
|
40
41
|
],
|
|
41
|
-
desc: '获取函数版本预置并发配置'
|
|
42
|
+
desc: (0, i18n_1.t)('获取函数版本预置并发配置')
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
execute(ctx, params, options) {
|
|
@@ -47,18 +48,18 @@ let getProvisionedConcurrency = class getProvisionedConcurrency extends common_1
|
|
|
47
48
|
const version = params === null || params === void 0 ? void 0 : params[1];
|
|
48
49
|
const { envId } = ctx;
|
|
49
50
|
const loading = (0, utils_1.loadingFactory)();
|
|
50
|
-
loading.start(
|
|
51
|
+
loading.start((0, i18n_1.t)('拉取函数 [{{name}}] 预置并发配置中...', { name }));
|
|
51
52
|
const res = yield (0, function_1.getProvisionedConcurrencyConfig)({
|
|
52
53
|
envId,
|
|
53
54
|
functionName: name,
|
|
54
55
|
qualifier: version
|
|
55
56
|
});
|
|
56
57
|
loading.stop();
|
|
57
|
-
const head = ['设置并发数', '已完成并发数', '预置任务状态', '状态说明', '版本号'];
|
|
58
|
+
const head = [(0, i18n_1.t)('设置并发数'), (0, i18n_1.t)('已完成并发数'), (0, i18n_1.t)('预置任务状态'), (0, i18n_1.t)('状态说明'), (0, i18n_1.t)('版本号')];
|
|
58
59
|
const tableData = res.Allocated.map((item) => [
|
|
59
60
|
item.AllocatedProvisionedConcurrencyNum,
|
|
60
61
|
item.AvailableProvisionedConcurrencyNum,
|
|
61
|
-
constant_1.ConcurrencyTaskStatus[item.Status] || '无',
|
|
62
|
+
constant_1.ConcurrencyTaskStatus[item.Status] || (0, i18n_1.t)('无'),
|
|
62
63
|
item.StatusReason,
|
|
63
64
|
item.Qualifier
|
|
64
65
|
]);
|
|
@@ -26,6 +26,7 @@ const common_1 = require("../../common");
|
|
|
26
26
|
const utils_1 = require("../../../utils");
|
|
27
27
|
const function_1 = require("../../../function");
|
|
28
28
|
const decorators_1 = require("../../../decorators");
|
|
29
|
+
const i18n_1 = require("../../../i18n");
|
|
29
30
|
let setProvisionedConcurrency = class setProvisionedConcurrency extends common_1.Command {
|
|
30
31
|
get options() {
|
|
31
32
|
return {
|
|
@@ -34,10 +35,10 @@ let setProvisionedConcurrency = class setProvisionedConcurrency extends common_1
|
|
|
34
35
|
options: [
|
|
35
36
|
{
|
|
36
37
|
flags: '-e, --envId <envId>',
|
|
37
|
-
desc: '环境 Id'
|
|
38
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
38
39
|
}
|
|
39
40
|
],
|
|
40
|
-
desc: '设置函数版本预置并发'
|
|
41
|
+
desc: (0, i18n_1.t)('设置函数版本预置并发')
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
execute(ctx, params) {
|
|
@@ -47,14 +48,14 @@ let setProvisionedConcurrency = class setProvisionedConcurrency extends common_1
|
|
|
47
48
|
const concurrency = Number((params === null || params === void 0 ? void 0 : params[2]) || 0);
|
|
48
49
|
const { envId } = ctx;
|
|
49
50
|
const loading = (0, utils_1.loadingFactory)();
|
|
50
|
-
loading.start(
|
|
51
|
+
loading.start((0, i18n_1.t)('配置函数 [{{name}}] 预置并发中...', { name }));
|
|
51
52
|
yield (0, function_1.setProvisionedConcurrencyConfig)({
|
|
52
53
|
envId,
|
|
53
54
|
functionName: name,
|
|
54
55
|
qualifier: version,
|
|
55
56
|
versionProvisionedConcurrencyNum: concurrency
|
|
56
57
|
});
|
|
57
|
-
loading.succeed(
|
|
58
|
+
loading.succeed((0, i18n_1.t)('配置函数 [{{name}}] 预置并发成功!', { name }));
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
};
|