@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.
Files changed (167) hide show
  1. package/bin/cloudbase.js +2 -1
  2. package/bin/tcb.js +35 -28
  3. package/cloudbase-cli-2.7.8.tgz +0 -0
  4. package/lib/auth/login.js +21 -13
  5. package/lib/commands/account/login.js +43 -42
  6. package/lib/commands/account/logout.js +3 -2
  7. package/lib/commands/ai/index.js +13 -12
  8. package/lib/commands/cloudfunction/base.js +24 -26
  9. package/lib/commands/cloudrun/base.js +87 -96
  10. package/lib/commands/common.js +11 -10
  11. package/lib/commands/config/delete.js +72 -0
  12. package/lib/commands/config/get.js +69 -0
  13. package/lib/commands/config/index.js +21 -0
  14. package/lib/commands/config/interface.js +24 -0
  15. package/lib/commands/config/list.js +72 -0
  16. package/lib/commands/config/set.js +89 -0
  17. package/lib/commands/db/base.js +33 -32
  18. package/lib/commands/env/base.js +12 -11
  19. package/lib/commands/env/domain.js +24 -23
  20. package/lib/commands/env/login.js +31 -30
  21. package/lib/commands/fun/base.js +37 -36
  22. package/lib/commands/functions/alias/getRoute.js +5 -4
  23. package/lib/commands/functions/alias/setRoute.js +7 -6
  24. package/lib/commands/functions/code-download.js +15 -11
  25. package/lib/commands/functions/code-update.js +8 -7
  26. package/lib/commands/functions/concurrency/delete.js +5 -4
  27. package/lib/commands/functions/concurrency/list.js +6 -5
  28. package/lib/commands/functions/concurrency/set.js +5 -4
  29. package/lib/commands/functions/config-update.js +8 -7
  30. package/lib/commands/functions/copy.js +7 -6
  31. package/lib/commands/functions/delete.js +8 -7
  32. package/lib/commands/functions/deploy.js +35 -34
  33. package/lib/commands/functions/detail.js +32 -31
  34. package/lib/commands/functions/invoke.js +16 -15
  35. package/lib/commands/functions/layer/bind.js +26 -25
  36. package/lib/commands/functions/layer/common.js +2 -1
  37. package/lib/commands/functions/layer/create.js +7 -6
  38. package/lib/commands/functions/layer/delete.js +9 -8
  39. package/lib/commands/functions/layer/download.js +10 -9
  40. package/lib/commands/functions/layer/list.js +10 -9
  41. package/lib/commands/functions/layer/sort.js +9 -8
  42. package/lib/commands/functions/list.js +9 -8
  43. package/lib/commands/functions/log.js +28 -27
  44. package/lib/commands/functions/run.js +21 -20
  45. package/lib/commands/functions/trigger-create.js +9 -8
  46. package/lib/commands/functions/trigger-delete.js +10 -9
  47. package/lib/commands/functions/version/list.js +9 -8
  48. package/lib/commands/functions/version/publish.js +5 -4
  49. package/lib/commands/gateway/create.js +14 -13
  50. package/lib/commands/gateway/delete.js +10 -9
  51. package/lib/commands/gateway/domain.js +25 -24
  52. package/lib/commands/gateway/list.js +11 -10
  53. package/lib/commands/gateway/switch.js +22 -19
  54. package/lib/commands/helpers/init.js +38 -37
  55. package/lib/commands/helpers/new.js +7 -6
  56. package/lib/commands/helpers/open.js +7 -6
  57. package/lib/commands/hosting/hosting.js +45 -44
  58. package/lib/commands/index.js +1 -0
  59. package/lib/commands/pull/pull.js +12 -11
  60. package/lib/commands/run/delete.js +16 -15
  61. package/lib/commands/run/image/common.js +2 -1
  62. package/lib/commands/run/image/delete.js +10 -9
  63. package/lib/commands/run/image/download.js +8 -7
  64. package/lib/commands/run/image/list.js +11 -10
  65. package/lib/commands/run/image/upload.js +9 -8
  66. package/lib/commands/run/list.js +10 -9
  67. package/lib/commands/run/service/config.js +13 -12
  68. package/lib/commands/run/service/deploy.js +24 -23
  69. package/lib/commands/run/service/list.js +10 -9
  70. package/lib/commands/run/service/update.js +22 -21
  71. package/lib/commands/run/standalonegateway/common.js +2 -1
  72. package/lib/commands/run/standalonegateway/create.js +14 -13
  73. package/lib/commands/run/standalonegateway/destroy.js +9 -8
  74. package/lib/commands/run/standalonegateway/list.js +7 -6
  75. package/lib/commands/run/standalonegateway/package.js +7 -6
  76. package/lib/commands/run/standalonegateway/turn.js +10 -9
  77. package/lib/commands/run/version/common.js +2 -1
  78. package/lib/commands/run/version/create.js +41 -40
  79. package/lib/commands/run/version/delete.js +10 -9
  80. package/lib/commands/run/version/list.js +13 -12
  81. package/lib/commands/run/version/modify.js +13 -12
  82. package/lib/commands/run/version/update.js +57 -54
  83. package/lib/commands/runf/base.js +42 -40
  84. package/lib/commands/self-update.js +11 -10
  85. package/lib/commands/smart.js +5 -4
  86. package/lib/commands/storage/storage.js +61 -56
  87. package/lib/commands/third/thirdAttach.js +6 -5
  88. package/lib/commands/utils.js +8 -5
  89. package/lib/constant.js +18 -17
  90. package/lib/decorators/deprecate.js +2 -1
  91. package/lib/function/alias.js +3 -2
  92. package/lib/function/base.js +9 -8
  93. package/lib/function/concurrency.js +4 -3
  94. package/lib/function/create.js +5 -4
  95. package/lib/function/delete.js +2 -1
  96. package/lib/function/layer/attach.js +2 -1
  97. package/lib/function/layer/create.js +2 -1
  98. package/lib/function/layer/download.js +2 -1
  99. package/lib/function/trigger.js +6 -5
  100. package/lib/function/update.js +3 -2
  101. package/lib/function/version.js +3 -2
  102. package/lib/help.js +22 -20
  103. package/lib/hosting.js +18 -17
  104. package/lib/i18n/index.js +81 -0
  105. package/lib/run/service/common.js +14 -13
  106. package/lib/run/service/config.js +4 -3
  107. package/lib/run/service/deployPackage.js +6 -5
  108. package/lib/run/service/showLogs.js +3 -2
  109. package/lib/run/service/update.js +7 -6
  110. package/lib/run/standalonegateway/list.js +5 -1
  111. package/lib/storage.js +2 -1
  112. package/lib/utils/ai/banner.js +12 -11
  113. package/lib/utils/ai/claudeWindows.js +5 -3
  114. package/lib/utils/ai/config.js +3 -2
  115. package/lib/utils/ai/const.js +4 -3
  116. package/lib/utils/ai/env.js +3 -2
  117. package/lib/utils/ai/envLocalManager.js +6 -5
  118. package/lib/utils/ai/nodeVersion.js +5 -1
  119. package/lib/utils/ai/router.js +129 -106
  120. package/lib/utils/ai/setup.js +95 -91
  121. package/lib/utils/checkTcbrEnv.js +22 -21
  122. package/lib/utils/cli-table.js +2 -1
  123. package/lib/utils/commonParamsCheck.js +4 -3
  124. package/lib/utils/debug-logger.js +2 -1
  125. package/lib/utils/dts.js +4 -3
  126. package/lib/utils/env.js +23 -21
  127. package/lib/utils/fs/index.js +5 -4
  128. package/lib/utils/function-packer.js +3 -2
  129. package/lib/utils/index.js +1 -0
  130. package/lib/utils/mcp-config-modifier.js +18 -17
  131. package/lib/utils/net/cloud-api-request.js +2 -1
  132. package/lib/utils/net/credential.js +2 -1
  133. package/lib/utils/net/http-request.js +2 -1
  134. package/lib/utils/progress-bar.js +2 -1
  135. package/lib/utils/prompt/select.js +8 -6
  136. package/lib/utils/store/auth.js +3 -2
  137. package/lib/utils/store/config.js +49 -0
  138. package/lib/utils/store/db.js +5 -0
  139. package/lib/utils/store/index.js +1 -1
  140. package/lib/utils/tcbrApi/callTcbrApi.js +2 -1
  141. package/lib/utils/template-manager.js +37 -36
  142. package/lib/utils/template.js +10 -9
  143. package/lib/utils/tools/common.js +3 -2
  144. package/lib/utils/url.js +19 -0
  145. package/lib/utils/validator.js +12 -4
  146. package/locales/README.md +160 -0
  147. package/locales/i18next-scanner.config.js +206 -0
  148. package/locales/langs/en.json +1235 -0
  149. package/locales/langs/zh.json +1235 -0
  150. package/locales/mapping.json +1235 -0
  151. package/package.json +10 -3
  152. package/types/commands/config/delete.d.ts +13 -0
  153. package/types/commands/config/get.d.ts +13 -0
  154. package/types/commands/config/index.d.ts +5 -0
  155. package/types/commands/config/interface.d.ts +17 -0
  156. package/types/commands/config/list.d.ts +13 -0
  157. package/types/commands/config/set.d.ts +13 -0
  158. package/types/commands/index.d.ts +1 -0
  159. package/types/i18n/index.d.ts +3 -0
  160. package/types/utils/ai/const.d.ts +1 -1
  161. package/types/utils/index.d.ts +1 -0
  162. package/types/utils/store/config.d.ts +8 -0
  163. package/types/utils/store/db.d.ts +2 -0
  164. package/types/utils/store/index.d.ts +1 -1
  165. package/types/utils/url.d.ts +18 -0
  166. package/dist/standalone/ccr.js +0 -78668
  167. package/dist/standalone/cli.js +0 -626422
@@ -30,23 +30,24 @@ const common_1 = require("../common");
30
30
  const error_1 = require("../../error");
31
31
  const decorators_1 = require("../../decorators");
32
32
  const function_1 = require("../../function");
33
+ const i18n_1 = require("../../i18n");
33
34
  let ConfigUpdate = class ConfigUpdate extends common_1.Command {
34
35
  get options() {
35
36
  return {
36
37
  cmd: 'fn',
37
38
  childCmd: {
38
39
  cmd: 'config',
39
- desc: '函数配置管理'
40
+ desc: (0, i18n_1.t)('函数配置管理')
40
41
  },
41
42
  childSubCmd: 'update [name]',
42
43
  deprecateCmd: 'functions:config:update [name]',
43
44
  options: [
44
45
  {
45
46
  flags: '-e, --envId <envId>',
46
- desc: '环境 Id'
47
+ desc: (0, i18n_1.t)('环境 Id')
47
48
  }
48
49
  ],
49
- desc: '更新云函数配置'
50
+ desc: (0, i18n_1.t)('更新云函数配置')
50
51
  };
51
52
  }
52
53
  execute(ctx, params, log) {
@@ -58,12 +59,12 @@ let ConfigUpdate = class ConfigUpdate extends common_1.Command {
58
59
  const { isBatch } = yield inquirer_1.default.prompt({
59
60
  type: 'confirm',
60
61
  name: 'isBatch',
61
- message: '无云函数名称,是否需要更新配置文件中的【全部云函数】的配置?',
62
+ message: (0, i18n_1.t)('无云函数名称,是否需要更新配置文件中的【全部云函数】的配置?'),
62
63
  default: false
63
64
  });
64
65
  isBathUpdate = isBatch;
65
66
  if (!isBathUpdate) {
66
- throw new error_1.CloudBaseError('请指定云函数名称!');
67
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
67
68
  }
68
69
  }
69
70
  if (isBathUpdate) {
@@ -76,14 +77,14 @@ let ConfigUpdate = class ConfigUpdate extends common_1.Command {
76
77
  }
77
78
  const functionItem = functions.find((item) => item.name === name);
78
79
  if (!functionItem) {
79
- throw new error_1.CloudBaseError('未找到相关函数配置,请检查函数名是否正确');
80
+ throw new error_1.CloudBaseError((0, i18n_1.t)('未找到相关函数配置,请检查函数名是否正确'));
80
81
  }
81
82
  yield (0, function_1.updateFunctionConfig)({
82
83
  envId,
83
84
  functionName: name,
84
85
  config: functionItem
85
86
  });
86
- log.success(`[${name}] 更新云函数配置成功!`);
87
+ log.success((0, i18n_1.t)('[{{name}}] 更新云函数配置成功!', { name }));
87
88
  });
88
89
  }
89
90
  };
@@ -26,6 +26,7 @@ const common_1 = require("../common");
26
26
  const error_1 = require("../../error");
27
27
  const function_1 = require("../../function");
28
28
  const decorators_1 = require("../../decorators");
29
+ const i18n_1 = require("../../i18n");
29
30
  let FunctionCopy = class FunctionCopy extends common_1.Command {
30
31
  get options() {
31
32
  return {
@@ -35,18 +36,18 @@ let FunctionCopy = class FunctionCopy extends common_1.Command {
35
36
  options: [
36
37
  {
37
38
  flags: '-e, --envId <envId>',
38
- desc: '环境 Id'
39
+ desc: (0, i18n_1.t)('环境 Id')
39
40
  },
40
41
  {
41
42
  flags: '-t, --target <targetEnvId>',
42
- desc: '目标环境 Id'
43
+ desc: (0, i18n_1.t)('目标环境 Id')
43
44
  },
44
45
  {
45
46
  flags: '--force',
46
- desc: '如果目标环境下存在同名函数,覆盖原函数'
47
+ desc: (0, i18n_1.t)('如果目标环境下存在同名函数,覆盖原函数')
47
48
  }
48
49
  ],
49
- desc: '拷贝云函数'
50
+ desc: (0, i18n_1.t)('拷贝云函数')
50
51
  };
51
52
  }
52
53
  execute(envId, options, params, log) {
@@ -55,13 +56,13 @@ let FunctionCopy = class FunctionCopy extends common_1.Command {
55
56
  let newFunctionName = params === null || params === void 0 ? void 0 : params[1];
56
57
  let { force, codeSecret, targetEnvId } = options;
57
58
  if (!name) {
58
- throw new error_1.CloudBaseError('请指定函数名称!');
59
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定函数名称!'));
59
60
  }
60
61
  const functionService = yield (0, function_1.getFunctionService)(envId);
61
62
  newFunctionName = newFunctionName || name;
62
63
  targetEnvId = targetEnvId || envId;
63
64
  yield functionService.copyFunction(name, newFunctionName, targetEnvId, force);
64
- log.success('拷贝函数成功');
65
+ log.success((0, i18n_1.t)('拷贝函数成功'));
65
66
  });
66
67
  }
67
68
  };
@@ -31,6 +31,7 @@ const error_1 = require("../../error");
31
31
  const utils_1 = require("../../utils");
32
32
  const function_1 = require("../../function");
33
33
  const decorators_1 = require("../../decorators");
34
+ const i18n_1 = require("../../i18n");
34
35
  let DeleteFunction = class DeleteFunction extends common_1.Command {
35
36
  get options() {
36
37
  return {
@@ -40,10 +41,10 @@ let DeleteFunction = class DeleteFunction extends common_1.Command {
40
41
  options: [
41
42
  {
42
43
  flags: '-e, --envId <envId>',
43
- desc: '环境 Id'
44
+ desc: (0, i18n_1.t)('环境 Id')
44
45
  }
45
46
  ],
46
- desc: '删除云函数'
47
+ desc: (0, i18n_1.t)('删除云函数')
47
48
  };
48
49
  }
49
50
  execute(ctx, params) {
@@ -56,20 +57,20 @@ let DeleteFunction = class DeleteFunction extends common_1.Command {
56
57
  const answer = yield inquirer_1.default.prompt({
57
58
  type: 'confirm',
58
59
  name: 'isBatch',
59
- message: '无云函数名称,是否需要删除配置文件中的全部云函数?',
60
+ message: (0, i18n_1.t)('无云函数名称,是否需要删除配置文件中的全部云函数?'),
60
61
  default: false
61
62
  });
62
63
  if (answer.isBatch) {
63
64
  const { reConfirm } = yield inquirer_1.default.prompt({
64
65
  type: 'confirm',
65
66
  name: 'reConfirm',
66
- message: '确定要删除配置文件中的全部云函数?',
67
+ message: (0, i18n_1.t)('确定要删除配置文件中的全部云函数?'),
67
68
  default: false
68
69
  });
69
70
  isBatchDelete = reConfirm;
70
71
  }
71
72
  if (!isBatchDelete) {
72
- throw new error_1.CloudBaseError('请指定需要删除的云函数名称!');
73
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要删除的云函数名称!'));
73
74
  }
74
75
  }
75
76
  if (isBatchDelete) {
@@ -79,11 +80,11 @@ let DeleteFunction = class DeleteFunction extends common_1.Command {
79
80
  });
80
81
  }
81
82
  const loading = (0, utils_1.loadingFactory)();
82
- loading.start(`删除函数 [${name}] 中...`);
83
+ loading.start((0, i18n_1.t)('删除函数 [{{name}}] 中...', { name }));
83
84
  yield functionService.deleteFunction({
84
85
  name
85
86
  });
86
- loading.succeed(`删除函数 [${name}] 成功!`);
87
+ loading.succeed((0, i18n_1.t)('删除函数 [{{name}}] 成功!', { name }));
87
88
  });
88
89
  }
89
90
  };
@@ -36,6 +36,7 @@ const utils_1 = require("../../utils");
36
36
  const constant_1 = require("../../constant");
37
37
  const decorators_1 = require("../../decorators");
38
38
  const function_2 = require("../../function");
39
+ const i18n_1 = require("../../i18n");
39
40
  const regionIdMap = {
40
41
  'ap-guangzhou': 1,
41
42
  'ap-shanghai': 4,
@@ -50,30 +51,30 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
50
51
  options: [
51
52
  {
52
53
  flags: '-e, --envId <envId>',
53
- desc: '环境 Id'
54
+ desc: (0, i18n_1.t)('环境 Id')
54
55
  },
55
56
  {
56
57
  flags: '--code-secret <codeSecret>',
57
- desc: '传入此参数将保护代码,格式为 36 位大小写字母和数字'
58
+ desc: (0, i18n_1.t)('传入此参数将保护代码,格式为 36 位大小写字母和数字')
58
59
  },
59
60
  {
60
61
  flags: '--force',
61
- desc: '如果存在同名函数,上传后覆盖同名函数'
62
+ desc: (0, i18n_1.t)('如果存在同名函数,上传后覆盖同名函数')
62
63
  },
63
64
  {
64
65
  flags: '--path <path>',
65
- desc: '自动创建HTTP 访问服务访问路径'
66
+ desc: (0, i18n_1.t)('自动创建HTTP 访问服务访问路径')
66
67
  },
67
68
  {
68
69
  flags: '--all',
69
- desc: '部署配置文件中的包含的全部云函数'
70
+ desc: (0, i18n_1.t)('部署配置文件中的包含的全部云函数')
70
71
  },
71
72
  {
72
73
  flags: '--dir <dir>',
73
- desc: '指定云函数的文件夹路径'
74
+ desc: (0, i18n_1.t)('指定云函数的文件夹路径')
74
75
  }
75
76
  ],
76
- desc: '部署云函数'
77
+ desc: (0, i18n_1.t)('部署云函数')
77
78
  };
78
79
  }
79
80
  execute(ctx, params, log) {
@@ -84,10 +85,10 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
84
85
  const functionRootPath = path_1.default.join(process.cwd(), config.functionRoot);
85
86
  const name = params === null || params === void 0 ? void 0 : params[0];
86
87
  if (access && (0, utils_1.checkFullAccess)(access)) {
87
- log.warn('--path 参数已更换为HTTP 访问服务路径,请使用 --dir 指定部署函数的文件夹路径');
88
+ log.warn((0, i18n_1.t)('--path 参数已更换为HTTP 访问服务路径,请使用 --dir 指定部署函数的文件夹路径'));
88
89
  }
89
90
  if (access && access[0] !== '/') {
90
- throw new error_1.CloudBaseError('HTTP 访问服务路径必须以 / 开头');
91
+ throw new error_1.CloudBaseError((0, i18n_1.t)('HTTP 访问服务路径必须以 / 开头'));
91
92
  }
92
93
  if ((!name && !dir) || all) {
93
94
  return this.deployAllFunction({
@@ -103,7 +104,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
103
104
  if (dir) {
104
105
  (0, utils_1.checkFullAccess)(dir, true);
105
106
  if (!(0, utils_1.isDirectory)(dir)) {
106
- throw new error_1.CloudBaseError('--dir 参数必须指定为云函数的文件夹路径');
107
+ throw new error_1.CloudBaseError((0, i18n_1.t)('--dir 参数必须指定为云函数的文件夹路径'));
107
108
  }
108
109
  }
109
110
  let newFunction;
@@ -111,11 +112,11 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
111
112
  newFunction = functions.find((item) => item.name === name);
112
113
  }
113
114
  if (!newFunction || !newFunction.name) {
114
- log.info('未找到函数发布配置,使用默认配置 => 运行时:Nodejs10.15/在线安装依赖');
115
+ log.info((0, i18n_1.t)('未找到函数发布配置,使用默认配置 => 运行时:Nodejs10.15/在线安装依赖'));
115
116
  newFunction = Object.assign({ name }, constant_1.DefaultFunctionDeployConfig);
116
117
  }
117
118
  const loading = (0, utils_1.loadingFactory)();
118
- loading.start('云函数部署中...');
119
+ loading.start((0, i18n_1.t)('云函数部署中...'));
119
120
  try {
120
121
  yield (0, function_1.createFunction)({
121
122
  force,
@@ -126,7 +127,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
126
127
  accessPath: access,
127
128
  functionPath: dir
128
129
  });
129
- loading.succeed(`[${newFunction.name}] 云函数部署成功!`);
130
+ loading.succeed((0, i18n_1.t)('[{{name}}] 云函数部署成功!', { name: newFunction.name }));
130
131
  this.printSuccessTips(envId);
131
132
  }
132
133
  catch (e) {
@@ -142,7 +143,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
142
143
  }
143
144
  if (access || newFunction.path) {
144
145
  const link = (0, utils_1.genClickableLink)(`https://${envId}.service.tcloudbase.com${access || newFunction.path}`);
145
- console.log(`\n云函数HTTP 访问服务访问链接:${link}`);
146
+ console.log((0, i18n_1.t)('\n云函数HTTP 访问服务访问链接:{{link}}', { link }));
146
147
  }
147
148
  });
148
149
  }
@@ -153,16 +154,16 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
153
154
  const { isBatch } = yield inquirer_1.default.prompt({
154
155
  type: 'confirm',
155
156
  name: 'isBatch',
156
- message: '没有指定需要部署的云函数,是否部署配置文件中的全部云函数?',
157
+ message: (0, i18n_1.t)('没有指定需要部署的云函数,是否部署配置文件中的全部云函数?'),
157
158
  default: false
158
159
  });
159
160
  if (!isBatch) {
160
- throw new error_1.CloudBaseError('请指定需要部署的云函数的名称或通过 --path 参数指定需要部署的函数的路径!');
161
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要部署的云函数的名称或通过 --path 参数指定需要部署的函数的路径!'));
161
162
  }
162
163
  }
163
164
  const loading = (0, utils_1.loadingFactory)();
164
165
  const tasks = functions.map((func) => () => __awaiter(this, void 0, void 0, function* () {
165
- loading.start('云函数部署中');
166
+ loading.start((0, i18n_1.t)('云函数部署中'));
166
167
  try {
167
168
  yield (0, function_1.createFunction)({
168
169
  func,
@@ -172,7 +173,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
172
173
  functionRootPath,
173
174
  accessPath: access
174
175
  });
175
- loading.succeed(`[${func.name}] 云函数部署成功`);
176
+ loading.succeed((0, i18n_1.t)('[{{name}}] 云函数部署成功', { name: func.name }));
176
177
  }
177
178
  catch (e) {
178
179
  loading.stop();
@@ -186,15 +187,15 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
186
187
  }
187
188
  }));
188
189
  if (tasks.length > 5) {
189
- utils_1.logger.info('函数数量较多,将使用队列部署');
190
+ utils_1.logger.info((0, i18n_1.t)('函数数量较多,将使用队列部署'));
190
191
  }
191
192
  const asyncTaskController = new utils_1.AsyncTaskParallelController(5, 50);
192
193
  asyncTaskController.loadTasks(tasks);
193
194
  const results = yield asyncTaskController.run();
194
195
  const success = results.filter((_) => !_);
195
- utils_1.logger.success(`成功部署 ${success === null || success === void 0 ? void 0 : success.length} 个函数`);
196
+ utils_1.logger.success((0, i18n_1.t)('成功部署 {{count}} 个函数', { count: success === null || success === void 0 ? void 0 : success.length }));
196
197
  const err = results.filter((_) => _);
197
- (err === null || err === void 0 ? void 0 : err.length) && utils_1.logger.error(`${err === null || err === void 0 ? void 0 : err.length} 个云函数部署失败`);
198
+ (err === null || err === void 0 ? void 0 : err.length) && utils_1.logger.error((0, i18n_1.t)('{{count}} 个云函数部署失败', { count: err === null || err === void 0 ? void 0 : err.length }));
198
199
  });
199
200
  }
200
201
  handleDeployFail(e, options) {
@@ -205,12 +206,12 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
205
206
  const { force } = yield inquirer_1.default.prompt({
206
207
  type: 'confirm',
207
208
  name: 'force',
208
- message: `存在同名云函数:[${func.name}],是否覆盖原函数代码与配置`,
209
+ message: (0, i18n_1.t)('存在同名云函数:[{{name}}],是否覆盖原函数代码与配置', { name: func.name }),
209
210
  default: false
210
211
  });
211
212
  const { triggers } = func;
212
213
  if (force) {
213
- loading.start('云函数更新部署中...');
214
+ loading.start((0, i18n_1.t)('云函数更新部署中...'));
214
215
  try {
215
216
  yield (0, function_2.updateFunctionCode)({
216
217
  func,
@@ -219,13 +220,13 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
219
220
  functionRootPath
220
221
  });
221
222
  yield this.waitForFunctionReady(envId, func.name, loading);
222
- loading.succeed(`[${func.name}] 云函数配置更新中...`);
223
+ loading.succeed((0, i18n_1.t)('[{{name}}] 云函数配置更新中...', { name: func.name }));
223
224
  yield (0, function_2.updateFunctionConfig)({
224
225
  envId,
225
226
  functionName: func.name,
226
227
  config: func
227
228
  });
228
- loading.succeed(`[${func.name}] 云函数更新成功!`);
229
+ loading.succeed((0, i18n_1.t)('[{{name}}] 云函数更新成功!', { name: func.name }));
229
230
  yield this.printSuccessTips(envId);
230
231
  }
231
232
  catch (e) {
@@ -246,7 +247,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
246
247
  let intervalId = null;
247
248
  const timeoutId = setTimeout(() => {
248
249
  clearInterval(intervalId);
249
- reject(new error_1.CloudBaseError(`[${functionName}] 等待函数更新超时,已等待 ${timeoutMinutes} 分钟`));
250
+ reject(new error_1.CloudBaseError((0, i18n_1.t)('[{{functionName}}] 等待函数更新超时,已等待 {{timeoutMinutes}} 分钟', { functionName, timeoutMinutes })));
250
251
  }, timeoutMs);
251
252
  intervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
252
253
  try {
@@ -254,15 +255,15 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
254
255
  if ((functionInfo === null || functionInfo === void 0 ? void 0 : functionInfo.Status) === 'Active') {
255
256
  clearTimeout(timeoutId);
256
257
  clearInterval(intervalId);
257
- loading.succeed(`[${functionName}] 云函数代码已更新!`);
258
+ loading.succeed((0, i18n_1.t)('[{{functionName}}] 云函数代码已更新!', { functionName }));
258
259
  resolve();
259
260
  }
260
261
  else {
261
- loading.text = `正在更新[${functionName}] 云函数代码... 当前状态: ${(functionInfo === null || functionInfo === void 0 ? void 0 : functionInfo.Status) || '未知'}`;
262
+ loading.text = (0, i18n_1.t)('正在更新[{{functionName}}] 云函数代码... 当前状态: {{status}}', { functionName, status: (functionInfo === null || functionInfo === void 0 ? void 0 : functionInfo.Status) || (0, i18n_1.t)('未知') });
262
263
  }
263
264
  }
264
265
  catch (error) {
265
- loading.text = `获取[${functionName}] 云函数状态失败,重试中...`;
266
+ loading.text = (0, i18n_1.t)('获取[{{functionName}}] 云函数状态失败,重试中...', { functionName });
266
267
  }
267
268
  }), 2000);
268
269
  });
@@ -270,13 +271,13 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
270
271
  }
271
272
  printSuccessTips(envId, log) {
272
273
  return __awaiter(this, void 0, void 0, function* () {
273
- let url = `https://console.cloud.tencent.com/tcb/scf?envId=${envId}`;
274
+ let url = `${utils_1.EUrl.TcbConsole}/scf?envId=${envId}`;
274
275
  const region = yield (0, toolbox_1.getRegion)();
275
276
  url += `&rid=${regionIdMap[region]}`;
276
277
  const link = (0, utils_1.genClickableLink)(url);
277
278
  log.breakLine();
278
- log.info(`控制台查看函数详情或创建HTTP 访问服务链接 🔗:${link}`);
279
- log.info(`使用 ${(0, utils_1.highlightCommand)('cloudbase functions:list')} 命令查看已部署云函数`);
279
+ log.info((0, i18n_1.t)('控制台查看函数详情或创建HTTP 访问服务链接 🔗:{{link}}', { link }));
280
+ log.info((0, i18n_1.t)('使用 {{command}} 命令查看已部署云函数', { command: (0, utils_1.highlightCommand)('cloudbase functions:list') }));
280
281
  });
281
282
  }
282
283
  genApiGateway(envId, name) {
@@ -289,7 +290,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
289
290
  });
290
291
  if ((res === null || res === void 0 ? void 0 : res.EnableService) === false)
291
292
  return;
292
- loading.start('生成云函数HTTP 访问服务中...');
293
+ loading.start((0, i18n_1.t)('生成云函数HTTP 访问服务中...'));
293
294
  let path;
294
295
  if (((_a = res === null || res === void 0 ? void 0 : res.APISet) === null || _a === void 0 ? void 0 : _a.length) > 0) {
295
296
  path = (_b = res.APISet[0]) === null || _b === void 0 ? void 0 : _b.Path;
@@ -304,7 +305,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
304
305
  }
305
306
  loading.stop();
306
307
  const link = (0, utils_1.genClickableLink)(`https://${envId}.service.tcloudbase.com${path}`);
307
- console.log(`\n云函数HTTP 访问服务链接:${link}`);
308
+ console.log((0, i18n_1.t)('\n云函数HTTP 访问服务链接:{{link}}', { link }));
308
309
  });
309
310
  }
310
311
  };
@@ -31,12 +31,13 @@ const error_1 = require("../../error");
31
31
  const function_1 = require("../../function");
32
32
  const utils_1 = require("../../utils");
33
33
  const decorators_1 = require("../../decorators");
34
+ const i18n_1 = require("../../i18n");
34
35
  const StatusMap = {
35
- Active: '部署完成',
36
- Creating: '创建中',
37
- CreateFailed: '创建失败',
38
- Updating: '更新中',
39
- UpdateFailed: '更新失败'
36
+ Active: (0, i18n_1.t)('部署完成'),
37
+ Creating: (0, i18n_1.t)('创建中'),
38
+ CreateFailed: (0, i18n_1.t)('创建失败'),
39
+ Updating: (0, i18n_1.t)('更新中'),
40
+ UpdateFailed: (0, i18n_1.t)('更新失败')
40
41
  };
41
42
  let FunctionDetail = class FunctionDetail extends common_1.Command {
42
43
  get options() {
@@ -47,14 +48,14 @@ let FunctionDetail = class FunctionDetail extends common_1.Command {
47
48
  options: [
48
49
  {
49
50
  flags: '-e, --envId <envId>',
50
- desc: '环境 Id'
51
+ desc: (0, i18n_1.t)('环境 Id')
51
52
  },
52
53
  {
53
54
  flags: '--code-secret <codeSecret>',
54
- desc: '代码加密的函数的 CodeSecret'
55
+ desc: (0, i18n_1.t)('代码加密的函数的 CodeSecret')
55
56
  }
56
57
  ],
57
- desc: '获取云函数信息'
58
+ desc: (0, i18n_1.t)('获取云函数信息')
58
59
  };
59
60
  }
60
61
  execute(ctx, params) {
@@ -63,10 +64,10 @@ let FunctionDetail = class FunctionDetail extends common_1.Command {
63
64
  const { codeSecret } = options;
64
65
  const name = params === null || params === void 0 ? void 0 : params[0];
65
66
  if (!name) {
66
- throw new error_1.CloudBaseError('请指定云函数名称!');
67
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
67
68
  }
68
69
  const loading = (0, utils_1.loadingFactory)();
69
- loading.start('获取函数信息中...');
70
+ loading.start((0, i18n_1.t)('获取函数信息中...'));
70
71
  const functionService = yield (0, function_1.getFunctionService)(envId);
71
72
  try {
72
73
  const data = yield functionService.getFunctionDetail(name, codeSecret);
@@ -75,7 +76,7 @@ let FunctionDetail = class FunctionDetail extends common_1.Command {
75
76
  }
76
77
  catch (e) {
77
78
  if (e.code === 'ResourceNotFound.FunctionName') {
78
- throw new error_1.CloudBaseError(`[${name}] 函数不存在`);
79
+ throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 函数不存在', { name }));
79
80
  }
80
81
  throw e;
81
82
  }
@@ -86,35 +87,35 @@ let FunctionDetail = class FunctionDetail extends common_1.Command {
86
87
  }
87
88
  logDetail(info, name, log) {
88
89
  const ResMap = {
89
- Namespace: '环境 Id',
90
- FunctionName: '函数名称',
91
- Status: '状态',
92
- CodeSize: '代码大小(B)',
93
- Environment: '环境变量(key=value)',
94
- Handler: '执行方法',
95
- MemorySize: '内存配置(MB)',
96
- Runtime: '运行环境',
97
- Timeout: '超时时间(S)',
98
- VpcConfig: '网络配置',
99
- Triggers: '触发器',
100
- ModTime: '修改时间',
101
- InstallDependency: '自动安装依赖'
90
+ Namespace: (0, i18n_1.t)('环境 Id'),
91
+ FunctionName: (0, i18n_1.t)('函数名称'),
92
+ Status: (0, i18n_1.t)('状态'),
93
+ CodeSize: (0, i18n_1.t)('代码大小(B)'),
94
+ Environment: (0, i18n_1.t)('环境变量(key=value)'),
95
+ Handler: (0, i18n_1.t)('执行方法'),
96
+ MemorySize: (0, i18n_1.t)('内存配置(MB)'),
97
+ Runtime: (0, i18n_1.t)('运行环境'),
98
+ Timeout: (0, i18n_1.t)('超时时间(S)'),
99
+ VpcConfig: (0, i18n_1.t)('网络配置'),
100
+ Triggers: (0, i18n_1.t)('触发器'),
101
+ ModTime: (0, i18n_1.t)('修改时间'),
102
+ InstallDependency: (0, i18n_1.t)('自动安装依赖')
102
103
  };
103
- const head = ['信息', '值'];
104
+ const head = [(0, i18n_1.t)('信息'), (0, i18n_1.t)('值')];
104
105
  const tableData = Object.keys(ResMap).map((key) => {
105
106
  if (key === 'Status') {
106
107
  return [ResMap[key], StatusMap[info[key]]];
107
108
  }
108
109
  if (key === 'Environment') {
109
110
  const data = info[key].Variables.map((item) => `${item.Key}=${item.Value}`).join('; ') ||
110
- '无';
111
+ (0, i18n_1.t)('无');
111
112
  return [ResMap[key], data];
112
113
  }
113
114
  if (key === 'Triggers') {
114
115
  let data = info[key]
115
116
  .map((item) => `${item.TriggerName}:${item.TriggerDesc}`)
116
117
  .join('\n');
117
- data = data.length ? `${data}\n` : '无';
118
+ data = data.length ? `${data}\n` : (0, i18n_1.t)('无');
118
119
  return [ResMap[key], data];
119
120
  }
120
121
  if (key === 'VpcConfig') {
@@ -127,7 +128,7 @@ let FunctionDetail = class FunctionDetail extends common_1.Command {
127
128
  return [ResMap[key], data];
128
129
  }
129
130
  else {
130
- return [ResMap[key], '无'];
131
+ return [ResMap[key], (0, i18n_1.t)('无')];
131
132
  }
132
133
  }
133
134
  if (key === 'CodeInfo') {
@@ -136,11 +137,11 @@ let FunctionDetail = class FunctionDetail extends common_1.Command {
136
137
  return [ResMap[key], info[key]];
137
138
  });
138
139
  if (info.StatusDesc) {
139
- tableData.push(['状态描述', info.StatusDesc]);
140
+ tableData.push([(0, i18n_1.t)('状态描述'), info.StatusDesc]);
140
141
  }
141
- log.info(chalk_1.default.green(`云函数 [${name}] 详情:`));
142
+ log.info(chalk_1.default.green((0, i18n_1.t)('云函数 [{{name}}] 详情:', { name })));
142
143
  (0, utils_1.printHorizontalTable)(head, tableData);
143
- log.info('函数代码(Java 函数以及入口大于 1 M 的函数不会显示)\n');
144
+ log.info((0, i18n_1.t)('函数代码(Java 函数以及入口大于 1 M 的函数不会显示)\n'));
144
145
  log.log(info['CodeInfo']);
145
146
  }
146
147
  };
@@ -31,6 +31,7 @@ const common_1 = require("../common");
31
31
  const error_1 = require("../../error");
32
32
  const function_1 = require("../../function");
33
33
  const decorators_1 = require("../../decorators");
34
+ const i18n_1 = require("../../i18n");
34
35
  let InvokeFunction = class InvokeFunction extends common_1.Command {
35
36
  get options() {
36
37
  return {
@@ -40,14 +41,14 @@ let InvokeFunction = class InvokeFunction extends common_1.Command {
40
41
  options: [
41
42
  {
42
43
  flags: '-e, --envId <envId>',
43
- desc: '环境 Id'
44
+ desc: (0, i18n_1.t)('环境 Id')
44
45
  },
45
46
  {
46
47
  flags: '--params <params>',
47
- desc: '调用函数的入参,JSON 字符串形式'
48
+ desc: (0, i18n_1.t)('调用函数的入参,JSON 字符串形式')
48
49
  }
49
50
  ],
50
- desc: '触发云端部署的云函数'
51
+ desc: (0, i18n_1.t)('触发云端部署的云函数')
51
52
  };
52
53
  }
53
54
  execute(ctx, argsParams, log) {
@@ -60,12 +61,12 @@ let InvokeFunction = class InvokeFunction extends common_1.Command {
60
61
  const { isBatch } = yield inquirer_1.default.prompt({
61
62
  type: 'confirm',
62
63
  name: 'isBatch',
63
- message: '无云函数名称,是否需要触发配置文件中的全部云函数?',
64
+ message: (0, i18n_1.t)('无云函数名称,是否需要触发配置文件中的全部云函数?'),
64
65
  default: false
65
66
  });
66
67
  isBatchInvoke = isBatch;
67
68
  if (!isBatchInvoke) {
68
- throw new error_1.CloudBaseError('请指定云函数名称!');
69
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
69
70
  }
70
71
  }
71
72
  let params;
@@ -76,7 +77,7 @@ let InvokeFunction = class InvokeFunction extends common_1.Command {
76
77
  }
77
78
  catch (e) {
78
79
  console.log(e);
79
- throw new error_1.CloudBaseError('jsonStringParams 参数不是正确的 JSON 字符串');
80
+ throw new error_1.CloudBaseError((0, i18n_1.t)('jsonStringParams 参数不是正确的 JSON 字符串'));
80
81
  }
81
82
  }
82
83
  if (isBatchInvoke) {
@@ -91,19 +92,19 @@ let InvokeFunction = class InvokeFunction extends common_1.Command {
91
92
  params = params || configParams;
92
93
  const result = yield functionService.invokeFunction(name, params);
93
94
  if (result.InvokeResult === 0) {
94
- log.success(`[${name}] 调用成功\n`);
95
+ log.success((0, i18n_1.t)('[{{name}}] 调用成功\n', { name }));
95
96
  }
96
97
  else {
97
- log.error(`[${name}] 调用失败\n`);
98
+ log.error((0, i18n_1.t)('[{{name}}] 调用失败\n', { name }));
98
99
  }
99
100
  const ResMap = {
100
- Duration: '运行时间',
101
- MemUsage: '内存占用',
102
- BillDuration: '计费时间',
103
- FunctionRequestId: '请求 Id ',
104
- RetMsg: '返回结果',
105
- ErrMsg: '错误信息',
106
- Log: '调用日志'
101
+ Duration: (0, i18n_1.t)('运行时间'),
102
+ MemUsage: (0, i18n_1.t)('内存占用'),
103
+ BillDuration: (0, i18n_1.t)('计费时间'),
104
+ FunctionRequestId: (0, i18n_1.t)('请求 Id '),
105
+ RetMsg: (0, i18n_1.t)('返回结果'),
106
+ ErrMsg: (0, i18n_1.t)('错误信息'),
107
+ Log: (0, i18n_1.t)('调用日志')
107
108
  };
108
109
  const formatInfo = Object.assign(Object.assign({}, result), { Duration: Number(result.Duration).toFixed(2) + 'ms', MemUsage: Number(Number(result.MemUsage) / Math.pow(1024, 2)).toFixed(2) + 'MB', BillDuration: result.BillDuration + 'ms' });
109
110
  const logInfo = Object.keys(ResMap)