@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
@@ -27,6 +27,7 @@ const common_1 = require("../common");
27
27
  const utils_1 = require("../../utils");
28
28
  const decorators_1 = require("../../decorators");
29
29
  const gateway_1 = require("../../gateway");
30
+ const i18n_1 = require("../../i18n");
30
31
  let DeleteServiceCommand = class DeleteServiceCommand extends common_1.Command {
31
32
  get options() {
32
33
  return {
@@ -36,22 +37,22 @@ let DeleteServiceCommand = class DeleteServiceCommand 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: '-p, --service-path <servicePath>',
43
- desc: 'HTTP 访问服务路径,删除此路径对应的 HTTP 访问服务'
44
+ desc: (0, i18n_1.t)('HTTP 访问服务路径,删除此路径对应的 HTTP 访问服务')
44
45
  },
45
46
  {
46
47
  flags: '-i, --service-id <serviceId>',
47
- desc: 'HTTP 访问服务 Id,删除此 Id 对应的 HTTP 访问服务'
48
+ desc: (0, i18n_1.t)('HTTP 访问服务 Id,删除此 Id 对应的 HTTP 访问服务')
48
49
  },
49
50
  {
50
51
  flags: '-n, --name <name>',
51
- desc: '云函数函数名称,删除此函数绑定的所有 HTTP 访问服务'
52
+ desc: (0, i18n_1.t)('云函数函数名称,删除此函数绑定的所有 HTTP 访问服务')
52
53
  }
53
54
  ],
54
- desc: '删除 HTTP 访问服务'
55
+ desc: (0, i18n_1.t)('删除 HTTP 访问服务')
55
56
  };
56
57
  }
57
58
  execute(envId, options) {
@@ -64,9 +65,9 @@ let DeleteServiceCommand = class DeleteServiceCommand extends common_1.Command {
64
65
  const { selected } = yield (0, enquirer_1.prompt)({
65
66
  type: 'select',
66
67
  name: 'selected',
67
- message: '请选择需要删除的 Service',
68
+ message: (0, i18n_1.t)('请选择需要删除的 Service'),
68
69
  choices: allServices.map((item) => ({
69
- name: `函数名:${item.Name}/路径:${item.Path}`,
70
+ name: (0, i18n_1.t)('函数名:{{name}}/路径:{{path}}', { name: item.Name, path: item.Path }),
70
71
  value: item.APIId
71
72
  })),
72
73
  result(choices) {
@@ -79,7 +80,7 @@ let DeleteServiceCommand = class DeleteServiceCommand extends common_1.Command {
79
80
  servicePath = servicePath[0] === '/' ? servicePath : `/${servicePath}`;
80
81
  }
81
82
  const loading = (0, utils_1.loadingFactory)();
82
- loading.start('HTTP 访问服务删除中...');
83
+ loading.start((0, i18n_1.t)('HTTP 访问服务删除中...'));
83
84
  try {
84
85
  yield (0, gateway_1.deleteGateway)({
85
86
  envId,
@@ -87,7 +88,7 @@ let DeleteServiceCommand = class DeleteServiceCommand extends common_1.Command {
87
88
  path: servicePath,
88
89
  gatewayId: serviceId
89
90
  });
90
- loading.succeed('HTTP 访问服务删除成功!');
91
+ loading.succeed((0, i18n_1.t)('HTTP 访问服务删除成功!'));
91
92
  }
92
93
  catch (e) {
93
94
  loading.stop();
@@ -27,27 +27,28 @@ const error_1 = require("../../error");
27
27
  const utils_1 = require("../../utils");
28
28
  const decorators_1 = require("../../decorators");
29
29
  const gateway_1 = require("../../gateway");
30
+ const i18n_1 = require("../../i18n");
30
31
  const SERVICE_STATUS_MAP = {
31
- 1: '部署中',
32
- 2: '部署失败',
33
- 3: '部署成功',
34
- 4: '删除中',
35
- 5: '删除失败'
32
+ 1: (0, i18n_1.t)('部署中'),
33
+ 2: (0, i18n_1.t)('部署失败'),
34
+ 3: (0, i18n_1.t)('部署成功'),
35
+ 4: (0, i18n_1.t)('删除中'),
36
+ 5: (0, i18n_1.t)('删除失败')
36
37
  };
37
38
  class BindCustomDomainCommand extends common_1.Command {
38
39
  get options() {
39
40
  return {
40
41
  cmd: 'service',
41
- childCmd: { cmd: 'domain', desc: 'HTTP 访问服务域名管理' },
42
+ childCmd: { cmd: 'domain', desc: (0, i18n_1.t)('HTTP 访问服务域名管理') },
42
43
  childSubCmd: 'bind <domain>',
43
44
  deprecateCmd: 'service:domain:bind <domain>',
44
45
  options: [
45
46
  {
46
47
  flags: '-e, --envId <envId>',
47
- desc: '环境 Id'
48
+ desc: (0, i18n_1.t)('环境 Id')
48
49
  }
49
50
  ],
50
- desc: '绑定自定义HTTP 访问服务域名'
51
+ desc: (0, i18n_1.t)('绑定自定义HTTP 访问服务域名')
51
52
  };
52
53
  }
53
54
  execute(envId, params) {
@@ -55,16 +56,16 @@ class BindCustomDomainCommand extends common_1.Command {
55
56
  const domain = params === null || params === void 0 ? void 0 : params[0];
56
57
  console.log(domain);
57
58
  if (!domain) {
58
- throw new error_1.CloudBaseError('请指定需要绑定的HTTP 访问服务域名!');
59
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要绑定的HTTP 访问服务域名!'));
59
60
  }
60
61
  const loading = (0, utils_1.loadingFactory)();
61
- loading.start(`HTTP 访问服务域名 [${domain}] 绑定中...`);
62
+ loading.start((0, i18n_1.t)('HTTP 访问服务域名 [{{domain}}] 绑定中...', { domain }));
62
63
  try {
63
64
  yield (0, gateway_1.bindGatewayDomain)({
64
65
  envId,
65
66
  domain
66
67
  });
67
- loading.succeed(`HTTP 访问服务域名[${domain}] 绑定成功!`);
68
+ loading.succeed((0, i18n_1.t)('HTTP 访问服务域名[{{domain}}] 绑定成功!', { domain }));
68
69
  }
69
70
  catch (e) {
70
71
  loading.stop();
@@ -92,14 +93,14 @@ let GetCustomDomainsCommand = class GetCustomDomainsCommand extends common_1.Com
92
93
  options: [
93
94
  {
94
95
  flags: '-e, --envId <envId>',
95
- desc: '环境 Id'
96
+ desc: (0, i18n_1.t)('环境 Id')
96
97
  },
97
98
  {
98
99
  flags: '-d, --domain <domain>',
99
- desc: '域名'
100
+ desc: (0, i18n_1.t)('域名')
100
101
  }
101
102
  ],
102
- desc: '查询 HTTP 访问服务自定义域名'
103
+ desc: (0, i18n_1.t)('查询 HTTP 访问服务自定义域名')
103
104
  };
104
105
  }
105
106
  execute(envId, options, log) {
@@ -107,21 +108,21 @@ let GetCustomDomainsCommand = class GetCustomDomainsCommand extends common_1.Com
107
108
  return __awaiter(this, void 0, void 0, function* () {
108
109
  const { domain: domainName } = options;
109
110
  if (!envId && !domainName) {
110
- throw new error_1.CloudBaseError('请指定需要查询的环境 ID 或HTTP 访问服务域名!');
111
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要查询的环境 ID 或HTTP 访问服务域名!'));
111
112
  }
112
113
  const loading = (0, utils_1.loadingFactory)();
113
- loading.start('查询HTTP 访问服务域名中...');
114
+ loading.start((0, i18n_1.t)('查询HTTP 访问服务域名中...'));
114
115
  try {
115
116
  const res = yield (0, gateway_1.queryGatewayDomain)({
116
117
  envId,
117
118
  domain: domainName
118
119
  });
119
- loading.succeed('查询HTTP 访问服务域名成功!');
120
+ loading.succeed((0, i18n_1.t)('查询HTTP 访问服务域名成功!'));
120
121
  if (!((_a = res === null || res === void 0 ? void 0 : res.ServiceSet) === null || _a === void 0 ? void 0 : _a.length)) {
121
- log.info('HTTP 访问服务域名为空!');
122
+ log.info((0, i18n_1.t)('HTTP 访问服务域名为空!'));
122
123
  return;
123
124
  }
124
- const head = ['域名', '状态', '创建时间'];
125
+ const head = [(0, i18n_1.t)('域名'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('创建时间')];
125
126
  const tableData = res.ServiceSet.map((item) => [
126
127
  item.Domain,
127
128
  SERVICE_STATUS_MAP[item.Status],
@@ -159,26 +160,26 @@ let UnbindCustomDomainCommand = class UnbindCustomDomainCommand extends common_1
159
160
  options: [
160
161
  {
161
162
  flags: '-e, --envId <envId>',
162
- desc: '环境 Id'
163
+ desc: (0, i18n_1.t)('环境 Id')
163
164
  }
164
165
  ],
165
- desc: '解绑自定义HTTP 访问服务域名'
166
+ desc: (0, i18n_1.t)('解绑自定义HTTP 访问服务域名')
166
167
  };
167
168
  }
168
169
  execute(envId, params) {
169
170
  return __awaiter(this, void 0, void 0, function* () {
170
171
  const domain = params === null || params === void 0 ? void 0 : params[0];
171
172
  if (!domain) {
172
- throw new error_1.CloudBaseError('请指定需要解绑的HTTP 访问服务域名!');
173
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要解绑的HTTP 访问服务域名!'));
173
174
  }
174
175
  const loading = (0, utils_1.loadingFactory)();
175
- loading.start(`HTTP Service域名 [${domain}] 解绑中...`);
176
+ loading.start((0, i18n_1.t)('HTTP Service域名 [{{domain}}] 解绑中...', { domain }));
176
177
  try {
177
178
  yield (0, gateway_1.unbindGatewayDomain)({
178
179
  envId,
179
180
  domain
180
181
  });
181
- loading.succeed(`HTTP Service域名 [${domain}] 解绑成功!`);
182
+ loading.succeed((0, i18n_1.t)('HTTP Service域名 [{{domain}}] 解绑成功!', { domain }));
182
183
  }
183
184
  catch (e) {
184
185
  loading.stop();
@@ -27,6 +27,7 @@ const error_1 = require("../../error");
27
27
  const gateway_1 = require("../../gateway");
28
28
  const decorators_1 = require("../../decorators");
29
29
  const utils_1 = require("../../utils");
30
+ const i18n_1 = require("../../i18n");
30
31
  let ListServiceCommand = class ListServiceCommand extends common_1.Command {
31
32
  get options() {
32
33
  return {
@@ -36,22 +37,22 @@ let ListServiceCommand = class ListServiceCommand 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: '-d, --domain <domain>',
43
- desc: '自定义域名'
44
+ desc: (0, i18n_1.t)('自定义域名')
44
45
  },
45
46
  {
46
47
  flags: '-p, --service-path <servicePath>',
47
- desc: 'Service Path'
48
+ desc: (0, i18n_1.t)('Service Path')
48
49
  },
49
50
  {
50
51
  flags: '-id, --service-id <serviceId>',
51
- desc: 'Service Id'
52
+ desc: (0, i18n_1.t)('Service Id')
52
53
  }
53
54
  ],
54
- desc: '获取 HTTP 访问服务列表'
55
+ desc: (0, i18n_1.t)('获取 HTTP 访问服务列表')
55
56
  };
56
57
  }
57
58
  execute(envId, options, log) {
@@ -59,10 +60,10 @@ let ListServiceCommand = class ListServiceCommand extends common_1.Command {
59
60
  return __awaiter(this, void 0, void 0, function* () {
60
61
  const { domain: domainName, servicePath, serviceId } = options;
61
62
  if (!envId && !domainName) {
62
- throw new error_1.CloudBaseError('请指定需要查询的环境 ID 或HTTP 访问服务自定义域名!');
63
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定需要查询的环境 ID 或HTTP 访问服务自定义域名!'));
63
64
  }
64
65
  const loading = (0, utils_1.loadingFactory)();
65
- loading.start('查询HTTP 访问服务中...');
66
+ loading.start((0, i18n_1.t)('查询HTTP 访问服务中...'));
66
67
  try {
67
68
  const res = yield (0, gateway_1.queryGateway)({
68
69
  envId,
@@ -72,14 +73,14 @@ let ListServiceCommand = class ListServiceCommand extends common_1.Command {
72
73
  });
73
74
  loading.stop();
74
75
  if (((_a = res === null || res === void 0 ? void 0 : res.APISet) === null || _a === void 0 ? void 0 : _a.length) === 0) {
75
- log.info('HTTP 访问服务为空');
76
+ log.info((0, i18n_1.t)('HTTP 访问服务为空'));
76
77
  return;
77
78
  }
78
- const head = ['触发路径', '关联资源', '触发类型', '创建时间'];
79
+ const head = [(0, i18n_1.t)('触发路径'), (0, i18n_1.t)('关联资源'), (0, i18n_1.t)('触发类型'), (0, i18n_1.t)('创建时间')];
79
80
  const tableData = res.APISet.map((item) => [
80
81
  item.Path,
81
82
  item.Name,
82
- item.Type === 1 ? '云函数' : '云托管',
83
+ item.Type === 1 ? (0, i18n_1.t)('云函数') : (0, i18n_1.t)('云托管'),
83
84
  (0, utils_1.formatDate)(item.CreateTime * 1000, 'yyyy-MM-dd hh:mm:ss')
84
85
  ]);
85
86
  (0, utils_1.printHorizontalTable)(head, tableData);
@@ -27,6 +27,7 @@ const common_1 = require("../common");
27
27
  const utils_1 = require("../../utils");
28
28
  const decorators_1 = require("../../decorators");
29
29
  const gateway_1 = require("../../gateway");
30
+ const i18n_1 = require("../../i18n");
30
31
  let ServiceSwitchCommand = class ServiceSwitchCommand extends common_1.Command {
31
32
  get options() {
32
33
  return {
@@ -36,32 +37,34 @@ let ServiceSwitchCommand = class ServiceSwitchCommand 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
- desc: '开启/关闭HTTP 访问服务'
43
+ desc: (0, i18n_1.t)('开启/关闭HTTP 访问服务')
43
44
  };
44
45
  }
45
46
  execute(envId) {
46
47
  return __awaiter(this, void 0, void 0, function* () {
47
48
  const loading = (0, utils_1.loadingFactory)();
48
- loading.start('数据加载中...');
49
+ loading.start((0, i18n_1.t)('数据加载中...'));
49
50
  const { EnableService } = yield (0, gateway_1.getHttpServicePrivilege)({ envId });
50
- const status = EnableService ? '已开启' : '已关闭';
51
+ const status = EnableService ? (0, i18n_1.t)('已开启') : (0, i18n_1.t)('已关闭');
51
52
  loading.stop();
52
53
  const { enable } = yield (0, enquirer_1.prompt)({
53
54
  type: 'select',
54
55
  name: 'enable',
55
- message: `开启/关闭HTTP 访问服务(当前状态:${status})`,
56
- choices: ['开启', '关闭']
56
+ message: (0, i18n_1.t)('开启/关闭HTTP 访问服务(当前状态:{{status}})', { status }),
57
+ choices: [(0, i18n_1.t)('开启'), (0, i18n_1.t)('关闭')]
57
58
  });
58
59
  try {
59
- loading.start(`HTTP 访问服务${enable}中`);
60
+ const loadingText = enable ? (0, i18n_1.t)('HTTP 访问服务开启中') : (0, i18n_1.t)('HTTP 访问服务关闭中');
61
+ loading.start(loadingText);
60
62
  yield (0, gateway_1.switchHttpService)({
61
63
  envId,
62
- enable: enable === '开启'
64
+ enable: enable === (0, i18n_1.t)('开启')
63
65
  });
64
- loading.succeed(`HTTP 访问服务${enable}成功!`);
66
+ const successText = enable ? (0, i18n_1.t)('HTTP 访问服务开启成功!') : (0, i18n_1.t)('HTTP 访问服务关闭成功!');
67
+ loading.succeed(successText);
65
68
  }
66
69
  catch (e) {
67
70
  loading.stop();
@@ -87,39 +90,39 @@ let ServiceAuthSwitch = class ServiceAuthSwitch extends common_1.Command {
87
90
  cmd: 'service',
88
91
  childCmd: {
89
92
  cmd: 'auth',
90
- desc: 'HTTP 访问服务访问鉴权管理'
93
+ desc: (0, i18n_1.t)('HTTP 访问服务访问鉴权管理')
91
94
  },
92
95
  childSubCmd: 'switch',
93
96
  deprecateCmd: 'service:auth:switch',
94
97
  options: [
95
98
  {
96
99
  flags: '-e, --envId <envId>',
97
- desc: '环境 Id'
100
+ desc: (0, i18n_1.t)('环境 Id')
98
101
  }
99
102
  ],
100
- desc: '开启/关闭HTTP 访问服务访问鉴权'
103
+ desc: (0, i18n_1.t)('开启/关闭HTTP 访问服务访问鉴权')
101
104
  };
102
105
  }
103
106
  execute(envId) {
104
107
  return __awaiter(this, void 0, void 0, function* () {
105
108
  const loading = (0, utils_1.loadingFactory)();
106
- loading.start('数据加载中...');
109
+ loading.start((0, i18n_1.t)('数据加载中...'));
107
110
  const { EnableAuth } = yield (0, gateway_1.getHttpServicePrivilege)({ envId });
108
- const status = EnableAuth ? '已开启' : '已关闭';
111
+ const status = EnableAuth ? (0, i18n_1.t)('已开启') : (0, i18n_1.t)('已关闭');
109
112
  loading.stop();
110
113
  const { enable } = yield (0, enquirer_1.prompt)({
111
114
  type: 'select',
112
115
  name: 'enable',
113
- message: `开启/关闭HTTP 访问服务访问鉴权(当前状态:${status})`,
114
- choices: ['开启', '关闭']
116
+ message: (0, i18n_1.t)('开启/关闭HTTP 访问服务访问鉴权(当前状态:{{status}})', { status }),
117
+ choices: [(0, i18n_1.t)('开启'), (0, i18n_1.t)('关闭')]
115
118
  });
116
119
  try {
117
- loading.start(`HTTP 访问服务访问鉴权${enable}中`);
120
+ loading.start((0, i18n_1.t)('HTTP 访问服务访问鉴权{{enable}}中', { enable }));
118
121
  yield (0, gateway_1.switchHttpServiceAuth)({
119
122
  envId,
120
- enable: enable === '开启'
123
+ enable: enable === (0, i18n_1.t)('开启')
121
124
  });
122
- loading.succeed(`HTTP 访问服务访问鉴权${enable}成功!`);
125
+ loading.succeed((0, i18n_1.t)('HTTP 访问服务访问鉴权{{enable}}成功!', { enable }));
123
126
  }
124
127
  catch (e) {
125
128
  loading.stop();
@@ -40,11 +40,12 @@ const utils_1 = require("../../utils");
40
40
  const auth_1 = require("../../auth");
41
41
  const constant_1 = require("../../constant");
42
42
  const decorators_1 = require("../../decorators");
43
+ const i18n_1 = require("../../i18n");
43
44
  const listUrl = 'https://tcli.service.tcloudbase.com/templates';
44
- const consoleUrl = 'https://console.cloud.tencent.com/tcb/env/index?action=CreateEnv&from=cli';
45
+ const consoleUrl = `${utils_1.EUrl.TcbConsole}/env/index?action=CreateEnv&from=cli`;
45
46
  const CREATE_ENV = 'CREATE';
46
47
  const getTemplateAddress = (templatePath) => `https://7463-tcli-1258016615.tcb.qcloud.la/cloudbase-templates/${templatePath}.zip`;
47
- const ENV_INIT_TIP = '环境初始化中,预计需要三分钟';
48
+ const ENV_INIT_TIP = (0, i18n_1.t)('环境初始化中,预计需要三分钟');
48
49
  let InitCommand = class InitCommand extends common_1.Command {
49
50
  get options() {
50
51
  return {
@@ -52,18 +53,18 @@ let InitCommand = class InitCommand extends common_1.Command {
52
53
  options: [
53
54
  {
54
55
  flags: '--template <template>',
55
- desc: '指定项目模板名称'
56
+ desc: (0, i18n_1.t)('指定项目模板名称')
56
57
  },
57
58
  {
58
59
  flags: '--without-template',
59
- desc: '不使用模板,在当前项目初始化'
60
+ desc: (0, i18n_1.t)('不使用模板,在当前项目初始化')
60
61
  },
61
62
  {
62
63
  flags: '--project <project>',
63
- desc: '指定项目名称'
64
+ desc: (0, i18n_1.t)('指定项目名称')
64
65
  }
65
66
  ],
66
- desc: '创建并初始化一个新的云开发项目',
67
+ desc: (0, i18n_1.t)('创建并初始化一个新的云开发项目'),
67
68
  requiredEnvId: false,
68
69
  withoutAuth: true
69
70
  };
@@ -71,7 +72,7 @@ let InitCommand = class InitCommand extends common_1.Command {
71
72
  execute(options, log) {
72
73
  var _a;
73
74
  return __awaiter(this, void 0, void 0, function* () {
74
- console.log(chalk_1.default.bold.yellowBright('\n', '⚠️ 此命令将被废弃,请使用新的命令 => tcb new <appName> [template]'), '\n');
75
+ console.log(chalk_1.default.bold.yellowBright('\n', (0, i18n_1.t)('⚠️ 此命令将被废弃,请使用新的命令 => tcb new <appName> [template]')), '\n');
75
76
  yield this.checkLogin();
76
77
  const isInitNow = yield this.checkTcbService();
77
78
  let envData = [];
@@ -87,18 +88,18 @@ let InitCommand = class InitCommand extends common_1.Command {
87
88
  }), 2000);
88
89
  });
89
90
  }, {
90
- startTip: '获取环境列表中'
91
+ startTip: (0, i18n_1.t)('获取环境列表中')
91
92
  });
92
93
  }
93
94
  else {
94
95
  envData = yield (0, utils_1.execWithLoading)(() => (0, env_1.listEnvs)(), {
95
- startTip: '获取环境列表中'
96
+ startTip: (0, i18n_1.t)('获取环境列表中')
96
97
  });
97
98
  }
98
99
  envData = envData || [];
99
100
  const envs = envData
100
101
  .map((item) => {
101
- let name = `${item.Alias} - [${item.EnvId}:${item.PackageName || '按量计费'}]`;
102
+ let name = `${item.Alias} - [${item.EnvId}:${item.PackageName || (0, i18n_1.t)('按量计费')}]`;
102
103
  if (item.Status !== "NORMAL") {
103
104
  name += `(${constant_1.STATUS_TEXT[item.Status]})`;
104
105
  }
@@ -111,7 +112,7 @@ let InitCommand = class InitCommand extends common_1.Command {
111
112
  const choices = [
112
113
  ...envs,
113
114
  {
114
- name: envData.length ? '创建新环境' : '无可用环境,创建新环境',
115
+ name: envData.length ? (0, i18n_1.t)('创建新环境') : (0, i18n_1.t)('无可用环境,创建新环境'),
115
116
  value: CREATE_ENV
116
117
  }
117
118
  ];
@@ -119,18 +120,18 @@ let InitCommand = class InitCommand extends common_1.Command {
119
120
  choices,
120
121
  type: 'select',
121
122
  name: 'env',
122
- message: '选择关联环境',
123
+ message: (0, i18n_1.t)('选择关联环境'),
123
124
  result(choice) {
124
125
  return this.map(choice)[choice];
125
126
  }
126
127
  });
127
128
  if (env === CREATE_ENV) {
128
- log.success('已打开控制台,请前往控制台创建环境');
129
+ log.success((0, i18n_1.t)('已打开控制台,请前往控制台创建环境'));
129
130
  const { envId } = yield (0, toolbox_1.getDataFromWeb)((port) => `${consoleUrl}&port=${port}`, 'getData');
130
131
  if (!envId) {
131
- throw new error_1.CloudBaseError('接收环境 Id 信息失败,请重新运行 init 命令!');
132
+ throw new error_1.CloudBaseError((0, i18n_1.t)('接收环境 Id 信息失败,请重新运行 init 命令!'));
132
133
  }
133
- log.success(`创建环境成功,环境 Id: ${envId}`);
134
+ log.success((0, i18n_1.t)('创建环境成功,环境 Id: {{envId}}', { envId }));
134
135
  env = envId;
135
136
  }
136
137
  yield this.checkEnvStatus(env);
@@ -138,7 +139,7 @@ let InitCommand = class InitCommand extends common_1.Command {
138
139
  let projectPath;
139
140
  if (!options.withoutTemplate) {
140
141
  const templates = yield (0, utils_1.execWithLoading)(() => (0, utils_1.fetch)(listUrl), {
141
- startTip: '拉取云开发模板列表中'
142
+ startTip: (0, i18n_1.t)('拉取云开发模板列表中')
142
143
  });
143
144
  let templateName;
144
145
  let tempateId;
@@ -149,7 +150,7 @@ let InitCommand = class InitCommand extends common_1.Command {
149
150
  let { selectTemplateName } = yield (0, enquirer_1.prompt)({
150
151
  type: 'select',
151
152
  name: 'selectTemplateName',
152
- message: '选择云开发模板',
153
+ message: (0, i18n_1.t)('选择云开发模板'),
153
154
  choices: templates.map((item) => item.name)
154
155
  });
155
156
  templateName = selectTemplateName;
@@ -158,7 +159,7 @@ let InitCommand = class InitCommand extends common_1.Command {
158
159
  ? templates.find((item) => item.name === templateName)
159
160
  : templates.find((item) => item.path === tempateId);
160
161
  if (!selectedTemplate) {
161
- log.info(`模板 \`${templateName || tempateId}\` 不存在`);
162
+ log.info((0, i18n_1.t)('模板 `{{templateName}}` 不存在', { templateName: templateName || tempateId }));
162
163
  return;
163
164
  }
164
165
  if (options.project) {
@@ -168,7 +169,7 @@ let InitCommand = class InitCommand extends common_1.Command {
168
169
  const { projectName: promptProjectName } = yield (0, enquirer_1.prompt)({
169
170
  type: 'input',
170
171
  name: 'projectName',
171
- message: '请输入项目名称',
172
+ message: (0, i18n_1.t)('请输入项目名称'),
172
173
  initial: selectedTemplate.path
173
174
  });
174
175
  projectName = promptProjectName;
@@ -178,11 +179,11 @@ let InitCommand = class InitCommand extends common_1.Command {
178
179
  const { cover } = yield (0, enquirer_1.prompt)({
179
180
  type: 'confirm',
180
181
  name: 'cover',
181
- message: `已存在同名文件夹:${projectName},是否覆盖?`,
182
+ message: (0, i18n_1.t)('已存在同名文件夹:{{projectName}},是否覆盖?', { projectName }),
182
183
  initial: false
183
184
  });
184
185
  if (!cover) {
185
- throw new error_1.CloudBaseError('操作终止!');
186
+ throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
186
187
  }
187
188
  else {
188
189
  fs_extra_1.default.removeSync(projectPath);
@@ -192,7 +193,7 @@ let InitCommand = class InitCommand extends common_1.Command {
192
193
  yield (0, utils_1.templateDownloadReport)(selectedTemplate.path, selectedTemplate.name);
193
194
  yield this.extractTemplate(projectPath, selectedTemplate.path, selectedTemplate.url);
194
195
  }), {
195
- startTip: '下载文件中'
196
+ startTip: (0, i18n_1.t)('下载文件中')
196
197
  });
197
198
  }
198
199
  else {
@@ -219,10 +220,10 @@ let InitCommand = class InitCommand extends common_1.Command {
219
220
  return __awaiter(this, void 0, void 0, function* () {
220
221
  const credential = yield (0, utils_1.checkAndGetCredential)();
221
222
  if (lodash_1.default.isEmpty(credential)) {
222
- log.info('你还没有登录,请在控制台中授权登录');
223
+ log.info((0, i18n_1.t)('你还没有登录,请在控制台中授权登录'));
223
224
  const res = yield (0, utils_1.execWithLoading)(() => (0, auth_1.login)(), {
224
- startTip: '在浏览器中打开的授权页面进行授权...',
225
- successTip: '授权登录成功!'
225
+ startTip: (0, i18n_1.t)('在浏览器中打开的授权页面进行授权...'),
226
+ successTip: (0, i18n_1.t)('授权登录成功!')
226
227
  });
227
228
  const envId = (_a = res === null || res === void 0 ? void 0 : res.credential) === null || _a === void 0 ? void 0 : _a.envId;
228
229
  if (envId) {
@@ -241,7 +242,7 @@ let InitCommand = class InitCommand extends common_1.Command {
241
242
  yield this.checkEnvAvaliable(envId);
242
243
  }
243
244
  else if (env.Status !== "NORMAL") {
244
- throw new error_1.CloudBaseError('所有环境状态异常');
245
+ throw new error_1.CloudBaseError((0, i18n_1.t)('所有环境状态异常'));
245
246
  }
246
247
  });
247
248
  }
@@ -264,7 +265,7 @@ let InitCommand = class InitCommand extends common_1.Command {
264
265
  });
265
266
  }, {
266
267
  startTip: ENV_INIT_TIP,
267
- successTip: `环境 ${envId} 初始化成功`
268
+ successTip: (0, i18n_1.t)('环境 {{envId}} 初始化成功', { envId })
268
269
  });
269
270
  });
270
271
  }
@@ -284,17 +285,17 @@ let InitCommand = class InitCommand extends common_1.Command {
284
285
  const { jump } = yield (0, enquirer_1.prompt)({
285
286
  type: 'confirm',
286
287
  name: 'jump',
287
- message: '你还没有开通云开发服务,是否跳转到控制台开通云开发服务?(取消将无法继续操作)',
288
+ message: (0, i18n_1.t)('你还没有开通云开发服务,是否跳转到控制台开通云开发服务?(取消将无法继续操作)'),
288
289
  initial: true
289
290
  });
290
291
  if (!jump) {
291
- throw new error_1.CloudBaseError('init 操作终止,请开通云开发服务后再进行操作!');
292
+ throw new error_1.CloudBaseError((0, i18n_1.t)('init 操作终止,请开通云开发服务后再进行操作!'));
292
293
  }
293
294
  (0, open_1.default)(consoleUrl);
294
- log.success('已打开云开发控制台,请登录并在云开发控制台中开通服务!');
295
+ log.success((0, i18n_1.t)('已打开云开发控制台,请登录并在云开发控制台中开通服务!'));
295
296
  yield (0, utils_1.execWithLoading)(() => this.waitForServiceEnable(), {
296
- startTip: '等待云开发服务开通中',
297
- successTip: '云开发服务开通成功!'
297
+ startTip: (0, i18n_1.t)('等待云开发服务开通中'),
298
+ successTip: (0, i18n_1.t)('云开发服务开通成功!')
298
299
  });
299
300
  return true;
300
301
  }
@@ -329,22 +330,22 @@ let InitCommand = class InitCommand extends common_1.Command {
329
330
  const url = remoteUrl || getTemplateAddress(templatePath);
330
331
  return (0, utils_1.fetchStream)(url).then((res) => __awaiter(this, void 0, void 0, function* () {
331
332
  if (!res) {
332
- throw new error_1.CloudBaseError('请求异常');
333
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请求异常'));
333
334
  }
334
335
  if (res.status !== 200) {
335
- throw new error_1.CloudBaseError('未找到文件');
336
+ throw new error_1.CloudBaseError((0, i18n_1.t)('未找到文件'));
336
337
  }
337
338
  yield (0, toolbox_1.unzipStream)(res.body, projectPath);
338
339
  }));
339
340
  });
340
341
  }
341
342
  initSuccessOutput(projectName, log) {
342
- log.success(`初始化项目${projectName}成功!\n`);
343
+ log.success((0, i18n_1.t)('初始化项目{{projectName}}成功!\n', { projectName }));
343
344
  if (projectName) {
344
345
  const command = chalk_1.default.bold.cyan(`cd ${projectName}`);
345
- log.info(`👉 执行命令 ${command} 进入项目文件夹`);
346
+ log.info((0, i18n_1.t)('👉 执行命令 {{command}} 进入项目文件夹', { command }));
346
347
  }
347
- log.info(`👉 开发完成后,执行命令 ${chalk_1.default.bold.cyan('cloudbase framework:deploy')} 一键部署`);
348
+ log.info((0, i18n_1.t)('👉 开发完成后,执行命令 {{command}} 一键部署', { command: chalk_1.default.bold.cyan('cloudbase framework:deploy') }));
348
349
  }
349
350
  };
350
351
  __decorate([