@winner-fed/winner-deploy 4.3.6 → 4.3.7
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/dist/index.cjs +7 -7
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7 -7
- package/package.json +1 -2
- package/templates/see/bash/scripts/afterInstall.sh +42 -0
- package/templates/see/bash/scripts/js/confuse.js +43 -0
- package/templates/see/bash/scripts/js/obfuscator.js +2 -0
- package/templates/see/bash/scripts/js/readme.md +16 -0
- package/templates/see/python/scripts/afterInstall.py +21 -3
- package/templates/see/python/scripts/js/confuse.js +43 -0
- package/templates/see/python/scripts/js/obfuscator.js +2 -0
- package/templates/see/python/scripts/js/readme.md +16 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
1. scripts/js/confuse.js
|
|
2
|
+
用 path.join(pkgRoot, webAppName, configBase + '.js') 定位配置文件,不再写死 frame-layout/sysconfig.js。
|
|
3
|
+
参数约定:argv[1] = SEE 的 webAppName;argv[2] = 配置名(不含 .js,默认 sysconfig);argv[3] = 发布包根目录(可选,默认可用 path.resolve(__dirname, '..', '..'))。
|
|
4
|
+
支持环境变量 WEB_APP_NAME、CONFIG_FILE_NAME。
|
|
5
|
+
缺 webAppName、文件不存在或混淆失败时 process.exit(1),便于 afterInstall.sh 判断。
|
|
6
|
+
|
|
7
|
+
2. scripts/afterInstall.sh
|
|
8
|
+
在安装前用 pkg_root=\pwd`记下发布包根目录(与检查${webAppName}` 时一致)。
|
|
9
|
+
cd 到脚本目录后执行:node ../js/confuse.js "${webAppName}" "{{configFileName}}" "$pkg_root"(原先 ./scripts/js/ 在 scripts/<name>/ 下会指错路径,已改为 ../js/)。
|
|
10
|
+
|
|
11
|
+
3. src/genWebPackage.ts
|
|
12
|
+
先生成 tplPath、再算 resolvedConfigFileName(与 winner / pro / 自定义 tpl 规则一致),再写脚本和 deploy.xml,避免以前「脚本里的名字」和「实际 template 名」不一致。
|
|
13
|
+
afterInstall 的 lodash 模板增加 configFileName: resolvedConfigFileName,打包后会把 {{configFileName}} 写成具体名字(如 sysconfig、config.local)。
|
|
14
|
+
genDeployXml 改为使用 resolvedConfigFileName。
|
|
15
|
+
生成 zip 时把 templates/see/bash/scripts/js 拷到 tmp/scripts/js,与 ../js/confuse.js 一致。
|
|
16
|
+
若你本地只改模板、不跑 genSeePackage,需在发布包里保留 scripts/js/,并保证 afterInstall 里第二段参数与 deploy.xml 里 ${webAppName}/xxx.js 的 xxx 一致。
|
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/python
|
|
2
2
|
# -*- coding: UTF-8 -*-
|
|
3
3
|
|
|
4
|
-
# 为上传之后的 pkg 包赋755权限
|
|
5
4
|
import os
|
|
5
|
+
import sys
|
|
6
6
|
import utils
|
|
7
7
|
|
|
8
8
|
# 读取 deploy.xml 配置文件定义的 webAppName
|
|
9
9
|
webAppName = "${webAppName}"
|
|
10
10
|
# TIPS: 执行脚本的路径是在 安装目录 下,对应 deploy.xml 里的 workspace 字段
|
|
11
11
|
pkgPath = os.path.join(os.getcwd(), webAppName)
|
|
12
|
+
pkg_root = os.getcwd()
|
|
12
13
|
|
|
13
14
|
def chmodPkg():
|
|
14
15
|
for root,dirs,files in os.walk(pkgPath):
|
|
15
16
|
for file in files:
|
|
16
17
|
if(not file[0] == "."):
|
|
17
|
-
# 生成完整路径
|
|
18
18
|
fp = os.path.join(root, file)
|
|
19
19
|
utils.chmod(fp, "755")
|
|
20
20
|
for dir in dirs:
|
|
21
21
|
if(not dir[0] == "."):
|
|
22
|
-
# 这句话没有起作用,因为walk自己还是会遍历到.dir下面去
|
|
23
22
|
dp = os.path.join(root, dir)
|
|
24
23
|
utils.chmod(dp, "755")
|
|
25
24
|
|
|
25
|
+
if not os.path.isdir(webAppName):
|
|
26
|
+
sys.stderr.write("错误: 安装检查失败。应用目录 '%s' 不存在。\n" % webAppName)
|
|
27
|
+
sys.exit(1)
|
|
28
|
+
|
|
29
|
+
if len(os.listdir(webAppName)) == 0:
|
|
30
|
+
sys.stderr.write("错误: 安装检查失败。应用目录 '%s' 存在但为空。\n" % webAppName)
|
|
31
|
+
sys.exit(1)
|
|
32
|
+
|
|
26
33
|
chmodPkg()
|
|
34
|
+
|
|
35
|
+
<% if (enableObfuscation) { %>
|
|
36
|
+
import subprocess
|
|
37
|
+
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
38
|
+
index_js = os.path.normpath(os.path.join(script_dir, '.', 'js', 'confuse.js'))
|
|
39
|
+
cmd = ['node', index_js, webAppName, '{{configFileName}}', pkg_root]
|
|
40
|
+
ret = subprocess.call(cmd)
|
|
41
|
+
if ret != 0:
|
|
42
|
+
sys.stderr.write("错误: 混淆配置文件失败。\n")
|
|
43
|
+
sys.exit(ret)
|
|
44
|
+
<% } %>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const JavaScriptObfuscator = require('./obfuscator')
|
|
4
|
+
try {
|
|
5
|
+
const webAppName = process.argv[2] || process.env.WEB_APP_NAME
|
|
6
|
+
const configBase = process.argv[3] || process.env.CONFIG_FILE_NAME || 'sysconfig'
|
|
7
|
+
const pkgRoot = process.argv[4] ? path.resolve(process.argv[4]) : path.resolve(__dirname, '..', '..')
|
|
8
|
+
if (!webAppName) {
|
|
9
|
+
console.error('缺少前端应用目录名:请传入第 1 个参数或设置环境变量 WEB_APP_NAME')
|
|
10
|
+
process.exit(1)
|
|
11
|
+
}
|
|
12
|
+
const filepath = path.join(pkgRoot, webAppName, `${configBase}.js`)
|
|
13
|
+
console.log(`__filename:${__filename}`)
|
|
14
|
+
console.log(`文件路径:${filepath}`)
|
|
15
|
+
if (!fs.existsSync(filepath)) {
|
|
16
|
+
console.error(`文件不存在: ${filepath}`)
|
|
17
|
+
process.exit(1)
|
|
18
|
+
}
|
|
19
|
+
const sourceCode = fs.readFileSync(filepath, 'utf8')
|
|
20
|
+
const obfuscationResult = JavaScriptObfuscator.obfuscate(
|
|
21
|
+
sourceCode,
|
|
22
|
+
{
|
|
23
|
+
compact: true,
|
|
24
|
+
controlFlowFlattening: true,
|
|
25
|
+
controlFlowFlatteningThreshold: 0.75,
|
|
26
|
+
deadCodeInjection: true,
|
|
27
|
+
deadCodeInjectionThreshold: 0.5,
|
|
28
|
+
numbersToExpressions: true,
|
|
29
|
+
simplify: true,
|
|
30
|
+
selfDefending: true,
|
|
31
|
+
shuffleStringArray: true,
|
|
32
|
+
splitStrings: true,
|
|
33
|
+
stringArrayThreshold: 0.75,
|
|
34
|
+
unicodeEscapeSequence: true
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
fs.writeFileSync(filepath, obfuscationResult.getObfuscatedCode())
|
|
38
|
+
console.log('代码混淆完成,并已更新成功')
|
|
39
|
+
console.log(`更新路径:${filepath}`)
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.error(e)
|
|
42
|
+
process.exit(1)
|
|
43
|
+
}
|