@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
@@ -0,0 +1,206 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
+ const fs = require('fs')
3
+ const path = require('path')
4
+ const chalk = require('chalk')
5
+ const parser = require('@babel/parser')
6
+ const traverse = require('@babel/traverse').default
7
+ const t = require('@babel/types')
8
+
9
+ module.exports = {
10
+ input: [
11
+ 'src/**/*.{ts,js}',
12
+ 'bin/**/*.{js,cjs}',
13
+ '!**/node_modules/**',
14
+ // 忽略 framework 和 lowcode
15
+ '!src/commands/framework/**/*.ts',
16
+ '!src/commands/lowcode/**/*.ts',
17
+ ],
18
+ output: './',
19
+ options: {
20
+ debug: false,
21
+ func: {
22
+ list: ['t'],
23
+ extensions: ['.js', '.ts']
24
+ },
25
+ // 禁用 Trans 组件解析
26
+ trans: false,
27
+ lngs: ['zh','en'],
28
+ defaultLng: 'zh',
29
+ defaultValue: '__STRING_NOT_TRANSLATED__',
30
+ resource: {
31
+ loadPath: path.resolve(__dirname, 'langs/{{lng}}.json'),
32
+ savePath: path.resolve(__dirname, 'langs/{{lng}}.json'),
33
+ jsonIndent: 4,
34
+ lineEnding: '\n'
35
+ },
36
+ nsSeparator: false,
37
+ keySeparator: false,
38
+ interpolation: {
39
+ prefix: '{{',
40
+ suffix: '}}'
41
+ },
42
+ // 禁用复数处理
43
+ plural: false,
44
+ metadata: {},
45
+ allowDynamicKeys: false,
46
+ },
47
+ transform: function (file, enc, done) {
48
+ const parser = this.parser
49
+ const content = fs.readFileSync(file.path, enc)
50
+ let count = 0
51
+
52
+ // 解析 t() 函数调用
53
+ parser.parseFuncFromString(content, { list: ['t'] }, (key, options) => {
54
+ // 使用文本内容作为 key,后续会通过脚本转换为标识
55
+ parser.set(key, { ...options })
56
+ ++count
57
+ })
58
+
59
+ if (count > 0) {
60
+ console.log(`i18next-scanner: ${chalk.yellow(file.relative)}, count=${chalk.cyan(count)}`)
61
+ }
62
+
63
+ // 检测未使用 t() 函数包裹的中文字符串
64
+ const unwrappedStrings = detectUnwrappedStrings(content, file.relative)
65
+ if (unwrappedStrings.length > 0) {
66
+ console.log(`i18next-scanner: ${chalk.red('未处理字符串')} ${chalk.yellow(file.relative)}, count=${chalk.red(unwrappedStrings.length)}`)
67
+ unwrappedStrings.forEach(item => {
68
+ const location = item.endLine && item.endLine !== item.line
69
+ ? `L${item.line}:${item.column}-L${item.endLine}:${item.endColumn}`
70
+ : `L${item.line}:${item.column}`
71
+ console.log(` ${chalk.gray(location)} ${chalk.yellow('"')}${chalk.cyan(item.text)}${chalk.yellow('"')}`)
72
+ })
73
+ }
74
+
75
+ done()
76
+ }
77
+ }
78
+
79
+ // 检测未使用 t() 函数包裹的中文字符串
80
+ function detectUnwrappedStrings(content, filePath) {
81
+ const unwrappedStrings = []
82
+
83
+ try {
84
+ // 使用 Babel 解析代码为 AST
85
+ const ast = parser.parse(content, {
86
+ sourceType: 'module',
87
+ allowImportExportEverywhere: true,
88
+ allowReturnOutsideFunction: true,
89
+ plugins: [
90
+ 'typescript',
91
+ 'jsx',
92
+ 'decorators-legacy',
93
+ 'classProperties',
94
+ 'objectRestSpread',
95
+ 'functionBind',
96
+ 'exportDefaultFrom',
97
+ 'exportNamespaceFrom',
98
+ 'dynamicImport',
99
+ 'nullishCoalescingOperator',
100
+ 'optionalChaining'
101
+ ]
102
+ })
103
+
104
+ // 遍历 AST 节点
105
+ traverse(ast, {
106
+ // 检测字符串字面量
107
+ StringLiteral(path) {
108
+ const { node, parent } = path
109
+ const value = node.value
110
+
111
+ // 检查是否包含中文字符
112
+ if (!containsChinese(value)) {
113
+ return
114
+ }
115
+
116
+ // 检查是否被 t() 函数包裹
117
+ if (isWrapped(parent)) {
118
+ return
119
+ }
120
+
121
+ // 过滤掉不需要国际化的字符串
122
+ if (shouldIgnoreString(value)) {
123
+ return
124
+ }
125
+
126
+ unwrappedStrings.push({
127
+ text: value,
128
+ line: node.loc?.start?.line || 0,
129
+ column: node.loc?.start?.column || 0,
130
+ endLine: node.loc?.end?.line || 0,
131
+ endColumn: node.loc?.end?.column || 0
132
+ })
133
+ },
134
+
135
+ // 检测模板字符串
136
+ TemplateLiteral(path) {
137
+ const { node, parent } = path
138
+
139
+ // 检查是否被 t() 函数包裹
140
+ if (isWrapped(parent)) {
141
+ return
142
+ }
143
+
144
+ // 检查模板字符串的各个部分
145
+ node.quasis.forEach(quasi => {
146
+ const value = quasi.value.raw
147
+ if (containsChinese(value) && !shouldIgnoreString(value)) {
148
+ unwrappedStrings.push({
149
+ text: value,
150
+ line: quasi.loc?.start?.line || 0,
151
+ column: quasi.loc?.start?.column || 0,
152
+ endLine: quasi.loc?.end?.line || 0,
153
+ endColumn: quasi.loc?.end?.column || 0
154
+ })
155
+ }
156
+ })
157
+ }
158
+ })
159
+
160
+ } catch (error) {
161
+ // 如果解析失败,输出警告但不中断流程
162
+ console.log(`i18next-scanner: 解析文件失败 ${filePath}: ${error.message}`)
163
+ }
164
+
165
+ return unwrappedStrings
166
+ }
167
+
168
+ // 检查字符串是否包含中文字符
169
+ function containsChinese(str) {
170
+ return /[\u4e00-\u9fff]/.test(str)
171
+ }
172
+
173
+ // 检查字符串是否被 t() 函数包裹
174
+ function isWrapped(parent) {
175
+ if (!parent) return false
176
+
177
+ // 检查是否是 CallExpression 且 callee 是 Identifier 't'
178
+ if (t.isCallExpression(parent)) {
179
+ const callee = parent.callee
180
+ if (t.isIdentifier(callee) && callee.name === 't') {
181
+ return true
182
+ }
183
+ // 检查是否是 t() 的链式调用
184
+ if (t.isMemberExpression(callee)) {
185
+ const object = callee.object
186
+ if (t.isIdentifier(object) && object.name === 't') {
187
+ return true
188
+ }
189
+ }
190
+ }
191
+
192
+ return false
193
+ }
194
+
195
+ // 判断是否应该忽略某个字符串
196
+ function shouldIgnoreString(string) {
197
+ const trimmed = string.trim()
198
+
199
+ // 如果字符串包含中文字符,则不忽略
200
+ if (containsChinese(trimmed)) {
201
+ return false
202
+ }
203
+
204
+ // 只忽略不包含中文的字符串
205
+ return true
206
+ }