zyd-server-build2 1.0.16 → 1.0.17
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/index.js +34 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -51,8 +51,16 @@ async function build({ src, dst, ignoreDir = [], ignoreFile = [], copyright = ""
|
|
|
51
51
|
compress: options,
|
|
52
52
|
mangle: {
|
|
53
53
|
// mangle options
|
|
54
|
+
// properties: {
|
|
55
|
+
// regex: /^_/ // 混淆以下划线开头的属性名
|
|
56
|
+
// },
|
|
57
|
+
// reserved: [], // 保留不被混淆的变量名列表
|
|
58
|
+
// keep_classnames: false, // 改为 false 允许混淆类名
|
|
59
|
+
// keep_fnames: false, // 改为 false 允许混淆函数名
|
|
54
60
|
},
|
|
55
61
|
format: {
|
|
62
|
+
ascii_only: true, // 这将把非ASCII字符(如中文)转换为Unicode转义序列
|
|
63
|
+
quote_style: 3 // 随机使用单引号和双引号
|
|
56
64
|
// format options (can also use `output` for backwards compatibility)
|
|
57
65
|
},
|
|
58
66
|
sourceMap: {
|
|
@@ -194,6 +202,29 @@ function generateComplexRandomString(length) {
|
|
|
194
202
|
return result;
|
|
195
203
|
}
|
|
196
204
|
|
|
205
|
+
function safeDelete(dir) {
|
|
206
|
+
try {
|
|
207
|
+
if (!fs.existsSync(dir)) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
// 先递归处理子目录
|
|
211
|
+
const files = fs.readdirSync(dir);
|
|
212
|
+
for (const file of files) {
|
|
213
|
+
const fullPath = path.join(dir, file);
|
|
214
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
215
|
+
safeDelete(fullPath);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// 处理完子目录后,再判断自己是否为空
|
|
219
|
+
if (fs.readdirSync(dir).length === 0) {
|
|
220
|
+
fs.rmdirSync(dir);
|
|
221
|
+
// console.log(`已删除: ${dir}`);
|
|
222
|
+
}
|
|
223
|
+
} catch (error) {
|
|
224
|
+
// console.error(`删除失败 [${dir}]:`, error.message);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
197
228
|
module.exports = async ({
|
|
198
229
|
src = ".",
|
|
199
230
|
dst = "./build",
|
|
@@ -235,8 +266,9 @@ module.exports = async ({
|
|
|
235
266
|
timer[0] = new Date()
|
|
236
267
|
exists(dst, noDeleteDir)
|
|
237
268
|
baseDst = dst.toString()
|
|
269
|
+
await execSync(`rm -rf ${dst}`)
|
|
238
270
|
await build({ src, dst, ignoreDir, ignoreFile, copyright, noBuildFile, noBuildDir, noEncryptionPathFile, options, encryptionPath })
|
|
239
|
-
process.nextTick(() => {
|
|
271
|
+
process.nextTick(async () => {
|
|
240
272
|
console.log("")
|
|
241
273
|
console.log(`number of files: \x1B[36m${count[0]}\x1B[0m`)
|
|
242
274
|
console.log(`Number of Obfuscated Files: \x1B[36m${count[1]}\x1B[0m`)
|
|
@@ -248,5 +280,6 @@ module.exports = async ({
|
|
|
248
280
|
│ build success √ │
|
|
249
281
|
└─────────────────┘
|
|
250
282
|
\x1B[0m\x1B[0m`)
|
|
283
|
+
safeDelete(dst)
|
|
251
284
|
})
|
|
252
285
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zyd-server-build2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "基于terser的js混淆build库,通过babel支持es6+",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"@babel/node": "^7.20.7",
|
|
24
24
|
"@babel/plugin-proposal-decorators": "^7.21.0",
|
|
25
25
|
"@babel/preset-env": "^7.21.4",
|
|
26
|
-
"terser": "^5.
|
|
26
|
+
"terser": "^5.39.0"
|
|
27
27
|
}
|
|
28
28
|
}
|