@cloudbase/cli 2.9.9 → 2.9.10
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/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 +95 -98
- 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 +25 -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 +7 -1
- 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/cloudrun/base.d.ts +1 -0
- 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
|
@@ -72,6 +72,7 @@ const utils_1 = require("../../utils");
|
|
|
72
72
|
const common_1 = require("../common");
|
|
73
73
|
const constants_1 = require("../constants");
|
|
74
74
|
const utils_2 = require("../utils");
|
|
75
|
+
const i18n_1 = require("../../i18n");
|
|
75
76
|
const { CloudAPI } = iac_core_1.CloudAPI;
|
|
76
77
|
const AccessType = {
|
|
77
78
|
OA: 'OA',
|
|
@@ -80,8 +81,8 @@ const AccessType = {
|
|
|
80
81
|
VPC: 'VPC'
|
|
81
82
|
};
|
|
82
83
|
const ResourceTitle = {
|
|
83
|
-
container: '容器型云托管',
|
|
84
|
-
function: '函数型云托管'
|
|
84
|
+
container: (0, i18n_1.t)('容器型云托管'),
|
|
85
|
+
function: (0, i18n_1.t)('函数型云托管')
|
|
85
86
|
};
|
|
86
87
|
function getCloudrunService(envId) {
|
|
87
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -123,24 +124,24 @@ let CloudRunInitCommand = class CloudRunInitCommand extends common_1.Command {
|
|
|
123
124
|
options: [
|
|
124
125
|
{
|
|
125
126
|
flags: '-e, --envId <envId>',
|
|
126
|
-
desc: '环境 ID'
|
|
127
|
+
desc: (0, i18n_1.t)('环境 ID')
|
|
127
128
|
},
|
|
128
129
|
{
|
|
129
130
|
flags: '-s, --serviceName <serviceName>',
|
|
130
|
-
desc: '服务名称'
|
|
131
|
+
desc: (0, i18n_1.t)('服务名称')
|
|
131
132
|
},
|
|
132
133
|
{
|
|
133
134
|
flags: '--template <template>',
|
|
134
|
-
desc: '模板名称'
|
|
135
|
+
desc: (0, i18n_1.t)('模板名称')
|
|
135
136
|
},
|
|
136
137
|
{
|
|
137
138
|
flags: '--targetPath <targetPath>',
|
|
138
|
-
desc: '项目初始化目标路径(绝对路径或相对路径,默认: 当前目录)'
|
|
139
|
+
desc: (0, i18n_1.t)('项目初始化目标路径(绝对路径或相对路径,默认: 当前目录)')
|
|
139
140
|
}
|
|
140
141
|
],
|
|
141
142
|
requiredEnvId: false,
|
|
142
143
|
autoRunLogin: true,
|
|
143
|
-
desc: '初始化云托管服务代码项目'
|
|
144
|
+
desc: (0, i18n_1.t)('初始化云托管服务代码项目')
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
147
|
execute(ctx, envId, log, options) {
|
|
@@ -160,7 +161,7 @@ let CloudRunInitCommand = class CloudRunInitCommand extends common_1.Command {
|
|
|
160
161
|
{
|
|
161
162
|
type: 'list',
|
|
162
163
|
name: 'templateId',
|
|
163
|
-
message: '请选择模板',
|
|
164
|
+
message: (0, i18n_1.t)('请选择模板'),
|
|
164
165
|
choices: templates.map((t) => ({
|
|
165
166
|
name: `${t.title}(${t.identifier})`,
|
|
166
167
|
value: t.identifier
|
|
@@ -170,7 +171,7 @@ let CloudRunInitCommand = class CloudRunInitCommand extends common_1.Command {
|
|
|
170
171
|
template = templateId;
|
|
171
172
|
}
|
|
172
173
|
const spinner = (0, ora_1.default)({
|
|
173
|
-
text: '正在初始化项目代码...',
|
|
174
|
+
text: (0, i18n_1.t)('正在初始化项目代码...'),
|
|
174
175
|
color: 'blue'
|
|
175
176
|
}).start();
|
|
176
177
|
try {
|
|
@@ -183,11 +184,11 @@ let CloudRunInitCommand = class CloudRunInitCommand extends common_1.Command {
|
|
|
183
184
|
envId,
|
|
184
185
|
cloudrun: { name: serviceName }
|
|
185
186
|
});
|
|
186
|
-
spinner.succeed('项目初始化成功');
|
|
187
|
-
console.log(chalk_1.default.green(
|
|
187
|
+
spinner.succeed((0, i18n_1.t)('项目初始化成功'));
|
|
188
|
+
console.log(chalk_1.default.green((0, i18n_1.t)('项目路径:{{projectDir}}', { projectDir })));
|
|
188
189
|
}
|
|
189
190
|
catch (e) {
|
|
190
|
-
spinner.fail('项目初始化失败');
|
|
191
|
+
spinner.fail((0, i18n_1.t)('项目初始化失败'));
|
|
191
192
|
const error = e instanceof Error ? e : new Error(String(e));
|
|
192
193
|
log.error(error.message);
|
|
193
194
|
}
|
|
@@ -216,31 +217,31 @@ let CloudRunListCommand = class CloudRunListCommand extends common_1.Command {
|
|
|
216
217
|
options: [
|
|
217
218
|
{
|
|
218
219
|
flags: '-e, --envId <envId>',
|
|
219
|
-
desc: '环境 ID'
|
|
220
|
+
desc: (0, i18n_1.t)('环境 ID')
|
|
220
221
|
},
|
|
221
222
|
{
|
|
222
223
|
flags: '--pageSize <pageSize>',
|
|
223
|
-
desc: '每页数量(默认值: 10)',
|
|
224
|
+
desc: (0, i18n_1.t)('每页数量(默认值: 10)'),
|
|
224
225
|
defaultValue: 10
|
|
225
226
|
},
|
|
226
227
|
{
|
|
227
228
|
flags: '--pageNum <pageNum>',
|
|
228
|
-
desc: '页码(默认值: 1)',
|
|
229
|
+
desc: (0, i18n_1.t)('页码(默认值: 1)'),
|
|
229
230
|
defaultValue: 1
|
|
230
231
|
},
|
|
231
232
|
{
|
|
232
233
|
flags: '--serviceName <serviceName>',
|
|
233
|
-
desc: '服务名称筛选'
|
|
234
|
+
desc: (0, i18n_1.t)('服务名称筛选')
|
|
234
235
|
},
|
|
235
236
|
{
|
|
236
237
|
flags: '--serverType <serverType>',
|
|
237
|
-
desc: '服务类型筛选(可选值: function | container)',
|
|
238
|
+
desc: (0, i18n_1.t)('服务类型筛选(可选值: function | container)'),
|
|
238
239
|
choices: ['function', 'container']
|
|
239
240
|
}
|
|
240
241
|
],
|
|
241
242
|
requiredEnvId: false,
|
|
242
243
|
autoRunLogin: true,
|
|
243
|
-
desc: '查看云托管服务列表'
|
|
244
|
+
desc: (0, i18n_1.t)('查看云托管服务列表')
|
|
244
245
|
};
|
|
245
246
|
}
|
|
246
247
|
execute(ctx, envId, log, options) {
|
|
@@ -249,7 +250,7 @@ let CloudRunListCommand = class CloudRunListCommand extends common_1.Command {
|
|
|
249
250
|
if (!envId) {
|
|
250
251
|
envId = yield _selectEnv();
|
|
251
252
|
}
|
|
252
|
-
log.info(
|
|
253
|
+
log.info((0, i18n_1.t)('当前环境:{{envId}}', { envId }));
|
|
253
254
|
const cloudrunService = yield getCloudrunService(envId);
|
|
254
255
|
const services = yield cloudrunService.list({
|
|
255
256
|
pageSize: parseInt(pageSize),
|
|
@@ -258,14 +259,14 @@ let CloudRunListCommand = class CloudRunListCommand extends common_1.Command {
|
|
|
258
259
|
serverType: serverType
|
|
259
260
|
});
|
|
260
261
|
const table = new cli_table3_1.default({
|
|
261
|
-
head: ['服务名称', '类型', '更新时间', '运行状态', '公网访问'],
|
|
262
|
+
head: [(0, i18n_1.t)('服务名称'), (0, i18n_1.t)('类型'), (0, i18n_1.t)('更新时间'), (0, i18n_1.t)('运行状态'), (0, i18n_1.t)('公网访问')],
|
|
262
263
|
style: {
|
|
263
264
|
head: ['green']
|
|
264
265
|
}
|
|
265
266
|
});
|
|
266
267
|
const serverTypeTitleMap = {
|
|
267
|
-
function: '函数型服务',
|
|
268
|
-
container: '容器型服务'
|
|
268
|
+
function: (0, i18n_1.t)('函数型服务'),
|
|
269
|
+
container: (0, i18n_1.t)('容器型服务')
|
|
269
270
|
};
|
|
270
271
|
services.ServerList.forEach((service) => {
|
|
271
272
|
table.push([
|
|
@@ -273,7 +274,7 @@ let CloudRunListCommand = class CloudRunListCommand extends common_1.Command {
|
|
|
273
274
|
serverTypeTitleMap[service.ServerType] || service.ServerType,
|
|
274
275
|
service.UpdateTime,
|
|
275
276
|
service.Status,
|
|
276
|
-
isPublicAccessOpen(service.AccessTypes) ? '允许' : '不允许'
|
|
277
|
+
isPublicAccessOpen(service.AccessTypes) ? (0, i18n_1.t)('允许') : (0, i18n_1.t)('不允许')
|
|
277
278
|
]);
|
|
278
279
|
});
|
|
279
280
|
console.log(table.toString());
|
|
@@ -305,27 +306,27 @@ let CloudRunDownloadCommand = class CloudRunDownloadCommand extends common_1.Com
|
|
|
305
306
|
options: [
|
|
306
307
|
{
|
|
307
308
|
flags: '-e, --envId <envId>',
|
|
308
|
-
desc: '环境 ID'
|
|
309
|
+
desc: (0, i18n_1.t)('环境 ID')
|
|
309
310
|
},
|
|
310
311
|
{
|
|
311
312
|
flags: '-s, --serviceName <serviceName>',
|
|
312
|
-
desc: '服务名称',
|
|
313
|
+
desc: (0, i18n_1.t)('服务名称'),
|
|
313
314
|
required: true
|
|
314
315
|
},
|
|
315
316
|
{
|
|
316
317
|
flags: '--targetPath <targetPath>',
|
|
317
|
-
desc: '代码下载目标路径(绝对路径或相对路径,默认: 当前目录)',
|
|
318
|
+
desc: (0, i18n_1.t)('代码下载目标路径(绝对路径或相对路径,默认: 当前目录)'),
|
|
318
319
|
defaultValue: process.cwd()
|
|
319
320
|
},
|
|
320
321
|
{
|
|
321
322
|
flags: '--force',
|
|
322
|
-
desc: '强制覆盖,不提示确认',
|
|
323
|
+
desc: (0, i18n_1.t)('强制覆盖,不提示确认'),
|
|
323
324
|
defaultValue: false
|
|
324
325
|
}
|
|
325
326
|
],
|
|
326
327
|
requiredEnvId: false,
|
|
327
328
|
autoRunLogin: true,
|
|
328
|
-
desc: '下载云托管服务代码'
|
|
329
|
+
desc: (0, i18n_1.t)('下载云托管服务代码')
|
|
329
330
|
};
|
|
330
331
|
}
|
|
331
332
|
execute(ctx, envId, log, options) {
|
|
@@ -336,7 +337,7 @@ let CloudRunDownloadCommand = class CloudRunDownloadCommand extends common_1.Com
|
|
|
336
337
|
if (!envId) {
|
|
337
338
|
envId = yield _selectEnv();
|
|
338
339
|
}
|
|
339
|
-
log.info(
|
|
340
|
+
log.info((0, i18n_1.t)('当前环境:{{envId}}', { envId }));
|
|
340
341
|
const cloudrunService = yield getCloudrunService(envId);
|
|
341
342
|
const maybeInProject = yield fs_extra_1.default.pathExists(path_1.default.join(targetDir, 'README.md'));
|
|
342
343
|
if (!serviceName) {
|
|
@@ -368,12 +369,12 @@ let CloudRunDownloadCommand = class CloudRunDownloadCommand extends common_1.Com
|
|
|
368
369
|
{
|
|
369
370
|
type: 'confirm',
|
|
370
371
|
name: 'confirm',
|
|
371
|
-
message:
|
|
372
|
+
message: (0, i18n_1.t)('下载将覆盖 {{targetDir}} 目录下的代码,是否继续?', { targetDir }),
|
|
372
373
|
default: true
|
|
373
374
|
}
|
|
374
375
|
]);
|
|
375
376
|
if (!answers.confirm) {
|
|
376
|
-
log.info('用户已取消下载操作');
|
|
377
|
+
log.info((0, i18n_1.t)('用户已取消下载操作'));
|
|
377
378
|
return;
|
|
378
379
|
}
|
|
379
380
|
}
|
|
@@ -386,7 +387,7 @@ let CloudRunDownloadCommand = class CloudRunDownloadCommand extends common_1.Com
|
|
|
386
387
|
envId,
|
|
387
388
|
cloudrun: { name: serviceName }
|
|
388
389
|
});
|
|
389
|
-
log.success(
|
|
390
|
+
log.success((0, i18n_1.t)('云托管服务 {{serviceName}} 代码已成功下载到: {{targetDir}}', { serviceName, targetDir }));
|
|
390
391
|
}
|
|
391
392
|
catch (e) {
|
|
392
393
|
const error = e instanceof Error ? e : new Error(String(e));
|
|
@@ -421,22 +422,22 @@ let CloudRunDeleteCommand = class CloudRunDeleteCommand extends common_1.Command
|
|
|
421
422
|
options: [
|
|
422
423
|
{
|
|
423
424
|
flags: '-e, --envId <envId>',
|
|
424
|
-
desc: '环境 ID'
|
|
425
|
+
desc: (0, i18n_1.t)('环境 ID')
|
|
425
426
|
},
|
|
426
427
|
{
|
|
427
428
|
flags: '-s, --serviceName <serviceName>',
|
|
428
|
-
desc: '服务名称',
|
|
429
|
+
desc: (0, i18n_1.t)('服务名称'),
|
|
429
430
|
required: true
|
|
430
431
|
},
|
|
431
432
|
{
|
|
432
433
|
flags: '--force',
|
|
433
|
-
desc: '强制删除,不提示确认',
|
|
434
|
+
desc: (0, i18n_1.t)('强制删除,不提示确认'),
|
|
434
435
|
defaultValue: false
|
|
435
436
|
}
|
|
436
437
|
],
|
|
437
438
|
requiredEnvId: false,
|
|
438
439
|
autoRunLogin: true,
|
|
439
|
-
desc: '删除云托管服务'
|
|
440
|
+
desc: (0, i18n_1.t)('删除云托管服务')
|
|
440
441
|
};
|
|
441
442
|
}
|
|
442
443
|
execute(ctx, envId, log, options) {
|
|
@@ -446,7 +447,7 @@ let CloudRunDeleteCommand = class CloudRunDeleteCommand extends common_1.Command
|
|
|
446
447
|
if (!envId) {
|
|
447
448
|
envId = yield _selectEnv();
|
|
448
449
|
}
|
|
449
|
-
log.info(
|
|
450
|
+
log.info((0, i18n_1.t)('当前环境:{{envId}}', { envId }));
|
|
450
451
|
const cloudrunService = yield getCloudrunService(envId);
|
|
451
452
|
if (!serviceName) {
|
|
452
453
|
const config = yield (0, utils_2.getCloudbaserc)(process.cwd());
|
|
@@ -461,12 +462,12 @@ let CloudRunDeleteCommand = class CloudRunDeleteCommand extends common_1.Command
|
|
|
461
462
|
{
|
|
462
463
|
type: 'confirm',
|
|
463
464
|
name: 'confirm',
|
|
464
|
-
message:
|
|
465
|
+
message: (0, i18n_1.t)('确定要删除云托管服务 {{serviceName}} 吗?', { serviceName }),
|
|
465
466
|
default: false
|
|
466
467
|
}
|
|
467
468
|
]);
|
|
468
469
|
if (!answers.confirm) {
|
|
469
|
-
log.info('已取消删除操作');
|
|
470
|
+
log.info((0, i18n_1.t)('已取消删除操作'));
|
|
470
471
|
return;
|
|
471
472
|
}
|
|
472
473
|
}
|
|
@@ -474,7 +475,7 @@ let CloudRunDeleteCommand = class CloudRunDeleteCommand extends common_1.Command
|
|
|
474
475
|
yield cloudrunService.delete({
|
|
475
476
|
serverName: serviceName
|
|
476
477
|
});
|
|
477
|
-
log.success(
|
|
478
|
+
log.success((0, i18n_1.t)('云托管服务 {{serviceName}} 删除成功', { serviceName }));
|
|
478
479
|
}
|
|
479
480
|
catch (e) {
|
|
480
481
|
const error = e instanceof Error ? e : new Error(String(e));
|
|
@@ -509,39 +510,44 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
509
510
|
options: [
|
|
510
511
|
{
|
|
511
512
|
flags: '-e, --envId <envId>',
|
|
512
|
-
desc: '环境 ID'
|
|
513
|
+
desc: (0, i18n_1.t)('环境 ID')
|
|
513
514
|
},
|
|
514
515
|
{
|
|
515
516
|
flags: '-s, --serviceName <serviceName>',
|
|
516
|
-
desc: '服务名称'
|
|
517
|
+
desc: (0, i18n_1.t)('服务名称')
|
|
517
518
|
},
|
|
518
519
|
{
|
|
519
520
|
flags: '--port <port>',
|
|
520
|
-
desc: '容器型云托管服务端口(函数型云托管设置无效)'
|
|
521
|
+
desc: (0, i18n_1.t)('容器型云托管服务端口(函数型云托管设置无效)')
|
|
521
522
|
},
|
|
522
523
|
{
|
|
523
524
|
flags: '--source <source>',
|
|
524
|
-
desc: '部署代码所在目录路径(绝对路径或相对路径,默认: 当前目录)'
|
|
525
|
+
desc: (0, i18n_1.t)('部署代码所在目录路径(绝对路径或相对路径,默认: 当前目录)')
|
|
525
526
|
},
|
|
526
527
|
{
|
|
527
528
|
flags: '--createAgent',
|
|
528
|
-
desc: '创建函数型 Agent'
|
|
529
|
+
desc: (0, i18n_1.t)('创建函数型 Agent')
|
|
529
530
|
},
|
|
530
531
|
{
|
|
531
532
|
flags: '--force',
|
|
532
|
-
desc: '强制部署,跳过所有确认提示',
|
|
533
|
+
desc: (0, i18n_1.t)('强制部署,跳过所有确认提示'),
|
|
533
534
|
defaultValue: false
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
flags: '--installDependency <installDependency>',
|
|
538
|
+
desc: '在线安装依赖',
|
|
539
|
+
defaultValue: true
|
|
534
540
|
}
|
|
535
541
|
],
|
|
536
542
|
requiredEnvId: false,
|
|
537
543
|
autoRunLogin: true,
|
|
538
|
-
desc: '部署云托管服务'
|
|
544
|
+
desc: (0, i18n_1.t)('部署云托管服务')
|
|
539
545
|
};
|
|
540
546
|
}
|
|
541
547
|
execute(ctx, envId, log, options) {
|
|
542
548
|
var _a, _b;
|
|
543
549
|
return __awaiter(this, void 0, void 0, function* () {
|
|
544
|
-
let { serviceName, source, force, port, createAgent } = options;
|
|
550
|
+
let { serviceName, source, force, port, createAgent, installDependency = true } = options;
|
|
545
551
|
const targetDir = path_1.default.resolve(source || process.cwd());
|
|
546
552
|
if (!envId) {
|
|
547
553
|
const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(targetDir));
|
|
@@ -552,16 +558,16 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
552
558
|
envId = yield _selectEnv();
|
|
553
559
|
}
|
|
554
560
|
}
|
|
555
|
-
log.info(
|
|
561
|
+
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
556
562
|
if (createAgent) {
|
|
557
563
|
const questions = [
|
|
558
564
|
{
|
|
559
565
|
type: 'input',
|
|
560
566
|
name: 'Name',
|
|
561
|
-
message: '请输入函数式 Agent 名称:',
|
|
567
|
+
message: (0, i18n_1.t)('请输入函数式 Agent 名称:'),
|
|
562
568
|
validate: (input) => {
|
|
563
569
|
if (!input.trim()) {
|
|
564
|
-
return '名称不能为空';
|
|
570
|
+
return (0, i18n_1.t)('名称不能为空');
|
|
565
571
|
}
|
|
566
572
|
return true;
|
|
567
573
|
}
|
|
@@ -569,10 +575,10 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
569
575
|
{
|
|
570
576
|
type: 'input',
|
|
571
577
|
name: 'BotId',
|
|
572
|
-
message: '请输入括号内的标识 ibot-(服务名-BotTag)。示例:agent-chat:',
|
|
578
|
+
message: (0, i18n_1.t)('请输入括号内的标识 ibot-(服务名-BotTag)。示例:agent-chat:'),
|
|
573
579
|
validate: (input) => {
|
|
574
580
|
if (!/^[a-z0-9_]+-[a-z0-9_]+$/.test(input)) {
|
|
575
|
-
return '标识格式错误,应为"xxx-xxx"';
|
|
581
|
+
return (0, i18n_1.t)('标识格式错误,应为"xxx-xxx"');
|
|
576
582
|
}
|
|
577
583
|
return true;
|
|
578
584
|
}
|
|
@@ -586,7 +592,7 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
586
592
|
BotId: botId
|
|
587
593
|
});
|
|
588
594
|
(0, utils_2.trackCallback)({
|
|
589
|
-
details:
|
|
595
|
+
details: (0, i18n_1.t)('请打开链接查看部署状态: {{url}}', { url: `${utils_1.EUrl.DevPlatform}?envId=${envId}#/ai?tab=agent&agent=${botId}` })
|
|
590
596
|
}, log);
|
|
591
597
|
return;
|
|
592
598
|
}
|
|
@@ -605,14 +611,14 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
605
611
|
const containerConfigFile = 'container.config.json';
|
|
606
612
|
const containerConfigPath = path_1.default.join(targetDir, containerConfigFile);
|
|
607
613
|
if (yield fs_extra_1.default.pathExists(containerConfigPath)) {
|
|
608
|
-
log.warn(
|
|
614
|
+
log.warn((0, i18n_1.t)('CLI 中 {{containerConfigFile}} 文件将不会生效,请通过命令行参数进行配置!', { containerConfigFile }));
|
|
609
615
|
}
|
|
610
616
|
if (!force) {
|
|
611
617
|
const answers = yield inquirer_1.default.prompt([
|
|
612
618
|
{
|
|
613
619
|
type: 'confirm',
|
|
614
620
|
name: 'confirm',
|
|
615
|
-
message: '即将开始部署,是否确认继续?',
|
|
621
|
+
message: (0, i18n_1.t)('即将开始部署,是否确认继续?'),
|
|
616
622
|
default: true
|
|
617
623
|
}
|
|
618
624
|
]);
|
|
@@ -643,26 +649,26 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
643
649
|
}
|
|
644
650
|
}
|
|
645
651
|
if (!serverType) {
|
|
646
|
-
throw new Error('无法判断云托管服务类型');
|
|
652
|
+
throw new Error((0, i18n_1.t)('无法判断云托管服务类型'));
|
|
647
653
|
}
|
|
648
654
|
if (!['container', 'function'].includes(serverType)) {
|
|
649
|
-
throw new Error(
|
|
655
|
+
throw new Error((0, i18n_1.t)('不支持的云托管服务类型:{{serverType}}', { serverType }));
|
|
650
656
|
}
|
|
651
657
|
yield _runDeploy();
|
|
652
658
|
function _runDeploy() {
|
|
653
659
|
return __awaiter(this, void 0, void 0, function* () {
|
|
654
660
|
try {
|
|
655
661
|
utils_2.trackCallback === null || utils_2.trackCallback === void 0 ? void 0 : (0, utils_2.trackCallback)({
|
|
656
|
-
details:
|
|
662
|
+
details: (0, i18n_1.t)('正在提交{{serverType}} {{serviceName}} 中,请稍候...', { serverType: ResourceTitle[serverType], serviceName }),
|
|
657
663
|
status: 'progress'
|
|
658
664
|
}, log);
|
|
659
665
|
yield cloudrunService.deploy({
|
|
660
666
|
serverName: serviceName,
|
|
661
667
|
targetPath: targetDir,
|
|
662
|
-
serverConfig: Object.assign({}, (port ? { Port: Number(port) } : {}))
|
|
668
|
+
serverConfig: Object.assign(Object.assign({}, (port ? { Port: Number(port) } : {})), { InstallDependency: installDependency !== 'false' })
|
|
663
669
|
});
|
|
664
670
|
utils_2.trackCallback === null || utils_2.trackCallback === void 0 ? void 0 : (0, utils_2.trackCallback)({
|
|
665
|
-
details:
|
|
671
|
+
details: (0, i18n_1.t)('提交{{serverType}} {{serviceName}} 已完成!', { serverType: ResourceTitle[serverType], serviceName }),
|
|
666
672
|
status: 'done'
|
|
667
673
|
}, log);
|
|
668
674
|
yield (0, utils_2.upsertCloudbaserc)(targetDir, {
|
|
@@ -670,7 +676,7 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
670
676
|
cloudrun: { name: serviceName }
|
|
671
677
|
});
|
|
672
678
|
(0, utils_2.trackCallback)({
|
|
673
|
-
details:
|
|
679
|
+
details: (0, i18n_1.t)('请打开链接查看部署状态: {{url}}', { url: `${utils_1.EUrl.DevPlatform}?envId=${envId}#/platform-run/service/detail?serverName=${serviceName}&tabId=deploy&envId=${envId}` })
|
|
674
680
|
}, log);
|
|
675
681
|
}
|
|
676
682
|
catch (e) {
|
|
@@ -680,7 +686,7 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
680
686
|
{
|
|
681
687
|
type: 'confirm',
|
|
682
688
|
name: 'confirm',
|
|
683
|
-
message: '平台当前有部署发布任务正在运行中。确认继续部署,正在执行的部署任务将被取消,并立即部署最新的代码',
|
|
689
|
+
message: (0, i18n_1.t)('平台当前有部署发布任务正在运行中。确认继续部署,正在执行的部署任务将被取消,并立即部署最新的代码'),
|
|
684
690
|
default: true
|
|
685
691
|
}
|
|
686
692
|
])
|
|
@@ -718,6 +724,7 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
718
724
|
details: `${e.message}`,
|
|
719
725
|
originalError: e
|
|
720
726
|
}, log);
|
|
727
|
+
throw e;
|
|
721
728
|
}
|
|
722
729
|
}
|
|
723
730
|
});
|
|
@@ -748,61 +755,51 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
748
755
|
options: [
|
|
749
756
|
{
|
|
750
757
|
flags: '--runMode <runMode>',
|
|
751
|
-
desc: '运行模式,可选值: normal(普通函数) | agent(函数式 Agent),默认值: normal'
|
|
758
|
+
desc: (0, i18n_1.t)('运行模式,可选值: normal(普通函数) | agent(函数式 Agent),默认值: normal')
|
|
752
759
|
},
|
|
753
760
|
{
|
|
754
761
|
flags: '--agentId <agentId>',
|
|
755
|
-
desc: '在 agent 模式下需要提供 Agent ID 进行调试'
|
|
762
|
+
desc: (0, i18n_1.t)('在 agent 模式下需要提供 Agent ID 进行调试')
|
|
756
763
|
},
|
|
757
764
|
{
|
|
758
765
|
flags: '-e, --envId <envId>',
|
|
759
|
-
desc: '环境 ID'
|
|
766
|
+
desc: (0, i18n_1.t)('环境 ID')
|
|
760
767
|
},
|
|
761
768
|
{
|
|
762
769
|
flags: '--port <port>',
|
|
763
|
-
desc:
|
|
764
|
-
`
|
|
770
|
+
desc: (0, i18n_1.t)('监听的端口,默认为 3000')
|
|
765
771
|
},
|
|
766
772
|
{
|
|
767
773
|
flags: '-w, --watch',
|
|
768
|
-
desc:
|
|
769
|
-
`
|
|
774
|
+
desc: (0, i18n_1.t)('是否启用热重启模式,如启用,将会在文件变更时自动重启服务,默认为 false')
|
|
770
775
|
},
|
|
771
776
|
{
|
|
772
777
|
flags: '--dry-run',
|
|
773
|
-
desc:
|
|
774
|
-
`
|
|
778
|
+
desc: (0, i18n_1.t)('是否不启动服务,只验证代码可以正常加载,默认为 false')
|
|
775
779
|
},
|
|
776
780
|
{
|
|
777
781
|
flags: '--logDirname <logDirname>',
|
|
778
|
-
desc:
|
|
779
|
-
`
|
|
782
|
+
desc: (0, i18n_1.t)('日志文件目录,默认为 ./logs')
|
|
780
783
|
},
|
|
781
784
|
{
|
|
782
785
|
flags: '--functionsConfigFile <functionsConfigFile>',
|
|
783
|
-
desc:
|
|
784
|
-
环境变量: FUNCTIONS_CONFIG_FILE
|
|
785
|
-
`
|
|
786
|
+
desc: (0, i18n_1.t)('多函数定义配置文件,默认为 ./cloudbase-functions.json。环境变量: FUNCTIONS_CONFIG_FILE')
|
|
786
787
|
},
|
|
787
788
|
{
|
|
788
789
|
flags: '--loadAllFunctions',
|
|
789
|
-
desc:
|
|
790
|
-
`
|
|
790
|
+
desc: (0, i18n_1.t)('是否加载 "functionsRoot" 目录中的所有函数。默认为 false')
|
|
791
791
|
},
|
|
792
792
|
{
|
|
793
793
|
flags: '--extendedContext <extendedContext>',
|
|
794
|
-
desc:
|
|
795
|
-
示例:--extendedContext '{"a":1,"b":2}'
|
|
796
|
-
环境变量:EXTENDED_CONTEXT
|
|
797
|
-
`
|
|
794
|
+
desc: (0, i18n_1.t)('用于解析 context.extendedContext 的值。""表示该功能已关闭。默认值为 null。示例:--extendedContext \'{"a":1,"b":2}\'。环境变量:EXTENDED_CONTEXT')
|
|
798
795
|
},
|
|
799
796
|
{
|
|
800
797
|
flags: '--open-debug-panel <openDebugPanel>',
|
|
801
|
-
desc: '是否打开调试面板,默认为 \'true\''
|
|
798
|
+
desc: (0, i18n_1.t)('是否打开调试面板,默认为 \'true\'')
|
|
802
799
|
}
|
|
803
800
|
],
|
|
804
801
|
requiredEnvId: false,
|
|
805
|
-
desc: '本地运行函数型云托管服务(不支持容器型云托管服务)'
|
|
802
|
+
desc: (0, i18n_1.t)('本地运行函数型云托管服务(不支持容器型云托管服务)')
|
|
806
803
|
};
|
|
807
804
|
}
|
|
808
805
|
execute(envId, logger, ctx, options) {
|
|
@@ -810,7 +807,7 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
810
807
|
debugger;
|
|
811
808
|
let { runMode = 'normal', agentId, openDebugPanel = true } = options;
|
|
812
809
|
const type = runMode;
|
|
813
|
-
console.log(chalk_1.default.green(
|
|
810
|
+
console.log(chalk_1.default.green((0, i18n_1.t)('当前运行模式: {{type}}', { type })));
|
|
814
811
|
if (!process.argv.some((arg) => arg.includes('--dotEnvFilePath='))) {
|
|
815
812
|
process.argv.push('--dotEnvFilePath=.env.local');
|
|
816
813
|
}
|
|
@@ -826,22 +823,22 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
826
823
|
envId = yield _selectEnv();
|
|
827
824
|
}
|
|
828
825
|
}
|
|
829
|
-
logger.info(
|
|
826
|
+
logger.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
830
827
|
if (type === 'agent') {
|
|
831
828
|
if (!agentId) {
|
|
832
829
|
const answers = yield inquirer_1.default.prompt([
|
|
833
830
|
{
|
|
834
831
|
type: 'input',
|
|
835
832
|
name: 'agentId',
|
|
836
|
-
message: '请输入 Agent ID(如没有请填写任意值):',
|
|
833
|
+
message: (0, i18n_1.t)('请输入 Agent ID(如没有请填写任意值):'),
|
|
837
834
|
validate: (val) => {
|
|
838
|
-
return val.trim() ? true : 'Agent ID 不能为空';
|
|
835
|
+
return val.trim() ? true : (0, i18n_1.t)('Agent ID 不能为空');
|
|
839
836
|
}
|
|
840
837
|
}
|
|
841
838
|
]);
|
|
842
839
|
agentId = answers.agentId;
|
|
843
840
|
}
|
|
844
|
-
logger.info(
|
|
841
|
+
logger.info((0, i18n_1.t)('当前 Agent ID: {{agentId}}', { agentId }));
|
|
845
842
|
}
|
|
846
843
|
const credential = yield (0, utils_2.getCredential)(ctx, options);
|
|
847
844
|
process.env.EXTENDED_CONTEXT = JSON.stringify({
|
|
@@ -931,7 +928,7 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
931
928
|
console.log(data.toString());
|
|
932
929
|
});
|
|
933
930
|
child.on('exit', (code) => {
|
|
934
|
-
console.log(
|
|
931
|
+
console.log((0, i18n_1.t)('子进程退出,退出码 {{code}}', { code }));
|
|
935
932
|
});
|
|
936
933
|
}
|
|
937
934
|
});
|
|
@@ -941,10 +938,10 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
941
938
|
let url = `http://127.0.0.1:${port}/cloudrun-run-ui/index.html?type=${type}&envId=${envId}&port=${port}`;
|
|
942
939
|
if (type === 'agent') {
|
|
943
940
|
url += `&agentId=${agentId}`;
|
|
944
|
-
console.log(chalk_1.default.green(
|
|
941
|
+
console.log(chalk_1.default.green((0, i18n_1.t)('点击 [{{url}}] 可以打开 Agent 调试应用', { url })));
|
|
945
942
|
}
|
|
946
943
|
else {
|
|
947
|
-
console.log(chalk_1.default.green(
|
|
944
|
+
console.log(chalk_1.default.green((0, i18n_1.t)('点击 [{{url}}] 可以打开函数调试面板', { url })));
|
|
948
945
|
}
|
|
949
946
|
if (isOpen) {
|
|
950
947
|
yield this.waitForPort(url);
|
|
@@ -970,7 +967,7 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
970
967
|
}
|
|
971
968
|
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
972
969
|
}
|
|
973
|
-
throw new Error(
|
|
970
|
+
throw new Error((0, i18n_1.t)('等待服务{{url}}就绪超时', { url }));
|
|
974
971
|
});
|
|
975
972
|
}
|
|
976
973
|
};
|
|
@@ -999,7 +996,7 @@ function _inputServiceName(defaultVal = '') {
|
|
|
999
996
|
{
|
|
1000
997
|
type: 'input',
|
|
1001
998
|
name: 'serviceName',
|
|
1002
|
-
message: '请输入服务名称',
|
|
999
|
+
message: (0, i18n_1.t)('请输入服务名称'),
|
|
1003
1000
|
default: defaultVal,
|
|
1004
1001
|
validate: (val) => {
|
|
1005
1002
|
const isValid = !val.startsWith('lcap') &&
|
|
@@ -1007,7 +1004,7 @@ function _inputServiceName(defaultVal = '') {
|
|
|
1007
1004
|
/^[A-Za-z][\w-_]{0,43}[A-Za-z0-9]$/.test(val);
|
|
1008
1005
|
return isValid
|
|
1009
1006
|
? true
|
|
1010
|
-
: '支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符';
|
|
1007
|
+
: (0, i18n_1.t)('支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符');
|
|
1011
1008
|
}
|
|
1012
1009
|
}
|
|
1013
1010
|
];
|
|
@@ -1021,7 +1018,7 @@ function _inputTargetPath(defaultVal = process.cwd()) {
|
|
|
1021
1018
|
{
|
|
1022
1019
|
type: 'input',
|
|
1023
1020
|
name: 'targetPath',
|
|
1024
|
-
message: '请输入目标路径(目录名称或绝对路径)',
|
|
1021
|
+
message: (0, i18n_1.t)('请输入目标路径(目录名称或绝对路径)'),
|
|
1025
1022
|
default: defaultVal,
|
|
1026
1023
|
validate: (val) => {
|
|
1027
1024
|
try {
|
|
@@ -1029,7 +1026,7 @@ function _inputTargetPath(defaultVal = process.cwd()) {
|
|
|
1029
1026
|
return true;
|
|
1030
1027
|
}
|
|
1031
1028
|
catch (e) {
|
|
1032
|
-
return '请输入有效的路径';
|
|
1029
|
+
return (0, i18n_1.t)('请输入有效的路径');
|
|
1033
1030
|
}
|
|
1034
1031
|
},
|
|
1035
1032
|
filter: (val) => {
|