feima-shortcuts 0.3.0-beta.3 → 0.3.0-beta.4
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.
package/package.json
CHANGED
|
@@ -109,16 +109,6 @@ function checkPageLocale(pageDir) {
|
|
|
109
109
|
|
|
110
110
|
const localeKeys = loadLocaleKeys(localePath)
|
|
111
111
|
const usedKeys = extractUsedKeys(code)
|
|
112
|
-
|
|
113
|
-
// 检测代码用到但 locale.ts 未定义的 key
|
|
114
|
-
const undefinedKeys = Array.from(usedKeys).filter((k) => !localeKeys.includes(k))
|
|
115
|
-
if (undefinedKeys.length) {
|
|
116
|
-
console.log(`\n❗ 页面中使用了 locale.ts 中不存在的 key:`)
|
|
117
|
-
console.log(` ${indexVue}`)
|
|
118
|
-
undefinedKeys.forEach((k) => console.log(` - ${k}`))
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 检测 locale.ts 里未使用的 key
|
|
122
112
|
const unused = localeKeys.filter((k) => !usedKeys.has(k))
|
|
123
113
|
|
|
124
114
|
if (unused.length) {
|
|
@@ -147,8 +137,6 @@ function checkComponentLocale(componentDir) {
|
|
|
147
137
|
const invalidFiles = []
|
|
148
138
|
const skippedFiles = []
|
|
149
139
|
|
|
150
|
-
const undefinedKeyMap = new Map() // 文件 -> [key]
|
|
151
|
-
|
|
152
140
|
vueFiles.forEach((file) => {
|
|
153
141
|
const code = fs.readFileSync(file, 'utf-8')
|
|
154
142
|
const localeImport = detectLocaleImport(code)
|
|
@@ -164,14 +152,7 @@ function checkComponentLocale(componentDir) {
|
|
|
164
152
|
return
|
|
165
153
|
}
|
|
166
154
|
|
|
167
|
-
|
|
168
|
-
keys.forEach((k) => usedKeys.add(k))
|
|
169
|
-
|
|
170
|
-
// 检测未定义 key
|
|
171
|
-
const undefinedKeys = Array.from(keys).filter((k) => !localeKeys.includes(k))
|
|
172
|
-
if (undefinedKeys.length) {
|
|
173
|
-
undefinedKeyMap.set(file, undefinedKeys)
|
|
174
|
-
}
|
|
155
|
+
extractUsedKeys(code).forEach((k) => usedKeys.add(k))
|
|
175
156
|
})
|
|
176
157
|
|
|
177
158
|
let hasError = false
|
|
@@ -200,15 +181,6 @@ function checkComponentLocale(componentDir) {
|
|
|
200
181
|
)
|
|
201
182
|
}
|
|
202
183
|
|
|
203
|
-
if (undefinedKeyMap.size) {
|
|
204
|
-
hasError = true
|
|
205
|
-
console.log(`\n❗ 组件中存在未定义的 locale key:`)
|
|
206
|
-
for (const [file, keys] of undefinedKeyMap.entries()) {
|
|
207
|
-
console.log(` ${path.relative(process.cwd(), file)}`)
|
|
208
|
-
keys.forEach((k) => console.log(` - ${k}`))
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
184
|
return hasError
|
|
213
185
|
}
|
|
214
186
|
|
|
@@ -239,7 +211,3 @@ function run() {
|
|
|
239
211
|
}
|
|
240
212
|
|
|
241
213
|
exports.run = run
|
|
242
|
-
|
|
243
|
-
if (require.main === module) {
|
|
244
|
-
run()
|
|
245
|
-
}
|