@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
|
@@ -30,6 +30,7 @@ const common_1 = require("../common");
|
|
|
30
30
|
const error_1 = require("../../error");
|
|
31
31
|
const function_1 = require("../../function");
|
|
32
32
|
const decorators_1 = require("../../decorators");
|
|
33
|
+
const i18n_1 = require("../../i18n");
|
|
33
34
|
let FunctionLog = class FunctionLog extends common_1.Command {
|
|
34
35
|
get options() {
|
|
35
36
|
return {
|
|
@@ -39,38 +40,38 @@ let FunctionLog = class FunctionLog extends common_1.Command {
|
|
|
39
40
|
options: [
|
|
40
41
|
{
|
|
41
42
|
flags: '-e, --envId <envId>',
|
|
42
|
-
desc: '环境 Id'
|
|
43
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
43
44
|
},
|
|
44
|
-
{ flags: '-i, --reqId <reqId>', desc: '函数请求 Id' },
|
|
45
|
+
{ flags: '-i, --reqId <reqId>', desc: (0, i18n_1.t)('函数请求 Id') },
|
|
45
46
|
{
|
|
46
47
|
flags: '-o, --offset <offset>',
|
|
47
|
-
desc: '数据的偏移量,Offset + Limit不能大于10000'
|
|
48
|
+
desc: (0, i18n_1.t)('数据的偏移量,Offset + Limit不能大于10000')
|
|
48
49
|
},
|
|
49
50
|
{
|
|
50
51
|
flags: '-l, --limit <limit>',
|
|
51
|
-
desc: '返回数据的长度,Offset + Limit不能大于10000'
|
|
52
|
+
desc: (0, i18n_1.t)('返回数据的长度,Offset + Limit不能大于10000')
|
|
52
53
|
},
|
|
53
54
|
{
|
|
54
55
|
flags: '--order <order>',
|
|
55
|
-
desc: '以升序还是降序的方式对日志进行排序,可选值 desc 和 asc'
|
|
56
|
+
desc: (0, i18n_1.t)('以升序还是降序的方式对日志进行排序,可选值 desc 和 asc')
|
|
56
57
|
},
|
|
57
58
|
{
|
|
58
59
|
flags: '--orderBy <orderBy>',
|
|
59
|
-
desc: '根据某个字段排序日志,支持以下字段:function_name, duration, mem_usage, start_time'
|
|
60
|
+
desc: (0, i18n_1.t)('根据某个字段排序日志,支持以下字段:function_name, duration, mem_usage, start_time')
|
|
60
61
|
},
|
|
61
62
|
{
|
|
62
63
|
flags: '--startTime <startTime>',
|
|
63
|
-
desc: '查询的具体日期,例如:2019-05-16 20:00:00,只能与 endtime 相差一天之内'
|
|
64
|
+
desc: (0, i18n_1.t)('查询的具体日期,例如:2019-05-16 20:00:00,只能与 endtime 相差一天之内')
|
|
64
65
|
},
|
|
65
66
|
{
|
|
66
67
|
flags: '--endTime <endTime>',
|
|
67
|
-
desc: '查询的具体日期,例如:2019-05-16 20:59:59,只能与 startTime 相差一天之内'
|
|
68
|
+
desc: (0, i18n_1.t)('查询的具体日期,例如:2019-05-16 20:59:59,只能与 startTime 相差一天之内')
|
|
68
69
|
},
|
|
69
|
-
{ flags: '-e, --error', desc: '只返回错误类型的日志' },
|
|
70
|
-
{ flags: '-s, --success', desc: '只返回正确类型的日志' },
|
|
71
|
-
{ flags: '-q, --qualifier <qualifier>', desc: '函数版本,,默认为 $LATEST' }
|
|
70
|
+
{ flags: '-e, --error', desc: (0, i18n_1.t)('只返回错误类型的日志') },
|
|
71
|
+
{ flags: '-s, --success', desc: (0, i18n_1.t)('只返回正确类型的日志') },
|
|
72
|
+
{ flags: '-q, --qualifier <qualifier>', desc: (0, i18n_1.t)('函数版本,,默认为 $LATEST') }
|
|
72
73
|
],
|
|
73
|
-
desc: '打印云函数日志'
|
|
74
|
+
desc: (0, i18n_1.t)('打印云函数日志')
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
execute(ctx, argsParams, log) {
|
|
@@ -79,20 +80,20 @@ let FunctionLog = class FunctionLog extends common_1.Command {
|
|
|
79
80
|
const name = argsParams === null || argsParams === void 0 ? void 0 : argsParams[0];
|
|
80
81
|
let { offset = 0, limit = 10, order, orderBy, error, success, startTime, endTime, reqId: requestId, qualifier } = options;
|
|
81
82
|
if (!name) {
|
|
82
|
-
throw new error_1.CloudBaseError('云函数名称不能为空');
|
|
83
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('云函数名称不能为空'));
|
|
83
84
|
}
|
|
84
85
|
const TimeLength = 19;
|
|
85
86
|
if (typeof startTime !== 'undefined' &&
|
|
86
87
|
typeof endTime !== 'undefined' &&
|
|
87
88
|
(startTime.length !== TimeLength || endTime.length !== TimeLength)) {
|
|
88
|
-
throw new error_1.CloudBaseError('时间格式错误,必须为 2019-05-16 20:59:59 类型');
|
|
89
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('时间格式错误,必须为 2019-05-16 20:59:59 类型'));
|
|
89
90
|
}
|
|
90
91
|
if (new Date(endTime).getTime() < new Date(startTime).getTime()) {
|
|
91
|
-
throw new error_1.CloudBaseError('开始时间不能晚于结束时间');
|
|
92
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('开始时间不能晚于结束时间'));
|
|
92
93
|
}
|
|
93
94
|
const OneDay = 86400000;
|
|
94
95
|
if (new Date(endTime).getTime() - new Date(startTime).getTime() > OneDay) {
|
|
95
|
-
throw new error_1.CloudBaseError('endTime 与 startTime 只能相差一天之内');
|
|
96
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('endTime 与 startTime 只能相差一天之内'));
|
|
96
97
|
}
|
|
97
98
|
let params = {
|
|
98
99
|
order,
|
|
@@ -110,23 +111,23 @@ let FunctionLog = class FunctionLog extends common_1.Command {
|
|
|
110
111
|
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
111
112
|
const logs = yield functionService.getCompleteFunctionLogs(Object.assign({ name }, params));
|
|
112
113
|
const ResMap = {
|
|
113
|
-
StartTime: '请求时间',
|
|
114
|
-
FunctionName: '函数名称',
|
|
115
|
-
Duration: '运行时间(ms)',
|
|
116
|
-
MemUsage: '占用内存',
|
|
117
|
-
RequestId: '请求 Id',
|
|
118
|
-
RetCode: '调用状态',
|
|
119
|
-
RetMsg: '返回结果'
|
|
114
|
+
StartTime: (0, i18n_1.t)('请求时间'),
|
|
115
|
+
FunctionName: (0, i18n_1.t)('函数名称'),
|
|
116
|
+
Duration: (0, i18n_1.t)('运行时间(ms)'),
|
|
117
|
+
MemUsage: (0, i18n_1.t)('占用内存'),
|
|
118
|
+
RequestId: (0, i18n_1.t)('请求 Id'),
|
|
119
|
+
RetCode: (0, i18n_1.t)('调用状态'),
|
|
120
|
+
RetMsg: (0, i18n_1.t)('返回结果')
|
|
120
121
|
};
|
|
121
|
-
log.success(chalk_1.default.green(
|
|
122
|
+
log.success(chalk_1.default.green((0, i18n_1.t)('函数:{{name}} 调用日志:\n', { name })));
|
|
122
123
|
if (logs.length === 0) {
|
|
123
|
-
return log.info('无调用日志');
|
|
124
|
+
return log.info((0, i18n_1.t)('无调用日志'));
|
|
124
125
|
}
|
|
125
126
|
logs.forEach((log) => {
|
|
126
127
|
const info = Object.keys(ResMap)
|
|
127
128
|
.map((key) => {
|
|
128
129
|
if (key === 'RetCode') {
|
|
129
|
-
return `${ResMap[key]}:${Number(log[key]) === 0 ? '成功' : '失败'}\n`;
|
|
130
|
+
return `${ResMap[key]}:${Number(log[key]) === 0 ? (0, i18n_1.t)('成功') : (0, i18n_1.t)('失败')}\n`;
|
|
130
131
|
}
|
|
131
132
|
if (key === 'MemUsage') {
|
|
132
133
|
const str = Number(Number(log[key]) / 1024 / 1024).toFixed(3);
|
|
@@ -135,7 +136,7 @@ let FunctionLog = class FunctionLog extends common_1.Command {
|
|
|
135
136
|
return `${ResMap[key]}:${log[key]} \n`;
|
|
136
137
|
})
|
|
137
138
|
.reduce((prev, next) => prev + next);
|
|
138
|
-
console.log(info +
|
|
139
|
+
console.log(info + (0, i18n_1.t)('日志:\n {{log}} \n', { log: log.LogJson }));
|
|
139
140
|
});
|
|
140
141
|
});
|
|
141
142
|
}
|
|
@@ -32,13 +32,14 @@ const common_1 = require("../common");
|
|
|
32
32
|
const error_1 = require("../../error");
|
|
33
33
|
const decorators_1 = require("../../decorators");
|
|
34
34
|
const utils_1 = require("../../utils");
|
|
35
|
+
const i18n_1 = require("../../i18n");
|
|
35
36
|
const bootstrapFilePath = path_1.default.join(__dirname, '../../../runtime/nodejs/bootstrap.js');
|
|
36
37
|
function checkJSON(data) {
|
|
37
38
|
try {
|
|
38
39
|
JSON.parse(data);
|
|
39
40
|
}
|
|
40
41
|
catch (e) {
|
|
41
|
-
throw new error_1.CloudBaseError('非法的 JSON 字符串');
|
|
42
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('非法的 JSON 字符串'));
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
function errorLog(msg, debug) {
|
|
@@ -62,7 +63,7 @@ function spawnNodeProcess(args, options) {
|
|
|
62
63
|
};
|
|
63
64
|
const exec = (0, child_process_1.spawn)('node', args, Object.assign(Object.assign({}, commonOptions), options));
|
|
64
65
|
exec.on('error', (e) => {
|
|
65
|
-
console.log(
|
|
66
|
+
console.log((0, i18n_1.t)('进程执行异常:{{message}}', { message: e.message }));
|
|
66
67
|
setTimeout(() => { }, 100);
|
|
67
68
|
});
|
|
68
69
|
exec.stdout.on('data', (data) => {
|
|
@@ -73,7 +74,7 @@ function spawnNodeProcess(args, options) {
|
|
|
73
74
|
});
|
|
74
75
|
exec.on('close', (code) => {
|
|
75
76
|
if (code !== 0) {
|
|
76
|
-
console.log(
|
|
77
|
+
console.log((0, i18n_1.t)('\n云函数执行异常退出,错误码:{{code}}', { code }));
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
80
|
}
|
|
@@ -81,7 +82,7 @@ function getSecret() {
|
|
|
81
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
83
|
const credential = yield (0, utils_1.checkAndGetCredential)();
|
|
83
84
|
if (lodash_1.default.isEmpty(credential)) {
|
|
84
|
-
console.log('未登录,无法直接调用 Node SDK');
|
|
85
|
+
console.log((0, i18n_1.t)('未登录,无法直接调用 Node SDK'));
|
|
85
86
|
return {};
|
|
86
87
|
}
|
|
87
88
|
const { secretId, secretKey, token } = credential;
|
|
@@ -103,30 +104,30 @@ function debugFunctionByPath(functionPath, options) {
|
|
|
103
104
|
if (isDir) {
|
|
104
105
|
const exists = (0, utils_1.checkFullAccess)(path_1.default.join(filePath, 'index.js'));
|
|
105
106
|
if (!exists) {
|
|
106
|
-
errorLog('index.js 文件不存在!', debug);
|
|
107
|
+
errorLog((0, i18n_1.t)('index.js 文件不存在!'), debug);
|
|
107
108
|
}
|
|
108
109
|
debugDirname = filePath;
|
|
109
110
|
}
|
|
110
111
|
else {
|
|
111
112
|
const { base, dir } = path_1.default.parse(filePath);
|
|
112
113
|
if (base !== 'index.js') {
|
|
113
|
-
errorLog('index.js 文件不存在!', debug);
|
|
114
|
+
errorLog((0, i18n_1.t)('index.js 文件不存在!'), debug);
|
|
114
115
|
}
|
|
115
116
|
debugDirname = dir;
|
|
116
117
|
}
|
|
117
118
|
try {
|
|
118
119
|
const fileExports = require(path_1.default.join(debugDirname, 'index.js'));
|
|
119
120
|
if (!fileExports.main) {
|
|
120
|
-
errorLog('main 方法不存在!', debug);
|
|
121
|
+
errorLog((0, i18n_1.t)('main 方法不存在!'), debug);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
catch (e) {
|
|
124
|
-
errorLog(
|
|
125
|
+
errorLog((0, i18n_1.t)('导入云函数异常:{{message}}', { message: e.message }), debug);
|
|
125
126
|
}
|
|
126
127
|
const secret = yield getSecret();
|
|
127
128
|
const debugArgs = getDebugArgs(port);
|
|
128
129
|
const args = debug ? [...debugArgs, bootstrapFilePath] : [bootstrapFilePath];
|
|
129
|
-
console.log('> 以默认配置启动 Node 云函数调试');
|
|
130
|
+
console.log((0, i18n_1.t)('> 以默认配置启动 Node 云函数调试'));
|
|
130
131
|
spawnNodeProcess(args, {
|
|
131
132
|
env: Object.assign(Object.assign(Object.assign({}, process.env), { SCF_FUNCTION_HANDLER: 'index.main', SCF_FUNCTION_NAME: 'main', GLOBAL_USER_FILE_PATH: path_1.default.join(debugDirname, path_1.default.sep), SCF_EVENT_BODY: params || '{}' }), secret)
|
|
132
133
|
});
|
|
@@ -151,14 +152,14 @@ function debugByConfig(ctx, name) {
|
|
|
151
152
|
if (isDir) {
|
|
152
153
|
const exists = (0, utils_1.checkFullAccess)(path_1.default.join(filePath, indexFile));
|
|
153
154
|
if (!exists) {
|
|
154
|
-
errorLog(
|
|
155
|
+
errorLog((0, i18n_1.t)('{{indexFile}} 文件不存在!', { indexFile }), debug);
|
|
155
156
|
}
|
|
156
157
|
debugDirname = filePath;
|
|
157
158
|
}
|
|
158
159
|
else {
|
|
159
160
|
const { base, dir } = path_1.default.parse(filePath);
|
|
160
161
|
if (base !== indexFile) {
|
|
161
|
-
errorLog(
|
|
162
|
+
errorLog((0, i18n_1.t)('{{indexFile}} 文件不存在!', { indexFile }), debug);
|
|
162
163
|
}
|
|
163
164
|
debugDirname = dir;
|
|
164
165
|
}
|
|
@@ -169,11 +170,11 @@ function debugByConfig(ctx, name) {
|
|
|
169
170
|
: finalPath;
|
|
170
171
|
const fileExports = require(requirePath);
|
|
171
172
|
if (!fileExports[mainFunction]) {
|
|
172
|
-
errorLog(
|
|
173
|
+
errorLog((0, i18n_1.t)('handler 中的 {{mainFunction}} 方法不存在,请检查你的配置!', { mainFunction }), debug);
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
catch (e) {
|
|
176
|
-
errorLog(
|
|
177
|
+
errorLog((0, i18n_1.t)('导入云函数异常:{{message}}', { message: e.message }), debug);
|
|
177
178
|
}
|
|
178
179
|
const secret = yield getSecret();
|
|
179
180
|
const debugArgs = getDebugArgs(port);
|
|
@@ -193,26 +194,26 @@ let FunctionDebug = class FunctionDebug extends common_1.Command {
|
|
|
193
194
|
options: [
|
|
194
195
|
{
|
|
195
196
|
flags: '--path <path>',
|
|
196
|
-
desc: '云函数路径,使用默认配置直接调用云函数,无需配置文件'
|
|
197
|
+
desc: (0, i18n_1.t)('云函数路径,使用默认配置直接调用云函数,无需配置文件')
|
|
197
198
|
},
|
|
198
199
|
{
|
|
199
200
|
flags: '--name <name>',
|
|
200
|
-
desc: '指定云函数的名称进行调用,需要配置文件'
|
|
201
|
+
desc: (0, i18n_1.t)('指定云函数的名称进行调用,需要配置文件')
|
|
201
202
|
},
|
|
202
203
|
{
|
|
203
204
|
flags: '--params <params>',
|
|
204
|
-
desc: '调用函数传入的参数,JSON 字符串格式'
|
|
205
|
+
desc: (0, i18n_1.t)('调用函数传入的参数,JSON 字符串格式')
|
|
205
206
|
},
|
|
206
207
|
{
|
|
207
208
|
flags: '--port <port>',
|
|
208
|
-
desc: '启动调试时监听的端口号,默认为 9229'
|
|
209
|
+
desc: (0, i18n_1.t)('启动调试时监听的端口号,默认为 9229')
|
|
209
210
|
},
|
|
210
211
|
{
|
|
211
212
|
flags: '--debug',
|
|
212
|
-
desc: '启动调试模式'
|
|
213
|
+
desc: (0, i18n_1.t)('启动调试模式')
|
|
213
214
|
}
|
|
214
215
|
],
|
|
215
|
-
desc: '本地运行云函数(当前仅支持 Node)'
|
|
216
|
+
desc: (0, i18n_1.t)('本地运行云函数(当前仅支持 Node)')
|
|
216
217
|
};
|
|
217
218
|
}
|
|
218
219
|
execute(ctx) {
|
|
@@ -226,7 +227,7 @@ let FunctionDebug = class FunctionDebug extends common_1.Command {
|
|
|
226
227
|
yield debugByConfig(ctx, name);
|
|
227
228
|
}
|
|
228
229
|
else {
|
|
229
|
-
throw new error_1.CloudBaseError('请指定运行函数的名称或函数的路径\n\n例如 cloudbase functions:run --name app');
|
|
230
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定运行函数的名称或函数的路径\n\n例如 cloudbase functions:run --name app'));
|
|
230
231
|
}
|
|
231
232
|
});
|
|
232
233
|
}
|
|
@@ -31,20 +31,21 @@ const logger_1 = require("../../logger");
|
|
|
31
31
|
const error_1 = require("../../error");
|
|
32
32
|
const function_1 = require("../../function");
|
|
33
33
|
const decorators_1 = require("../../decorators");
|
|
34
|
+
const i18n_1 = require("../../i18n");
|
|
34
35
|
let CreateTrigger = class CreateTrigger extends common_1.Command {
|
|
35
36
|
get options() {
|
|
36
37
|
return {
|
|
37
38
|
cmd: 'fn',
|
|
38
|
-
childCmd: { cmd: 'trigger', desc: '函数触发器操作' },
|
|
39
|
+
childCmd: { cmd: 'trigger', desc: (0, i18n_1.t)('函数触发器操作') },
|
|
39
40
|
childSubCmd: 'create [functionName]',
|
|
40
41
|
deprecateCmd: 'functions:trigger:create [functionName]',
|
|
41
42
|
options: [
|
|
42
43
|
{
|
|
43
44
|
flags: '-e, --envId <envId>',
|
|
44
|
-
desc: '环境 Id'
|
|
45
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
45
46
|
}
|
|
46
47
|
],
|
|
47
|
-
desc: '创建云函数触发器'
|
|
48
|
+
desc: (0, i18n_1.t)('创建云函数触发器')
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
execute(ctx, params) {
|
|
@@ -57,12 +58,12 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
|
|
|
57
58
|
const { isBatch } = yield inquirer_1.default.prompt({
|
|
58
59
|
type: 'confirm',
|
|
59
60
|
name: 'isBatch',
|
|
60
|
-
message: '无云函数名称,是否需要部署配置文件中的【全部云函数】的全部触发器?',
|
|
61
|
+
message: (0, i18n_1.t)('无云函数名称,是否需要部署配置文件中的【全部云函数】的全部触发器?'),
|
|
61
62
|
default: false
|
|
62
63
|
});
|
|
63
64
|
isBatchCreateTrigger = isBatch;
|
|
64
65
|
if (!isBatchCreateTrigger) {
|
|
65
|
-
throw new error_1.CloudBaseError('请指定云函数名称!');
|
|
66
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
if (isBatchCreateTrigger) {
|
|
@@ -73,14 +74,14 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
|
|
|
73
74
|
}
|
|
74
75
|
const functionItem = functions.find((item) => item.name === name);
|
|
75
76
|
if (!functionItem) {
|
|
76
|
-
throw new error_1.CloudBaseError('未找到相关函数配置,请检查函数名是否正确');
|
|
77
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('未找到相关函数配置,请检查函数名是否正确'));
|
|
77
78
|
}
|
|
78
79
|
const { triggers } = functionItem;
|
|
79
80
|
if (!triggers || !triggers.length) {
|
|
80
|
-
throw new error_1.CloudBaseError('触发器配置不能为空');
|
|
81
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('触发器配置不能为空'));
|
|
81
82
|
}
|
|
82
83
|
yield functionService.createFunctionTriggers(name, triggers);
|
|
83
|
-
(0, logger_1.successLog)(
|
|
84
|
+
(0, logger_1.successLog)((0, i18n_1.t)('[{{name}}] 创建云函数触发器成功!', { name }));
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
87
|
};
|
|
@@ -29,21 +29,22 @@ const inquirer_1 = __importDefault(require("inquirer"));
|
|
|
29
29
|
const common_1 = require("../common");
|
|
30
30
|
const error_1 = require("../../error");
|
|
31
31
|
const decorators_1 = require("../../decorators");
|
|
32
|
+
const i18n_1 = require("../../i18n");
|
|
32
33
|
const function_1 = require("../../function");
|
|
33
34
|
let DeleteTrigger = class DeleteTrigger extends common_1.Command {
|
|
34
35
|
get options() {
|
|
35
36
|
return {
|
|
36
37
|
cmd: 'fn',
|
|
37
|
-
childCmd: { cmd: 'trigger', desc: '函数触发器操作' },
|
|
38
|
+
childCmd: { cmd: 'trigger', desc: (0, i18n_1.t)('函数触发器操作') },
|
|
38
39
|
childSubCmd: 'delete [functionName] [triggerName]',
|
|
39
40
|
deprecateCmd: 'functions:trigger:delete [functionName] [triggerName]',
|
|
40
41
|
options: [
|
|
41
42
|
{
|
|
42
43
|
flags: '-e, --envId <envId>',
|
|
43
|
-
desc: '环境 Id'
|
|
44
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
44
45
|
}
|
|
45
46
|
],
|
|
46
|
-
desc: '删除云函数触发器'
|
|
47
|
+
desc: (0, i18n_1.t)('删除云函数触发器')
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
execute(ctx, params) {
|
|
@@ -58,20 +59,20 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
|
|
|
58
59
|
const answer = yield inquirer_1.default.prompt({
|
|
59
60
|
type: 'confirm',
|
|
60
61
|
name: 'isBatch',
|
|
61
|
-
message: '无云函数名称,是否需要删除配置文件中的【全部云函数】的全部触发器?',
|
|
62
|
+
message: (0, i18n_1.t)('无云函数名称,是否需要删除配置文件中的【全部云函数】的全部触发器?'),
|
|
62
63
|
default: false
|
|
63
64
|
});
|
|
64
65
|
if (answer.isBatch) {
|
|
65
66
|
const { reConfirm } = yield inquirer_1.default.prompt({
|
|
66
67
|
type: 'confirm',
|
|
67
68
|
name: 'reConfirm',
|
|
68
|
-
message: '确定要删除配置文件中的【全部云函数】的全部触发器?',
|
|
69
|
+
message: (0, i18n_1.t)('确定要删除配置文件中的【全部云函数】的全部触发器?'),
|
|
69
70
|
default: false
|
|
70
71
|
});
|
|
71
72
|
isBatchDeleteTriggers = reConfirm;
|
|
72
73
|
}
|
|
73
74
|
if (!isBatchDeleteTriggers) {
|
|
74
|
-
throw new error_1.CloudBaseError('请指定云函数名称以及触发器名称!');
|
|
75
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
if (isBatchDeleteTriggers) {
|
|
@@ -84,12 +85,12 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
|
|
|
84
85
|
const { isBatch } = yield inquirer_1.default.prompt({
|
|
85
86
|
type: 'confirm',
|
|
86
87
|
name: 'isBatch',
|
|
87
|
-
message: '没有指定触发器名称,是否需要此云函数的全部触发器?',
|
|
88
|
+
message: (0, i18n_1.t)('没有指定触发器名称,是否需要此云函数的全部触发器?'),
|
|
88
89
|
default: false
|
|
89
90
|
});
|
|
90
91
|
isBatchDeleteFunctionTriggers = isBatch;
|
|
91
92
|
if (!isBatchDeleteFunctionTriggers) {
|
|
92
|
-
throw new error_1.CloudBaseError('请指定云函数名称以及触发器名称!');
|
|
93
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
if (isBatchDeleteFunctionTriggers) {
|
|
@@ -100,7 +101,7 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
|
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
if (!triggerName) {
|
|
103
|
-
throw new error_1.CloudBaseError('触发器名称不能为空');
|
|
104
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('触发器名称不能为空'));
|
|
104
105
|
}
|
|
105
106
|
yield functionService.deleteFunctionTrigger(name, triggerName);
|
|
106
107
|
});
|
|
@@ -28,6 +28,7 @@ const utils_1 = require("../../../utils");
|
|
|
28
28
|
const function_1 = require("../../../function");
|
|
29
29
|
const decorators_1 = require("../../../decorators");
|
|
30
30
|
const constant_1 = require("../../../constant");
|
|
31
|
+
const i18n_1 = require("../../../i18n");
|
|
31
32
|
let ListFunctionVersion = class ListFunctionVersion extends common_1.Command {
|
|
32
33
|
get options() {
|
|
33
34
|
return {
|
|
@@ -36,15 +37,15 @@ let ListFunctionVersion = class ListFunctionVersion extends common_1.Command {
|
|
|
36
37
|
options: [
|
|
37
38
|
{
|
|
38
39
|
flags: '-e, --envId <envId>',
|
|
39
|
-
desc: '环境 Id'
|
|
40
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
40
41
|
},
|
|
41
|
-
{ flags: '-l, --limit <limit>', desc: '返回数据长度,默认值为 20' },
|
|
42
|
+
{ flags: '-l, --limit <limit>', desc: (0, i18n_1.t)('返回数据长度,默认值为 20') },
|
|
42
43
|
{
|
|
43
44
|
flags: '-o, --offset <offset>',
|
|
44
|
-
desc: '数据偏移量,默认值为 0'
|
|
45
|
+
desc: (0, i18n_1.t)('数据偏移量,默认值为 0')
|
|
45
46
|
}
|
|
46
47
|
],
|
|
47
|
-
desc: '展示函数版本列表'
|
|
48
|
+
desc: (0, i18n_1.t)('展示函数版本列表')
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
execute(ctx, params, options) {
|
|
@@ -54,14 +55,14 @@ let ListFunctionVersion = class ListFunctionVersion extends common_1.Command {
|
|
|
54
55
|
limit = Number(limit);
|
|
55
56
|
offset = Number(offset);
|
|
56
57
|
if (!Number.isInteger(limit) || !Number.isInteger(offset)) {
|
|
57
|
-
throw new error_1.CloudBaseError('limit 和 offset 必须为整数');
|
|
58
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为整数'));
|
|
58
59
|
}
|
|
59
60
|
if (limit < 0 || offset < 0) {
|
|
60
|
-
throw new error_1.CloudBaseError('limit 和 offset 必须为大于 0 的整数');
|
|
61
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为大于 0 的整数'));
|
|
61
62
|
}
|
|
62
63
|
const { envId } = ctx;
|
|
63
64
|
const loading = (0, utils_1.loadingFactory)();
|
|
64
|
-
loading.start(
|
|
65
|
+
loading.start((0, i18n_1.t)('拉取函数 [{{name}}] 版本列表中...', { name }));
|
|
65
66
|
const res = yield (0, function_1.listFunctionVersions)({
|
|
66
67
|
envId,
|
|
67
68
|
functionName: name,
|
|
@@ -69,7 +70,7 @@ let ListFunctionVersion = class ListFunctionVersion extends common_1.Command {
|
|
|
69
70
|
limit
|
|
70
71
|
});
|
|
71
72
|
loading.stop();
|
|
72
|
-
const head = ['版本', '描述', '创建时间', '修改时间', '状态'];
|
|
73
|
+
const head = [(0, i18n_1.t)('版本'), (0, i18n_1.t)('描述'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('修改时间'), (0, i18n_1.t)('状态')];
|
|
73
74
|
const tableData = res.Versions.map((item) => [
|
|
74
75
|
item.Version,
|
|
75
76
|
item.Description,
|
|
@@ -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 PublishFunctionVersion = class PublishFunctionVersion extends common_1.Command {
|
|
30
31
|
get options() {
|
|
31
32
|
return {
|
|
@@ -34,10 +35,10 @@ let PublishFunctionVersion = class PublishFunctionVersion extends common_1.Comma
|
|
|
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 PublishFunctionVersion = class PublishFunctionVersion extends common_1.Comma
|
|
|
46
47
|
const description = 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.publishVersion)({
|
|
51
52
|
envId,
|
|
52
53
|
functionName: name,
|
|
53
54
|
description
|
|
54
55
|
});
|
|
55
|
-
loading.succeed(
|
|
56
|
+
loading.succeed((0, i18n_1.t)('发布函数 [{{name}}] 新版本成功!', { name }));
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
};
|
|
@@ -30,6 +30,7 @@ const function_1 = require("../../function");
|
|
|
30
30
|
const validator_1 = require("../../utils/validator");
|
|
31
31
|
const utils_1 = require("../../utils");
|
|
32
32
|
const decorators_1 = require("../../decorators");
|
|
33
|
+
const i18n_1 = require("../../i18n");
|
|
33
34
|
let CreateService = class CreateService extends common_1.Command {
|
|
34
35
|
get options() {
|
|
35
36
|
return {
|
|
@@ -39,18 +40,18 @@ let CreateService = class CreateService extends common_1.Command {
|
|
|
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
46
|
flags: '-p, --service-path <servicePath>',
|
|
46
|
-
desc: 'HTTP 访问服务路径,如 api'
|
|
47
|
+
desc: (0, i18n_1.t)('HTTP 访问服务路径,如 api')
|
|
47
48
|
},
|
|
48
49
|
{
|
|
49
50
|
flags: '-f, --function <name>',
|
|
50
|
-
desc: 'HTTP 访问服务路径绑定的云函数名称'
|
|
51
|
+
desc: (0, i18n_1.t)('HTTP 访问服务路径绑定的云函数名称')
|
|
51
52
|
}
|
|
52
53
|
],
|
|
53
|
-
desc: '创建 HTTP 访问服务'
|
|
54
|
+
desc: (0, i18n_1.t)('创建 HTTP 访问服务')
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
execute(envId, options) {
|
|
@@ -59,28 +60,28 @@ let CreateService = class CreateService extends common_1.Command {
|
|
|
59
60
|
let { function: functionName, servicePath } = options;
|
|
60
61
|
const loading = (0, utils_1.loadingFactory)();
|
|
61
62
|
if (!servicePath || !functionName) {
|
|
62
|
-
loading.start('数据加载中...');
|
|
63
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
63
64
|
const functions = yield functionsService.listFunctions(100, 0);
|
|
64
65
|
loading.stop();
|
|
65
66
|
if (!functions.length) {
|
|
66
|
-
throw new error_1.CloudBaseError('当前环境下不存在可用的云函数,请先创建云函数!');
|
|
67
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('当前环境下不存在可用的云函数,请先创建云函数!'));
|
|
67
68
|
}
|
|
68
69
|
let { name } = yield (0, enquirer_1.prompt)({
|
|
69
70
|
type: 'select',
|
|
70
71
|
name: 'name',
|
|
71
|
-
message: '请选择创建HTTP 访问服务的云函数',
|
|
72
|
+
message: (0, i18n_1.t)('请选择创建HTTP 访问服务的云函数'),
|
|
72
73
|
choices: functions.map((item) => item.FunctionName)
|
|
73
74
|
});
|
|
74
75
|
let { path } = yield (0, enquirer_1.prompt)({
|
|
75
76
|
type: 'input',
|
|
76
77
|
name: 'path',
|
|
77
|
-
message: '请输入HTTP 访问服务路径'
|
|
78
|
+
message: (0, i18n_1.t)('请输入HTTP 访问服务路径')
|
|
78
79
|
});
|
|
79
80
|
functionName = name;
|
|
80
81
|
servicePath = path;
|
|
81
82
|
}
|
|
82
|
-
(0, validator_1.assertTruthy)(servicePath, '请指定需要创建的HTTP 访问服务路径!');
|
|
83
|
-
loading.start(
|
|
83
|
+
(0, validator_1.assertTruthy)(servicePath, (0, i18n_1.t)('请指定需要创建的HTTP 访问服务路径!'));
|
|
84
|
+
loading.start((0, i18n_1.t)('[{{functionName}}] HTTP 访问服务创建中...', { functionName }));
|
|
84
85
|
servicePath = servicePath[0] === '/' ? servicePath : `/${servicePath}`;
|
|
85
86
|
try {
|
|
86
87
|
const functionList = yield (0, function_1.listFunction)({
|
|
@@ -89,7 +90,7 @@ let CreateService = class CreateService extends common_1.Command {
|
|
|
89
90
|
});
|
|
90
91
|
const isExisted = functionList.filter((item) => item.FunctionName === functionName);
|
|
91
92
|
if (isExisted.length <= 0) {
|
|
92
|
-
throw new error_1.CloudBaseError(
|
|
93
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('[{{functionName}}] 云函数不存在!', { functionName }));
|
|
93
94
|
}
|
|
94
95
|
yield (0, gateway_1.createGateway)({
|
|
95
96
|
envId,
|
|
@@ -98,12 +99,12 @@ let CreateService = class CreateService extends common_1.Command {
|
|
|
98
99
|
});
|
|
99
100
|
const res = yield (0, gateway_1.queryGatewayDomain)({ envId });
|
|
100
101
|
const link = (0, utils_1.genClickableLink)(`https://${res.DefaultDomain}${servicePath}`);
|
|
101
|
-
loading.succeed(
|
|
102
|
+
loading.succeed((0, i18n_1.t)('HTTP 访问服务创建成功!\n点击访问> {{link}}', { link }));
|
|
102
103
|
}
|
|
103
104
|
catch (e) {
|
|
104
105
|
loading.stop();
|
|
105
106
|
if (e.code === 'InvalidParameter.APICreated') {
|
|
106
|
-
throw new error_1.CloudBaseError('路径已存在!');
|
|
107
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('路径已存在!'));
|
|
107
108
|
}
|
|
108
109
|
throw e;
|
|
109
110
|
}
|