@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
@@ -25,17 +25,18 @@ const os_1 = __importDefault(require("os"));
25
25
  const common_1 = require("./common");
26
26
  const error_1 = require("../error");
27
27
  const child_process_1 = require("child_process");
28
+ const i18n_1 = require("../i18n");
28
29
  let SelfUpdateCommand = class SelfUpdateCommand extends common_1.Command {
29
30
  get options() {
30
31
  return {
31
32
  cmd: 'self-update',
32
- desc: '更新当前 CloudBase CLI(独立发行版)到指定或最新版本',
33
+ desc: (0, i18n_1.t)('更新当前 CloudBase CLI(独立发行版)到指定或最新版本'),
33
34
  requiredEnvId: false,
34
35
  withoutAuth: true,
35
36
  options: [
36
- { flags: '--version <version>', desc: '指定版本号,缺省为最新' },
37
- { flags: '--channel <channel>', desc: '渠道:stable|beta,默认 stable' },
38
- { flags: '--download-base <url>', desc: '下载基址,默认 https://static.cloudbase.net/cli' }
37
+ { flags: '--version <version>', desc: (0, i18n_1.t)('指定版本号,缺省为最新') },
38
+ { flags: '--channel <channel>', desc: (0, i18n_1.t)('渠道:stable|beta,默认 stable') },
39
+ { flags: '--download-base <url>', desc: (0, i18n_1.t)('下载基址,默认 https://static.cloudbase.net/cli') }
39
40
  ]
40
41
  };
41
42
  }
@@ -63,7 +64,7 @@ let SelfUpdateCommand = class SelfUpdateCommand extends common_1.Command {
63
64
  (0, child_process_1.execSync)(`${env} ${installerCmd}`, { stdio: 'inherit' });
64
65
  }
65
66
  catch (e) {
66
- throw new error_1.CloudBaseError(`自更新失败:${(e === null || e === void 0 ? void 0 : e.message) || e}`);
67
+ throw new error_1.CloudBaseError((0, i18n_1.t)('自更新失败:{{error}}', { error: (e === null || e === void 0 ? void 0 : e.message) || e }));
67
68
  }
68
69
  });
69
70
  }
@@ -76,7 +77,7 @@ let RollbackCommand = class RollbackCommand extends common_1.Command {
76
77
  get options() {
77
78
  return {
78
79
  cmd: 'rollback',
79
- desc: '回滚 CloudBase CLI(独立发行版)到上一版本',
80
+ desc: (0, i18n_1.t)('回滚 CloudBase CLI(独立发行版)到上一版本'),
80
81
  requiredEnvId: false,
81
82
  withoutAuth: true,
82
83
  options: []
@@ -88,13 +89,13 @@ let RollbackCommand = class RollbackCommand extends common_1.Command {
88
89
  const root = path_1.default.join(home, '.local/share/cloudbase-cli');
89
90
  const versionsDir = path_1.default.join(root, 'versions');
90
91
  if (!fs_1.default.existsSync(versionsDir)) {
91
- throw new error_1.CloudBaseError('未找到已安装版本目录,无法回滚');
92
+ throw new error_1.CloudBaseError((0, i18n_1.t)('未找到已安装版本目录,无法回滚'));
92
93
  }
93
94
  const entries = fs_1.default.readdirSync(versionsDir)
94
95
  .filter((n) => !n.startsWith('.') && fs_1.default.statSync(path_1.default.join(versionsDir, n)).isDirectory())
95
96
  .sort();
96
97
  if (entries.length < 2) {
97
- throw new error_1.CloudBaseError('没有可回滚的历史版本');
98
+ throw new error_1.CloudBaseError((0, i18n_1.t)('没有可回滚的历史版本'));
98
99
  }
99
100
  const target = entries[entries.length - 2];
100
101
  const currentLink = path_1.default.join(root, 'current');
@@ -119,10 +120,10 @@ let RollbackCommand = class RollbackCommand extends common_1.Command {
119
120
  }
120
121
  catch (_) { }
121
122
  fs_1.default.symlinkSync(targetDir, currentLink);
122
- console.log(`已回滚到版本: ${target}`);
123
+ console.log((0, i18n_1.t)('已回滚到版本: {{version}}', { version: target }));
123
124
  }
124
125
  catch (e) {
125
- throw new error_1.CloudBaseError(`回滚失败:${(e === null || e === void 0 ? void 0 : e.message) || e}`);
126
+ throw new error_1.CloudBaseError((0, i18n_1.t)('回滚失败:{{error}}', { error: (e === null || e === void 0 ? void 0 : e.message) || e }));
126
127
  }
127
128
  });
128
129
  }
@@ -47,10 +47,11 @@ const utils_1 = require("../utils");
47
47
  const Hosting = __importStar(require("../hosting"));
48
48
  const Function = __importStar(require("../function"));
49
49
  const auth_1 = require("../auth");
50
+ const i18n_1 = require("../i18n");
50
51
  function smartDeploy() {
51
52
  return __awaiter(this, void 0, void 0, function* () {
52
53
  const loading = (0, utils_1.loadingFactory)();
53
- loading.start('环境检测中');
54
+ loading.start((0, i18n_1.t)('环境检测中'));
54
55
  yield (0, auth_1.checkLogin)();
55
56
  yield (0, utils_1.checkTcbService)();
56
57
  const files = fs_1.default.readdirSync(process.cwd());
@@ -63,17 +64,17 @@ function smartDeploy() {
63
64
  }
64
65
  let region = yield (0, toolbox_1.getRegion)(true);
65
66
  if (!files.length) {
66
- utils_1.logger.info('当前目录为空,初始化云开发项目\n');
67
+ utils_1.logger.info((0, i18n_1.t)('当前目录为空,初始化云开发项目\n'));
67
68
  region = yield (0, utils_1.getSelectRegion)();
68
69
  const envId = yield (0, utils_1.getSelectedEnv)();
69
70
  const projectPath = yield (0, utils_1.downloadTemplate)();
70
71
  yield (0, utils_1.initProjectConfig)(envId, region, projectPath);
71
- utils_1.logger.success('初始化项目成功!\n');
72
+ utils_1.logger.success((0, i18n_1.t)('初始化项目成功!\n'));
72
73
  }
73
74
  const { setup } = yield (0, enquirer_1.prompt)({
74
75
  type: 'confirm',
75
76
  name: 'setup',
76
- message: `是否使用云开发部署当前项目 <${chalk_1.default.bold.cyan(relative)}> ?`,
77
+ message: (0, i18n_1.t)('是否使用云开发部署当前项目 <{{path}}> ?', { path: chalk_1.default.bold.cyan(relative) }),
77
78
  initial: true
78
79
  });
79
80
  if (!setup) {
@@ -33,11 +33,12 @@ const common_1 = require("../common");
33
33
  const utils_1 = require("../../utils");
34
34
  const error_1 = require("../../error");
35
35
  const decorators_1 = require("../../decorators");
36
+ const i18n_1 = require("../../i18n");
36
37
  const AclMap = {
37
- READONLY: '所有用户可读,仅创建者和管理员可写',
38
- PRIVATE: '仅创建者及管理员可读写',
39
- ADMINWRITE: '所有用户可读,仅管理员可写',
40
- ADMINONLY: '仅管理员可读写'
38
+ READONLY: (0, i18n_1.t)('所有用户可读,仅创建者和管理员可写'),
39
+ PRIVATE: (0, i18n_1.t)('仅创建者及管理员可读写'),
40
+ ADMINWRITE: (0, i18n_1.t)('所有用户可读,仅管理员可写'),
41
+ ADMINONLY: (0, i18n_1.t)('仅管理员可读写')
41
42
  };
42
43
  function getStorageService(envId) {
43
44
  return __awaiter(this, void 0, void 0, function* () {
@@ -47,7 +48,7 @@ function getStorageService(envId) {
47
48
  }
48
49
  function checkCloudPath(cloudPath) {
49
50
  if ((cloudPath === null || cloudPath === void 0 ? void 0 : cloudPath[0]) === '/') {
50
- throw new error_1.CloudBaseError('cloudPath 不能以 "/" 开头');
51
+ throw new error_1.CloudBaseError((0, i18n_1.t)('cloudPath 不能以 "/" 开头'));
51
52
  }
52
53
  }
53
54
  let UploadCommand = class UploadCommand extends common_1.Command {
@@ -59,15 +60,15 @@ let UploadCommand = class UploadCommand extends common_1.Command {
59
60
  options: [
60
61
  {
61
62
  flags: '-e, --envId <envId>',
62
- desc: '环境 Id'
63
+ desc: (0, i18n_1.t)('环境 Id')
63
64
  },
64
- { flags: '--times <times>', desc: '设置上传重试次数,默认值为 1' },
65
+ { flags: '--times <times>', desc: (0, i18n_1.t)('设置上传重试次数,默认值为 1') },
65
66
  {
66
67
  flags: '--interval <interval>',
67
- desc: '设置上传失败时,重试时间间隔(毫秒),默认值为 500'
68
+ desc: (0, i18n_1.t)('设置上传失败时,重试时间间隔(毫秒),默认值为 500')
68
69
  }
69
70
  ],
70
- desc: '上传文件/文件夹'
71
+ desc: (0, i18n_1.t)('上传文件/文件夹')
71
72
  };
72
73
  }
73
74
  execute(envId, params, options, log) {
@@ -78,13 +79,13 @@ let UploadCommand = class UploadCommand extends common_1.Command {
78
79
  const retryInterval = options === null || options === void 0 ? void 0 : options.interval;
79
80
  const resolveLocalPath = path_1.default.resolve(localPath);
80
81
  if (!(0, utils_1.checkFullAccess)(resolveLocalPath)) {
81
- throw new error_1.CloudBaseError('文件未找到!');
82
+ throw new error_1.CloudBaseError((0, i18n_1.t)('文件未找到!'));
82
83
  }
83
84
  if (retryCount > 10) {
84
- throw new error_1.CloudBaseError('上传重试次数为 0-10 次之间');
85
+ throw new error_1.CloudBaseError((0, i18n_1.t)('上传重试次数为 0-10 次之间'));
85
86
  }
86
87
  const loading = (0, utils_1.loadingFactory)();
87
- loading.start('准备上传中...');
88
+ loading.start((0, i18n_1.t)('准备上传中...'));
88
89
  const storageService = yield getStorageService(envId);
89
90
  const isDir = fs_1.default.statSync(resolveLocalPath).isDirectory();
90
91
  let totalFiles = 0;
@@ -94,7 +95,7 @@ let UploadCommand = class UploadCommand extends common_1.Command {
94
95
  totalFiles = files.length;
95
96
  }
96
97
  const onProgress = (0, utils_1.createUploadProgressBar)(() => {
97
- !isDir && log.success('上传文件成功!');
98
+ !isDir && log.success((0, i18n_1.t)('上传文件成功!'));
98
99
  }, () => {
99
100
  loading.stop();
100
101
  });
@@ -119,19 +120,19 @@ let UploadCommand = class UploadCommand extends common_1.Command {
119
120
  retryInterval,
120
121
  parallel: 20
121
122
  });
122
- log.success(`文件共计 ${totalFiles} 个`);
123
- log.success(`文件上传成功 ${successFiles.length} 个`);
123
+ log.success((0, i18n_1.t)('文件共计 {{count}} 个', { count: totalFiles }));
124
+ log.success((0, i18n_1.t)('文件上传成功 {{count}} 个', { count: successFiles.length }));
124
125
  if (totalFiles <= 50) {
125
- (0, utils_1.printHorizontalTable)(['状态', '文件'], successFiles.map((item) => [log_symbols_1.default.success, item]));
126
+ (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
126
127
  }
127
- log.error(`文件上传失败 ${failedFiles.length} 个`);
128
+ log.error((0, i18n_1.t)('文件上传失败 {{count}} 个', { count: failedFiles.length }));
128
129
  if (failedFiles.length) {
129
130
  if (totalFiles <= 50) {
130
- (0, utils_1.printHorizontalTable)(['状态', '文件'], failedFiles.map((item) => [log_symbols_1.default.error, item]));
131
+ (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
131
132
  }
132
133
  else {
133
134
  const errorLogPath = path_1.default.resolve('./cloudbase-error.log');
134
- log.error('上传失败文件:');
135
+ log.error((0, i18n_1.t)('上传失败文件:'));
135
136
  console.log(errorLogPath);
136
137
  fs_1.default.writeFileSync(errorLogPath, failedFiles.join('\n'));
137
138
  }
@@ -171,14 +172,14 @@ let DownloadCommand = class DownloadCommand extends common_1.Command {
171
172
  options: [
172
173
  {
173
174
  flags: '-e, --envId <envId>',
174
- desc: '环境 Id'
175
+ desc: (0, i18n_1.t)('环境 Id')
175
176
  },
176
177
  {
177
178
  flags: '-d, --dir',
178
- desc: '下载目标是否为文件夹'
179
+ desc: (0, i18n_1.t)('下载目标是否为文件夹')
179
180
  }
180
181
  ],
181
- desc: '下载文件/文件夹,文件夹需指定 --dir 选项'
182
+ desc: (0, i18n_1.t)('下载文件/文件夹,文件夹需指定 --dir 选项')
182
183
  };
183
184
  }
184
185
  execute(envId, options, params) {
@@ -188,12 +189,12 @@ let DownloadCommand = class DownloadCommand extends common_1.Command {
188
189
  const storageService = yield getStorageService(envId);
189
190
  const resolveLocalPath = path_1.default.resolve(localPath);
190
191
  const { dir } = options;
191
- const fileText = dir ? '文件夹' : '文件';
192
+ const fileText = dir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
192
193
  if (dir && !(0, utils_1.checkFullAccess)(resolveLocalPath)) {
193
- throw new error_1.CloudBaseError('存储文件夹不存在!');
194
+ throw new error_1.CloudBaseError((0, i18n_1.t)('存储文件夹不存在!'));
194
195
  }
195
196
  const loading = (0, utils_1.loadingFactory)();
196
- loading.start(`下载${fileText}中`);
197
+ loading.start((0, i18n_1.t)('下载{{type}}中', { type: fileText }));
197
198
  if (dir) {
198
199
  yield storageService.downloadDirectory({
199
200
  localPath: resolveLocalPath,
@@ -207,7 +208,7 @@ let DownloadCommand = class DownloadCommand extends common_1.Command {
207
208
  localPath: resolveLocalPath
208
209
  });
209
210
  }
210
- loading.succeed(`下载${fileText}成功!`);
211
+ loading.succeed((0, i18n_1.t)('下载{{type}}成功!', { type: fileText }));
211
212
  });
212
213
  }
213
214
  };
@@ -233,14 +234,14 @@ let DeleteFileCommand = class DeleteFileCommand extends common_1.Command {
233
234
  options: [
234
235
  {
235
236
  flags: '-e, --envId <envId>',
236
- desc: '环境 Id'
237
+ desc: (0, i18n_1.t)('环境 Id')
237
238
  },
238
239
  {
239
240
  flags: '-d, --dir',
240
- desc: '下载目标是否为文件夹'
241
+ desc: (0, i18n_1.t)('下载目标是否为文件夹')
241
242
  }
242
243
  ],
243
- desc: '删除文件/文件夹,文件夹需指定 --dir 选项'
244
+ desc: (0, i18n_1.t)('删除文件/文件夹,文件夹需指定 --dir 选项')
244
245
  };
245
246
  }
246
247
  execute(envId, options, params) {
@@ -253,26 +254,26 @@ let DeleteFileCommand = class DeleteFileCommand extends common_1.Command {
253
254
  const { confirm } = yield inquirer_1.default.prompt({
254
255
  type: 'confirm',
255
256
  name: 'confirm',
256
- message: '指定云端路径为空,将会删除所有文件,是否继续',
257
+ message: (0, i18n_1.t)('指定云端路径为空,将会删除所有文件,是否继续'),
257
258
  default: false
258
259
  });
259
260
  if (!confirm) {
260
- throw new error_1.CloudBaseError('操作终止!');
261
+ throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
261
262
  }
262
263
  isDir = true;
263
264
  }
264
265
  if (cloudPath === '/') {
265
266
  isDir = true;
266
267
  }
267
- const fileText = isDir ? '文件夹' : '文件';
268
- loading.start(`删除${fileText}中`);
268
+ const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
269
+ loading.start((0, i18n_1.t)('删除{{type}}中', { type: fileText }));
269
270
  if (isDir) {
270
271
  yield storageService.deleteDirectory(cloudPath);
271
272
  }
272
273
  else {
273
274
  yield storageService.deleteFile([cloudPath]);
274
275
  }
275
- loading.succeed(`删除${fileText}成功!`);
276
+ loading.succeed((0, i18n_1.t)('删除{{type}}成功!', { type: fileText }));
276
277
  });
277
278
  }
278
279
  };
@@ -298,10 +299,10 @@ let StorageListCommand = class StorageListCommand extends common_1.Command {
298
299
  options: [
299
300
  {
300
301
  flags: '-e, --envId <envId>',
301
- desc: '环境 Id'
302
+ desc: (0, i18n_1.t)('环境 Id')
302
303
  }
303
304
  ],
304
- desc: '获取文件存储的文件列表,不指定路径时获取全部文件列表'
305
+ desc: (0, i18n_1.t)('获取文件存储的文件列表,不指定路径时获取全部文件列表')
305
306
  };
306
307
  }
307
308
  execute(envId, params) {
@@ -309,10 +310,10 @@ let StorageListCommand = class StorageListCommand extends common_1.Command {
309
310
  const cloudPath = params === null || params === void 0 ? void 0 : params[0];
310
311
  const storageService = yield getStorageService(envId);
311
312
  const loading = (0, utils_1.loadingFactory)();
312
- loading.start('获取文件列表中...');
313
+ loading.start((0, i18n_1.t)('获取文件列表中...'));
313
314
  const list = yield storageService.listDirectoryFiles(cloudPath);
314
315
  loading.stop();
315
- const head = ['序号', 'Key', 'LastModified', 'ETag', 'Size(KB)'];
316
+ const head = [(0, i18n_1.t)('序号'), 'Key', 'LastModified', 'ETag', 'Size(KB)'];
316
317
  const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
317
318
  const tableData = list
318
319
  .filter(notDir)
@@ -348,10 +349,10 @@ let GetUrlCommand = class GetUrlCommand extends common_1.Command {
348
349
  options: [
349
350
  {
350
351
  flags: '-e, --envId <envId>',
351
- desc: '环境 Id'
352
+ desc: (0, i18n_1.t)('环境 Id')
352
353
  }
353
354
  ],
354
- desc: '获取文件临时访问地址'
355
+ desc: (0, i18n_1.t)('获取文件临时访问地址')
355
356
  };
356
357
  }
357
358
  execute(envId, params, log) {
@@ -360,7 +361,7 @@ let GetUrlCommand = class GetUrlCommand extends common_1.Command {
360
361
  const storageService = yield getStorageService(envId);
361
362
  const fileList = yield storageService.getTemporaryUrl([cloudPath]);
362
363
  const { url } = fileList[0];
363
- log.success(`文件临时访问地址:${url}`);
364
+ log.success((0, i18n_1.t)('文件临时访问地址:{{url}}', { url }));
364
365
  });
365
366
  }
366
367
  };
@@ -386,10 +387,10 @@ let StorageDetailCommand = class StorageDetailCommand extends common_1.Command {
386
387
  options: [
387
388
  {
388
389
  flags: '-e, --envId <envId>',
389
- desc: '环境 Id'
390
+ desc: (0, i18n_1.t)('环境 Id')
390
391
  }
391
392
  ],
392
- desc: '获取文件信息'
393
+ desc: (0, i18n_1.t)('获取文件信息')
393
394
  };
394
395
  }
395
396
  execute(envId, params) {
@@ -398,8 +399,12 @@ let StorageDetailCommand = class StorageDetailCommand extends common_1.Command {
398
399
  const storageService = yield getStorageService(envId);
399
400
  const fileInfo = yield storageService.getFileInfo(cloudPath);
400
401
  const date = (0, utils_1.formatDate)(fileInfo.Date, 'yyyy-MM-dd hh:mm:ss');
401
- const logInfo = `文件大小:${fileInfo.Size}\n文件类型:${fileInfo.Type}\n修改日期:${date}\nETag:${fileInfo.ETag}
402
- `;
402
+ const logInfo = (0, i18n_1.t)('文件大小:{{size}}\n文件类型:{{type}}\n修改日期:{{date}}\nETag{{etag}}', {
403
+ size: fileInfo.Size,
404
+ type: fileInfo.Type,
405
+ date,
406
+ etag: fileInfo.ETag
407
+ });
403
408
  console.log(logInfo);
404
409
  });
405
410
  }
@@ -425,17 +430,17 @@ let GetAclCommand = class GetAclCommand extends common_1.Command {
425
430
  options: [
426
431
  {
427
432
  flags: '-e, --envId <envId>',
428
- desc: '环境 Id'
433
+ desc: (0, i18n_1.t)('环境 Id')
429
434
  }
430
435
  ],
431
- desc: '获取文件存储权限信息'
436
+ desc: (0, i18n_1.t)('获取文件存储权限信息')
432
437
  };
433
438
  }
434
439
  execute(envId) {
435
440
  return __awaiter(this, void 0, void 0, function* () {
436
441
  const storageService = yield getStorageService(envId);
437
442
  const acl = yield storageService.getStorageAcl();
438
- console.log(`当前权限【${AclMap[acl]}】`);
443
+ console.log((0, i18n_1.t)('当前权限【{{acl}}】', { acl: AclMap[acl] }));
439
444
  });
440
445
  }
441
446
  };
@@ -459,10 +464,10 @@ let setAclCommand = class setAclCommand extends common_1.Command {
459
464
  options: [
460
465
  {
461
466
  flags: '-e, --envId <envId>',
462
- desc: '环境 Id'
467
+ desc: (0, i18n_1.t)('环境 Id')
463
468
  }
464
469
  ],
465
- desc: '设置文件存储权限信息'
470
+ desc: (0, i18n_1.t)('设置文件存储权限信息')
466
471
  };
467
472
  }
468
473
  execute(envId, log) {
@@ -471,28 +476,28 @@ let setAclCommand = class setAclCommand extends common_1.Command {
471
476
  const { acl } = yield inquirer_1.default.prompt({
472
477
  type: 'list',
473
478
  name: 'acl',
474
- message: '选择权限',
479
+ message: (0, i18n_1.t)('选择权限'),
475
480
  choices: [
476
481
  {
477
- name: '所有用户可读,仅创建者和管理员可写',
482
+ name: (0, i18n_1.t)('所有用户可读,仅创建者和管理员可写'),
478
483
  value: 'READONLY'
479
484
  },
480
485
  {
481
- name: '仅创建者及管理员可读写',
486
+ name: (0, i18n_1.t)('仅创建者及管理员可读写'),
482
487
  value: 'PRIVATE'
483
488
  },
484
489
  {
485
- name: '所有用户可读,仅管理员可写',
490
+ name: (0, i18n_1.t)('所有用户可读,仅管理员可写'),
486
491
  value: 'ADMINWRITE'
487
492
  },
488
493
  {
489
- name: '仅管理员可读写',
494
+ name: (0, i18n_1.t)('仅管理员可读写'),
490
495
  value: 'ADMINONLY'
491
496
  }
492
497
  ]
493
498
  });
494
499
  yield storageService.setStorageAcl(acl);
495
- log.success('设置存储权限成功!');
500
+ log.success((0, i18n_1.t)('设置存储权限成功!'));
496
501
  });
497
502
  }
498
503
  };
@@ -26,6 +26,7 @@ const common_1 = require("../common");
26
26
  const utils_1 = require("../../utils");
27
27
  const third_1 = require("../../third");
28
28
  const decorators_1 = require("../../decorators");
29
+ const i18n_1 = require("../../i18n");
29
30
  class DeleteThirdAttach extends common_1.Command {
30
31
  get options() {
31
32
  return {
@@ -35,14 +36,14 @@ class DeleteThirdAttach extends common_1.Command {
35
36
  options: [
36
37
  {
37
38
  flags: '--source <source>',
38
- desc: '第三方来源'
39
+ desc: (0, i18n_1.t)('第三方来源')
39
40
  },
40
41
  {
41
42
  flags: '--thirdAppId <thirdAppId>',
42
- desc: '第三方appId'
43
+ desc: (0, i18n_1.t)('第三方appId')
43
44
  }
44
45
  ],
45
- desc: '解除第三方绑定',
46
+ desc: (0, i18n_1.t)('解除第三方绑定'),
46
47
  requiredEnvId: false
47
48
  };
48
49
  }
@@ -54,10 +55,10 @@ class DeleteThirdAttach extends common_1.Command {
54
55
  typeFlag = 1;
55
56
  }
56
57
  if (!typeFlag) {
57
- throw new Error('请指定对应的source');
58
+ throw new Error((0, i18n_1.t)('请指定对应的source'));
58
59
  }
59
60
  const loading = (0, utils_1.loadingFactory)();
60
- loading.start('数据加载中...');
61
+ loading.start((0, i18n_1.t)('数据加载中...'));
61
62
  const data = yield (0, third_1.deleteThirdPartAttach)({
62
63
  TypeFlag: typeFlag,
63
64
  ThirdPartAppid: thirdAppId
@@ -34,17 +34,18 @@ const path_1 = __importDefault(require("path"));
34
34
  const env_1 = require("../env");
35
35
  const utils_1 = require("../utils");
36
36
  const constants_1 = require("./constants");
37
+ const i18n_1 = require("../i18n");
37
38
  function selectEnv(options = {}) {
38
39
  return __awaiter(this, void 0, void 0, function* () {
39
40
  const loading = (0, utils_1.loadingFactory)();
40
41
  const { source = [] } = options;
41
- loading.start('获取环境列表中...');
42
+ loading.start((0, i18n_1.t)('获取环境列表中...'));
42
43
  let data = yield (0, env_1.listEnvs)({ source }).finally(() => {
43
44
  loading.stop();
44
45
  });
45
46
  const choices = (0, lodash_1.sortBy)(data, ['Alias']).map((item) => {
46
47
  return {
47
- name: `${item.Alias || item.EnvId} (${item.EnvId}) ${item.Status === constants_1.EnvStatus.NORMAL ? '正常' : '不可用'}`,
48
+ name: `${item.Alias || item.EnvId} (${item.EnvId}) ${item.Status === constants_1.EnvStatus.NORMAL ? (0, i18n_1.t)('正常') : (0, i18n_1.t)('不可用')}`,
48
49
  value: item.EnvId
49
50
  };
50
51
  });
@@ -52,7 +53,7 @@ function selectEnv(options = {}) {
52
53
  {
53
54
  type: 'list',
54
55
  name: 'env',
55
- message: '请选择环境',
56
+ message: (0, i18n_1.t)('请选择环境'),
56
57
  choices: choices
57
58
  }
58
59
  ];
@@ -124,7 +125,7 @@ exports.fetchAccessToken = fetchAccessToken;
124
125
  function rawFetchAccessToken(params) {
125
126
  return __awaiter(this, void 0, void 0, function* () {
126
127
  const { envId, secretId, secretKey, token } = params;
127
- const domain = `${envId}.api.tcloudbasegateway.com`;
128
+ const domain = `${envId}.${utils_1.EDomain.Gateway}`;
128
129
  const url = `https://${domain}/auth/v1/token/clientCredential`;
129
130
  const method = 'POST';
130
131
  const body = {
@@ -176,7 +177,9 @@ function upsertCloudbaserc(projectPath, inputData) {
176
177
  yield (0, fs_extra_1.writeJson)(configPath, mergedConfig, { spaces: 2 });
177
178
  }
178
179
  catch (error) {
179
- throw new Error(`更新 cloudbaserc.json 失败: ${error instanceof Error ? error.message : String(error)}`);
180
+ throw new Error((0, i18n_1.t)('更新 cloudbaserc.json 失败: {{error}}', {
181
+ error: error instanceof Error ? error.message : String(error)
182
+ }));
180
183
  }
181
184
  });
182
185
  }
package/lib/constant.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EnvType = exports.DEFAULT_CPU_MEM_SET = exports.CPU_MEM_OPTS = exports.ConcurrencyTaskStatus = exports.StatusMap = exports.ALL_COMMANDS = exports.STATUS_TEXT = exports.REQUEST_TIMEOUT = exports.DefaultCloudBaseConfig = exports.DefaultFunctionDeployConfig = exports.ConfigItems = void 0;
4
+ const i18n_1 = require("./i18n");
4
5
  class ConfigItems {
5
6
  }
6
7
  exports.ConfigItems = ConfigItems;
@@ -19,11 +20,11 @@ exports.DefaultCloudBaseConfig = {
19
20
  };
20
21
  exports.REQUEST_TIMEOUT = 15000;
21
22
  exports.STATUS_TEXT = {
22
- UNAVAILABLE: '创建中',
23
- NORMAL: '正常',
24
- ISOLATE: '隔离中',
25
- ABNORMAL: '异常',
26
- ERROR: '异常'
23
+ UNAVAILABLE: (0, i18n_1.t)('创建中'),
24
+ NORMAL: (0, i18n_1.t)('正常'),
25
+ ISOLATE: (0, i18n_1.t)('隔离中'),
26
+ ABNORMAL: (0, i18n_1.t)('异常'),
27
+ ERROR: (0, i18n_1.t)('异常')
27
28
  };
28
29
  exports.ALL_COMMANDS = [
29
30
  'login',
@@ -98,20 +99,20 @@ exports.ALL_COMMANDS = [
98
99
  'run service:config'
99
100
  ];
100
101
  exports.StatusMap = {
101
- Active: '部署完成',
102
- Creating: '创建中',
103
- CreateFailed: '创建失败',
104
- Updating: '更新中',
105
- UpdateFailed: '更新失败',
106
- Publishing: '函数版本发布中',
107
- PublishFailed: '函数版本发布失败',
108
- Deleting: '函数删除中',
109
- DeleteFailed: '函数删除失败'
102
+ Active: (0, i18n_1.t)('部署完成'),
103
+ Creating: (0, i18n_1.t)('创建中'),
104
+ CreateFailed: (0, i18n_1.t)('创建失败'),
105
+ Updating: (0, i18n_1.t)('更新中'),
106
+ UpdateFailed: (0, i18n_1.t)('更新失败'),
107
+ Publishing: (0, i18n_1.t)('函数版本发布中'),
108
+ PublishFailed: (0, i18n_1.t)('函数版本发布失败'),
109
+ Deleting: (0, i18n_1.t)('函数删除中'),
110
+ DeleteFailed: (0, i18n_1.t)('函数删除失败')
110
111
  };
111
112
  exports.ConcurrencyTaskStatus = {
112
- Done: '已完成',
113
- InProgress: '进行中',
114
- Failed: '失败'
113
+ Done: (0, i18n_1.t)('已完成'),
114
+ InProgress: (0, i18n_1.t)('进行中'),
115
+ Failed: (0, i18n_1.t)('失败')
115
116
  };
116
117
  exports.CPU_MEM_OPTS = [
117
118
  { cpu: 0.25, mems: [0.5] },
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Deprecate = void 0;
4
+ const i18n_1 = require("../i18n");
4
5
  const utils_1 = require("../utils");
5
6
  const Deprecate = (options) => (target, key, descriptor) => {
6
7
  const { tip, allowExecute } = options;
7
8
  const rawFunc = descriptor.value;
8
9
  descriptor.value = function (...args) {
9
10
  const log = new utils_1.Logger();
10
- log.error(tip || '此命令已废弃!');
11
+ log.error(tip || (0, i18n_1.t)('此命令已废弃!'));
11
12
  if (allowExecute) {
12
13
  rawFunc.apply(this, args);
13
14
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getFunctionAliasConfig = exports.setFunctionAliasConfig = void 0;
13
13
  const error_1 = require("../error");
14
14
  const base_1 = require("./base");
15
+ const i18n_1 = require("../i18n");
15
16
  function setFunctionAliasConfig(options) {
16
17
  return __awaiter(this, void 0, void 0, function* () {
17
18
  const { envId, functionName, name, functionVersion, description, routingConfig } = options;
@@ -26,7 +27,7 @@ function setFunctionAliasConfig(options) {
26
27
  });
27
28
  }
28
29
  catch (e) {
29
- throw new error_1.CloudBaseError(`[${functionName}] 设置函数流量配置失败: ${e.message}`, {
30
+ throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 设置函数流量配置失败: {{error}}', { name: functionName, error: e.message }), {
30
31
  code: e.code
31
32
  });
32
33
  }
@@ -44,7 +45,7 @@ function getFunctionAliasConfig(options) {
44
45
  });
45
46
  }
46
47
  catch (e) {
47
- throw new error_1.CloudBaseError(`[${functionName}] 查询函数别名配置失败: ${e.message}`, {
48
+ throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 查询函数别名配置失败: {{error}}', { name: functionName, error: e.message }), {
48
49
  code: e.code
49
50
  });
50
51
  }