@cloudbase/cli 2.9.9 → 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 (164) hide show
  1. package/bin/cloudbase.js +2 -1
  2. package/bin/tcb.js +35 -28
  3. package/lib/auth/login.js +21 -13
  4. package/lib/commands/account/login.js +43 -42
  5. package/lib/commands/account/logout.js +3 -2
  6. package/lib/commands/ai/index.js +13 -12
  7. package/lib/commands/cloudfunction/base.js +24 -26
  8. package/lib/commands/cloudrun/base.js +87 -96
  9. package/lib/commands/common.js +11 -10
  10. package/lib/commands/config/delete.js +72 -0
  11. package/lib/commands/config/get.js +69 -0
  12. package/lib/commands/config/index.js +21 -0
  13. package/lib/commands/config/interface.js +24 -0
  14. package/lib/commands/config/list.js +72 -0
  15. package/lib/commands/config/set.js +89 -0
  16. package/lib/commands/db/base.js +33 -32
  17. package/lib/commands/env/base.js +12 -11
  18. package/lib/commands/env/domain.js +24 -23
  19. package/lib/commands/env/login.js +31 -30
  20. package/lib/commands/fun/base.js +37 -36
  21. package/lib/commands/functions/alias/getRoute.js +5 -4
  22. package/lib/commands/functions/alias/setRoute.js +7 -6
  23. package/lib/commands/functions/code-download.js +15 -11
  24. package/lib/commands/functions/code-update.js +8 -7
  25. package/lib/commands/functions/concurrency/delete.js +5 -4
  26. package/lib/commands/functions/concurrency/list.js +6 -5
  27. package/lib/commands/functions/concurrency/set.js +5 -4
  28. package/lib/commands/functions/config-update.js +8 -7
  29. package/lib/commands/functions/copy.js +7 -6
  30. package/lib/commands/functions/delete.js +8 -7
  31. package/lib/commands/functions/deploy.js +35 -34
  32. package/lib/commands/functions/detail.js +32 -31
  33. package/lib/commands/functions/invoke.js +16 -15
  34. package/lib/commands/functions/layer/bind.js +26 -25
  35. package/lib/commands/functions/layer/common.js +2 -1
  36. package/lib/commands/functions/layer/create.js +7 -6
  37. package/lib/commands/functions/layer/delete.js +9 -8
  38. package/lib/commands/functions/layer/download.js +10 -9
  39. package/lib/commands/functions/layer/list.js +10 -9
  40. package/lib/commands/functions/layer/sort.js +9 -8
  41. package/lib/commands/functions/list.js +9 -8
  42. package/lib/commands/functions/log.js +28 -27
  43. package/lib/commands/functions/run.js +21 -20
  44. package/lib/commands/functions/trigger-create.js +9 -8
  45. package/lib/commands/functions/trigger-delete.js +10 -9
  46. package/lib/commands/functions/version/list.js +9 -8
  47. package/lib/commands/functions/version/publish.js +5 -4
  48. package/lib/commands/gateway/create.js +14 -13
  49. package/lib/commands/gateway/delete.js +10 -9
  50. package/lib/commands/gateway/domain.js +25 -24
  51. package/lib/commands/gateway/list.js +11 -10
  52. package/lib/commands/gateway/switch.js +22 -19
  53. package/lib/commands/helpers/init.js +38 -37
  54. package/lib/commands/helpers/new.js +7 -6
  55. package/lib/commands/helpers/open.js +7 -6
  56. package/lib/commands/hosting/hosting.js +45 -44
  57. package/lib/commands/index.js +1 -0
  58. package/lib/commands/pull/pull.js +12 -11
  59. package/lib/commands/run/delete.js +16 -15
  60. package/lib/commands/run/image/common.js +2 -1
  61. package/lib/commands/run/image/delete.js +10 -9
  62. package/lib/commands/run/image/download.js +8 -7
  63. package/lib/commands/run/image/list.js +11 -10
  64. package/lib/commands/run/image/upload.js +9 -8
  65. package/lib/commands/run/list.js +10 -9
  66. package/lib/commands/run/service/config.js +13 -12
  67. package/lib/commands/run/service/deploy.js +24 -23
  68. package/lib/commands/run/service/list.js +10 -9
  69. package/lib/commands/run/service/update.js +22 -21
  70. package/lib/commands/run/standalonegateway/common.js +2 -1
  71. package/lib/commands/run/standalonegateway/create.js +14 -13
  72. package/lib/commands/run/standalonegateway/destroy.js +9 -8
  73. package/lib/commands/run/standalonegateway/list.js +7 -6
  74. package/lib/commands/run/standalonegateway/package.js +7 -6
  75. package/lib/commands/run/standalonegateway/turn.js +10 -9
  76. package/lib/commands/run/version/common.js +2 -1
  77. package/lib/commands/run/version/create.js +41 -40
  78. package/lib/commands/run/version/delete.js +10 -9
  79. package/lib/commands/run/version/list.js +13 -12
  80. package/lib/commands/run/version/modify.js +13 -12
  81. package/lib/commands/run/version/update.js +57 -54
  82. package/lib/commands/runf/base.js +42 -40
  83. package/lib/commands/self-update.js +11 -10
  84. package/lib/commands/smart.js +5 -4
  85. package/lib/commands/storage/storage.js +61 -56
  86. package/lib/commands/third/thirdAttach.js +6 -5
  87. package/lib/commands/utils.js +8 -5
  88. package/lib/constant.js +18 -17
  89. package/lib/decorators/deprecate.js +2 -1
  90. package/lib/function/alias.js +3 -2
  91. package/lib/function/base.js +9 -8
  92. package/lib/function/concurrency.js +4 -3
  93. package/lib/function/create.js +5 -4
  94. package/lib/function/delete.js +2 -1
  95. package/lib/function/layer/attach.js +2 -1
  96. package/lib/function/layer/create.js +2 -1
  97. package/lib/function/layer/download.js +2 -1
  98. package/lib/function/trigger.js +6 -5
  99. package/lib/function/update.js +3 -2
  100. package/lib/function/version.js +3 -2
  101. package/lib/help.js +22 -20
  102. package/lib/hosting.js +18 -17
  103. package/lib/i18n/index.js +81 -0
  104. package/lib/run/service/common.js +14 -13
  105. package/lib/run/service/config.js +4 -3
  106. package/lib/run/service/deployPackage.js +6 -5
  107. package/lib/run/service/showLogs.js +3 -2
  108. package/lib/run/service/update.js +7 -6
  109. package/lib/run/standalonegateway/list.js +5 -1
  110. package/lib/storage.js +2 -1
  111. package/lib/utils/ai/banner.js +12 -11
  112. package/lib/utils/ai/claudeWindows.js +5 -3
  113. package/lib/utils/ai/config.js +3 -2
  114. package/lib/utils/ai/const.js +4 -3
  115. package/lib/utils/ai/env.js +3 -2
  116. package/lib/utils/ai/envLocalManager.js +6 -5
  117. package/lib/utils/ai/nodeVersion.js +5 -1
  118. package/lib/utils/ai/router.js +129 -106
  119. package/lib/utils/ai/setup.js +95 -91
  120. package/lib/utils/checkTcbrEnv.js +22 -21
  121. package/lib/utils/cli-table.js +2 -1
  122. package/lib/utils/commonParamsCheck.js +4 -3
  123. package/lib/utils/debug-logger.js +2 -1
  124. package/lib/utils/dts.js +4 -3
  125. package/lib/utils/env.js +23 -21
  126. package/lib/utils/fs/index.js +5 -4
  127. package/lib/utils/function-packer.js +3 -2
  128. package/lib/utils/index.js +1 -0
  129. package/lib/utils/mcp-config-modifier.js +18 -17
  130. package/lib/utils/net/cloud-api-request.js +2 -1
  131. package/lib/utils/net/credential.js +2 -1
  132. package/lib/utils/net/http-request.js +2 -1
  133. package/lib/utils/progress-bar.js +2 -1
  134. package/lib/utils/prompt/select.js +8 -6
  135. package/lib/utils/store/auth.js +3 -2
  136. package/lib/utils/store/config.js +49 -0
  137. package/lib/utils/store/db.js +5 -0
  138. package/lib/utils/store/index.js +1 -1
  139. package/lib/utils/tcbrApi/callTcbrApi.js +2 -1
  140. package/lib/utils/template-manager.js +37 -36
  141. package/lib/utils/template.js +10 -9
  142. package/lib/utils/tools/common.js +3 -2
  143. package/lib/utils/url.js +19 -0
  144. package/lib/utils/validator.js +12 -4
  145. package/locales/README.md +160 -0
  146. package/locales/i18next-scanner.config.js +206 -0
  147. package/locales/langs/en.json +1235 -0
  148. package/locales/langs/zh.json +1235 -0
  149. package/locales/mapping.json +1235 -0
  150. package/package.json +9 -2
  151. package/types/commands/config/delete.d.ts +13 -0
  152. package/types/commands/config/get.d.ts +13 -0
  153. package/types/commands/config/index.d.ts +5 -0
  154. package/types/commands/config/interface.d.ts +17 -0
  155. package/types/commands/config/list.d.ts +13 -0
  156. package/types/commands/config/set.d.ts +13 -0
  157. package/types/commands/index.d.ts +1 -0
  158. package/types/i18n/index.d.ts +3 -0
  159. package/types/utils/ai/const.d.ts +1 -1
  160. package/types/utils/index.d.ts +1 -0
  161. package/types/utils/store/config.d.ts +8 -0
  162. package/types/utils/store/db.d.ts +2 -0
  163. package/types/utils/store/index.d.ts +1 -1
  164. package/types/utils/url.d.ts +18 -0
@@ -33,6 +33,7 @@ const common_1 = require("../common");
33
33
  const utils_1 = require("../../utils");
34
34
  const decorators_1 = require("../../decorators");
35
35
  const auth_1 = require("../../auth");
36
+ const i18n_1 = require("../../i18n");
36
37
  let NewCommand = class NewCommand extends common_1.Command {
37
38
  get options() {
38
39
  return {
@@ -40,14 +41,14 @@ let NewCommand = class NewCommand 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: '--clone',
47
- desc: '从 Git 创建模板时是否 Clone 整个仓库'
48
+ desc: (0, i18n_1.t)('从 Git 创建模板时是否 Clone 整个仓库')
48
49
  }
49
50
  ],
50
- desc: '创建一个新的云开发应用',
51
+ desc: (0, i18n_1.t)('创建一个新的云开发应用'),
51
52
  requiredEnvId: false,
52
53
  withoutAuth: true
53
54
  };
@@ -95,12 +96,12 @@ let NewCommand = class NewCommand extends common_1.Command {
95
96
  });
96
97
  }
97
98
  initSuccessOutput(appName, log) {
98
- log.success(appName ? `创建应用 ${appName} 成功!\n` : '创建应用成功!');
99
+ log.success(appName ? (0, i18n_1.t)('创建应用 {{appName}} 成功!\n', { appName }) : (0, i18n_1.t)('创建应用成功!'));
99
100
  if (appName) {
100
101
  const command = chalk_1.default.bold.cyan(`cd ${appName}`);
101
- log.info(`👉 执行命令 ${command} 进入文件夹`);
102
+ log.info((0, i18n_1.t)('👉 执行命令 {{command}} 进入文件夹', { command }));
102
103
  }
103
- log.info(`👉 开发完成后,执行命令 ${chalk_1.default.bold.cyan('tcb')} 一键部署`);
104
+ log.info((0, i18n_1.t)('👉 开发完成后,执行命令 {{command}} 一键部署', { command: chalk_1.default.bold.cyan('tcb') }));
104
105
  }
105
106
  };
106
107
  __decorate([
@@ -31,9 +31,10 @@ const inquirer_1 = __importDefault(require("inquirer"));
31
31
  const error_1 = require("../../error");
32
32
  const common_1 = require("../common");
33
33
  const decorators_1 = require("../../decorators");
34
+ const i18n_1 = require("../../i18n");
34
35
  const links = [
35
36
  {
36
- name: 'CLI 文档',
37
+ name: (0, i18n_1.t)('CLI 文档'),
37
38
  value: 'cli-doc',
38
39
  url: 'https://tencentcloudbase.github.io/2019-09-03-cli/'
39
40
  }
@@ -43,7 +44,7 @@ let OpenLinkCommand = class OpenLinkCommand extends common_1.Command {
43
44
  return {
44
45
  cmd: 'open [link]',
45
46
  options: [],
46
- desc: '在浏览器中打开云开发相关连接',
47
+ desc: (0, i18n_1.t)('在浏览器中打开云开发相关连接'),
47
48
  requiredEnvId: false,
48
49
  withoutAuth: true
49
50
  };
@@ -55,22 +56,22 @@ let OpenLinkCommand = class OpenLinkCommand extends common_1.Command {
55
56
  if (link) {
56
57
  openLink = links.find((item) => item.value === link);
57
58
  if (!openLink) {
58
- throw new error_1.CloudBaseError(`${link} 链接不存在!`);
59
+ throw new error_1.CloudBaseError((0, i18n_1.t)('{{link}} 链接不存在!', { link }));
59
60
  }
60
61
  }
61
62
  else {
62
63
  const { selectLink } = yield inquirer_1.default.prompt({
63
64
  type: 'list',
64
65
  name: 'selectLink',
65
- message: '请选择需要打开的链接',
66
+ message: (0, i18n_1.t)('请选择需要打开的链接'),
66
67
  choices: links
67
68
  });
68
69
  openLink = links.find((item) => item.value === selectLink);
69
70
  }
70
71
  if (!openLink) {
71
- throw new error_1.CloudBaseError('请指定需要打开的链接!');
72
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要打开的链接!'));
72
73
  }
73
- console.log(`在您的默认浏览器中打开 ${openLink.name} 链接:`);
74
+ console.log((0, i18n_1.t)('在您的默认浏览器中打开 {{name}} 链接:', { name: openLink.name }));
74
75
  console.log(chalk_1.default.underline.bold(openLink.url));
75
76
  (0, open_1.default)(openLink.url);
76
77
  });
@@ -34,14 +34,15 @@ const hosting_1 = require("../../hosting");
34
34
  const error_1 = require("../../error");
35
35
  const utils_1 = require("../../utils");
36
36
  const decorators_1 = require("../../decorators");
37
+ const i18n_1 = require("../../i18n");
37
38
  const HostingStatusMap = {
38
- init: '初始化中',
39
- process: '处理中',
40
- online: '已上线',
41
- destroying: '销毁中',
42
- offline: '已下线',
43
- create_fail: '初始化失败',
44
- destroy_fail: '销毁失败'
39
+ init: (0, i18n_1.t)('初始化中'),
40
+ process: (0, i18n_1.t)('处理中'),
41
+ online: (0, i18n_1.t)('已上线'),
42
+ destroying: (0, i18n_1.t)('销毁中'),
43
+ offline: (0, i18n_1.t)('已下线'),
44
+ create_fail: (0, i18n_1.t)('初始化失败'),
45
+ destroy_fail: (0, i18n_1.t)('销毁失败')
45
46
  };
46
47
  function getHostingService(envId) {
47
48
  return __awaiter(this, void 0, void 0, function* () {
@@ -58,10 +59,10 @@ let HostingDetail = class HostingDetail extends common_1.Command {
58
59
  options: [
59
60
  {
60
61
  flags: '-e, --envId <envId>',
61
- desc: '环境 Id'
62
+ desc: (0, i18n_1.t)('环境 Id')
62
63
  }
63
64
  ],
64
- desc: '查看静态网站服务信息'
65
+ desc: (0, i18n_1.t)('查看静态网站服务信息')
65
66
  };
66
67
  }
67
68
  execute(envId, log) {
@@ -75,9 +76,9 @@ let HostingDetail = class HostingDetail extends common_1.Command {
75
76
  }
76
77
  const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
77
78
  if (website.status !== 'offline') {
78
- log.info(`静态网站域名:${link}`);
79
+ log.info((0, i18n_1.t)('静态网站域名:{{link}}', { link }));
79
80
  }
80
- log.info(`静态网站状态:【${HostingStatusMap[website.status]}】`);
81
+ log.info((0, i18n_1.t)('静态网站状态:【{{status}}】', { status: HostingStatusMap[website.status] }));
81
82
  });
82
83
  }
83
84
  };
@@ -102,10 +103,10 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
102
103
  options: [
103
104
  {
104
105
  flags: '-e, --envId <envId>',
105
- desc: '环境 Id'
106
+ desc: (0, i18n_1.t)('环境 Id')
106
107
  }
107
108
  ],
108
- desc: '部署静态网站文件'
109
+ desc: (0, i18n_1.t)('部署静态网站文件')
109
110
  };
110
111
  }
111
112
  execute(envId, params, log) {
@@ -113,12 +114,12 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
113
114
  return __awaiter(this, void 0, void 0, function* () {
114
115
  const localPath = (params === null || params === void 0 ? void 0 : params[0]) || '.';
115
116
  const cloudPath = (params === null || params === void 0 ? void 0 : params[1]) || '';
116
- log.verbose('本地目录', localPath);
117
+ log.verbose((0, i18n_1.t)('本地目录'), localPath);
117
118
  const resolveLocalPath = path_1.default.resolve(localPath);
118
119
  (0, utils_1.checkFullAccess)(resolveLocalPath, true);
119
120
  const isDir = (0, utils_1.isDirectory)(resolveLocalPath);
120
121
  const loading = (0, utils_1.loadingFactory)();
121
- loading.start('准备上传中...');
122
+ loading.start((0, i18n_1.t)('准备上传中...'));
122
123
  let totalFiles = 0;
123
124
  if (isDir) {
124
125
  let files = yield (0, hosting_1.walkLocalDir)(envId, resolveLocalPath);
@@ -126,7 +127,7 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
126
127
  totalFiles = files.length;
127
128
  }
128
129
  const onProgress = (0, utils_1.createUploadProgressBar)(() => {
129
- !isDir && log.success('文件部署成功!');
130
+ !isDir && log.success((0, i18n_1.t)('文件部署成功!'));
130
131
  }, () => {
131
132
  loading.stop();
132
133
  });
@@ -154,25 +155,25 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
154
155
  });
155
156
  const website = (_a = info === null || info === void 0 ? void 0 : info.data) === null || _a === void 0 ? void 0 : _a[0];
156
157
  const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
157
- log.success(`\n部署完成 👉 ${link}`);
158
+ log.success((0, i18n_1.t)('\n部署完成 👉 {{link}}', { link }));
158
159
  if (isDir) {
159
- log.success(`文件共计 ${totalFiles} 个`);
160
- log.success(`文件上传成功 ${successFiles.length} 个`);
160
+ log.success((0, i18n_1.t)('文件共计 {{totalFiles}} 个', { totalFiles }));
161
+ log.success((0, i18n_1.t)('文件上传成功 {{count}} 个', { count: successFiles.length }));
161
162
  if (totalFiles <= 50) {
162
- (0, utils_1.printHorizontalTable)(['状态', '文件'], successFiles.map((item) => [log_symbols_1.default.success, item]));
163
+ (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
163
164
  }
164
- log.error(`文件上传失败 ${failedFiles.length} 个`);
165
+ log.error((0, i18n_1.t)('文件上传失败 {{count}} 个', { count: failedFiles.length }));
165
166
  if (failedFiles.length) {
166
167
  if (totalFiles <= 50) {
167
- (0, utils_1.printHorizontalTable)(['状态', '文件'], failedFiles.map((item) => [log_symbols_1.default.error, item]));
168
+ (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
168
169
  }
169
170
  else {
170
171
  const errorLogPath = path_1.default.resolve('./cloudbase-error.log');
171
- log.error('上传失败文件:');
172
+ log.error((0, i18n_1.t)('上传失败文件:'));
172
173
  console.log(errorLogPath);
173
174
  fs_1.default.writeFileSync(errorLogPath, failedFiles.join('\n'));
174
175
  }
175
- throw new error_1.CloudBaseError('部分文件上传失败,进程退出');
176
+ throw new error_1.CloudBaseError((0, i18n_1.t)('部分文件上传失败,进程退出'));
176
177
  }
177
178
  }
178
179
  });
@@ -200,14 +201,14 @@ let HostingDeleteFiles = class HostingDeleteFiles extends common_1.Command {
200
201
  options: [
201
202
  {
202
203
  flags: '-e, --envId <envId>',
203
- desc: '环境 Id'
204
+ desc: (0, i18n_1.t)('环境 Id')
204
205
  },
205
206
  {
206
207
  flags: '-d, --dir',
207
- desc: '删除目标是否为文件夹'
208
+ desc: (0, i18n_1.t)('删除目标是否为文件夹')
208
209
  }
209
210
  ],
210
- desc: '删除静态网站文件/文件夹,文件夹需指定 --dir 选项'
211
+ desc: (0, i18n_1.t)('删除静态网站文件/文件夹,文件夹需指定 --dir 选项')
211
212
  };
212
213
  }
213
214
  execute(envId, options, params) {
@@ -218,30 +219,30 @@ let HostingDeleteFiles = class HostingDeleteFiles extends common_1.Command {
218
219
  const { confirm } = yield inquirer_1.default.prompt({
219
220
  type: 'confirm',
220
221
  name: 'confirm',
221
- message: '指定云端路径为空,将会删除所有文件,是否继续',
222
+ message: (0, i18n_1.t)('指定云端路径为空,将会删除所有文件,是否继续'),
222
223
  default: false
223
224
  });
224
225
  if (!confirm) {
225
- throw new error_1.CloudBaseError('操作终止!');
226
+ throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
226
227
  }
227
228
  isDir = true;
228
229
  }
229
230
  if (cloudPath === '/') {
230
231
  isDir = true;
231
232
  }
232
- const fileText = isDir ? '文件夹' : '文件';
233
+ const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
233
234
  const loading = (0, utils_1.loadingFactory)();
234
- loading.start(`删除${fileText}中...`);
235
+ loading.start((0, i18n_1.t)('删除{{fileText}}中...', { fileText }));
235
236
  try {
236
237
  yield (0, hosting_1.hostingDelete)({
237
238
  envId,
238
239
  isDir,
239
240
  cloudPath
240
241
  });
241
- loading.succeed(`删除${fileText}成功!`);
242
+ loading.succeed((0, i18n_1.t)('删除{{fileText}}成功!', { fileText }));
242
243
  }
243
244
  catch (e) {
244
- loading.fail(`删除${fileText}失败!`);
245
+ loading.fail((0, i18n_1.t)('删除{{fileText}}失败!', { fileText }));
245
246
  throw new error_1.CloudBaseError(e.message);
246
247
  }
247
248
  });
@@ -269,22 +270,22 @@ let HostingList = class HostingList extends common_1.Command {
269
270
  options: [
270
271
  {
271
272
  flags: '-e, --envId <envId>',
272
- desc: '环境 Id'
273
+ desc: (0, i18n_1.t)('环境 Id')
273
274
  }
274
275
  ],
275
- desc: '展示文件列表'
276
+ desc: (0, i18n_1.t)('展示文件列表')
276
277
  };
277
278
  }
278
279
  execute(envId) {
279
280
  return __awaiter(this, void 0, void 0, function* () {
280
281
  const loading = (0, utils_1.loadingFactory)();
281
- loading.start('获取文件列表中...');
282
+ loading.start((0, i18n_1.t)('获取文件列表中...'));
282
283
  try {
283
284
  const list = yield (0, hosting_1.hostingList)({
284
285
  envId
285
286
  });
286
287
  loading.stop();
287
- const head = ['序号', 'Key', 'LastModified', 'ETag', 'Size(KB)'];
288
+ const head = [(0, i18n_1.t)('序号'), (0, i18n_1.t)('Key'), (0, i18n_1.t)('LastModified'), (0, i18n_1.t)('ETag'), (0, i18n_1.t)('Size(KB)')];
288
289
  const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
289
290
  const tableData = list
290
291
  .filter(notDir)
@@ -298,7 +299,7 @@ let HostingList = class HostingList extends common_1.Command {
298
299
  (0, utils_1.printHorizontalTable)(head, tableData);
299
300
  }
300
301
  catch (e) {
301
- loading.fail('获取文件列表失败!');
302
+ loading.fail((0, i18n_1.t)('获取文件列表失败!'));
302
303
  throw new error_1.CloudBaseError(e.message);
303
304
  }
304
305
  });
@@ -323,14 +324,14 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
323
324
  options: [
324
325
  {
325
326
  flags: '-e, --envId <envId>',
326
- desc: '环境 Id'
327
+ desc: (0, i18n_1.t)('环境 Id')
327
328
  },
328
329
  {
329
330
  flags: '-d, --dir',
330
- desc: '下载目标是否为文件夹'
331
+ desc: (0, i18n_1.t)('下载目标是否为文件夹')
331
332
  }
332
333
  ],
333
- desc: '下载文件/文件夹,文件夹需指定 --dir 选项'
334
+ desc: (0, i18n_1.t)('下载文件/文件夹,文件夹需指定 --dir 选项')
334
335
  };
335
336
  }
336
337
  execute(envId, options, params) {
@@ -340,9 +341,9 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
340
341
  const hostingService = yield getHostingService(envId);
341
342
  const resolveLocalPath = path_1.default.resolve(localPath);
342
343
  const { dir } = options;
343
- const fileText = dir ? '文件夹' : '文件';
344
+ const fileText = dir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
344
345
  const loading = (0, utils_1.loadingFactory)();
345
- loading.start(`下载${fileText}中`);
346
+ loading.start((0, i18n_1.t)('下载{{fileText}}中', { fileText }));
346
347
  if (/^\/.+/.test(cloudPath)) {
347
348
  cloudPath = cloudPath.slice(1);
348
349
  }
@@ -358,7 +359,7 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
358
359
  localPath: resolveLocalPath
359
360
  });
360
361
  }
361
- loading.succeed(`下载${fileText}成功!`);
362
+ loading.succeed((0, i18n_1.t)('下载{{fileText}}成功!', { fileText }));
362
363
  });
363
364
  }
364
365
  };
@@ -35,3 +35,4 @@ __exportStar(require("./cloudrun"), exports);
35
35
  __exportStar(require("./ai"), exports);
36
36
  __exportStar(require("./pull"), exports);
37
37
  __exportStar(require("./self-update"), exports);
38
+ __exportStar(require("./config"), exports);
@@ -27,6 +27,7 @@ const decorators_1 = require("../../decorators");
27
27
  const log_1 = require("../../utils/log");
28
28
  const template_manager_1 = require("../../utils/template-manager");
29
29
  const error_1 = require("../../error");
30
+ const i18n_1 = require("../../i18n");
30
31
  let PullCommand = class PullCommand extends common_1.Command {
31
32
  get options() {
32
33
  return {
@@ -34,18 +35,18 @@ let PullCommand = class PullCommand extends common_1.Command {
34
35
  options: [
35
36
  {
36
37
  flags: '-s, --source <source>',
37
- desc: '指定模板来源'
38
+ desc: (0, i18n_1.t)('指定模板来源')
38
39
  },
39
40
  {
40
41
  flags: '-o, --output <output>',
41
- desc: '指定输出目录'
42
+ desc: (0, i18n_1.t)('指定输出目录')
42
43
  },
43
44
  {
44
45
  flags: '-f, --force',
45
- desc: '强制清理目标输出目录(慎用)'
46
+ desc: (0, i18n_1.t)('强制清理目标输出目录(慎用)')
46
47
  }
47
48
  ],
48
- desc: '拉取项目模板\n\n支持的内置模板:\n miniprogram - 微信小程序 + CloudBase\n react - Web 应用 - React + CloudBase\n vue - Web 应用 - Vue + CloudBase\n uniapp - 跨端应用 - UniApp + CloudBase\n rules - AI 规则和配置\n\n支持的 Git 仓库:\n GitHub: https://github.com/user/repo\n Gitee: https://gitee.com/user/repo\n CNB: https://cnb.cool/user/repo\n SSH: git@github.com:user/repo.git\n\n支持 Git 子目录:\n https://github.com/user/repo/tree/main/src/templates\n https://cnb.cool/user/repo/tree/main/examples\n\n示例:\n tcb pull miniprogram\n tcb pull https://github.com/user/repo\n tcb pull https://cnb.cool/user/repo\n tcb pull https://cnb.cool/user/repo/tree/main/examples --output ./my-project',
49
+ desc: (0, i18n_1.t)('拉取项目模板\n\n支持的内置模板:\n miniprogram - 微信小程序 + CloudBase\n react - Web 应用 - React + CloudBase\n vue - Web 应用 - Vue + CloudBase\n uniapp - 跨端应用 - UniApp + CloudBase\n rules - AI 规则和配置\n\n支持的 Git 仓库:\n GitHub: https://github.com/user/repo\n Gitee: https://gitee.com/user/repo\n CNB: https://cnb.cool/user/repo\n SSH: git@github.com:user/repo.git\n\n支持 Git 子目录:\n https://github.com/user/repo/tree/main/src/templates\n https://cnb.cool/user/repo/tree/main/examples\n\n示例:\n tcb pull miniprogram\n tcb pull https://github.com/user/repo\n tcb pull https://cnb.cool/user/repo\n tcb pull https://cnb.cool/user/repo/tree/main/examples --output ./my-project'),
49
50
  requiredEnvId: false,
50
51
  withoutAuth: true
51
52
  };
@@ -59,34 +60,34 @@ let PullCommand = class PullCommand extends common_1.Command {
59
60
  return;
60
61
  }
61
62
  if (!source || typeof source !== 'string') {
62
- throw new error_1.CloudBaseError('请指定要拉取的模板来源');
63
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定要拉取的模板来源'));
63
64
  }
64
65
  try {
65
66
  const templateManager = new template_manager_1.TemplateManager();
66
67
  yield templateManager.pullTemplate(source, { output, force }, log);
67
- log.info('🎉 模板拉取完成!');
68
+ log.info((0, i18n_1.t)('🎉 模板拉取完成!'));
68
69
  if (output) {
69
- log.info(`📁 项目已创建在: ${output}`);
70
+ log.info((0, i18n_1.t)('📁 项目已创建在: {{output}}', { output }));
70
71
  }
71
72
  }
72
73
  catch (error) {
73
- throw new error_1.CloudBaseError(`拉取模板失败: ${error.message}`, { original: error });
74
+ throw new error_1.CloudBaseError((0, i18n_1.t)('拉取模板失败: {{message}}', { message: error.message }), { original: error });
74
75
  }
75
76
  });
76
77
  }
77
78
  showTemplateList(templateManager, log) {
78
79
  return __awaiter(this, void 0, void 0, function* () {
79
80
  const templates = templateManager.getBuiltinTemplates();
80
- log.info('📋 可用的内置模板:');
81
+ log.info((0, i18n_1.t)('📋 可用的内置模板:'));
81
82
  for (const [key, name] of Object.entries(templates)) {
82
83
  log.info(` ${key.padEnd(12)} - ${name}`);
83
84
  }
84
- log.info('\n🌐 支持的 Git 仓库格式:');
85
+ log.info((0, i18n_1.t)('\n🌐 支持的 Git 仓库格式:'));
85
86
  log.info(' GitHub: https://github.com/user/repo');
86
87
  log.info(' Gitee: https://gitee.com/user/repo');
87
88
  log.info(' CNB: https://cnb.cool/user/repo');
88
89
  log.info(' SSH: git@github.com:user/repo.git');
89
- log.info('\n📁 支持 Git 子目录:');
90
+ log.info((0, i18n_1.t)('\n📁 支持 Git 子目录:'));
90
91
  log.info(' https://github.com/user/repo/tree/main/src/templates');
91
92
  });
92
93
  }
@@ -28,6 +28,7 @@ const error_1 = require("../../error");
28
28
  const run_1 = require("../../run");
29
29
  const decorators_1 = require("../../decorators");
30
30
  const utils_1 = require("../../utils");
31
+ const i18n_1 = require("../../i18n");
31
32
  let DeleteRun = class DeleteRun extends common_1.Command {
32
33
  get options() {
33
34
  return {
@@ -36,14 +37,14 @@ let DeleteRun = class DeleteRun extends common_1.Command {
36
37
  options: [
37
38
  {
38
39
  flags: '-e, --envId <envId>',
39
- desc: '环境 Id'
40
+ desc: (0, i18n_1.t)('环境 Id')
40
41
  },
41
42
  {
42
43
  flags: '-s, --serviceName <serviceName>',
43
- desc: '云托管服务 name'
44
+ desc: (0, i18n_1.t)('云托管服务 name')
44
45
  },
45
46
  ],
46
- desc: '删除云托管服务'
47
+ desc: (0, i18n_1.t)('删除云托管服务')
47
48
  };
48
49
  }
49
50
  execute(envId, options) {
@@ -55,33 +56,33 @@ let DeleteRun = class DeleteRun extends common_1.Command {
55
56
  }
56
57
  let { serviceName = '' } = options;
57
58
  if (serviceName.length === 0) {
58
- throw new error_1.CloudBaseError('必须输入服务名');
59
+ throw new error_1.CloudBaseError((0, i18n_1.t)('必须输入服务名'));
59
60
  }
60
61
  const loading = (0, utils_1.loadingFactory)();
61
- loading.start('数据加载中...');
62
+ loading.start((0, i18n_1.t)('数据加载中...'));
62
63
  const versions = yield (0, run_1.listVersion)({ envId, serverName: serviceName, limit: 1, offset: 0 });
63
64
  if (versions.length > 0)
64
- throw new error_1.CloudBaseError('服务下还有版本存在,请先清空版本列表');
65
+ throw new error_1.CloudBaseError((0, i18n_1.t)('服务下还有版本存在,请先清空版本列表'));
65
66
  const imageRepo = yield (0, run_1.describeImageRepo)({ envId, serverName: serviceName });
66
- loading.start('正在删除服务');
67
+ loading.start((0, i18n_1.t)('正在删除服务'));
67
68
  const res = yield (0, run_1.deleteRun)({ envId, serverName: serviceName });
68
69
  if (res === 'succ')
69
- loading.succeed('服务删除完成');
70
+ loading.succeed((0, i18n_1.t)('服务删除完成'));
70
71
  else
71
- throw new error_1.CloudBaseError('服务删除失败');
72
+ throw new error_1.CloudBaseError((0, i18n_1.t)('服务删除失败'));
72
73
  if ((yield (0, enquirer_1.prompt)({
73
74
  type: 'select',
74
75
  name: 'flag',
75
- message: `是否删除绑定的镜像仓库${imageRepo}`,
76
- choices: ['是', '否']
77
- })).flag === '是') {
78
- loading.start('正在删除镜像仓库');
76
+ message: (0, i18n_1.t)('是否删除绑定的镜像仓库{{imageRepo}}', { imageRepo }),
77
+ choices: [(0, i18n_1.t)('是'), (0, i18n_1.t)('否')]
78
+ })).flag === (0, i18n_1.t)('是')) {
79
+ loading.start((0, i18n_1.t)('正在删除镜像仓库'));
79
80
  const res = yield (0, run_1.deleteImageRepo)({ imageRepo });
80
81
  if (res === '') {
81
- loading.succeed('仓库删除完成');
82
+ loading.succeed((0, i18n_1.t)('仓库删除完成'));
82
83
  }
83
84
  else {
84
- throw new error_1.CloudBaseError('仓库删除失败');
85
+ throw new error_1.CloudBaseError((0, i18n_1.t)('仓库删除失败'));
85
86
  }
86
87
  }
87
88
  });
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.imageCommonOptions = void 0;
4
+ const i18n_1 = require("../../../i18n");
4
5
  const imageCommonOptions = (sub) => ({
5
6
  cmd: 'run:deprecated',
6
7
  childCmd: {
7
8
  cmd: 'image',
8
- desc: '云托管镜像管理'
9
+ desc: (0, i18n_1.t)('云托管镜像管理')
9
10
  },
10
11
  childSubCmd: sub
11
12
  });
@@ -28,22 +28,23 @@ const run_1 = require("../../../run");
28
28
  const utils_1 = require("../../../utils");
29
29
  const decorators_1 = require("../../../decorators");
30
30
  const common_2 = require("./common");
31
+ const i18n_1 = require("../../../i18n");
31
32
  let DeleteImage = class DeleteImage extends common_1.Command {
32
33
  get options() {
33
34
  return Object.assign(Object.assign({}, (0, common_2.imageCommonOptions)('delete')), { options: [
34
35
  {
35
36
  flags: '-e, --envId <envId>',
36
- desc: '环境 Id'
37
+ desc: (0, i18n_1.t)('环境 Id')
37
38
  },
38
39
  {
39
40
  flags: '-s, --serviceName <serviceName>',
40
- desc: '托管服务 name'
41
+ desc: (0, i18n_1.t)('托管服务 name')
41
42
  },
42
43
  {
43
44
  flags: '-t, --imageTag <imageTag>',
44
- desc: '镜像 tag'
45
+ desc: (0, i18n_1.t)('镜像 tag')
45
46
  }
46
- ], desc: '删除云开发环境下云托管服务的版本' });
47
+ ], desc: (0, i18n_1.t)('删除云开发环境下云托管服务的版本') });
47
48
  }
48
49
  execute(envId, options) {
49
50
  return __awaiter(this, void 0, void 0, function* () {
@@ -54,10 +55,10 @@ let DeleteImage = class DeleteImage extends common_1.Command {
54
55
  }
55
56
  let { serviceName = '', imageTag = '' } = options;
56
57
  if (serviceName.length === 0 || imageTag.length === 0) {
57
- throw new error_1.CloudBaseError('必须输入 serviceName 和 imageTag');
58
+ throw new error_1.CloudBaseError((0, i18n_1.t)('必须输入 serviceName 和 imageTag'));
58
59
  }
59
60
  const loading = (0, utils_1.loadingFactory)();
60
- loading.start('数据加载中...');
61
+ loading.start((0, i18n_1.t)('数据加载中...'));
61
62
  const imageRepo = yield (0, run_1.describeImageRepo)({ envId, serverName: serviceName });
62
63
  const imageUrl = `ccr.ccs.tencentyun.com/${imageRepo}:${imageTag}`;
63
64
  try {
@@ -66,12 +67,12 @@ let DeleteImage = class DeleteImage extends common_1.Command {
66
67
  imageUrl: imageUrl
67
68
  });
68
69
  if (res === 'success')
69
- loading.succeed(`成功删除 ${serviceName} 服务下的 ${imageUrl} 镜像`);
70
+ loading.succeed((0, i18n_1.t)('成功删除 {{serviceName}} 服务下的 {{imageUrl}} 镜像', { serviceName, imageUrl }));
70
71
  else
71
- throw new error_1.CloudBaseError('删除失败');
72
+ throw new error_1.CloudBaseError((0, i18n_1.t)('删除失败'));
72
73
  }
73
74
  catch (e) {
74
- throw new error_1.CloudBaseError('删除失败');
75
+ throw new error_1.CloudBaseError((0, i18n_1.t)('删除失败'));
75
76
  }
76
77
  });
77
78
  }
@@ -29,22 +29,23 @@ const run_1 = require("../../../run");
29
29
  const utils_1 = require("../../../utils");
30
30
  const decorators_1 = require("../../../decorators");
31
31
  const common_2 = require("./common");
32
+ const i18n_1 = require("../../../i18n");
32
33
  let DownLoadImage = class DownLoadImage extends common_1.Command {
33
34
  get options() {
34
35
  return Object.assign(Object.assign({}, (0, common_2.imageCommonOptions)('download')), { options: [
35
36
  {
36
37
  flags: '-e, --envId <envId>',
37
- desc: '环境 Id'
38
+ desc: (0, i18n_1.t)('环境 Id')
38
39
  },
39
40
  {
40
41
  flags: '-s, --serviceName <serviceName>',
41
- desc: '托管服务 name'
42
+ desc: (0, i18n_1.t)('托管服务 name')
42
43
  },
43
44
  {
44
45
  flags: '-t, --imageTag <imageTag>',
45
- desc: '镜像 tag'
46
+ desc: (0, i18n_1.t)('镜像 tag')
46
47
  }
47
- ], desc: '删除云开发环境下云托管服务的版本' });
48
+ ], desc: (0, i18n_1.t)('下载云开发环境下云托管服务的镜像') });
48
49
  }
49
50
  execute(envId, options) {
50
51
  return __awaiter(this, void 0, void 0, function* () {
@@ -55,19 +56,19 @@ let DownLoadImage = class DownLoadImage extends common_1.Command {
55
56
  }
56
57
  let { serviceName = '', imageTag = '' } = options;
57
58
  if (serviceName.length === 0 || imageTag.length === 0) {
58
- throw new error_1.CloudBaseError('必须输入 serviceName 和 imageTag');
59
+ throw new error_1.CloudBaseError((0, i18n_1.t)('必须输入 serviceName 和 imageTag'));
59
60
  }
60
61
  const loading = (0, utils_1.loadingFactory)();
61
62
  const imageRepo = yield (0, run_1.describeImageRepo)({ envId, serverName: serviceName });
62
63
  const imageUrl = `ccr.ccs.tencentyun.com/${imageRepo}:${imageTag}`;
63
64
  if (!(yield (0, run_1.getAuthFlag)())) {
64
- throw new error_1.CloudBaseError('无法找到~/.docker/config.json或未登录,需要执行docker login');
65
+ throw new error_1.CloudBaseError((0, i18n_1.t)('无法找到~/.docker/config.json或未登录,需要执行docker login'));
65
66
  }
66
67
  let sh = new Promise((resolve, reject) => {
67
68
  (0, child_process_1.exec)(`docker pull ${imageUrl}`, (err, stdout) => err ? reject(err) : resolve({ code: 0, info: stdout })).stdout.pipe(process.stdout);
68
69
  });
69
70
  yield sh;
70
- loading.succeed('拉取成功');
71
+ loading.succeed((0, i18n_1.t)('拉取成功'));
71
72
  });
72
73
  }
73
74
  };