@cloudbase/cli 2.9.8 → 2.9.10-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cloudbase.js +2 -1
- package/bin/tcb.js +35 -28
- package/cloudbase-cli-2.7.8.tgz +0 -0
- package/lib/auth/login.js +21 -13
- package/lib/commands/account/login.js +43 -42
- package/lib/commands/account/logout.js +3 -2
- package/lib/commands/ai/index.js +13 -12
- package/lib/commands/cloudfunction/base.js +24 -26
- package/lib/commands/cloudrun/base.js +87 -96
- package/lib/commands/common.js +11 -10
- package/lib/commands/config/delete.js +72 -0
- package/lib/commands/config/get.js +69 -0
- package/lib/commands/config/index.js +21 -0
- package/lib/commands/config/interface.js +24 -0
- package/lib/commands/config/list.js +72 -0
- package/lib/commands/config/set.js +89 -0
- package/lib/commands/db/base.js +33 -32
- package/lib/commands/env/base.js +12 -11
- package/lib/commands/env/domain.js +24 -23
- package/lib/commands/env/login.js +31 -30
- package/lib/commands/fun/base.js +37 -36
- package/lib/commands/functions/alias/getRoute.js +5 -4
- package/lib/commands/functions/alias/setRoute.js +7 -6
- package/lib/commands/functions/code-download.js +15 -11
- package/lib/commands/functions/code-update.js +8 -7
- package/lib/commands/functions/concurrency/delete.js +5 -4
- package/lib/commands/functions/concurrency/list.js +6 -5
- package/lib/commands/functions/concurrency/set.js +5 -4
- package/lib/commands/functions/config-update.js +8 -7
- package/lib/commands/functions/copy.js +7 -6
- package/lib/commands/functions/delete.js +8 -7
- package/lib/commands/functions/deploy.js +35 -34
- package/lib/commands/functions/detail.js +32 -31
- package/lib/commands/functions/invoke.js +16 -15
- package/lib/commands/functions/layer/bind.js +26 -25
- package/lib/commands/functions/layer/common.js +2 -1
- package/lib/commands/functions/layer/create.js +7 -6
- package/lib/commands/functions/layer/delete.js +9 -8
- package/lib/commands/functions/layer/download.js +10 -9
- package/lib/commands/functions/layer/list.js +10 -9
- package/lib/commands/functions/layer/sort.js +9 -8
- package/lib/commands/functions/list.js +9 -8
- package/lib/commands/functions/log.js +28 -27
- package/lib/commands/functions/run.js +21 -20
- package/lib/commands/functions/trigger-create.js +9 -8
- package/lib/commands/functions/trigger-delete.js +10 -9
- package/lib/commands/functions/version/list.js +9 -8
- package/lib/commands/functions/version/publish.js +5 -4
- package/lib/commands/gateway/create.js +14 -13
- package/lib/commands/gateway/delete.js +10 -9
- package/lib/commands/gateway/domain.js +25 -24
- package/lib/commands/gateway/list.js +11 -10
- package/lib/commands/gateway/switch.js +22 -19
- package/lib/commands/helpers/init.js +38 -37
- package/lib/commands/helpers/new.js +7 -6
- package/lib/commands/helpers/open.js +7 -6
- package/lib/commands/hosting/hosting.js +45 -44
- package/lib/commands/index.js +1 -0
- package/lib/commands/pull/pull.js +12 -11
- package/lib/commands/run/delete.js +16 -15
- package/lib/commands/run/image/common.js +2 -1
- package/lib/commands/run/image/delete.js +10 -9
- package/lib/commands/run/image/download.js +8 -7
- package/lib/commands/run/image/list.js +11 -10
- package/lib/commands/run/image/upload.js +9 -8
- package/lib/commands/run/list.js +10 -9
- package/lib/commands/run/service/config.js +13 -12
- package/lib/commands/run/service/deploy.js +24 -23
- package/lib/commands/run/service/list.js +10 -9
- package/lib/commands/run/service/update.js +22 -21
- package/lib/commands/run/standalonegateway/common.js +2 -1
- package/lib/commands/run/standalonegateway/create.js +14 -13
- package/lib/commands/run/standalonegateway/destroy.js +9 -8
- package/lib/commands/run/standalonegateway/list.js +7 -6
- package/lib/commands/run/standalonegateway/package.js +7 -6
- package/lib/commands/run/standalonegateway/turn.js +10 -9
- package/lib/commands/run/version/common.js +2 -1
- package/lib/commands/run/version/create.js +41 -40
- package/lib/commands/run/version/delete.js +10 -9
- package/lib/commands/run/version/list.js +13 -12
- package/lib/commands/run/version/modify.js +13 -12
- package/lib/commands/run/version/update.js +57 -54
- package/lib/commands/runf/base.js +42 -40
- package/lib/commands/self-update.js +11 -10
- package/lib/commands/smart.js +5 -4
- package/lib/commands/storage/storage.js +61 -56
- package/lib/commands/third/thirdAttach.js +6 -5
- package/lib/commands/utils.js +8 -5
- package/lib/constant.js +18 -17
- package/lib/decorators/deprecate.js +2 -1
- package/lib/function/alias.js +3 -2
- package/lib/function/base.js +9 -8
- package/lib/function/concurrency.js +4 -3
- package/lib/function/create.js +5 -4
- package/lib/function/delete.js +2 -1
- package/lib/function/layer/attach.js +2 -1
- package/lib/function/layer/create.js +2 -1
- package/lib/function/layer/download.js +2 -1
- package/lib/function/trigger.js +6 -5
- package/lib/function/update.js +3 -2
- package/lib/function/version.js +3 -2
- package/lib/help.js +22 -20
- package/lib/hosting.js +18 -17
- package/lib/i18n/index.js +81 -0
- package/lib/run/service/common.js +14 -13
- package/lib/run/service/config.js +4 -3
- package/lib/run/service/deployPackage.js +6 -5
- package/lib/run/service/showLogs.js +3 -2
- package/lib/run/service/update.js +7 -6
- package/lib/run/standalonegateway/list.js +5 -1
- package/lib/storage.js +2 -1
- package/lib/utils/ai/banner.js +12 -11
- package/lib/utils/ai/claudeWindows.js +5 -3
- package/lib/utils/ai/config.js +3 -2
- package/lib/utils/ai/const.js +4 -3
- package/lib/utils/ai/env.js +3 -2
- package/lib/utils/ai/envLocalManager.js +6 -5
- package/lib/utils/ai/nodeVersion.js +5 -1
- package/lib/utils/ai/router.js +129 -106
- package/lib/utils/ai/setup.js +95 -91
- package/lib/utils/checkTcbrEnv.js +22 -21
- package/lib/utils/cli-table.js +2 -1
- package/lib/utils/commonParamsCheck.js +4 -3
- package/lib/utils/debug-logger.js +2 -1
- package/lib/utils/dts.js +4 -3
- package/lib/utils/env.js +23 -21
- package/lib/utils/fs/index.js +5 -4
- package/lib/utils/function-packer.js +3 -2
- package/lib/utils/index.js +1 -0
- package/lib/utils/mcp-config-modifier.js +18 -17
- package/lib/utils/net/cloud-api-request.js +2 -1
- package/lib/utils/net/credential.js +2 -1
- package/lib/utils/net/http-request.js +2 -1
- package/lib/utils/progress-bar.js +2 -1
- package/lib/utils/prompt/select.js +8 -6
- package/lib/utils/store/auth.js +3 -2
- package/lib/utils/store/config.js +49 -0
- package/lib/utils/store/db.js +5 -0
- package/lib/utils/store/index.js +1 -1
- package/lib/utils/tcbrApi/callTcbrApi.js +2 -1
- package/lib/utils/template-manager.js +37 -36
- package/lib/utils/template.js +10 -9
- package/lib/utils/tools/common.js +3 -2
- package/lib/utils/url.js +19 -0
- package/lib/utils/validator.js +12 -4
- package/locales/README.md +160 -0
- package/locales/i18next-scanner.config.js +206 -0
- package/locales/langs/en.json +1235 -0
- package/locales/langs/zh.json +1235 -0
- package/locales/mapping.json +1235 -0
- package/package.json +10 -3
- package/types/commands/config/delete.d.ts +13 -0
- package/types/commands/config/get.d.ts +13 -0
- package/types/commands/config/index.d.ts +5 -0
- package/types/commands/config/interface.d.ts +17 -0
- package/types/commands/config/list.d.ts +13 -0
- package/types/commands/config/set.d.ts +13 -0
- package/types/commands/index.d.ts +1 -0
- package/types/i18n/index.d.ts +3 -0
- package/types/utils/ai/const.d.ts +1 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/store/config.d.ts +8 -0
- package/types/utils/store/db.d.ts +2 -0
- package/types/utils/store/index.d.ts +1 -1
- package/types/utils/url.d.ts +18 -0
- package/dist/standalone/ccr.js +0 -78668
- package/dist/standalone/cli.js +0 -626422
package/lib/utils/cli-table.js
CHANGED
|
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.printHorizontalTable = void 0;
|
|
7
7
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
8
|
+
const i18n_1 = require("../i18n");
|
|
8
9
|
function printHorizontalTable(head, data = [], options) {
|
|
9
10
|
if (!(data === null || data === void 0 ? void 0 : data.length)) {
|
|
10
|
-
console.log('列表数据为空');
|
|
11
|
+
console.log((0, i18n_1.t)('列表数据为空'));
|
|
11
12
|
}
|
|
12
13
|
const table = new cli_table3_1.default(Object.assign({ head, style: { head: ['yellow'] }, colAligns: new Array(head.length).fill('center') }, options));
|
|
13
14
|
data.forEach((item) => {
|
|
@@ -4,6 +4,7 @@ exports.parseInputParam = exports.parseOptionalParams = void 0;
|
|
|
4
4
|
const error_1 = require("../error");
|
|
5
5
|
const run_1 = require("../run");
|
|
6
6
|
const validator_1 = require("./validator");
|
|
7
|
+
const i18n_1 = require("../i18n");
|
|
7
8
|
function parseOptionalParams(options) {
|
|
8
9
|
let cpuConverted;
|
|
9
10
|
let memConverted;
|
|
@@ -15,18 +16,18 @@ function parseOptionalParams(options) {
|
|
|
15
16
|
if (options.maxNum) {
|
|
16
17
|
maxNumConverted = (0, run_1.convertNumber)(options.maxNum);
|
|
17
18
|
if (maxNumConverted < 0 || maxNumConverted > 50) {
|
|
18
|
-
throw new error_1.CloudBaseError('最大副本数必须大于等于0且小于等于50');
|
|
19
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('最大副本数必须大于等于0且小于等于50'));
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
let minNumConverted;
|
|
22
23
|
if (options.minNum) {
|
|
23
24
|
minNumConverted = (0, run_1.convertNumber)(options.minNum);
|
|
24
25
|
if (minNumConverted < 0 || minNumConverted > 50) {
|
|
25
|
-
throw new error_1.CloudBaseError('最小副本数必须大于等于0且小于等于50');
|
|
26
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('最小副本数必须大于等于0且小于等于50'));
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
if (minNumConverted > maxNumConverted) {
|
|
29
|
-
throw new error_1.CloudBaseError('最小副本数不能大于最大副本数');
|
|
30
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('最小副本数不能大于最大副本数'));
|
|
30
31
|
}
|
|
31
32
|
return {
|
|
32
33
|
cpuConverted,
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.debugLogger = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const i18n_1 = require("../i18n");
|
|
9
10
|
function debugLogger(req, resp, startTime, endTime, writeToLocal = true) {
|
|
10
11
|
if (process.env.NODE_ENV !== 'DEBUG') {
|
|
11
12
|
return;
|
|
@@ -22,7 +23,7 @@ function debugLogger(req, resp, startTime, endTime, writeToLocal = true) {
|
|
|
22
23
|
const logContent = `\n{start:${startTimeFormatted}, req: ${JSON.stringify(req)}, end:${endTimeFormatted}, resp: ${JSON.stringify(resp)}, cost: ${cost}}`;
|
|
23
24
|
fs_1.default.appendFile(filePath, logContent, (err) => {
|
|
24
25
|
if (err) {
|
|
25
|
-
console.error(chalk_1.default.red(
|
|
26
|
+
console.error(chalk_1.default.red((0, i18n_1.t)('\n写入日志失败:{{error}}', { error: JSON.stringify(err) })));
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
29
|
}
|
package/lib/utils/dts.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.generateDataModelDTS = void 0;
|
|
|
13
13
|
const json_schema_to_typescript_1 = require("json-schema-to-typescript");
|
|
14
14
|
const lodash_1 = require("lodash");
|
|
15
15
|
const tools_1 = require("./tools");
|
|
16
|
+
const i18n_1 = require("../i18n");
|
|
16
17
|
function generateDataModelDTS(dataModelList) {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
const dtsList = yield Promise.all(dataModelList.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -32,7 +33,7 @@ ${dtsList
|
|
|
32
33
|
.map((item) => {
|
|
33
34
|
return `
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
+
* ${(0, i18n_1.t)('数据模型')}:${item.title}
|
|
36
37
|
*/
|
|
37
38
|
${_toValidFieldName(item.name)}: DataModelMethods<${getModelInterfaceName(item.name)}>;`;
|
|
38
39
|
})
|
|
@@ -63,7 +64,7 @@ declare global {
|
|
|
63
64
|
if (['related', 'father-son'].includes(field.format)) {
|
|
64
65
|
schema.properties[`@${key}`] = {
|
|
65
66
|
type: 'object',
|
|
66
|
-
description:
|
|
67
|
+
description: (0, i18n_1.t)('关联{{title}}对象', { title: field.title }),
|
|
67
68
|
properties: {
|
|
68
69
|
v1: {
|
|
69
70
|
type: 'object',
|
|
@@ -125,7 +126,7 @@ declare global {
|
|
|
125
126
|
return dts;
|
|
126
127
|
}
|
|
127
128
|
catch (e) {
|
|
128
|
-
console.error('_compile error:', e);
|
|
129
|
+
console.error((0, i18n_1.t)('_compile error: {{error}}', { error: e }));
|
|
129
130
|
return '';
|
|
130
131
|
}
|
|
131
132
|
});
|
package/lib/utils/env.js
CHANGED
|
@@ -22,10 +22,12 @@ const constant_1 = require("../constant");
|
|
|
22
22
|
const net_1 = require("./net");
|
|
23
23
|
const output_1 = require("./output");
|
|
24
24
|
const log_1 = require("./log");
|
|
25
|
+
const url_1 = require("./url");
|
|
26
|
+
const i18n_1 = require("../i18n");
|
|
25
27
|
const tcbService = net_1.CloudApiService.getInstance('tcb');
|
|
26
|
-
const ENV_INIT_TIP = '环境初始化中,预计需要三分钟';
|
|
28
|
+
const ENV_INIT_TIP = (0, i18n_1.t)('环境初始化中,预计需要三分钟');
|
|
27
29
|
const CREATE_ENV = 'CREATE';
|
|
28
|
-
const consoleUrl =
|
|
30
|
+
const consoleUrl = `${url_1.EUrl.TcbConsole}/env/index?action=CreateEnv&from=cli`;
|
|
29
31
|
function getSelectedEnv(inputEnvId) {
|
|
30
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
33
|
const isInitNow = yield checkTcbService();
|
|
@@ -42,25 +44,25 @@ function getSelectedEnv(inputEnvId) {
|
|
|
42
44
|
}), 2000);
|
|
43
45
|
});
|
|
44
46
|
}, {
|
|
45
|
-
startTip: '获取环境列表中'
|
|
47
|
+
startTip: (0, i18n_1.t)('获取环境列表中')
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
50
|
else {
|
|
49
51
|
envData = yield (0, output_1.execWithLoading)(() => (0, env_1.listEnvs)(), {
|
|
50
|
-
startTip: '获取环境列表中'
|
|
52
|
+
startTip: (0, i18n_1.t)('获取环境列表中')
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
envData = envData || [];
|
|
54
56
|
if ((envData === null || envData === void 0 ? void 0 : envData.length) && inputEnvId) {
|
|
55
57
|
const inputEnvIdExist = envData.find((_) => _.EnvId === inputEnvId);
|
|
56
58
|
if (!inputEnvIdExist) {
|
|
57
|
-
throw new error_1.CloudBaseError(
|
|
59
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('你指定的环境 Id {{envId}} 不存在,请指定正确的环境 Id!', { envId: inputEnvId }));
|
|
58
60
|
}
|
|
59
61
|
return inputEnvId;
|
|
60
62
|
}
|
|
61
63
|
const envs = envData
|
|
62
64
|
.map((item) => {
|
|
63
|
-
let name = `${item.Alias} - [${item.EnvId}:${item.PackageName || '按量计费'}]`;
|
|
65
|
+
let name = `${item.Alias} - [${item.EnvId}:${item.PackageName || (0, i18n_1.t)('按量计费')}]`;
|
|
64
66
|
if (item.Status !== "NORMAL") {
|
|
65
67
|
name += `(${constant_1.STATUS_TEXT[item.Status]})`;
|
|
66
68
|
}
|
|
@@ -73,7 +75,7 @@ function getSelectedEnv(inputEnvId) {
|
|
|
73
75
|
const choices = [
|
|
74
76
|
...envs,
|
|
75
77
|
{
|
|
76
|
-
name: envData.length ? '创建新环境' : '无可用环境,创建新环境',
|
|
78
|
+
name: envData.length ? (0, i18n_1.t)('创建新环境') : (0, i18n_1.t)('无可用环境,创建新环境'),
|
|
77
79
|
value: CREATE_ENV
|
|
78
80
|
}
|
|
79
81
|
];
|
|
@@ -81,18 +83,18 @@ function getSelectedEnv(inputEnvId) {
|
|
|
81
83
|
choices,
|
|
82
84
|
type: 'select',
|
|
83
85
|
name: 'env',
|
|
84
|
-
message: '请选择关联环境',
|
|
86
|
+
message: (0, i18n_1.t)('请选择关联环境'),
|
|
85
87
|
result(choice) {
|
|
86
88
|
return this.map(choice)[choice];
|
|
87
89
|
}
|
|
88
90
|
});
|
|
89
91
|
if (env === CREATE_ENV) {
|
|
90
|
-
log_1.logger.success('已打开控制台,请前往控制台创建环境');
|
|
92
|
+
log_1.logger.success((0, i18n_1.t)('已打开控制台,请前往控制台创建环境'));
|
|
91
93
|
const { envId } = yield (0, toolbox_1.getDataFromWeb)((port) => `${consoleUrl}&port=${port}`, 'getData');
|
|
92
94
|
if (!envId) {
|
|
93
|
-
throw new error_1.CloudBaseError('接收环境 Id 信息失败,请重新运行 init 命令!');
|
|
95
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('接收环境 Id 信息失败,请重新运行 init 命令!'));
|
|
94
96
|
}
|
|
95
|
-
log_1.logger.success(
|
|
97
|
+
log_1.logger.success((0, i18n_1.t)('创建环境成功,环境 Id: {{envId}}', { envId }));
|
|
96
98
|
env = envId;
|
|
97
99
|
}
|
|
98
100
|
yield checkEnvStatus(env);
|
|
@@ -105,17 +107,17 @@ function getSelectRegion() {
|
|
|
105
107
|
const { region } = yield (0, enquirer_1.prompt)({
|
|
106
108
|
choices: [
|
|
107
109
|
{
|
|
108
|
-
name: '上海',
|
|
110
|
+
name: (0, i18n_1.t)('上海'),
|
|
109
111
|
value: 'ap-shanghai'
|
|
110
112
|
},
|
|
111
113
|
{
|
|
112
|
-
name: '广州',
|
|
114
|
+
name: (0, i18n_1.t)('广州'),
|
|
113
115
|
value: 'ap-guangzhou'
|
|
114
116
|
}
|
|
115
117
|
],
|
|
116
118
|
type: 'select',
|
|
117
119
|
name: 'region',
|
|
118
|
-
message: '请选择环境所在地域',
|
|
120
|
+
message: (0, i18n_1.t)('请选择环境所在地域'),
|
|
119
121
|
result(choice) {
|
|
120
122
|
return this.map(choice)[choice];
|
|
121
123
|
}
|
|
@@ -141,17 +143,17 @@ function checkTcbService() {
|
|
|
141
143
|
const { jump } = yield (0, enquirer_1.prompt)({
|
|
142
144
|
type: 'confirm',
|
|
143
145
|
name: 'jump',
|
|
144
|
-
message: '你还没有开通云开发服务,是否跳转到控制台开通云开发服务?(取消将无法继续操作)',
|
|
146
|
+
message: (0, i18n_1.t)('你还没有开通云开发服务,是否跳转到控制台开通云开发服务?(取消将无法继续操作)'),
|
|
145
147
|
initial: true
|
|
146
148
|
});
|
|
147
149
|
if (!jump) {
|
|
148
|
-
throw new error_1.CloudBaseError('init 操作终止,请开通云开发服务后再进行操作!');
|
|
150
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('init 操作终止,请开通云开发服务后再进行操作!'));
|
|
149
151
|
}
|
|
150
152
|
(0, open_1.default)(consoleUrl);
|
|
151
|
-
log_1.logger.success('已打开云开发控制台,请登录并在云开发控制台中开通服务!');
|
|
153
|
+
log_1.logger.success((0, i18n_1.t)('已打开云开发控制台,请登录并在云开发控制台中开通服务!'));
|
|
152
154
|
yield (0, output_1.execWithLoading)(() => waitForServiceEnable(), {
|
|
153
|
-
startTip: '等待云开发服务开通中',
|
|
154
|
-
successTip: '云开发服务开通成功!'
|
|
155
|
+
startTip: (0, i18n_1.t)('等待云开发服务开通中'),
|
|
156
|
+
successTip: (0, i18n_1.t)('云开发服务开通成功!')
|
|
155
157
|
});
|
|
156
158
|
return true;
|
|
157
159
|
}
|
|
@@ -166,7 +168,7 @@ function checkEnvStatus(envId) {
|
|
|
166
168
|
yield checkEnvAvaliable(envId);
|
|
167
169
|
}
|
|
168
170
|
else if (env.Status !== "NORMAL") {
|
|
169
|
-
throw new error_1.CloudBaseError('所有环境状态异常');
|
|
171
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('所有环境状态异常'));
|
|
170
172
|
}
|
|
171
173
|
});
|
|
172
174
|
}
|
|
@@ -190,7 +192,7 @@ function checkEnvAvaliable(envId) {
|
|
|
190
192
|
});
|
|
191
193
|
}, {
|
|
192
194
|
startTip: ENV_INIT_TIP,
|
|
193
|
-
successTip:
|
|
195
|
+
successTip: (0, i18n_1.t)('环境 {{envId}} 初始化成功', { envId })
|
|
194
196
|
});
|
|
195
197
|
});
|
|
196
198
|
}
|
package/lib/utils/fs/index.js
CHANGED
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
20
20
|
exports.formateFileSize = exports.isDirectory = exports.checkReadable = exports.checkWritable = exports.checkFullAccess = void 0;
|
|
21
21
|
const fs_1 = __importDefault(require("fs"));
|
|
22
22
|
const error_1 = require("../../error");
|
|
23
|
+
const i18n_1 = require("../../i18n");
|
|
23
24
|
__exportStar(require("./del"), exports);
|
|
24
25
|
function checkFullAccess(dest, throwError = false) {
|
|
25
26
|
try {
|
|
@@ -27,7 +28,7 @@ function checkFullAccess(dest, throwError = false) {
|
|
|
27
28
|
}
|
|
28
29
|
catch (e) {
|
|
29
30
|
if (throwError) {
|
|
30
|
-
throw new error_1.CloudBaseError(
|
|
31
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('路径不存在:{{path}}', { path: dest }));
|
|
31
32
|
}
|
|
32
33
|
return false;
|
|
33
34
|
}
|
|
@@ -37,7 +38,7 @@ function checkFullAccess(dest, throwError = false) {
|
|
|
37
38
|
}
|
|
38
39
|
catch (e) {
|
|
39
40
|
if (throwError) {
|
|
40
|
-
throw new error_1.CloudBaseError(
|
|
41
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('路径无读写权限:{{path}}', { path: dest }));
|
|
41
42
|
}
|
|
42
43
|
return false;
|
|
43
44
|
}
|
|
@@ -52,7 +53,7 @@ function checkWritable(dest, throwError = false) {
|
|
|
52
53
|
}
|
|
53
54
|
catch (e) {
|
|
54
55
|
if (throwError) {
|
|
55
|
-
throw new error_1.CloudBaseError(
|
|
56
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('路径不存在或没有权限访问:{{path}}', { path: dest }));
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
59
|
return false;
|
|
@@ -68,7 +69,7 @@ function checkReadable(dest, throwError = false) {
|
|
|
68
69
|
}
|
|
69
70
|
catch (e) {
|
|
70
71
|
if (throwError) {
|
|
71
|
-
throw new error_1.CloudBaseError(
|
|
72
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('路径不存在或没有权限访问:{{path}}', { path: dest }));
|
|
72
73
|
}
|
|
73
74
|
else {
|
|
74
75
|
return false;
|
|
@@ -19,6 +19,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
19
19
|
const make_dir_1 = __importDefault(require("make-dir"));
|
|
20
20
|
const tools_1 = require("./tools");
|
|
21
21
|
const toolbox_1 = require("@cloudbase/toolbox");
|
|
22
|
+
const i18n_1 = require("../i18n");
|
|
22
23
|
var CodeType;
|
|
23
24
|
(function (CodeType) {
|
|
24
25
|
CodeType[CodeType["File"] = 0] = "File";
|
|
@@ -63,7 +64,7 @@ class FunctionPacker {
|
|
|
63
64
|
}
|
|
64
65
|
catch (error) {
|
|
65
66
|
this.clean();
|
|
66
|
-
throw new toolbox_1.CloudBaseError(
|
|
67
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('函数代码打包失败:\n {{error}}', { error: error.message }));
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
if (type === CodeType.File) {
|
|
@@ -73,7 +74,7 @@ class FunctionPacker {
|
|
|
73
74
|
}
|
|
74
75
|
catch (error) {
|
|
75
76
|
this.clean();
|
|
76
|
-
throw new toolbox_1.CloudBaseError(
|
|
77
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('函数代码打包失败:\n {{error}}', { error: error.message }));
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
});
|
package/lib/utils/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __exportStar(require("./auth"), exports);
|
|
|
32
32
|
__exportStar(require("./store"), exports);
|
|
33
33
|
__exportStar(require("./notice"), exports);
|
|
34
34
|
__exportStar(require("./parallel"), exports);
|
|
35
|
+
__exportStar(require("./url"), exports);
|
|
35
36
|
__exportStar(require("./tcbrApi"), exports);
|
|
36
37
|
__exportStar(require("./checkTcbrEnv"), exports);
|
|
37
38
|
__exportStar(require("./commonParamsCheck"), exports);
|
|
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
exports.MCPConfigModifier = void 0;
|
|
39
39
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
40
40
|
const path_1 = __importDefault(require("path"));
|
|
41
|
+
const i18n_1 = require("../i18n");
|
|
41
42
|
const IDE_FILE_MAPPINGS = {
|
|
42
43
|
cursor: [
|
|
43
44
|
{ path: '.cursor/rules/cloudbase-rules.mdc' },
|
|
@@ -77,15 +78,15 @@ class MCPConfigModifier {
|
|
|
77
78
|
modifyMCPConfigs(extractDir, log) {
|
|
78
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
80
|
try {
|
|
80
|
-
log.info('🔧 正在修改 MCP 配置文件...');
|
|
81
|
+
log.info((0, i18n_1.t)('🔧 正在修改 MCP 配置文件...'));
|
|
81
82
|
for (const [ide, files] of Object.entries(IDE_FILE_MAPPINGS)) {
|
|
82
83
|
for (const descriptor of files) {
|
|
83
84
|
if (!descriptor.isMcpConfig)
|
|
84
85
|
continue;
|
|
85
86
|
const filePath = path_1.default.join(extractDir, descriptor.path);
|
|
86
|
-
log.debug(
|
|
87
|
+
log.debug((0, i18n_1.t)('检查文件: {{filePath}}', { filePath }));
|
|
87
88
|
if (yield fs_extra_1.default.pathExists(filePath)) {
|
|
88
|
-
log.debug(
|
|
89
|
+
log.debug((0, i18n_1.t)('找到 MCP 配置文件: {{filePath}}', { filePath }));
|
|
89
90
|
const format = inferConfigFormat(descriptor.path);
|
|
90
91
|
if (format === 'json') {
|
|
91
92
|
yield this.modifyMCPJsonFile(filePath, log);
|
|
@@ -95,14 +96,14 @@ class MCPConfigModifier {
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
else {
|
|
98
|
-
log.debug(
|
|
99
|
+
log.debug((0, i18n_1.t)('文件不存在: {{filePath}}', { filePath }));
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
log.info('✅ MCP 配置文件修改完成');
|
|
103
|
+
log.info((0, i18n_1.t)('✅ MCP 配置文件修改完成'));
|
|
103
104
|
}
|
|
104
105
|
catch (error) {
|
|
105
|
-
log.warn(
|
|
106
|
+
log.warn((0, i18n_1.t)('⚠️ MCP 配置文件修改失败: {{error}}', { error: error.message }));
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
109
|
}
|
|
@@ -111,7 +112,7 @@ class MCPConfigModifier {
|
|
|
111
112
|
try {
|
|
112
113
|
const content = yield fs_extra_1.default.readFile(filePath, 'utf-8');
|
|
113
114
|
const config = JSON.parse(content);
|
|
114
|
-
log.debug(
|
|
115
|
+
log.debug((0, i18n_1.t)('读取配置文件 {{filePath}}: {{config}}', { filePath, config: JSON.stringify(config) }));
|
|
115
116
|
let modified = false;
|
|
116
117
|
const modifyCommands = (obj) => {
|
|
117
118
|
if (typeof obj !== 'object' || obj === null) {
|
|
@@ -123,20 +124,20 @@ class MCPConfigModifier {
|
|
|
123
124
|
const result = Object.assign({}, obj);
|
|
124
125
|
if (result.command === 'npx' && Array.isArray(result.args)) {
|
|
125
126
|
const argsStr = result.args.join(' ');
|
|
126
|
-
log.debug(
|
|
127
|
+
log.debug(`${(0, i18n_1.t)('检查命令')}: command=${result.command}, args=${JSON.stringify(result.args)}`);
|
|
127
128
|
if (argsStr.includes('npm-global-exec@latest') &&
|
|
128
129
|
argsStr.includes('@cloudbase/cloudbase-mcp@latest')) {
|
|
129
|
-
log.debug(
|
|
130
|
+
log.debug((0, i18n_1.t)('匹配到需要修改的命令: {{argsStr}}', { argsStr }));
|
|
130
131
|
result.command = 'cloudbase-mcp';
|
|
131
132
|
result.args = [];
|
|
132
133
|
result.env = {
|
|
133
134
|
INTEGRATION_IDE: process.env.INTEGRATION_IDE || 'CloudBaseCLI'
|
|
134
135
|
};
|
|
135
136
|
modified = true;
|
|
136
|
-
log.debug(
|
|
137
|
+
log.debug(`${(0, i18n_1.t)('修改配置文件')} ${filePath}: npx -> cloudbase-mcp`);
|
|
137
138
|
}
|
|
138
139
|
else {
|
|
139
|
-
log.debug(
|
|
140
|
+
log.debug((0, i18n_1.t)('命令不匹配修改条件: {{argsStr}}', { argsStr }));
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
for (const [key, value] of Object.entries(result)) {
|
|
@@ -147,14 +148,14 @@ class MCPConfigModifier {
|
|
|
147
148
|
const modifiedConfig = modifyCommands(config);
|
|
148
149
|
if (modified) {
|
|
149
150
|
yield fs_extra_1.default.writeJson(filePath, modifiedConfig, { spaces: 2 });
|
|
150
|
-
log.debug(
|
|
151
|
+
log.debug((0, i18n_1.t)('✅ 已修改 {{filePath}}', { filePath }));
|
|
151
152
|
}
|
|
152
153
|
else {
|
|
153
|
-
log.debug(
|
|
154
|
+
log.debug((0, i18n_1.t)('⚠️ 配置文件 {{filePath}} 未发生修改', { filePath }));
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
catch (error) {
|
|
157
|
-
log.warn(
|
|
158
|
+
log.warn((0, i18n_1.t)('⚠️ 修改配置文件 {{filePath}} 失败: {{error}}', { filePath, error: error.message }));
|
|
158
159
|
}
|
|
159
160
|
});
|
|
160
161
|
}
|
|
@@ -182,7 +183,7 @@ class MCPConfigModifier {
|
|
|
182
183
|
INTEGRATION_IDE: process.env.INTEGRATION_IDE || 'CloudBaseCLI'
|
|
183
184
|
};
|
|
184
185
|
modified = true;
|
|
185
|
-
log.debug(
|
|
186
|
+
log.debug(`${(0, i18n_1.t)('修改配置文件')} ${filePath}: npx -> cloudbase-mcp`);
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
for (const [key, value] of Object.entries(result)) {
|
|
@@ -194,11 +195,11 @@ class MCPConfigModifier {
|
|
|
194
195
|
if (modified) {
|
|
195
196
|
const tomlString = this.objectToToml(modifiedConfig);
|
|
196
197
|
yield fs_extra_1.default.writeFile(filePath, tomlString, 'utf-8');
|
|
197
|
-
log.debug(`✅ 已修改 ${filePath}`);
|
|
198
|
+
log.debug(`✅ ${(0, i18n_1.t)('已修改')} ${filePath}`);
|
|
198
199
|
}
|
|
199
200
|
}
|
|
200
201
|
catch (error) {
|
|
201
|
-
log.warn(
|
|
202
|
+
log.warn((0, i18n_1.t)('⚠️ 修改配置文件 {{filePath}} 失败: {{errorMessage}}', { filePath, errorMessage: error.message }));
|
|
202
203
|
}
|
|
203
204
|
});
|
|
204
205
|
}
|
|
@@ -15,6 +15,7 @@ const cloud_api_1 = require("@cloudbase/cloud-api");
|
|
|
15
15
|
const error_1 = require("../../error");
|
|
16
16
|
const constant_1 = require("../../constant");
|
|
17
17
|
const debug_logger_1 = require("../debug-logger");
|
|
18
|
+
const i18n_1 = require("../../i18n");
|
|
18
19
|
let commonCredential;
|
|
19
20
|
const isTokenExpired = (credential, gap = 120) => credential.accessTokenExpired && Number(credential.accessTokenExpired) < Date.now() + gap * 1000;
|
|
20
21
|
class CloudApiService {
|
|
@@ -40,7 +41,7 @@ class CloudApiService {
|
|
|
40
41
|
}
|
|
41
42
|
const credential = yield (0, toolbox_1.getCredentialWithoutCheck)();
|
|
42
43
|
if (!credential) {
|
|
43
|
-
throw new error_1.CloudBaseError('无有效身份信息,请使用 cloudbase login 登录');
|
|
44
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('无有效身份信息,请使用 cloudbase login 登录'));
|
|
44
45
|
}
|
|
45
46
|
commonCredential = credential;
|
|
46
47
|
return Object.assign(Object.assign({}, credential), { tokenExpired: Number(credential.accessTokenExpired) });
|
|
@@ -21,6 +21,7 @@ const tools_1 = require("../tools");
|
|
|
21
21
|
const platform_1 = require("../platform");
|
|
22
22
|
const proxy_1 = require("./proxy");
|
|
23
23
|
const http_request_1 = require("./http-request");
|
|
24
|
+
const i18n_1 = require("../../i18n");
|
|
24
25
|
const refreshTokenUrl = 'https://iaas.cloud.tencent.com/tcb_refresh';
|
|
25
26
|
function refreshTmpToken(metaData) {
|
|
26
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -50,7 +51,7 @@ function checkAndGetCredential(throwError = false) {
|
|
|
50
51
|
});
|
|
51
52
|
if (!credential || lodash_1.default.isEmpty(credential)) {
|
|
52
53
|
if (throwError) {
|
|
53
|
-
throw new error_1.CloudBaseError('无有效身份信息,请使用 cloudbase login 登录');
|
|
54
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('无有效身份信息,请使用 cloudbase login 登录'));
|
|
54
55
|
}
|
|
55
56
|
return null;
|
|
56
57
|
}
|
|
@@ -19,9 +19,10 @@ const constant_1 = require("../../constant");
|
|
|
19
19
|
const error_1 = require("../../error");
|
|
20
20
|
const proxy_1 = require("./proxy");
|
|
21
21
|
const debug_logger_1 = require("../debug-logger");
|
|
22
|
+
const i18n_1 = require("../../i18n");
|
|
22
23
|
function handleTimeout(e) {
|
|
23
24
|
if (e.type === 'request-timeout') {
|
|
24
|
-
throw new error_1.CloudBaseError('请求超时,请检查你的网络,如果终端无法直接访问公网,请设置终端 HTTP 请求代理!');
|
|
25
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请求超时,请检查你的网络,如果终端无法直接访问公网,请设置终端 HTTP 请求代理!'));
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
27
28
|
throw e;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createUploadProgressBar = void 0;
|
|
7
7
|
const progress_1 = __importDefault(require("progress"));
|
|
8
|
+
const i18n_1 = require("../i18n");
|
|
8
9
|
function createUploadProgressBar(onFinished, onStart) {
|
|
9
10
|
let bar;
|
|
10
11
|
let lastLoaded = 0;
|
|
@@ -30,7 +31,7 @@ function createUploadProgressBar(onFinished, onStart) {
|
|
|
30
31
|
bar.tick(tick);
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
bar = new progress_1.default('文件传输中 [:bar] :percent :etas', {
|
|
34
|
+
bar = new progress_1.default((0, i18n_1.t)('文件传输中 [:bar] :percent :etas'), {
|
|
34
35
|
total,
|
|
35
36
|
complete: '=',
|
|
36
37
|
incomplete: ' ',
|
|
@@ -12,25 +12,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.pagingSelectPromp = void 0;
|
|
13
13
|
const enquirer_1 = require("enquirer");
|
|
14
14
|
const error_1 = require("../../error");
|
|
15
|
+
const i18n_1 = require("../../i18n");
|
|
15
16
|
const pagingSelectPromp = (type, listFetcher, options, message, filter = _ => true, mapper = item => item) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
17
|
let res = [];
|
|
17
18
|
let offset = 0;
|
|
18
19
|
let nextRoundList;
|
|
20
|
+
const nextPageText = (0, i18n_1.t)('下一页');
|
|
19
21
|
while (true) {
|
|
20
22
|
const thisRoundList = nextRoundList || (yield listFetcher(Object.assign(Object.assign({}, options), { limit: 10, offset: offset }))).filter(filter).map(mapper);
|
|
21
23
|
offset += 10;
|
|
22
24
|
nextRoundList = (yield listFetcher(Object.assign(Object.assign({}, options), { limit: 10, offset: offset }))).filter(filter).map(mapper);
|
|
23
25
|
if (!thisRoundList || !thisRoundList.length)
|
|
24
|
-
throw new error_1.CloudBaseError('列表没有数据');
|
|
26
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('列表没有数据'));
|
|
25
27
|
if (type === 'select') {
|
|
26
28
|
let receiver = (yield (0, enquirer_1.prompt)({
|
|
27
29
|
type: type,
|
|
28
30
|
name: 'receiver',
|
|
29
31
|
message: message,
|
|
30
|
-
choices: (nextRoundList === null || nextRoundList === void 0 ? void 0 : nextRoundList.length) ? [...thisRoundList,
|
|
32
|
+
choices: (nextRoundList === null || nextRoundList === void 0 ? void 0 : nextRoundList.length) ? [...thisRoundList, nextPageText] : [...thisRoundList]
|
|
31
33
|
})).receiver;
|
|
32
34
|
res = receiver;
|
|
33
|
-
if (receiver !==
|
|
35
|
+
if (receiver !== nextPageText)
|
|
34
36
|
break;
|
|
35
37
|
}
|
|
36
38
|
else {
|
|
@@ -38,12 +40,12 @@ const pagingSelectPromp = (type, listFetcher, options, message, filter = _ => tr
|
|
|
38
40
|
type: type,
|
|
39
41
|
name: 'receiver',
|
|
40
42
|
message: message,
|
|
41
|
-
choices: (nextRoundList === null || nextRoundList === void 0 ? void 0 : nextRoundList.length) ? [...thisRoundList,
|
|
43
|
+
choices: (nextRoundList === null || nextRoundList === void 0 ? void 0 : nextRoundList.length) ? [...thisRoundList, nextPageText] : [...thisRoundList]
|
|
42
44
|
});
|
|
43
45
|
if (!receiver)
|
|
44
46
|
receiver = [];
|
|
45
|
-
res = [...res, ...receiver.filter(item => item !==
|
|
46
|
-
if (receiver.indexOf(
|
|
47
|
+
res = [...res, ...receiver.filter(item => item !== nextPageText)];
|
|
48
|
+
if (receiver.indexOf(nextPageText) === -1)
|
|
47
49
|
break;
|
|
48
50
|
}
|
|
49
51
|
}
|
package/lib/utils/store/auth.js
CHANGED
|
@@ -19,6 +19,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
19
19
|
const fs_2 = require("../fs");
|
|
20
20
|
const db_1 = require("./db");
|
|
21
21
|
const constant_1 = require("../../constant");
|
|
22
|
+
const i18n_1 = require("../../i18n");
|
|
22
23
|
class AuthStore extends db_1.LocalStore {
|
|
23
24
|
constructor(defaults) {
|
|
24
25
|
super(defaults, 'auth');
|
|
@@ -45,14 +46,14 @@ class AuthStore extends db_1.LocalStore {
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
exports.authStore = new AuthStore({
|
|
48
|
-
_: '这是您的 CloudBase 身份凭据文件,请不要分享给他人!',
|
|
49
|
+
_: (0, i18n_1.t)('这是您的 CloudBase 身份凭据文件,请不要分享给他人!'),
|
|
49
50
|
[constant_1.ConfigItems.credential]: {},
|
|
50
51
|
[constant_1.ConfigItems.ssh]: {}
|
|
51
52
|
});
|
|
52
53
|
function getUin() {
|
|
53
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
55
|
const credential = yield exports.authStore.get(constant_1.ConfigItems.credential);
|
|
55
|
-
return (credential === null || credential === void 0 ? void 0 : credential.uin) || '无';
|
|
56
|
+
return (credential === null || credential === void 0 ? void 0 : credential.uin) || (0, i18n_1.t)('无');
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
exports.getUin = getUin;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.configStore = void 0;
|
|
13
|
+
const commands_1 = require("../../commands");
|
|
14
|
+
const db_1 = require("./db");
|
|
15
|
+
class ConfigStore extends db_1.LocalStore {
|
|
16
|
+
constructor() {
|
|
17
|
+
super({}, 'config');
|
|
18
|
+
}
|
|
19
|
+
get(key) {
|
|
20
|
+
const _super = Object.create(null, {
|
|
21
|
+
get: { get: () => super.get }
|
|
22
|
+
});
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const value = yield _super.get.call(this, key);
|
|
25
|
+
if (value !== undefined)
|
|
26
|
+
return value;
|
|
27
|
+
const envKey = commands_1.CONFIGS[key].envKey;
|
|
28
|
+
if (envKey) {
|
|
29
|
+
const envValue = process.env[envKey];
|
|
30
|
+
if (envValue !== undefined)
|
|
31
|
+
return envValue;
|
|
32
|
+
}
|
|
33
|
+
return commands_1.DEFAULT_CONFIGS[key];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
getSync(key) {
|
|
37
|
+
const value = super.getSyncDB().get(key).value();
|
|
38
|
+
if (value !== undefined)
|
|
39
|
+
return value;
|
|
40
|
+
const envKey = commands_1.CONFIGS[key].envKey;
|
|
41
|
+
if (envKey) {
|
|
42
|
+
const envValue = process.env[envKey];
|
|
43
|
+
if (envValue !== undefined)
|
|
44
|
+
return envValue;
|
|
45
|
+
}
|
|
46
|
+
return commands_1.DEFAULT_CONFIGS[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.configStore = new ConfigStore();
|
package/lib/utils/store/db.js
CHANGED
|
@@ -49,6 +49,11 @@ class LocalStore {
|
|
|
49
49
|
return db;
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
+
getSyncDB() {
|
|
53
|
+
const db = this.dbSync || getSyncDB(this.dbKey);
|
|
54
|
+
this.dbSync = db;
|
|
55
|
+
return db;
|
|
56
|
+
}
|
|
52
57
|
get(key) {
|
|
53
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
59
|
const defaultValue = this.defaults[key];
|
package/lib/utils/store/index.js
CHANGED
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./auth"), exports);
|
|
18
17
|
__exportStar(require("./db"), exports);
|
|
18
|
+
__exportStar(require("./config"), exports);
|
|
19
19
|
__exportStar(require("./auth"), exports);
|
|
20
20
|
__exportStar(require("./usage"), exports);
|
|
21
21
|
__exportStar(require("./common"), exports);
|