@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
|
@@ -29,24 +29,25 @@ const utils_1 = require("../../../utils");
|
|
|
29
29
|
const error_1 = require("../../../error");
|
|
30
30
|
const decorators_1 = require("../../../decorators");
|
|
31
31
|
const common_2 = require("./common");
|
|
32
|
+
const i18n_1 = require("../../../i18n");
|
|
32
33
|
const LayerStatusMap = {
|
|
33
|
-
Active: '正常',
|
|
34
|
-
Publishing: '发布中',
|
|
35
|
-
PublishFailed: '发布失败',
|
|
36
|
-
Deleted: '已删除'
|
|
34
|
+
Active: (0, i18n_1.t)('正常'),
|
|
35
|
+
Publishing: (0, i18n_1.t)('发布中'),
|
|
36
|
+
PublishFailed: (0, i18n_1.t)('发布失败'),
|
|
37
|
+
Deleted: (0, i18n_1.t)('已删除')
|
|
37
38
|
};
|
|
38
39
|
let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
39
40
|
get options() {
|
|
40
41
|
return Object.assign(Object.assign({}, (0, common_2.layerCommonOptions)('bind <name>')), { deprecateCmd: 'functions:layer:bind <name>', options: [
|
|
41
42
|
{
|
|
42
43
|
flags: '-e, --envId <envId>',
|
|
43
|
-
desc: '环境 Id'
|
|
44
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
44
45
|
},
|
|
45
46
|
{
|
|
46
47
|
flags: '--code-secret, <codeSecret>',
|
|
47
|
-
desc: '代码加密的函数的 CodeSecret'
|
|
48
|
+
desc: (0, i18n_1.t)('代码加密的函数的 CodeSecret')
|
|
48
49
|
}
|
|
49
|
-
], desc: '绑定文件层到云函数' });
|
|
50
|
+
], desc: (0, i18n_1.t)('绑定文件层到云函数') });
|
|
50
51
|
}
|
|
51
52
|
execute(envId, params, options) {
|
|
52
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -54,13 +55,13 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
|
54
55
|
const fnName = params === null || params === void 0 ? void 0 : params[0];
|
|
55
56
|
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
56
57
|
const loading = (0, utils_1.loadingFactory)();
|
|
57
|
-
loading.start('数据加载中...');
|
|
58
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
58
59
|
const envFunctions = yield functionService.listAllFunctions({
|
|
59
60
|
envId
|
|
60
61
|
});
|
|
61
62
|
const exist = envFunctions.find((fn) => fn.FunctionName === fnName);
|
|
62
63
|
if (!exist) {
|
|
63
|
-
throw new error_1.CloudBaseError(
|
|
64
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('当前环境不存在此函数 [{{fnName}}]', { fnName }));
|
|
64
65
|
}
|
|
65
66
|
const listLayersRes = yield functionService.listLayers({
|
|
66
67
|
offset: 0,
|
|
@@ -69,16 +70,16 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
|
69
70
|
const layers = listLayersRes.Layers || [];
|
|
70
71
|
loading.stop();
|
|
71
72
|
const newLayers = layers.map((item) => ({
|
|
72
|
-
name: `[${LayerStatusMap[item.Status] || '异常'}] ${item.LayerName}`,
|
|
73
|
+
name: `[${LayerStatusMap[item.Status] || (0, i18n_1.t)('异常')}] ${item.LayerName}`,
|
|
73
74
|
value: item.LayerName
|
|
74
75
|
}));
|
|
75
76
|
if (!newLayers.length) {
|
|
76
|
-
throw new error_1.CloudBaseError('没有可用的文件层,请先创建文件层!');
|
|
77
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('没有可用的文件层,请先创建文件层!'));
|
|
77
78
|
}
|
|
78
79
|
const { layer } = yield (0, enquirer_1.prompt)({
|
|
79
80
|
type: 'select',
|
|
80
81
|
name: 'layer',
|
|
81
|
-
message: '选择文件层名称',
|
|
82
|
+
message: (0, i18n_1.t)('选择文件层名称'),
|
|
82
83
|
choices: newLayers,
|
|
83
84
|
result(choices) {
|
|
84
85
|
const keys = Object.values(this.map(choices));
|
|
@@ -91,15 +92,15 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
|
91
92
|
let layerVersions = listLayerVersionsRes.LayerVersions || [];
|
|
92
93
|
const versions = layerVersions.map((item) => String(item.LayerVersion));
|
|
93
94
|
if (!versions.length) {
|
|
94
|
-
throw new error_1.CloudBaseError('没有可用的文件层版本,请先创建文件层版本!');
|
|
95
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('没有可用的文件层版本,请先创建文件层版本!'));
|
|
95
96
|
}
|
|
96
97
|
const { version } = yield (0, enquirer_1.prompt)({
|
|
97
98
|
type: 'select',
|
|
98
99
|
name: 'version',
|
|
99
|
-
message: '选择文件层版本',
|
|
100
|
+
message: (0, i18n_1.t)('选择文件层版本'),
|
|
100
101
|
choices: versions
|
|
101
102
|
});
|
|
102
|
-
loading.start('文件层绑定中...');
|
|
103
|
+
loading.start((0, i18n_1.t)('文件层绑定中...'));
|
|
103
104
|
yield functionService.attachLayer({
|
|
104
105
|
envId,
|
|
105
106
|
functionName: fnName,
|
|
@@ -107,7 +108,7 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
|
107
108
|
layerVersion: Number(version),
|
|
108
109
|
codeSecret
|
|
109
110
|
});
|
|
110
|
-
loading.succeed('文件层绑定成功!');
|
|
111
|
+
loading.succeed((0, i18n_1.t)('文件层绑定成功!'));
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
114
|
};
|
|
@@ -129,13 +130,13 @@ let UnAttachFileLayer = class UnAttachFileLayer extends common_1.Command {
|
|
|
129
130
|
return Object.assign(Object.assign({}, (0, common_2.layerCommonOptions)('unbind <name>')), { deprecateCmd: 'functions:layer:unbind <name>', options: [
|
|
130
131
|
{
|
|
131
132
|
flags: '-e, --envId <envId>',
|
|
132
|
-
desc: '环境 Id'
|
|
133
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
133
134
|
},
|
|
134
135
|
{
|
|
135
136
|
flags: '--code-secret, <codeSecret>',
|
|
136
|
-
desc: '代码加密的函数的 CodeSecret'
|
|
137
|
+
desc: (0, i18n_1.t)('代码加密的函数的 CodeSecret')
|
|
137
138
|
}
|
|
138
|
-
], desc: '删除云函数绑定的文件层' });
|
|
139
|
+
], desc: (0, i18n_1.t)('删除云函数绑定的文件层') });
|
|
139
140
|
}
|
|
140
141
|
execute(envId, params, options) {
|
|
141
142
|
var _a;
|
|
@@ -143,27 +144,27 @@ let UnAttachFileLayer = class UnAttachFileLayer extends common_1.Command {
|
|
|
143
144
|
const { codeSecret } = options;
|
|
144
145
|
const fnName = params === null || params === void 0 ? void 0 : params[0];
|
|
145
146
|
const loading = (0, utils_1.loadingFactory)();
|
|
146
|
-
loading.start('数据加载中...');
|
|
147
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
147
148
|
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
148
149
|
const detail = yield functionService.getFunctionDetail(fnName, codeSecret);
|
|
149
150
|
if (!((_a = detail === null || detail === void 0 ? void 0 : detail.Layers) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
150
|
-
throw new error_1.CloudBaseError('该云函数未绑定文件层!');
|
|
151
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('该云函数未绑定文件层!'));
|
|
151
152
|
}
|
|
152
153
|
loading.stop();
|
|
153
154
|
const layers = detail.Layers.map((item) => ({
|
|
154
|
-
name:
|
|
155
|
+
name: (0, i18n_1.t)('名称:{{layerName}} / 版本: {{layerVersion}}', { layerName: item.LayerName, layerVersion: item.LayerVersion }),
|
|
155
156
|
value: item
|
|
156
157
|
}));
|
|
157
158
|
const { layer } = yield (0, enquirer_1.prompt)({
|
|
158
159
|
type: 'select',
|
|
159
160
|
name: 'layer',
|
|
160
|
-
message: '选择文件层',
|
|
161
|
+
message: (0, i18n_1.t)('选择文件层'),
|
|
161
162
|
choices: layers,
|
|
162
163
|
result(choice) {
|
|
163
164
|
return this.map(choice)[choice];
|
|
164
165
|
}
|
|
165
166
|
});
|
|
166
|
-
loading.start('文件层解绑中...');
|
|
167
|
+
loading.start((0, i18n_1.t)('文件层解绑中...'));
|
|
167
168
|
yield functionService.unAttachLayer({
|
|
168
169
|
envId,
|
|
169
170
|
functionName: fnName,
|
|
@@ -171,7 +172,7 @@ let UnAttachFileLayer = class UnAttachFileLayer extends common_1.Command {
|
|
|
171
172
|
layerVersion: layer.LayerVersion,
|
|
172
173
|
codeSecret
|
|
173
174
|
});
|
|
174
|
-
loading.succeed('文件层解绑成功!');
|
|
175
|
+
loading.succeed((0, i18n_1.t)('文件层解绑成功!'));
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.layerCommonOptions = void 0;
|
|
4
|
+
const i18n_1 = require("../../../i18n");
|
|
4
5
|
const layerCommonOptions = (sub) => ({
|
|
5
6
|
cmd: 'fn',
|
|
6
7
|
childCmd: {
|
|
7
8
|
cmd: 'layer',
|
|
8
|
-
desc: '云函数层管理'
|
|
9
|
+
desc: (0, i18n_1.t)('云函数层管理')
|
|
9
10
|
},
|
|
10
11
|
childSubCmd: sub
|
|
11
12
|
});
|
|
@@ -32,18 +32,19 @@ const utils_1 = require("../../../utils");
|
|
|
32
32
|
const decorators_1 = require("../../../decorators");
|
|
33
33
|
const common_2 = require("./common");
|
|
34
34
|
const toolbox_1 = require("@cloudbase/toolbox");
|
|
35
|
+
const i18n_1 = require("../../../i18n");
|
|
35
36
|
let CreateFileLayer = class CreateFileLayer extends common_1.Command {
|
|
36
37
|
get options() {
|
|
37
38
|
return Object.assign(Object.assign({}, (0, common_2.layerCommonOptions)('create <alias>')), { deprecateCmd: 'functions:layer:create <alias>', options: [
|
|
38
39
|
{
|
|
39
40
|
flags: '-e, --envId <envId>',
|
|
40
|
-
desc: '环境 Id'
|
|
41
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
41
42
|
},
|
|
42
43
|
{
|
|
43
44
|
flags: '--file, <file>',
|
|
44
|
-
desc: '文件路径'
|
|
45
|
+
desc: (0, i18n_1.t)('文件路径')
|
|
45
46
|
}
|
|
46
|
-
], desc: '创建函数文件层' });
|
|
47
|
+
], desc: (0, i18n_1.t)('创建函数文件层') });
|
|
47
48
|
}
|
|
48
49
|
execute(envId, options, params) {
|
|
49
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -57,18 +58,18 @@ let CreateFileLayer = class CreateFileLayer extends common_1.Command {
|
|
|
57
58
|
});
|
|
58
59
|
const layers = listLayerRes.Layers || [];
|
|
59
60
|
if (layers.find(({ LayerName }) => LayerName === layerName)) {
|
|
60
|
-
throw new toolbox_1.CloudBaseError(
|
|
61
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('层名称 {{layerName}} 已被您的当前环境或其他环境占用,请换用别的名称', { layerName }));
|
|
61
62
|
}
|
|
62
63
|
const filePath = path_1.default.resolve(file);
|
|
63
64
|
const runtimes = ['Nodejs14.18', 'Nodejs12.16', 'Nodejs8.9', 'Php7', 'Java8'];
|
|
64
65
|
const loading = (0, utils_1.loadingFactory)();
|
|
65
|
-
loading.start('文件层创建中...');
|
|
66
|
+
loading.start((0, i18n_1.t)('文件层创建中...'));
|
|
66
67
|
yield functionsService.createLayer({
|
|
67
68
|
name: layerName,
|
|
68
69
|
runtimes,
|
|
69
70
|
contentPath: filePath
|
|
70
71
|
});
|
|
71
|
-
loading.succeed('文件层创建成功!');
|
|
72
|
+
loading.succeed((0, i18n_1.t)('文件层创建成功!'));
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
};
|
|
@@ -29,19 +29,20 @@ const error_1 = require("../../../error");
|
|
|
29
29
|
const decorators_1 = require("../../../decorators");
|
|
30
30
|
const function_1 = require("../../../function");
|
|
31
31
|
const common_2 = require("./common");
|
|
32
|
+
const i18n_1 = require("../../../i18n");
|
|
32
33
|
let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
|
|
33
34
|
get options() {
|
|
34
35
|
return Object.assign(Object.assign({}, (0, common_2.layerCommonOptions)('delete')), { deprecateCmd: 'functions:layer:delete', options: [
|
|
35
36
|
{
|
|
36
37
|
flags: '-e, --envId <envId>',
|
|
37
|
-
desc: '环境 Id'
|
|
38
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
38
39
|
}
|
|
39
|
-
], desc: '删除当前环境的文件层' });
|
|
40
|
+
], desc: (0, i18n_1.t)('删除当前环境的文件层') });
|
|
40
41
|
}
|
|
41
42
|
execute(envId) {
|
|
42
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
44
|
const loading = (0, utils_1.loadingFactory)();
|
|
44
|
-
loading.start('数据加载中...');
|
|
45
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
45
46
|
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
46
47
|
const listLayersRes = yield functionService.listLayers({
|
|
47
48
|
offset: 0,
|
|
@@ -50,12 +51,12 @@ let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
|
|
|
50
51
|
loading.stop();
|
|
51
52
|
const layers = listLayersRes.Layers || [];
|
|
52
53
|
if (!layers.length) {
|
|
53
|
-
throw new error_1.CloudBaseError('当前环境没有可用的文件层,请先创建文件层!');
|
|
54
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('当前环境没有可用的文件层,请先创建文件层!'));
|
|
54
55
|
}
|
|
55
56
|
const { layer } = yield (0, enquirer_1.prompt)({
|
|
56
57
|
type: 'select',
|
|
57
58
|
name: 'layer',
|
|
58
|
-
message: '选择文件层名称',
|
|
59
|
+
message: (0, i18n_1.t)('选择文件层名称'),
|
|
59
60
|
choices: layers.map((item) => item.LayerName)
|
|
60
61
|
});
|
|
61
62
|
let listLayerVersionsRes = yield functionService.listLayerVersions({
|
|
@@ -66,15 +67,15 @@ let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
|
|
|
66
67
|
const { version } = yield (0, enquirer_1.prompt)({
|
|
67
68
|
type: 'select',
|
|
68
69
|
name: 'version',
|
|
69
|
-
message: '选择文件层版本',
|
|
70
|
+
message: (0, i18n_1.t)('选择文件层版本'),
|
|
70
71
|
choices: versions
|
|
71
72
|
});
|
|
72
|
-
loading.start('文件层删除中...');
|
|
73
|
+
loading.start((0, i18n_1.t)('文件层删除中...'));
|
|
73
74
|
yield functionService.deleteLayerVersion({
|
|
74
75
|
name: layer,
|
|
75
76
|
version: Number(version)
|
|
76
77
|
});
|
|
77
|
-
loading.succeed('文件层删除成功!');
|
|
78
|
+
loading.succeed((0, i18n_1.t)('文件层删除成功!'));
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
};
|
|
@@ -34,25 +34,26 @@ const common_1 = require("../../common");
|
|
|
34
34
|
const decorators_1 = require("../../../decorators");
|
|
35
35
|
const function_1 = require("../../../function");
|
|
36
36
|
const common_2 = require("./common");
|
|
37
|
+
const i18n_1 = require("../../../i18n");
|
|
37
38
|
let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
|
|
38
39
|
get options() {
|
|
39
40
|
return Object.assign(Object.assign({}, (0, common_2.layerCommonOptions)('download')), { deprecateCmd: 'functions:layer:download', 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: '--dest <dest>',
|
|
46
|
-
desc: '下载文件存放的地址'
|
|
47
|
+
desc: (0, i18n_1.t)('下载文件存放的地址')
|
|
47
48
|
}
|
|
48
|
-
], desc: '下载云函数文件层' });
|
|
49
|
+
], desc: (0, i18n_1.t)('下载云函数文件层') });
|
|
49
50
|
}
|
|
50
51
|
execute(envId, options) {
|
|
51
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
53
|
const { dest } = options;
|
|
53
54
|
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
54
55
|
const loading = (0, utils_1.loadingFactory)();
|
|
55
|
-
loading.start('数据加载中...');
|
|
56
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
56
57
|
const listLayersRes = yield functionService.listLayers({
|
|
57
58
|
offset: 0,
|
|
58
59
|
limit: 200,
|
|
@@ -60,12 +61,12 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
|
|
|
60
61
|
const layers = listLayersRes.Layers || [];
|
|
61
62
|
loading.stop();
|
|
62
63
|
if (!layers.length) {
|
|
63
|
-
throw new error_1.CloudBaseError('当前环境没有可用的文件层,请先创建文件层!');
|
|
64
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('当前环境没有可用的文件层,请先创建文件层!'));
|
|
64
65
|
}
|
|
65
66
|
const { layer } = yield (0, enquirer_1.prompt)({
|
|
66
67
|
type: 'select',
|
|
67
68
|
name: 'layer',
|
|
68
|
-
message: '选择文件层名称',
|
|
69
|
+
message: (0, i18n_1.t)('选择文件层名称'),
|
|
69
70
|
choices: layers.map((item) => item.LayerName)
|
|
70
71
|
});
|
|
71
72
|
let listLayerVersionsRes = yield functionService.listLayerVersions({
|
|
@@ -76,7 +77,7 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
|
|
|
76
77
|
const { version } = yield (0, enquirer_1.prompt)({
|
|
77
78
|
type: 'select',
|
|
78
79
|
name: 'version',
|
|
79
|
-
message: '选择文件层版本',
|
|
80
|
+
message: (0, i18n_1.t)('选择文件层版本'),
|
|
80
81
|
choices: versions
|
|
81
82
|
});
|
|
82
83
|
let destPath;
|
|
@@ -86,14 +87,14 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
|
|
|
86
87
|
else {
|
|
87
88
|
destPath = path_1.default.resolve(dest);
|
|
88
89
|
}
|
|
89
|
-
loading.start('文件下载中...');
|
|
90
|
+
loading.start((0, i18n_1.t)('文件下载中...'));
|
|
90
91
|
yield fs_extra_1.default.ensureDir(destPath);
|
|
91
92
|
yield functionService.downloadLayer({
|
|
92
93
|
destPath,
|
|
93
94
|
version: Number(version),
|
|
94
95
|
name: layer
|
|
95
96
|
});
|
|
96
|
-
loading.succeed('文件下载成功!');
|
|
97
|
+
loading.succeed((0, i18n_1.t)('文件下载成功!'));
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
};
|
|
@@ -27,32 +27,33 @@ const utils_1 = require("../../../utils");
|
|
|
27
27
|
const decorators_1 = require("../../../decorators");
|
|
28
28
|
const function_1 = require("../../../function");
|
|
29
29
|
const common_2 = require("./common");
|
|
30
|
+
const i18n_1 = require("../../../i18n");
|
|
30
31
|
let ListFileLayer = class ListFileLayer extends common_1.Command {
|
|
31
32
|
get options() {
|
|
32
33
|
return Object.assign(Object.assign({}, (0, common_2.layerCommonOptions)('list')), { deprecateCmd: 'functions:layer:list', options: [
|
|
33
34
|
{
|
|
34
35
|
flags: '-e, --envId <envId>',
|
|
35
|
-
desc: '环境 Id'
|
|
36
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
36
37
|
},
|
|
37
38
|
{
|
|
38
39
|
flags: '--name, <name>',
|
|
39
|
-
desc: '函数名称'
|
|
40
|
+
desc: (0, i18n_1.t)('函数名称')
|
|
40
41
|
},
|
|
41
42
|
{
|
|
42
43
|
flags: '--layer, <layer>',
|
|
43
|
-
desc: '文件层别名'
|
|
44
|
+
desc: (0, i18n_1.t)('文件层别名')
|
|
44
45
|
},
|
|
45
46
|
{
|
|
46
47
|
flags: '--code-secret, <codeSecret>',
|
|
47
|
-
desc: '代码加密的函数的 CodeSecret'
|
|
48
|
+
desc: (0, i18n_1.t)('代码加密的函数的 CodeSecret')
|
|
48
49
|
}
|
|
49
|
-
], desc: '展示文件层列表' });
|
|
50
|
+
], desc: (0, i18n_1.t)('展示文件层列表') });
|
|
50
51
|
}
|
|
51
52
|
execute(envId, options, log) {
|
|
52
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
54
|
const { name, layer, codeSecret } = options;
|
|
54
55
|
const loading = (0, utils_1.loadingFactory)();
|
|
55
|
-
loading.start('数据加载中...');
|
|
56
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
56
57
|
let data;
|
|
57
58
|
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
58
59
|
if (layer && typeof layer === 'string') {
|
|
@@ -74,18 +75,18 @@ let ListFileLayer = class ListFileLayer extends common_1.Command {
|
|
|
74
75
|
data = listLayersRes.Layers || [];
|
|
75
76
|
}
|
|
76
77
|
loading.stop();
|
|
77
|
-
const head = ['优先级', '名称', '状态', '版本', '证书', '支持运行时', '创建时间'];
|
|
78
|
+
const head = [(0, i18n_1.t)('优先级'), (0, i18n_1.t)('名称'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('版本'), (0, i18n_1.t)('证书'), (0, i18n_1.t)('支持运行时'), (0, i18n_1.t)('创建时间')];
|
|
78
79
|
const tableData = data.map((item, index) => [
|
|
79
80
|
index + 1,
|
|
80
81
|
item.LayerName,
|
|
81
82
|
item.Status,
|
|
82
83
|
item.LayerVersion,
|
|
83
|
-
item.LicenseInfo || '空',
|
|
84
|
+
item.LicenseInfo || (0, i18n_1.t)('空'),
|
|
84
85
|
item.CompatibleRuntimes.join(' | '),
|
|
85
86
|
item.AddTime
|
|
86
87
|
]);
|
|
87
88
|
(0, utils_1.printHorizontalTable)(head, tableData);
|
|
88
|
-
log.info('Tips:函数绑定多个版本时,同名文件将按优先级从小到大的顺序进行覆盖执行。');
|
|
89
|
+
log.info((0, i18n_1.t)('Tips:函数绑定多个版本时,同名文件将按优先级从小到大的顺序进行覆盖执行。'));
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
};
|
|
@@ -33,18 +33,19 @@ const error_1 = require("../../../error");
|
|
|
33
33
|
const function_1 = require("../../../function");
|
|
34
34
|
const decorators_1 = require("../../../decorators");
|
|
35
35
|
const common_2 = require("./common");
|
|
36
|
+
const i18n_1 = require("../../../i18n");
|
|
36
37
|
let SortFileLayer = class SortFileLayer extends common_1.Command {
|
|
37
38
|
get options() {
|
|
38
39
|
return Object.assign(Object.assign({}, (0, common_2.layerCommonOptions)('sort <name>')), { deprecateCmd: 'functions:layer:sort <name>', options: [
|
|
39
40
|
{
|
|
40
41
|
flags: '-e, --envId <envId>',
|
|
41
|
-
desc: '环境 Id'
|
|
42
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
42
43
|
},
|
|
43
44
|
{
|
|
44
45
|
flags: '--code-secret, <codeSecret>',
|
|
45
|
-
desc: '代码加密的函数的 CodeSecret'
|
|
46
|
+
desc: (0, i18n_1.t)('代码加密的函数的 CodeSecret')
|
|
46
47
|
}
|
|
47
|
-
], desc: '重新排列云函数绑定的文件层的顺序' });
|
|
48
|
+
], desc: (0, i18n_1.t)('重新排列云函数绑定的文件层的顺序') });
|
|
48
49
|
}
|
|
49
50
|
execute(ctx) {
|
|
50
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -52,7 +53,7 @@ let SortFileLayer = class SortFileLayer extends common_1.Command {
|
|
|
52
53
|
const { codeSecret } = options;
|
|
53
54
|
const fnName = params === null || params === void 0 ? void 0 : params[0];
|
|
54
55
|
const loading = (0, utils_1.loadingFactory)();
|
|
55
|
-
loading.start('数据加载中...');
|
|
56
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
56
57
|
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
57
58
|
const detail = yield functionService.getFunctionDetail(fnName, codeSecret);
|
|
58
59
|
loading.stop();
|
|
@@ -61,12 +62,12 @@ let SortFileLayer = class SortFileLayer extends common_1.Command {
|
|
|
61
62
|
value: item
|
|
62
63
|
}));
|
|
63
64
|
if (!layers.length) {
|
|
64
|
-
throw new error_1.CloudBaseError('没有可用的文件层,请先创建文件层!');
|
|
65
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('没有可用的文件层,请先创建文件层!'));
|
|
65
66
|
}
|
|
66
67
|
let { sortLayers } = yield (0, enquirer_1.prompt)({
|
|
67
68
|
type: 'sort',
|
|
68
69
|
name: 'sortLayers',
|
|
69
|
-
message: '选择文件层',
|
|
70
|
+
message: (0, i18n_1.t)('选择文件层'),
|
|
70
71
|
numbered: true,
|
|
71
72
|
choices: layers,
|
|
72
73
|
result(choices) {
|
|
@@ -74,13 +75,13 @@ let SortFileLayer = class SortFileLayer extends common_1.Command {
|
|
|
74
75
|
}
|
|
75
76
|
});
|
|
76
77
|
sortLayers = sortLayers.map((item) => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
77
|
-
loading.start('文件层排序中...');
|
|
78
|
+
loading.start((0, i18n_1.t)('文件层排序中...'));
|
|
78
79
|
yield functionService.updateFunctionLayer({
|
|
79
80
|
envId,
|
|
80
81
|
functionName: fnName,
|
|
81
82
|
layers: sortLayers
|
|
82
83
|
});
|
|
83
|
-
loading.succeed('文件层排序成功!');
|
|
84
|
+
loading.succeed((0, i18n_1.t)('文件层排序成功!'));
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
87
|
};
|
|
@@ -28,6 +28,7 @@ const function_1 = require("../../function");
|
|
|
28
28
|
const utils_1 = require("../../utils");
|
|
29
29
|
const decorators_1 = require("../../decorators");
|
|
30
30
|
const constant_1 = require("../../constant");
|
|
31
|
+
const i18n_1 = require("../../i18n");
|
|
31
32
|
let ListFunction = class ListFunction extends common_1.Command {
|
|
32
33
|
get options() {
|
|
33
34
|
return {
|
|
@@ -37,15 +38,15 @@ let ListFunction = class ListFunction extends common_1.Command {
|
|
|
37
38
|
options: [
|
|
38
39
|
{
|
|
39
40
|
flags: '-e, --envId <envId>',
|
|
40
|
-
desc: '环境 Id'
|
|
41
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
41
42
|
},
|
|
42
|
-
{ flags: '-l, --limit <limit>', desc: '返回数据长度,默认值为 20' },
|
|
43
|
+
{ flags: '-l, --limit <limit>', desc: (0, i18n_1.t)('返回数据长度,默认值为 20') },
|
|
43
44
|
{
|
|
44
45
|
flags: '-o, --offset <offset>',
|
|
45
|
-
desc: '数据偏移量,默认值为 0'
|
|
46
|
+
desc: (0, i18n_1.t)('数据偏移量,默认值为 0')
|
|
46
47
|
}
|
|
47
48
|
],
|
|
48
|
-
desc: '展示云函数列表'
|
|
49
|
+
desc: (0, i18n_1.t)('展示云函数列表')
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
execute(envId, options) {
|
|
@@ -55,16 +56,16 @@ let ListFunction = class ListFunction extends common_1.Command {
|
|
|
55
56
|
limit = Number(limit);
|
|
56
57
|
offset = Number(offset);
|
|
57
58
|
if (!Number.isInteger(limit) || !Number.isInteger(offset)) {
|
|
58
|
-
throw new error_1.CloudBaseError('limit 和 offset 必须为整数');
|
|
59
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为整数'));
|
|
59
60
|
}
|
|
60
61
|
if (limit < 0 || offset < 0) {
|
|
61
|
-
throw new error_1.CloudBaseError('limit 和 offset 必须为大于 0 的整数');
|
|
62
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为大于 0 的整数'));
|
|
62
63
|
}
|
|
63
64
|
const loading = (0, utils_1.loadingFactory)();
|
|
64
|
-
loading.start('数据加载中...');
|
|
65
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
65
66
|
const data = yield functionsService.listFunctions(Number(limit), Number(offset));
|
|
66
67
|
loading.stop();
|
|
67
|
-
const head = ['函数 Id', '函数名称', '运行时', '创建时间', '修改时间', '状态'];
|
|
68
|
+
const head = [(0, i18n_1.t)('函数 Id'), (0, i18n_1.t)('函数名称'), (0, i18n_1.t)('运行时'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('修改时间'), (0, i18n_1.t)('状态')];
|
|
68
69
|
const tableData = data.map((item) => [
|
|
69
70
|
item.FunctionId,
|
|
70
71
|
item.FunctionName,
|