vue2server7 7.0.48 → 7.0.49
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 +1 -1
- package/test/111111111111111112222 +60 -0
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// scripts/check-permission-duplicate.js
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
const rootDir = path.resolve(process.cwd(), 'src')
|
|
6
|
+
|
|
7
|
+
const permissionMap = new Map()
|
|
8
|
+
|
|
9
|
+
function scanFile(filePath) {
|
|
10
|
+
const content = fs.readFileSync(filePath, 'utf-8')
|
|
11
|
+
|
|
12
|
+
// 匹配 v-permission="xxx" 或 v-permission="'xxx'"
|
|
13
|
+
const regex = /v-permission\s*=\s*["']([^"']+)["']/g
|
|
14
|
+
|
|
15
|
+
let match
|
|
16
|
+
while ((match = regex.exec(content))) {
|
|
17
|
+
const permission = match[1].trim()
|
|
18
|
+
|
|
19
|
+
if (!permissionMap.has(permission)) {
|
|
20
|
+
permissionMap.set(permission, [])
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
permissionMap.get(permission).push(filePath)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function scanDir(dir) {
|
|
28
|
+
const files = fs.readdirSync(dir)
|
|
29
|
+
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
const fullPath = path.join(dir, file)
|
|
32
|
+
const stat = fs.statSync(fullPath)
|
|
33
|
+
|
|
34
|
+
if (stat.isDirectory()) {
|
|
35
|
+
scanDir(fullPath)
|
|
36
|
+
} else if (/\.(vue|js|ts|jsx|tsx)$/.test(file)) {
|
|
37
|
+
scanFile(fullPath)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
scanDir(rootDir)
|
|
43
|
+
|
|
44
|
+
// 输出重复
|
|
45
|
+
console.log('\n🔍 重复的权限指令如下:\n')
|
|
46
|
+
|
|
47
|
+
let hasDuplicate = false
|
|
48
|
+
|
|
49
|
+
for (const [key, files] of permissionMap.entries()) {
|
|
50
|
+
if (files.length > 1) {
|
|
51
|
+
hasDuplicate = true
|
|
52
|
+
console.log(`🚨 权限:${key}`)
|
|
53
|
+
files.forEach(f => console.log(` - ${f}`))
|
|
54
|
+
console.log('')
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!hasDuplicate) {
|
|
59
|
+
console.log('✅ 没有发现重复权限')
|
|
60
|
+
}
|