-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
195 lines (186 loc) · 5.45 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import pack from './package.json'
const main = {
dependencies: pack.dependencies,
devDependencies: pack.devDependencies,
}
const dev = {
dependencies: {
'@headlessui/vue': '^1.7.22',
'@imengyu/vue3-context-menu': '^1.4.2',
'@vueuse/components': '^11.0.3',
'@vueuse/core': '^11.0.3',
'@vueuse/integrations': '^11.0.3',
'axios': '^1.7.7',
'dayjs': '^1.11.13',
'defu': '^6.1.4',
'disable-devtool': '^0.3.7',
'element-plus': '^2.8.1',
'eruda': '^3.2.3',
'floating-vue': '5.2.2',
'hotkeys-js': '^3.13.7',
'lodash-es': '^4.17.21',
'mitt': '^3.0.1',
'mockjs': '^1.1.0',
'nprogress': '^0.2.0',
'overlayscrollbars': '^2.10.0',
'overlayscrollbars-vue': '^0.5.9',
'path-browserify': '^1.0.1',
'path-to-regexp': '^7.1.0',
'pinia': '^2.2.2',
'qs': '^6.13.0',
'scule': '^1.3.0',
'vconsole': '^3.15.1',
'vue': '^3.4.38',
'vue-m-message': '^4.0.2',
'vue-router': '^4.4.3',
},
devDependencies: {
'@antfu/eslint-config': '2.24.1',
'@iconify/json': '^2.2.243',
'@iconify/vue': '^4.1.2',
'@stylistic/stylelint-config': '^2.0.0',
'@types/lodash-es': '^4.17.12',
'@types/mockjs': '^1.0.10',
'@types/nprogress': '^0.2.3',
'@types/path-browserify': '^1.0.3',
'@types/qs': '^6.9.15',
'@unocss/eslint-plugin': '^0.62.3',
'@vitejs/plugin-legacy': '^5.4.2',
'@vitejs/plugin-vue': '^5.1.3',
'@vitejs/plugin-vue-jsx': '^4.0.1',
'archiver': '^7.0.1',
'autoprefixer': '^10.4.20',
'boxen': '^8.0.1',
'bumpp': '^9.5.2',
'cz-git': '^1.9.4',
'eslint': '^9.9.1',
'esno': '^4.7.0',
'fs-extra': '^11.2.0',
'http-server': '^14.1.1',
'inquirer': '^10.1.8',
'lint-staged': '^15.2.9',
'npm-run-all2': '^6.2.2',
'picocolors': '^1.0.1',
'plop': '^4.0.1',
'postcss': '^8.4.42',
'postcss-nested': '^6.2.0',
'sass': '^1.77.8',
'simple-git-hooks': '^2.11.1',
'stylelint': '^16.9.0',
'stylelint-config-recess-order': '^5.1.0',
'stylelint-config-standard-scss': '^13.1.0',
'stylelint-config-standard-vue': '^1.0.0',
'stylelint-scss': '^6.5.1',
'svgo': '^3.3.2',
'typescript': '^5.5.4',
'unocss': '^0.62.3',
'unocss-preset-scrollbar': '^0.3.1',
'unplugin-auto-import': '^0.18.2',
'unplugin-turbo-console': '^1.10.1',
'unplugin-vue-components': '^0.27.4',
'vite': '^5.4.2',
'vite-plugin-banner': '^0.7.1',
'vite-plugin-compression2': '^1.2.0',
'vite-plugin-fake-server': '^2.1.1',
'vite-plugin-pages': '^0.32.3',
'vite-plugin-svg-icons': '^2.0.1',
'vite-plugin-vue-devtools': '^7.3.9',
'vite-plugin-vue-meta-layouts': '^0.4.3',
'vue-tsc': '^2.1.4',
},
}
// main 循环查找 dev 依赖一样的包就用 dev 的版本
for (const key in main.dependencies) {
if (dev.dependencies[key]) {
main.dependencies[key] = dev.dependencies[key]
}
}
for (const key in main.devDependencies) {
if (dev.devDependencies[key]) {
main.devDependencies[key] = dev.devDependencies[key]
}
}
console.log('// main 循环查找 dev 依赖一样的包就用 dev 的版本')// eslint-disable-line no-console
console.log(JSON.stringify(main, null, 2))// eslint-disable-line no-console
// 找出不同的包
const diff = {
dependencies: {},
devDependencies: {},
}
for (const key in dev.dependencies) {
if (!main.dependencies[key]) {
diff.dependencies[key] = dev.dependencies[key]
}
}
for (const key in dev.devDependencies) {
if (!main.devDependencies[key]) {
diff.devDependencies[key] = dev.devDependencies[key]
}
}
console.log('// 找出不同的包')// eslint-disable-line no-console
console.log(JSON.stringify(diff, null, 2))// eslint-disable-line no-console
// 找出 main 有 dev 没有的包
const diff2 = {
dependencies: {},
devDependencies: {},
}
for (const key in main.dependencies) {
if (!dev.dependencies[key]) {
diff2.dependencies[key] = main.dependencies[key]
}
}
for (const key in main.devDependencies) {
if (!dev.devDependencies[key]) {
diff2.devDependencies[key] = main.devDependencies[key]
}
}
console.log('// 找出 main 有 dev 没有的包') // eslint-disable-line no-console
console.log(JSON.stringify(diff2, null, 2)) // eslint-disable-line no-console
// 找出 dev 有 main 没有的包
const diff3 = {
dependencies: {},
devDependencies: {},
}
for (const key in dev.dependencies) {
if (!main.dependencies[key]) {
diff3.dependencies[key] = dev.dependencies[key]
}
}
for (const key in dev.devDependencies) {
if (!main.devDependencies[key]) {
diff3.devDependencies[key] = dev.devDependencies[key]
}
}
console.log('// 找出 dev 有 main 没有的包') // eslint-disable-line no-console
console.log(JSON.stringify(diff3, null, 2)) // eslint-disable-line no-console
// const i18n = {
// key: {
// app: () => {
// return 'app'
// },
// subKey: {
// subApp: () => {
// return 'subApp'
// },
// },
// },
// key2: {
// app1: () => {
// return 'app1'
// },
// },
// }
// function executeFunctionsInObject(obj) {
// for (const key in obj) {
// if (typeof obj[key] === 'object' && obj[key] !== null) {
// // 如果值是一个对象,递归调用自身
// executeFunctionsInObject(obj[key])
// }
// else if (typeof obj[key] === 'function') {
// // 如果值是一个函数,调用函数并将结果存回原位置
// obj[key] = obj[key]({ normalize: val => `${val}` })
// }
// }
// }
//
// executeFunctionsInObject(i18n)