zyd-server-build2 1.0.12 → 1.0.15
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/README.md +2 -1
- package/index.js +9 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,7 +89,8 @@ zsb({
|
|
|
89
89
|
},
|
|
90
90
|
},
|
|
91
91
|
encryptionPath: 0, // 加密路径,1为加密,默认:0
|
|
92
|
-
|
|
92
|
+
noEncryptionPathFile: ["../server/middleware/index.js"] // 不需要加密的文件(完整路径),文件路径前需要包含src的内容,如实例,文件路径会被无改动打包到目标文件夹中
|
|
93
|
+
})
|
|
93
94
|
```
|
|
94
95
|
## License
|
|
95
96
|
[MIT](https://github.com/hfzhae/zyd-server-build/blob/main/LICENSE)
|
package/index.js
CHANGED
|
@@ -10,8 +10,10 @@ const path = require("path")
|
|
|
10
10
|
const count = [0, 0, 0]
|
|
11
11
|
const timer = []
|
|
12
12
|
const version = require('./package.json').version
|
|
13
|
+
let baseDst = ''
|
|
14
|
+
const operatingDir = generateComplexRandomString(5)
|
|
13
15
|
|
|
14
|
-
async function build({ src, dst, ignoreDir = [], ignoreFile = [], copyright = "", noBuildFile = [], noBuildDir = [], confused = 1, options = {}, encryptionPath = 0 }) {
|
|
16
|
+
async function build({ src, dst, ignoreDir = [], ignoreFile = [], copyright = "", noBuildFile = [], noBuildDir = [], noEncryptionPathFile = [], confused = 1, options = {}, encryptionPath = 0 }) {
|
|
15
17
|
if (!src || !dst) {
|
|
16
18
|
return
|
|
17
19
|
}
|
|
@@ -19,22 +21,9 @@ async function build({ src, dst, ignoreDir = [], ignoreFile = [], copyright = ""
|
|
|
19
21
|
await fs.readdirSync(src).forEach(async file => {
|
|
20
22
|
const _src = src + "/" + file
|
|
21
23
|
let _dst = dst + "/" + file
|
|
22
|
-
if (encryptionPath && !ignore(noBuildFile, _src)) {
|
|
23
|
-
|
|
24
|
-
if (dst.indexOf("/operating") !== -1) {
|
|
25
|
-
_dst = `${dst}/${generateComplexRandomString(5)}.${Math.random().toString(36).substring(2, 10)}.js`
|
|
26
|
-
} else {
|
|
27
|
-
_dst = `${dst}/operating/${generateComplexRandomString(5)}.${Math.random().toString(36).substring(2, 10)}.js`
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
if (dst.indexOf("/operating") !== -1) {
|
|
31
|
-
_dst = dst
|
|
32
|
-
} else {
|
|
33
|
-
_dst = dst + "/operating"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
24
|
+
if (encryptionPath && !ignore(noBuildFile, _src) && confused === 1 && path.extname(_src) === ".js" && !ignore(noEncryptionPathFile, _src)) {
|
|
25
|
+
_dst = `${baseDst}/z.${operatingDir}/${generateComplexRandomString(5)}.${Math.random().toString(36).substring(2, 10)}.js`
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
const st = fs.statSync(_src)
|
|
39
28
|
if (st.isFile()) {
|
|
40
29
|
count[2] += st.size
|
|
@@ -95,7 +84,7 @@ async function build({ src, dst, ignoreDir = [], ignoreFile = [], copyright = ""
|
|
|
95
84
|
return
|
|
96
85
|
}
|
|
97
86
|
makeDir(_dst)
|
|
98
|
-
await build({ src: _src, dst: _dst, ignoreDir, ignoreFile, copyright, noBuildFile, noBuildDir, confused: ignore(noBuildDir, _src) ? 0 : 1, encryptionPath })
|
|
87
|
+
await build({ src: _src, dst: _dst, ignoreDir, ignoreFile, copyright, noBuildFile, noBuildDir, noEncryptionPathFile, confused: ignore(noBuildDir, _src) ? 0 : 1, encryptionPath })
|
|
99
88
|
}
|
|
100
89
|
})
|
|
101
90
|
}
|
|
@@ -213,6 +202,7 @@ module.exports = async ({
|
|
|
213
202
|
copyright = "",
|
|
214
203
|
noBuildFile = [],
|
|
215
204
|
noBuildDir = [],
|
|
205
|
+
noEncryptionPathFile = [],
|
|
216
206
|
noDeleteDir = [".git", "node_modules"],
|
|
217
207
|
options = {
|
|
218
208
|
drop_console: true, // 删除console
|
|
@@ -244,7 +234,8 @@ module.exports = async ({
|
|
|
244
234
|
console.log("\x1B[36m\x1B[1mStart build...\x1B[0m\x1B[0m\n")
|
|
245
235
|
timer[0] = new Date()
|
|
246
236
|
exists(dst, noDeleteDir)
|
|
247
|
-
|
|
237
|
+
baseDst = dst.toString()
|
|
238
|
+
await build({ src, dst, ignoreDir, ignoreFile, copyright, noBuildFile, noBuildDir, noEncryptionPathFile, options, encryptionPath })
|
|
248
239
|
process.nextTick(() => {
|
|
249
240
|
console.log("")
|
|
250
241
|
console.log(`number of files: \x1B[36m${count[0]}\x1B[0m`)
|