@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
|
@@ -28,6 +28,7 @@ const run_1 = require("../../../run");
|
|
|
28
28
|
const utils_1 = require("../../../utils");
|
|
29
29
|
const decorators_1 = require("../../../decorators");
|
|
30
30
|
const common_2 = require("./common");
|
|
31
|
+
const i18n_1 = require("../../../i18n");
|
|
31
32
|
const modifyByFlow = (envId, serviceName, mode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
33
|
const versionFlowItems = [];
|
|
33
34
|
const loading = (0, utils_1.loadingFactory)();
|
|
@@ -41,8 +42,8 @@ const modifyByFlow = (envId, serviceName, mode) => __awaiter(void 0, void 0, voi
|
|
|
41
42
|
});
|
|
42
43
|
let sum = versionFlowItems.reduce((sum, item) => sum + item.FlowRatio, 0);
|
|
43
44
|
if (sum !== 100 && sum !== 0)
|
|
44
|
-
throw new error_1.CloudBaseError('流量配置的总和需要为 0 或 100');
|
|
45
|
-
loading.start('数据加载中...');
|
|
45
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('流量配置的总和需要为 0 或 100'));
|
|
46
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
46
47
|
const res = yield (0, run_1.modifyVersion)({
|
|
47
48
|
envId,
|
|
48
49
|
serverName: serviceName,
|
|
@@ -50,8 +51,8 @@ const modifyByFlow = (envId, serviceName, mode) => __awaiter(void 0, void 0, voi
|
|
|
50
51
|
versionFlowItems
|
|
51
52
|
});
|
|
52
53
|
if (res !== 'succ')
|
|
53
|
-
throw new error_1.CloudBaseError('分配失败');
|
|
54
|
-
loading.succeed('分配成功');
|
|
54
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('分配失败'));
|
|
55
|
+
loading.succeed((0, i18n_1.t)('分配成功'));
|
|
55
56
|
});
|
|
56
57
|
const modifyByURL = (envId, serviceName, mode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
58
|
const versionFlowItems = [];
|
|
@@ -80,7 +81,7 @@ const modifyByURL = (envId, serviceName, mode) => __awaiter(void 0, void 0, void
|
|
|
80
81
|
else {
|
|
81
82
|
versionFlowItems.find((item) => item.VersionName === mode.split('|')[2]).IsDefaultPriority = true;
|
|
82
83
|
}
|
|
83
|
-
loading.start('数据加载中...');
|
|
84
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
84
85
|
const res = yield (0, run_1.modifyVersion)({
|
|
85
86
|
envId,
|
|
86
87
|
serverName: serviceName,
|
|
@@ -88,25 +89,25 @@ const modifyByURL = (envId, serviceName, mode) => __awaiter(void 0, void 0, void
|
|
|
88
89
|
versionFlowItems
|
|
89
90
|
});
|
|
90
91
|
if (res !== 'succ')
|
|
91
|
-
throw new error_1.CloudBaseError('分配失败');
|
|
92
|
-
loading.succeed('分配成功');
|
|
92
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('分配失败'));
|
|
93
|
+
loading.succeed((0, i18n_1.t)('分配成功'));
|
|
93
94
|
});
|
|
94
95
|
let ModifyVersion = class ModifyVersion extends common_1.Command {
|
|
95
96
|
get options() {
|
|
96
97
|
return Object.assign(Object.assign({}, (0, common_2.versionCommonOptions)('modify')), { options: [
|
|
97
98
|
{
|
|
98
99
|
flags: '-e, --envId <envId>',
|
|
99
|
-
desc: '环境 Id'
|
|
100
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
100
101
|
},
|
|
101
102
|
{
|
|
102
103
|
flags: '-s, --serviceName <serviceName>',
|
|
103
|
-
desc: '托管服务 name'
|
|
104
|
+
desc: (0, i18n_1.t)('托管服务 name')
|
|
104
105
|
},
|
|
105
106
|
{
|
|
106
107
|
flags: '-t, --traffic <traffic>',
|
|
107
|
-
desc: '配置 type,按百分比分配即为FLOW|versionName1=a&...&versionName1=b,按URL分配则是URL|key1,value1,version1&...&key1,value1,version1|defaultVersion'
|
|
108
|
+
desc: (0, i18n_1.t)('配置 type,按百分比分配即为FLOW|versionName1=a&...&versionName1=b,按URL分配则是URL|key1,value1,version1&...&key1,value1,version1|defaultVersion')
|
|
108
109
|
}
|
|
109
|
-
], desc: '展示选择的云托管服务的版本列表' });
|
|
110
|
+
], desc: (0, i18n_1.t)('展示选择的云托管服务的版本列表') });
|
|
110
111
|
}
|
|
111
112
|
execute(envId, options) {
|
|
112
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -117,7 +118,7 @@ let ModifyVersion = class ModifyVersion extends common_1.Command {
|
|
|
117
118
|
}
|
|
118
119
|
let { serviceName = '', traffic: _traffic = 'FLOW' } = options;
|
|
119
120
|
if (serviceName.length === 0)
|
|
120
|
-
throw new error_1.CloudBaseError('请填入有效云托管服务名');
|
|
121
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请填入有效云托管服务名'));
|
|
121
122
|
if (_traffic.split('|')[0] === 'URL') {
|
|
122
123
|
modifyByURL(envId, serviceName, _traffic);
|
|
123
124
|
}
|
|
@@ -30,10 +30,11 @@ const run_1 = require("../../../run");
|
|
|
30
30
|
const utils_1 = require("../../../utils");
|
|
31
31
|
const decorators_1 = require("../../../decorators");
|
|
32
32
|
const common_2 = require("./common");
|
|
33
|
+
const i18n_1 = require("../../../i18n");
|
|
33
34
|
const uploadTypeMap = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
[(0, i18n_1.t)('本地代码')]: 'package',
|
|
36
|
+
[(0, i18n_1.t)('代码库拉取')]: 'repository',
|
|
37
|
+
[(0, i18n_1.t)('镜像拉取')]: 'image'
|
|
37
38
|
};
|
|
38
39
|
const memMap = {
|
|
39
40
|
0.25: [2, 8],
|
|
@@ -45,92 +46,94 @@ const memMap = {
|
|
|
45
46
|
16: [2, 4]
|
|
46
47
|
};
|
|
47
48
|
const describeVersion = (base) => {
|
|
48
|
-
console.log('目前的配置如下');
|
|
49
|
-
console.log(
|
|
50
|
-
console.log(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
console.log(
|
|
58
|
-
console.log(
|
|
59
|
-
console.log(
|
|
60
|
-
console.log(
|
|
49
|
+
console.log((0, i18n_1.t)('目前的配置如下'));
|
|
50
|
+
console.log((0, i18n_1.t)('镜像名 {{name}}', { name: base.ImageUrl.split(':')[1] }));
|
|
51
|
+
console.log((0, i18n_1.t)('上传方式 {{type}}', {
|
|
52
|
+
type: base.UploadType === 'image'
|
|
53
|
+
? (0, i18n_1.t)('镜像拉取')
|
|
54
|
+
: base.UploadType === 'package'
|
|
55
|
+
? (0, i18n_1.t)('本地代码上传')
|
|
56
|
+
: (0, i18n_1.t)('代码仓库拉取')
|
|
57
|
+
}));
|
|
58
|
+
console.log((0, i18n_1.t)('监听端口 {{port}}', { port: base.VersionPort }));
|
|
59
|
+
console.log((0, i18n_1.t)('扩缩容条件 {{type}}使用率 > {{threshold}}', { type: base.PolicyType, threshold: base.PolicyThreshold }));
|
|
60
|
+
console.log((0, i18n_1.t)('规格 cpu {{cpu}}核 mem {{mem}}G', { cpu: base.Cpu, mem: base.Mem }));
|
|
61
|
+
console.log((0, i18n_1.t)('InitialDelaySeconds {{seconds}}', { seconds: base.InitialDelaySeconds }));
|
|
62
|
+
console.log((0, i18n_1.t)('日志采集路径 {{path}}', { path: base.InitialDelaySeconds }));
|
|
63
|
+
console.log((0, i18n_1.t)('环境变量 {{vars}}', { vars: base.EnvParams }));
|
|
61
64
|
};
|
|
62
65
|
let UpdateVersion = class UpdateVersion extends common_1.Command {
|
|
63
66
|
get options() {
|
|
64
67
|
return Object.assign(Object.assign({}, (0, common_2.versionCommonOptions)('update')), { options: [
|
|
65
68
|
{
|
|
66
69
|
flags: '-e, --envId <envId>',
|
|
67
|
-
desc: '环境 Id'
|
|
70
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
68
71
|
},
|
|
69
72
|
{
|
|
70
73
|
flags: '-s, --serviceName <serviceName>',
|
|
71
|
-
desc: '托管服务 name'
|
|
74
|
+
desc: (0, i18n_1.t)('托管服务 name')
|
|
72
75
|
},
|
|
73
76
|
{
|
|
74
77
|
flags: '-v, --versionName <versionName>',
|
|
75
|
-
desc: '版本名称 Name'
|
|
78
|
+
desc: (0, i18n_1.t)('版本名称 Name')
|
|
76
79
|
},
|
|
77
80
|
{
|
|
78
81
|
flags: '-p, --path <path>',
|
|
79
|
-
desc: '本地代码路径,选择本地代码上传时使用'
|
|
82
|
+
desc: (0, i18n_1.t)('本地代码路径,选择本地代码上传时使用')
|
|
80
83
|
},
|
|
81
84
|
{
|
|
82
85
|
flags: '--repo <repo>',
|
|
83
|
-
desc: '仓库信息,形如 channel|fullName|branch,channel为github、gitlab或gitee,选择代码库拉取时使用'
|
|
86
|
+
desc: (0, i18n_1.t)('仓库信息,形如 channel|fullName|branch,channel为github、gitlab或gitee,选择代码库拉取时使用')
|
|
84
87
|
},
|
|
85
88
|
{
|
|
86
89
|
flags: '-i, --image <image>',
|
|
87
|
-
desc: '镜像url,选择镜像拉取时使用'
|
|
90
|
+
desc: (0, i18n_1.t)('镜像url,选择镜像拉取时使用')
|
|
88
91
|
},
|
|
89
92
|
{
|
|
90
93
|
flags: '--port <port>',
|
|
91
|
-
desc: '监听端口,默认为80'
|
|
94
|
+
desc: (0, i18n_1.t)('监听端口,默认为80')
|
|
92
95
|
},
|
|
93
96
|
{
|
|
94
97
|
flags: '-f, --flow <flow>',
|
|
95
|
-
desc: '流量策略(%),0或100,默认为0'
|
|
98
|
+
desc: (0, i18n_1.t)('流量策略(%),0或100,默认为0')
|
|
96
99
|
},
|
|
97
100
|
{
|
|
98
101
|
flags: '-m, --remark <remark>',
|
|
99
|
-
desc: '备注信息,默认为空'
|
|
102
|
+
desc: (0, i18n_1.t)('备注信息,默认为空')
|
|
100
103
|
},
|
|
101
104
|
{
|
|
102
105
|
flags: '-c, --cpu <cpu>',
|
|
103
|
-
desc: 'cpu规格(核数),默认为0.5'
|
|
106
|
+
desc: (0, i18n_1.t)('cpu规格(核数),默认为0.5')
|
|
104
107
|
},
|
|
105
108
|
{
|
|
106
109
|
flags: '--mem <mem>',
|
|
107
|
-
desc: '内存规格(G),默认为1'
|
|
110
|
+
desc: (0, i18n_1.t)('内存规格(G),默认为1')
|
|
108
111
|
},
|
|
109
112
|
{
|
|
110
113
|
flags: '--copy <copy>',
|
|
111
|
-
desc: '副本个数,格式为最小个数~最大个数,默认为0~50'
|
|
114
|
+
desc: (0, i18n_1.t)('副本个数,格式为最小个数~最大个数,默认为0~50')
|
|
112
115
|
},
|
|
113
116
|
{
|
|
114
117
|
flags: '--policy <policy>',
|
|
115
|
-
desc: '扩缩容条件,格式为条件类型|条件比例(%),cpu条件为cpu,内存为条件mem,默认为cpu|60'
|
|
118
|
+
desc: (0, i18n_1.t)('扩缩容条件,格式为条件类型|条件比例(%),cpu条件为cpu,内存为条件mem,默认为cpu|60')
|
|
116
119
|
},
|
|
117
120
|
{
|
|
118
121
|
flags: '--dockerFile <dockerFile>',
|
|
119
|
-
desc: 'dockerfile名称,非镜像拉取时使用,默认为Dockerfile'
|
|
122
|
+
desc: (0, i18n_1.t)('dockerfile名称,非镜像拉取时使用,默认为Dockerfile')
|
|
120
123
|
},
|
|
121
124
|
{
|
|
122
125
|
flags: '-l, --log <log>',
|
|
123
|
-
desc: '日志采集路径,默认为stdout'
|
|
126
|
+
desc: (0, i18n_1.t)('日志采集路径,默认为stdout')
|
|
124
127
|
},
|
|
125
128
|
{
|
|
126
129
|
flags: '-d, --delay <delay>',
|
|
127
|
-
desc: '初始延迟时间(秒),默认为2'
|
|
130
|
+
desc: (0, i18n_1.t)('初始延迟时间(秒),默认为2')
|
|
128
131
|
},
|
|
129
132
|
{
|
|
130
133
|
flags: '--env <env>',
|
|
131
|
-
desc: '环境变量,格式为xx=a&yy=b,默认为空'
|
|
134
|
+
desc: (0, i18n_1.t)('环境变量,格式为xx=a&yy=b,默认为空')
|
|
132
135
|
}
|
|
133
|
-
], desc: '创建云开发环境下云托管服务的版本' });
|
|
136
|
+
], desc: (0, i18n_1.t)('创建云开发环境下云托管服务的版本') });
|
|
134
137
|
}
|
|
135
138
|
execute(envId, options) {
|
|
136
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -141,7 +144,7 @@ let UpdateVersion = class UpdateVersion extends common_1.Command {
|
|
|
141
144
|
}
|
|
142
145
|
let { serviceName = '', versionName = '', path: _path = '', repo: _repo = '', image: _image = '', port: _port = '80', flow: _flow = '0', remark: _remark = '', cpu: _cpu = '0.5', mem: _mem = '1', copy: _copy = '0~50', policy: _policy = 'cpu|60', dockerfile: _dockerfile = 'Dockerfile', log: _log = 'stdout', delay: _delay = '2', env: _env = '' } = options;
|
|
143
146
|
if (!serviceName || !versionName) {
|
|
144
|
-
throw new error_1.CloudBaseError('必须输入 serviceName 和 versionName');
|
|
147
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('必须输入 serviceName 和 versionName'));
|
|
145
148
|
}
|
|
146
149
|
let path;
|
|
147
150
|
let repositoryType;
|
|
@@ -166,9 +169,9 @@ let UpdateVersion = class UpdateVersion extends common_1.Command {
|
|
|
166
169
|
if (_path) {
|
|
167
170
|
path = _path;
|
|
168
171
|
if ((0, fs_1.statSync)(path).isDirectory()) {
|
|
169
|
-
loading.start('正在压缩中');
|
|
172
|
+
loading.start((0, i18n_1.t)('正在压缩中'));
|
|
170
173
|
yield (0, toolbox_1.zipDir)(path, `./code${uid}.zip`);
|
|
171
|
-
loading.succeed('压缩完成');
|
|
174
|
+
loading.succeed((0, i18n_1.t)('压缩完成'));
|
|
172
175
|
path = `./code${uid}.zip`;
|
|
173
176
|
}
|
|
174
177
|
}
|
|
@@ -185,58 +188,58 @@ let UpdateVersion = class UpdateVersion extends common_1.Command {
|
|
|
185
188
|
};
|
|
186
189
|
}
|
|
187
190
|
else {
|
|
188
|
-
throw new error_1.CloudBaseError('请至少选择一个上传方式');
|
|
191
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请至少选择一个上传方式'));
|
|
189
192
|
}
|
|
190
193
|
containerPort = Number(_port);
|
|
191
194
|
if (isNaN(containerPort)) {
|
|
192
|
-
throw new error_1.CloudBaseError('请输入合法的端口号');
|
|
195
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的端口号'));
|
|
193
196
|
}
|
|
194
197
|
flowRatio = Number(_flow);
|
|
195
198
|
if (![100, 0].includes(flowRatio)) {
|
|
196
|
-
throw new error_1.CloudBaseError('请输入合法的流量策略');
|
|
199
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的流量策略'));
|
|
197
200
|
}
|
|
198
201
|
versionRemark = _remark;
|
|
199
202
|
cpu = Number(_cpu);
|
|
200
203
|
mem = Number(_mem);
|
|
201
204
|
if (isNaN(cpu) || isNaN(mem)) {
|
|
202
|
-
throw new error_1.CloudBaseError('请输入合法的cpu和内存规格');
|
|
205
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的cpu和内存规格'));
|
|
203
206
|
}
|
|
204
207
|
minNum = Number(_copy.split('~')[0]);
|
|
205
208
|
maxNum = Number(_copy.split('~')[1]);
|
|
206
209
|
if (isNaN(maxNum) || isNaN(minNum)) {
|
|
207
|
-
throw new error_1.CloudBaseError('请输入合法的副本个数');
|
|
210
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的副本个数'));
|
|
208
211
|
}
|
|
209
212
|
policyType = _policy.split('|')[0];
|
|
210
213
|
policyThreshold = Number(_policy.split('|')[1]);
|
|
211
214
|
if (!['cpu', 'mem'].includes(policyType) || isNaN(policyThreshold)) {
|
|
212
|
-
throw new error_1.CloudBaseError('请输入合法的扩缩容条件');
|
|
215
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的扩缩容条件'));
|
|
213
216
|
}
|
|
214
217
|
dockerfilePath = _dockerfile;
|
|
215
218
|
customLogs = _log;
|
|
216
219
|
initialDelaySeconds = Number(_delay);
|
|
217
220
|
if (isNaN(initialDelaySeconds)) {
|
|
218
|
-
throw new error_1.CloudBaseError('请输入合法的延迟时间');
|
|
221
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的延迟时间'));
|
|
219
222
|
}
|
|
220
223
|
let _envParams = {};
|
|
221
224
|
_env.split('&').forEach((item) => {
|
|
222
225
|
_envParams[item.split('=')[0]] = item.split('=')[1];
|
|
223
226
|
});
|
|
224
227
|
envParams = JSON.stringify(_envParams);
|
|
225
|
-
loading.start('加载中...');
|
|
228
|
+
loading.start((0, i18n_1.t)('加载中...'));
|
|
226
229
|
let res = '';
|
|
227
230
|
let runId = '';
|
|
228
231
|
if (_path) {
|
|
229
|
-
loading.start('正在上传中');
|
|
232
|
+
loading.start((0, i18n_1.t)('正在上传中'));
|
|
230
233
|
let { PackageName, PackageVersion, UploadHeaders, UploadUrl } = yield (0, run_1.createBuild)({
|
|
231
234
|
envId,
|
|
232
235
|
serviceName
|
|
233
236
|
});
|
|
234
237
|
yield (0, run_1.uploadZip)(path, UploadUrl, UploadHeaders[0]);
|
|
235
|
-
loading.succeed('上传成功');
|
|
238
|
+
loading.succeed((0, i18n_1.t)('上传成功'));
|
|
236
239
|
if (path === `./code${uid}.zip`) {
|
|
237
|
-
loading.start('删除本地压缩包');
|
|
240
|
+
loading.start((0, i18n_1.t)('删除本地压缩包'));
|
|
238
241
|
(0, fs_1.unlinkSync)(path);
|
|
239
|
-
loading.succeed('成功删除本地压缩包');
|
|
242
|
+
loading.succeed((0, i18n_1.t)('成功删除本地压缩包'));
|
|
240
243
|
}
|
|
241
244
|
let response = yield (0, run_1.updateVersion)({
|
|
242
245
|
envId,
|
|
@@ -315,24 +318,24 @@ let UpdateVersion = class UpdateVersion extends common_1.Command {
|
|
|
315
318
|
runId = response.RunId;
|
|
316
319
|
}
|
|
317
320
|
if (res !== 'succ')
|
|
318
|
-
throw new error_1.CloudBaseError('提交构建任务失败');
|
|
319
|
-
loading.start('正在部署中');
|
|
321
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('提交构建任务失败'));
|
|
322
|
+
loading.start((0, i18n_1.t)('正在部署中'));
|
|
320
323
|
while (true) {
|
|
321
324
|
let { Percent, Status } = yield (0, run_1.basicOperate)({ envId, runId });
|
|
322
325
|
if (Status === 'build_fail') {
|
|
323
326
|
let logs = yield (0, run_1.logCreate)({ envId, runId });
|
|
324
327
|
(0, fs_1.writeFileSync)(`./log${runId}`, logs.reduce((res, item) => res + item + '\n', ''));
|
|
325
|
-
throw new error_1.CloudBaseError(
|
|
328
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('构建失败,日志写入{{file}}中', { file: `./log${runId}` }));
|
|
326
329
|
}
|
|
327
330
|
else if (Status !== 'updating') {
|
|
328
331
|
break;
|
|
329
332
|
}
|
|
330
|
-
loading.start(
|
|
333
|
+
loading.start((0, i18n_1.t)('目前构建进度{{percent}}%', { percent: Percent }));
|
|
331
334
|
yield new Promise((resolve) => {
|
|
332
335
|
setTimeout((_) => resolve('again'), 2000);
|
|
333
336
|
});
|
|
334
337
|
}
|
|
335
|
-
loading.succeed('构建成功');
|
|
338
|
+
loading.succeed((0, i18n_1.t)('构建成功'));
|
|
336
339
|
});
|
|
337
340
|
}
|
|
338
341
|
};
|
|
@@ -40,6 +40,8 @@ const decorators_1 = require("../../decorators");
|
|
|
40
40
|
const common_1 = require("../common");
|
|
41
41
|
const constants_1 = require("../constants");
|
|
42
42
|
const utils_1 = require("../utils");
|
|
43
|
+
const utils_2 = require("../../utils");
|
|
44
|
+
const i18n_1 = require("../../i18n");
|
|
43
45
|
const { CloudAPI } = iac_core_1.CloudAPI;
|
|
44
46
|
let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
|
|
45
47
|
get options() {
|
|
@@ -49,20 +51,20 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
|
|
|
49
51
|
options: [
|
|
50
52
|
{
|
|
51
53
|
flags: '-e, --envId <envId>',
|
|
52
|
-
desc: '环境 Id'
|
|
54
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
53
55
|
},
|
|
54
56
|
{
|
|
55
57
|
flags: '-s, --serviceName <serviceName>',
|
|
56
|
-
desc: '服务名称'
|
|
58
|
+
desc: (0, i18n_1.t)('服务名称')
|
|
57
59
|
},
|
|
58
60
|
{
|
|
59
61
|
flags: '--source <source>',
|
|
60
|
-
desc: '目标函数文件所在目录路径。默认为当前路径'
|
|
62
|
+
desc: (0, i18n_1.t)('目标函数文件所在目录路径。默认为当前路径')
|
|
61
63
|
}
|
|
62
64
|
],
|
|
63
65
|
requiredEnvId: false,
|
|
64
66
|
autoRunLogin: true,
|
|
65
|
-
desc: '部署云函数 2.0 服务'
|
|
67
|
+
desc: (0, i18n_1.t)('部署云函数 2.0 服务')
|
|
66
68
|
};
|
|
67
69
|
}
|
|
68
70
|
execute(ctx, envId, log, options) {
|
|
@@ -73,14 +75,14 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
|
|
|
73
75
|
const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(targetDir));
|
|
74
76
|
if (envConfig.envId) {
|
|
75
77
|
envId = envConfig.envId;
|
|
76
|
-
log.info(
|
|
78
|
+
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
77
79
|
}
|
|
78
80
|
else {
|
|
79
81
|
envId = yield _selectEnv();
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
else {
|
|
83
|
-
log.info(
|
|
85
|
+
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
84
86
|
}
|
|
85
87
|
if (!serviceName) {
|
|
86
88
|
const { shortName } = yield (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
|
|
@@ -90,7 +92,7 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
|
|
|
90
92
|
{
|
|
91
93
|
type: 'confirm',
|
|
92
94
|
name: 'confirm',
|
|
93
|
-
message:
|
|
95
|
+
message: (0, i18n_1.t)('即将开始部署,是否确认继续?'),
|
|
94
96
|
default: true
|
|
95
97
|
}
|
|
96
98
|
]);
|
|
@@ -117,7 +119,7 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
|
|
|
117
119
|
});
|
|
118
120
|
const { envId: _envId, name, resourceType: _resourceType } = res === null || res === void 0 ? void 0 : res.data;
|
|
119
121
|
(0, utils_1.trackCallback)({
|
|
120
|
-
details:
|
|
122
|
+
details: (0, i18n_1.t)('请打开链接查看部署状态: {{url}}', { url: `${utils_2.EUrl.DevPlatform}?envId=${_envId}#/platform-run/service/detail?serverName=${name}&tabId=deploy&envId=${_envId}` })
|
|
121
123
|
}, log);
|
|
122
124
|
}
|
|
123
125
|
catch (e) {
|
|
@@ -127,7 +129,7 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
|
|
|
127
129
|
{
|
|
128
130
|
type: 'confirm',
|
|
129
131
|
name: 'confirm',
|
|
130
|
-
message:
|
|
132
|
+
message: (0, i18n_1.t)('平台当前有部署发布任务正在运行中。确认继续部署,正在执行的部署任务将被取消,并立即部署最新的代码'),
|
|
131
133
|
default: true
|
|
132
134
|
}
|
|
133
135
|
])
|
|
@@ -192,20 +194,20 @@ let RunfDownloadCommand = class RunfDownloadCommand extends common_1.Command {
|
|
|
192
194
|
options: [
|
|
193
195
|
{
|
|
194
196
|
flags: '-e, --envId <envId>',
|
|
195
|
-
desc: '环境 Id'
|
|
197
|
+
desc: (0, i18n_1.t)('环境 Id')
|
|
196
198
|
},
|
|
197
199
|
{
|
|
198
200
|
flags: '-s, --serviceName <serviceName>',
|
|
199
|
-
desc: '服务名称'
|
|
201
|
+
desc: (0, i18n_1.t)('服务名称')
|
|
200
202
|
},
|
|
201
203
|
{
|
|
202
204
|
flags: '--source <source>',
|
|
203
|
-
desc: '目标函数文件所在目录路径。默认为当前路径'
|
|
205
|
+
desc: (0, i18n_1.t)('目标函数文件所在目录路径。默认为当前路径')
|
|
204
206
|
}
|
|
205
207
|
],
|
|
206
208
|
requiredEnvId: false,
|
|
207
209
|
autoRunLogin: true,
|
|
208
|
-
desc: '下载云函数 2.0 服务代码'
|
|
210
|
+
desc: (0, i18n_1.t)('下载云函数 2.0 服务代码')
|
|
209
211
|
};
|
|
210
212
|
}
|
|
211
213
|
execute(ctx, envId, log, options) {
|
|
@@ -217,7 +219,7 @@ let RunfDownloadCommand = class RunfDownloadCommand extends common_1.Command {
|
|
|
217
219
|
envId = envConfig.envId || (yield _selectEnv());
|
|
218
220
|
}
|
|
219
221
|
else {
|
|
220
|
-
log.info(
|
|
222
|
+
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
221
223
|
}
|
|
222
224
|
if (!serviceName) {
|
|
223
225
|
const { shortName } = yield (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
|
|
@@ -232,7 +234,7 @@ let RunfDownloadCommand = class RunfDownloadCommand extends common_1.Command {
|
|
|
232
234
|
{
|
|
233
235
|
type: 'confirm',
|
|
234
236
|
name: 'confirm',
|
|
235
|
-
message:
|
|
237
|
+
message: (0, i18n_1.t)('下载将覆盖 {{targetDir}} 目录下的代码,是否继续?', { targetDir }),
|
|
236
238
|
default: true
|
|
237
239
|
}
|
|
238
240
|
]);
|
|
@@ -288,65 +290,65 @@ let RunfRunCommand = class RunfRunCommand extends common_1.Command {
|
|
|
288
290
|
options: [
|
|
289
291
|
{
|
|
290
292
|
flags: '--source <source>',
|
|
291
|
-
desc: `目标函数文件所在目录路径,默认为当前路径
|
|
292
|
-
`
|
|
293
|
+
desc: (0, i18n_1.t)(`目标函数文件所在目录路径,默认为当前路径
|
|
294
|
+
`)
|
|
293
295
|
},
|
|
294
296
|
{
|
|
295
297
|
flags: '--port <port>',
|
|
296
|
-
desc: `监听的端口,默认为 3000
|
|
297
|
-
`
|
|
298
|
+
desc: (0, i18n_1.t)(`监听的端口,默认为 3000
|
|
299
|
+
`)
|
|
298
300
|
},
|
|
299
301
|
{
|
|
300
302
|
flags: '-w, --watch',
|
|
301
|
-
desc: `是否启用热重启模式,如启用,将会在文件变更时自动重启服务,默认为 false
|
|
302
|
-
`
|
|
303
|
+
desc: (0, i18n_1.t)(`是否启用热重启模式,如启用,将会在文件变更时自动重启服务,默认为 false
|
|
304
|
+
`)
|
|
303
305
|
},
|
|
304
306
|
{
|
|
305
307
|
flags: '--dry-run',
|
|
306
|
-
desc: `是否不启动服务,只验证代码可以正常加载,默认为 false
|
|
307
|
-
`
|
|
308
|
+
desc: (0, i18n_1.t)(`是否不启动服务,只验证代码可以正常加载,默认为 false
|
|
309
|
+
`)
|
|
308
310
|
},
|
|
309
311
|
{
|
|
310
312
|
flags: '--logDirname <logDirname>',
|
|
311
|
-
desc: `日志文件目录,默认为 ./logs
|
|
312
|
-
`
|
|
313
|
+
desc: (0, i18n_1.t)(`日志文件目录,默认为 ./logs
|
|
314
|
+
`)
|
|
313
315
|
},
|
|
314
316
|
{
|
|
315
317
|
flags: '--functionsConfigFile <functionsConfigFile>',
|
|
316
|
-
desc: `多函数定义配置文件,默认为 ./cloudbase-functions.json。
|
|
318
|
+
desc: (0, i18n_1.t)(`多函数定义配置文件,默认为 ./cloudbase-functions.json。
|
|
317
319
|
环境变量: FUNCTIONS_CONFIG_FILE
|
|
318
|
-
`
|
|
320
|
+
`)
|
|
319
321
|
},
|
|
320
322
|
{
|
|
321
323
|
flags: '--loadAllFunctions',
|
|
322
|
-
desc: `是否加载 "functionsRoot" 目录中的所有函数。默认为 false
|
|
323
|
-
`
|
|
324
|
+
desc: (0, i18n_1.t)(`是否加载 "functionsRoot" 目录中的所有函数。默认为 false
|
|
325
|
+
`)
|
|
324
326
|
},
|
|
325
327
|
{
|
|
326
328
|
flags: '--enableCors <enableCors>',
|
|
327
|
-
desc: `为已配置的源启用跨域资源共享(CORS),默认值为 false
|
|
329
|
+
desc: (0, i18n_1.t)(`为已配置的源启用跨域资源共享(CORS),默认值为 false
|
|
328
330
|
环境变量: ENABLE_CORS
|
|
329
|
-
`
|
|
331
|
+
`)
|
|
330
332
|
},
|
|
331
333
|
{
|
|
332
334
|
flags: '--allowedOrigins <allowedOrigins>',
|
|
333
|
-
desc: `设置 CORS 允许的源。默认允许 localhost 和 127.0.0.1。
|
|
335
|
+
desc: (0, i18n_1.t)(`设置 CORS 允许的源。默认允许 localhost 和 127.0.0.1。
|
|
334
336
|
支持通配符源,例如 ['.example.com']。
|
|
335
337
|
多个源应该用逗号分隔。
|
|
336
338
|
示例:--allowedOrigins .example.com,www.another.com
|
|
337
339
|
环境变量:ALLOWED_ORIGINSS
|
|
338
|
-
`
|
|
340
|
+
`)
|
|
339
341
|
},
|
|
340
342
|
{
|
|
341
343
|
flags: '--extendedContext <extendedContext>',
|
|
342
|
-
desc: `用于解析 context.extendedContext 的值。""表示该功能已关闭。默认值为 null
|
|
344
|
+
desc: (0, i18n_1.t)(`用于解析 context.extendedContext 的值。""表示该功能已关闭。默认值为 null
|
|
343
345
|
示例:--extendedContext '{"a":1,"b":2}'
|
|
344
346
|
环境变量:EXTENDED_CONTEXT
|
|
345
|
-
`
|
|
347
|
+
`)
|
|
346
348
|
}
|
|
347
349
|
],
|
|
348
350
|
requiredEnvId: false,
|
|
349
|
-
desc: '本地运行云函数 2.0 代码'
|
|
351
|
+
desc: (0, i18n_1.t)('本地运行云函数 2.0 代码')
|
|
350
352
|
};
|
|
351
353
|
}
|
|
352
354
|
execute(logger, ctx, options) {
|
|
@@ -368,7 +370,7 @@ let RunfRunCommand = class RunfRunCommand extends common_1.Command {
|
|
|
368
370
|
if (watchFlag.some((flag) => args.includes(flag))) {
|
|
369
371
|
const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
|
|
370
372
|
if (!nodemon) {
|
|
371
|
-
throw new Error('缺少开发依赖 nodemon,独立发行版已不内置。请在本地开发环境中安装再使用该命令。');
|
|
373
|
+
throw new Error((0, i18n_1.t)('缺少开发依赖 nodemon,独立发行版已不内置。请在本地开发环境中安装再使用该命令。'));
|
|
372
374
|
}
|
|
373
375
|
nodemon({
|
|
374
376
|
script: '',
|
|
@@ -396,7 +398,7 @@ let RunfRunCommand = class RunfRunCommand extends common_1.Command {
|
|
|
396
398
|
logger.info(`[nodemon ${e.type}] ${e.message}`);
|
|
397
399
|
})
|
|
398
400
|
.on('crash', () => {
|
|
399
|
-
logger.error(
|
|
401
|
+
logger.error('Server crashed.');
|
|
400
402
|
process.exit(1);
|
|
401
403
|
})
|
|
402
404
|
.on('exit', (e) => {
|
|
@@ -433,7 +435,7 @@ function _inputServiceName(defaultVal = '') {
|
|
|
433
435
|
{
|
|
434
436
|
type: 'input',
|
|
435
437
|
name: 'serviceName',
|
|
436
|
-
message: '请输入服务名称',
|
|
438
|
+
message: (0, i18n_1.t)('请输入服务名称'),
|
|
437
439
|
default: defaultVal,
|
|
438
440
|
validate: (val) => {
|
|
439
441
|
const isValid = !val.startsWith('lcap') &&
|
|
@@ -441,7 +443,7 @@ function _inputServiceName(defaultVal = '') {
|
|
|
441
443
|
/^[A-Za-z][\w-_]{0,43}[A-Za-z0-9]$/.test(val);
|
|
442
444
|
return isValid
|
|
443
445
|
? true
|
|
444
|
-
: '支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符';
|
|
446
|
+
: (0, i18n_1.t)('支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符');
|
|
445
447
|
}
|
|
446
448
|
}
|
|
447
449
|
];
|