@winner-fed/winner-deploy 4.3.8 → 4.3.10
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 +46 -34
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -7
- package/package.json +1 -2
- package/templates/see/bash/deploy.xml +3 -3
- package/templates/see/bash/scripts/afterInstall.sh +11 -4
- package/templates/see/bash/scripts/js/confuse.sh +4 -2
- package/templates/see/bash/scripts/js/readme.md +2 -2
- package/templates/see/docker/deploy.xml +3 -3
- package/templates/see/python/deploy.xml +3 -3
- package/templates/see/python/scripts/afterInstall.py +11 -10
- package/templates/see/python/scripts/js/confuse.sh +4 -2
- package/templates/see/python/scripts/js/readme.md +2 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
- 🐳 支持 Docker 容器化部署(`seePackageType: 'docker'`)
|
|
14
14
|
- 🔧 灵活的模板变量配置系统(`variablesFunc` / `tplPath`)
|
|
15
15
|
- 📝 支持 Python 和 Bash 两种脚本类型
|
|
16
|
-
- 🔒 可选的安装后配置 JS 混淆(`enableObfuscation
|
|
16
|
+
- 🔒 可选的安装后配置 JS 混淆(`enableObfuscation`):有 node 走强混淆,无 node 回退 bash 轻量混淆
|
|
17
17
|
- 🎯 可自定义文件拷贝和配置生成逻辑
|
|
18
18
|
|
|
19
19
|
## 安装
|
|
@@ -91,28 +91,28 @@ generateSeePackageZip(
|
|
|
91
91
|
|
|
92
92
|
#### 参数说明
|
|
93
93
|
|
|
94
|
-
| 参数名 | 类型 | 默认值 | 必填 | 说明
|
|
95
|
-
| ----------------- | -------------------------------------- | ------------------------------------ | ---- |
|
|
96
|
-
| system | string | `'winner-front'` | 否 | 系统类型,SEE 平台分组维度
|
|
97
|
-
| type | `'bizframe' \| 'subsystem'` | `'bizframe'` | 否 | 应用类型:外框架或子系统
|
|
98
|
-
| name | string | - | 是 | 发布物名称(子系统标识、脚本目录名等)
|
|
99
|
-
| version | string | - | 是 | 发布包版本
|
|
100
|
-
| description | string | - | 否 | 发布包说明,写入 deploy.xml
|
|
101
|
-
| appType | string | `name` | 否 | 发布物类型
|
|
102
|
-
| appName | string | `name` | 否 | deploy.xml 中 `appName` 标签
|
|
103
|
-
| group | string | `'bizframe'` | 否 | 应用分组
|
|
104
|
-
| configName | string | `'config.local'` | 否 | 配置文件名(不含 `.js`)。为空时可构建不含配置 JS 的静态包,此时 `scriptsType` 应使用 `bash`。实际写入 template 的文件名还会按项目类型自动推断:存在 `dist/config.local.js` 时用 `config.local`,存在 `dist/sysconfig.js`(或子包路径下)时用 `sysconfig`
|
|
105
|
-
| outputName | string | `'dist'` | 否 | 构建产物目录名(相对项目根目录)
|
|
106
|
-
| seePackageName | string | `` `${system}-${name}-${version}` `` | 否 | zip 包文件名(不含 `.zip`)
|
|
107
|
-
| seePackagePath | string | `'package'` | 否 | zip 输出目录,相对项目根目录;设为 `'/'` 时输出到当前目录
|
|
108
|
-
| seePackageType | `'web' \| 'docker'` | `'web'` | 否 | 发布物类型
|
|
109
|
-
| dockerImage | string | - | 否 | Docker 镜像名,`seePackageType` 为 `'docker'` 时生效
|
|
110
|
-
| scriptsType | `'python' \| 'bash'` | `'python'` | 否 | 集群脚本语言
|
|
111
|
-
| enableObfuscation | boolean | `false` | 否 | 为 `true` 时打包 `scripts/{name}/js
|
|
112
|
-
| tplPath | `Record<string, string>` | `{}` | 否 |
|
|
113
|
-
| copyFiles | `string[]` | - | 否 | 额外拷贝到包内 `source/{name}/` 的文件名列表,源路径为 `` `${outputName}/${name}/${file}` ``
|
|
114
|
-
| templateFunc | `() => string \| undefined` | 见下文 | 否 | 返回待写入 template 的配置 JS 源文件路径
|
|
115
|
-
| variablesFunc | `() => FieldAttributes[] \| undefined` | 见下文 | 否 | 返回 deploy.xml 动态表单项
|
|
94
|
+
| 参数名 | 类型 | 默认值 | 必填 | 说明 |
|
|
95
|
+
| ----------------- | -------------------------------------- | ------------------------------------ | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
96
|
+
| system | string | `'winner-front'` | 否 | 系统类型,SEE 平台分组维度 |
|
|
97
|
+
| type | `'bizframe' \| 'subsystem'` | `'bizframe'` | 否 | 应用类型:外框架或子系统 |
|
|
98
|
+
| name | string | - | 是 | 发布物名称(子系统标识、脚本目录名等) |
|
|
99
|
+
| version | string | - | 是 | 发布包版本 |
|
|
100
|
+
| description | string | - | 否 | 发布包说明,写入 deploy.xml |
|
|
101
|
+
| appType | string | `name` | 否 | 发布物类型 |
|
|
102
|
+
| appName | string | `name` | 否 | deploy.xml 中 `appName` 标签 |
|
|
103
|
+
| group | string | `'bizframe'` | 否 | 应用分组 |
|
|
104
|
+
| configName | string | `'config.local'` | 否 | 配置文件名(不含 `.js`)。为空时可构建不含配置 JS 的静态包,此时 `scriptsType` 应使用 `bash`。实际写入 template 的文件名还会按项目类型自动推断:存在 `dist/config.local.js` 时用 `config.local`,存在 `dist/sysconfig.js`(或子包路径下)时用 `sysconfig` |
|
|
105
|
+
| outputName | string | `'dist'` | 否 | 构建产物目录名(相对项目根目录) |
|
|
106
|
+
| seePackageName | string | `` `${system}-${name}-${version}` `` | 否 | zip 包文件名(不含 `.zip`) |
|
|
107
|
+
| seePackagePath | string | `'package'` | 否 | zip 输出目录,相对项目根目录;设为 `'/'` 时输出到当前目录 |
|
|
108
|
+
| seePackageType | `'web' \| 'docker'` | `'web'` | 否 | 发布物类型 |
|
|
109
|
+
| dockerImage | string | - | 否 | Docker 镜像名,`seePackageType` 为 `'docker'` 时生效 |
|
|
110
|
+
| scriptsType | `'python' \| 'bash'` | `'python'` | 否 | 集群脚本语言 |
|
|
111
|
+
| enableObfuscation | boolean | `false` | 否 | 为 `true` 时打包 `scripts/{name}/js/`,并在 `afterInstall` 中对已注入变量后的配置 JS 做混淆:有 `node` 用 `confuse.js`(javascript-obfuscator 强混淆),无 `node` 用 `confuse.sh`(base64 + `TextDecoder`/`new Function` 轻量包裹,UTF-8 安全,强度较弱);为 `false` 时不拷贝、不执行混淆 |
|
|
112
|
+
| tplPath | `Record<string, string>` | `{}` | 否 | 多模板入口。`deploy.xml` 覆盖自动生成;`*.js` 经变量解析写入 `template/` 并登记为多条 `<config>`;其他文件原样进 `template/`。未提供任何 `*.js` 时仍走 `configName` + `templateFunc` 单文件逻辑 |
|
|
113
|
+
| copyFiles | `string[]` | - | 否 | 额外拷贝到包内 `source/{name}/` 的文件名列表,源路径为 `` `${outputName}/${name}/${file}` `` |
|
|
114
|
+
| templateFunc | `() => string \| undefined` | 见下文 | 否 | 返回待写入 template 的配置 JS 源文件路径 |
|
|
115
|
+
| variablesFunc | `() => FieldAttributes[] \| undefined` | 见下文 | 否 | 返回 deploy.xml 动态表单项 |
|
|
116
116
|
|
|
117
117
|
#### templateFunc 默认值
|
|
118
118
|
|
|
@@ -145,13 +145,16 @@ variablesFunc: () => {
|
|
|
145
145
|
|
|
146
146
|
```javascript
|
|
147
147
|
tplPath: {
|
|
148
|
-
'deploy.xml': '/abs/path/custom-deploy.xml',
|
|
149
|
-
'
|
|
150
|
-
|
|
148
|
+
'deploy.xml': '/abs/path/custom-deploy.xml', // 覆盖自动生成的 deploy.xml
|
|
149
|
+
'config.local.js': '/abs/path/config.local.js', // 变量解析 + 登记 <config>
|
|
150
|
+
'logo.js': '/abs/path/logo.js' // 同上,可多个 .js
|
|
151
|
+
};
|
|
151
152
|
```
|
|
152
153
|
|
|
153
|
-
-
|
|
154
|
-
-
|
|
154
|
+
- `*.js`:经 `genTemplate` 做 SEE 变量替换后写入 `template/`,并在 `deploy.xml` 中各生成一条 `<config>`;`enableObfuscation` 时 `afterInstall` 会逐个混淆。
|
|
155
|
+
- `deploy.xml`:原样覆盖包内 deploy.xml。
|
|
156
|
+
- 其他 key:原样拷贝到 `template/`。
|
|
157
|
+
- 若 `tplPath` 中没有任何 `*.js`,仍使用 `configName` + `templateFunc` 生成单个配置文件。
|
|
155
158
|
|
|
156
159
|
#### copyFiles 说明
|
|
157
160
|
|
|
@@ -224,7 +227,7 @@ const variables = [
|
|
|
224
227
|
see-package.zip
|
|
225
228
|
├── deploy.xml
|
|
226
229
|
├── template/
|
|
227
|
-
│ └── config.local.js | sysconfig.js |
|
|
230
|
+
│ └── config.local.js | sysconfig.js | 自定义多个 *.js
|
|
228
231
|
├── scripts/
|
|
229
232
|
│ └── {name}/
|
|
230
233
|
│ ├── install.py | install.sh
|
|
@@ -234,8 +237,9 @@ see-package.zip
|
|
|
234
237
|
│ ├── beforeInstall.sh # 仅 python
|
|
235
238
|
│ ├── conf/manifest.*.json # 仅 python 且 dist 含 manifest 时
|
|
236
239
|
│ └── js/ # 仅 enableObfuscation === true
|
|
237
|
-
│ ├── confuse.js
|
|
238
|
-
│
|
|
240
|
+
│ ├── confuse.js # node 强混淆入口
|
|
241
|
+
│ ├── confuse.sh # 无 node 时的 bash 轻量混淆
|
|
242
|
+
│ └── obfuscator.js # javascript-obfuscator 运行时
|
|
239
243
|
└── source/ # 安装脚本从 tmp/source 部署到 workspace
|
|
240
244
|
└── ...
|
|
241
245
|
```
|
|
@@ -276,7 +280,7 @@ generateSeePackageZip(
|
|
|
276
280
|
|
|
277
281
|
### 3. 开启配置 JS 混淆
|
|
278
282
|
|
|
279
|
-
|
|
283
|
+
混淆必须在 SEE 注入配置变量之后执行,因此放在 `afterInstall`,不能提前到打包阶段。
|
|
280
284
|
|
|
281
285
|
```javascript
|
|
282
286
|
generateSeePackageZip(
|
|
@@ -291,6 +295,14 @@ generateSeePackageZip(
|
|
|
291
295
|
);
|
|
292
296
|
```
|
|
293
297
|
|
|
298
|
+
运行时策略(bash / python 脚本一致):
|
|
299
|
+
|
|
300
|
+
1. 检测到 `node` → 执行 `confuse.js`(AST 级强混淆)
|
|
301
|
+
2. 未检测到 `node` → 执行 `confuse.sh`(整文件 base64 + `TextDecoder`/`new Function` 包裹,UTF-8 安全)
|
|
302
|
+
3. 文件已含 `__WINNER_BASH_OBFUSCATED__` 标记时,`confuse.sh` 会跳过,避免重复包裹
|
|
303
|
+
|
|
304
|
+
`confuse.sh` 仅作无 node 环境的兼容兜底,防护强度远低于 `confuse.js`。
|
|
305
|
+
|
|
294
306
|
### 4. Docker 容器化部署
|
|
295
307
|
|
|
296
308
|
```javascript
|
|
@@ -312,8 +324,8 @@ generateSeePackageZip(
|
|
|
312
324
|
2. **configName**:除手动指定外,会根据 `outputName` 下是否存在 `config.local.js` / `sysconfig.js` 自动选用文件名。
|
|
313
325
|
3. **name 特殊字符**:`@`、`/` 会在打包前替换为 `-`。
|
|
314
326
|
4. **Docker**:使用 Docker 部署时需确保镜像已构建并可被 SEE 环境拉取。
|
|
315
|
-
5. **混淆**:`enableObfuscation: true`
|
|
316
|
-
6. **Python 脚本**:目标环境需具备 Python
|
|
327
|
+
5. **混淆**:`enableObfuscation: true` 时打包 `scripts/{name}/js/`;`afterInstall` 优先用 `node`+`confuse.js`,无 `node` 时回退 `bash`+`confuse.sh`。纯 bash 无法复现 javascript-obfuscator 级别的混淆。
|
|
328
|
+
6. **Python 脚本**:目标环境需具备 Python 运行时;开启混淆时建议有 `node`,否则走 bash 轻量混淆(仍需系统有 `bash` / `base64`)。
|
|
317
329
|
|
|
318
330
|
## 更新日志
|
|
319
331
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** build time:
|
|
2
|
-
var xe=Object.create;var
|
|
3
|
-
`)}else if(
|
|
4
|
-
`):""}else{if(
|
|
5
|
-
`),description
|
|
6
|
-
`),description
|
|
7
|
-
`),
|
|
1
|
+
/** build time: Mon Sep 07 2026 09:05:55 GMT+0800 (中国标准时间), build version 4.3.10 **/
|
|
2
|
+
var xe=Object.create;var K=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames,ee=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable;var te=(r,e,n)=>e in r?K(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,U=(r,e)=>{for(var n in e||(e={}))ne.call(e,n)&&te(r,n,e[n]);if(ee)for(var n of ee(e))Ae.call(e,n)&&te(r,n,e[n]);return r};var Te=(r,e)=>{for(var n in e)K(r,n,{get:e[n],enumerable:!0})},re=(r,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Oe(e))!ne.call(r,l)&&l!==n&&K(r,l,{get:()=>e[l],enumerable:!(i=be(e,l))||i.enumerable});return r};var b=(r,e,n)=>(n=r!=null?xe(Fe(r)):{},re(e||!r||!r.__esModule?K(n,"default",{value:r,enumerable:!0}):n,r)),ke=r=>re(K({},"__esModule",{value:!0}),r);var Ie={};Te(Ie,{generateSeePackageZip:()=>je});module.exports=ke(Ie);var Se=b(require("chalk"),1),$e=b(require("path"),1),A=b(require("fs-extra"),1);var ye=b(require("path"),1),h=b(require("fs-extra"),1),G=require("rimraf");var V=b(require("path"),1),L=b(require("fs-extra"),1),oe=b(require("archiver"),1),q=b(require("xml"),1);var B=process.cwd(),C=function(e){let n={""":'"',"'":"'","<":"<",">":">"},i=/(")|(')|(<)|(>)/g;return e&&e.replace?e.replace(i,function(l){return n[l]}):e},w=function(e,n){let i=n||"",l=V.default.resolve(B,e,i,"sysconfig.js");return L.default.pathExistsSync(l)},J=function(e){let n=V.default.resolve(B,e,"config.local.js");return L.default.pathExistsSync(n)},E=function(e,n,i,l){let o=V.default.join(B,n);n!=="/"&&L.default.ensureDirSync(o);let t=L.default.createWriteStream(`${n==="/"?".":o}/${e}.zip`);t.on("close",function(){setTimeout(function(){l&&l()})});let s=(0,oe.default)("zip",{zlib:{level:9}});s.on("error",function(c){console.error(),console.error(c.stack||c),c.details&&console.error(c.details)}),s.pipe(t),s.directory(i,!1),s.finalize()},Z=function(e,n,i){let{type:l,label:o,name:t,tooltip:s="",visible:c="true",required:a="false",fixed:$="false",fold:p="false",options:u="",validate:f="",upgrade:m="false"}=e,O=e.default;if(i==="form"){let T=(0,q.default)({form:[{_attr:{name:t,tooltip:s,visible:c,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m}},n]});return C(T)}let y=l==="complexSelect"?{default:e.default}:{},d=(0,q.default)({field:[{_attr:U({type:l,label:o,name:t,tooltip:s,visible:c,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m},y)},n||O]});return C(d)},ie=function(e){let i=e.children.map(l=>{let t=l.children.map(s=>Z(s)).join("");return Z(l,t,"form")}).join("");return Z(e,i)},z=function r(e,n,i="",l=""){for(let o=0;o<e.length;o++){let t=e[o];if(t.type==="complexSelect"?(t.fullName=`${t.name}`,t.fullPath=`${t.type}`):(t.fullName=`${i===""?"":i+"."}${t.name}`,t.fullPath=`${l===""?"":l+"-"}${t.type}`),n(t))return t;if(t.children&&t.children.length>0){let s=r(t.children,n,t.fullName,t.fullPath);if(s)return s}}return null};function le(r="python"){return r==="python"?"py":"sh"}var M=b(require("fs-extra"),1),se=b(require("path"),1),R=b(require("lodash.template"),1),ce=b(require("xml"),1),ae=b(require("@babel/core"),1);var _e=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],Q=r=>se.default.resolve(__dirname,`../templates/see/${r}`),W=r=>{let e=r.type;if(!_e.includes(e))return"";let{label:n,name:i,tooltip:l="",visible:o="true",required:t="false",fixed:s="false",fold:c="false",options:a="",validate:$="",upgrade:p="false",expose:u="",algorithm:f="",merge:m="",isomeris:O="",old_name:y=""}=r,d=r.default;if(e==="table"){let g=r.keys||[];d=(r.columns||g).map(P=>W(P)).join(`
|
|
3
|
+
`)}else if(e==="switchForm"||e==="division"){let g=r.children;d=g?g.map(x=>W(x)).join(`
|
|
4
|
+
`):""}else{if(e==="complexSelect")return ie(r);e==="editor"?d=typeof d=="object"?[JSON.stringify(d)]:[d]:d=[d]}let T=e==="switchForm"?{default:r.default}:{},D=U({type:e,label:n,name:i,tooltip:l,visible:o,required:t,fixed:s,fold:c,options:a,validate:$,upgrade:p,expose:u,algorithm:f,merge:m,isomeris:O,old_name:y},T),j=Object.fromEntries(Object.entries(D).filter(([g,x])=>x!==""&&x!==null&&x!==void 0)),v=(0,ce.default)({field:[{_attr:j},...Array.isArray(d)?d:[d]]});return C(v)},pe=function({system:e,type:n,name:i,appType:l,appName:o,group:t,version:s,configFileName:c="config.local",configFileNames:a,variables:$=[],description:p,scriptsType:u="python"}){let f=Array.isArray(a)?a:c?[c]:[],m=M.default.readFileSync(Q(`${u}/deploy.xml`)).toString();return(0,R.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:o,appType:l,group:t,version:s,configFileName:f[0],configFileNames:f,variables:$.map(O=>W(O)).join(`
|
|
5
|
+
`),description:p})},X=function(e,n){let i=`${n.scriptsType}/scripts/${e}.${n.scriptsType==="python"?"py":"sh"}`;e==="beforeInstall"&&(i=`${n.scriptsType}/scripts/${e}.sh`);let l=M.default.readFileSync(Q(i)).toString();return(0,R.default)(l,{interpolate:/{{([\s\S]+?)}}/g})(n)},N=function(e,n=[]){let{code:i}=ae.default.transformFileSync(e,{babelrc:!1,plugins:[function(){return{visitor:{Literal(o){if(o.parentPath.isProperty()){let t=o.parentPath.get("key").node,s=t.name;t.type==="StringLiteral"&&(t.type="Identifier",t.name=t.value,s=t.value);let c=z(n,a=>s===a.name);if(c){if(c.fullPath.includes("complexSelect")&&(c.name=c.fullName),o.isStringLiteral()){o.node.value=`$!{${c.name}}`;return}if(o.isNumericLiteral()){o.node.value=`$!{${c.name}}`;return}if(o.isBooleanLiteral()){if(o.node.type="StringLiteral",c.fullPath.includes("complexSelect")){o.node.value=`$!{${c.fullName}}`;return}o.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(o){if(o.parentPath.isProperty()){let t=z(n,s=>o.parentPath.get("key").node.name===s.name);if(t){if(t.fullPath.includes("editor")){o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS]\${${t.name}}[NO_QUOTATION_MARKS]`;return}t.fullPath.includes("complexSelect")&&(t.name=t.fullName);let s="",c=t.keys||[],a=t.columns||c;if(t.options){s=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) '$row' , #end][NO_QUOTATION_MARKS]`,o.node.type="StringLiteral",o.node.value=s;return}a&&a.length&&a.forEach(p=>{s+=`${p.name}: '$!{row.${p.name}}',`}),o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) {${s}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(o){if(o.parentPath.isProperty()){let t=o.parentPath.get("key").node,s=t.name;if(t){let c=z(n,a=>s===a.name);if(c){if(o.node.type="StringLiteral",c.fullPath.includes("editor")){o.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`;return}o.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return i.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},fe=function({system:e,type:n,name:i,appName:l,appType:o,version:t,group:s,configFileName:c="config.local",configFileNames:a,variables:$=[],description:p,web_app_web_service_name:u,dockerImage:f}){let m=Array.isArray(a)?a:c?[c]:[],O=M.default.readFileSync(Q("docker/deploy.xml")).toString();return(0,R.default)(O,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:l,appType:o,version:t,group:s,configFileName:m[0],configFileNames:m,variables:$.map(y=>W(y)).join(`
|
|
6
|
+
`),description:p,web_app_web_service_name:u,dockerImage:f})},me=function(e){let n=M.default.readFileSync(Q("docker/k8s-deploy-res.yaml")).toString();return(0,R.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(e)},ue=function(e){let n=M.default.readFileSync(Q("docker/Dockerfile")).toString();return(0,R.default)(n)(e)};var S="tmp";function Pe(r){return r.endsWith(".js")}function Ne(r){return r.replace(/\.js$/i,"")}var ge=function(e,n,i){let{system:l,type:o,name:t,appType:s,appName:c,group:a,version:$,template:p,variables:u=[],configName:f,outputName:m="dist",description:O,scriptsType:y,enableObfuscation:d=!1,seePackagePath:T,tplPath:D}=n;h.default.ensureDirSync(S),h.default.ensureDirSync(`${S}/scripts`),h.default.ensureDirSync(`${S}/template`);let j=!1,v=[];if(D&&Object.keys(D).length>0)for(let[F,I]of Object.entries(D)){if(F==="deploy.xml"){h.default.copyFileSync(I,`./${S}/deploy.xml`),j=!0;continue}if(Pe(F)){h.default.outputFileSync(`./${S}/template/${F}`,N(I,u)),v.push(Ne(F));continue}h.default.copyFileSync(I,`./${S}/template/${F}`)}let g=[];v.length>0?g=v:J(m)?(g=["config.local"],h.default.outputFileSync(`./${S}/template/config.local.js`,p?N(p,u):"")):w(m)||w(m,t)?(g=["sysconfig"],h.default.outputFileSync(`./${S}/template/sysconfig.js`,p?N(p,u):"")):f&&(g=[f],h.default.outputFileSync(`./${S}/template/${f}.js`,p?N(p,u):""));let x=g[0];if(d&&(y==="bash"||y==="python")){let F=ye.default.resolve(__dirname,`../templates/see/${y}/scripts/js`);h.default.pathExistsSync(F)&&h.default.copySync(F,`./${S}/scripts/${t}/js`)}let P=le(y);y==="python"&&(h.default.outputFileSync(`./${S}/scripts/${t}/utils.${P}`,X("utils",{scriptsType:y})),h.default.outputFileSync(`./${S}/scripts/${t}/beforeInstall.sh`,X("beforeInstall",{scriptsType:y}))),h.default.outputFileSync(`./${S}/scripts/${t}/install.${P}`,X("install",{name:t,type:o,scriptsType:y})),h.default.outputFileSync(`./${S}/scripts/${t}/afterInstall.${P}`,X("afterInstall",{name:t,scriptsType:y,configFileName:x,configFileNames:g,enableObfuscation:d})),h.default.outputFileSync(`./${S}/scripts/${t}/uninstall.${P}`,X("uninstall",{name:t,type:o,scriptsType:y})),j||h.default.outputFileSync(`./${S}/deploy.xml`,pe({system:l,type:o,name:t,appType:s,appName:c,group:a,version:$,configFileName:x,configFileNames:g,variables:u,description:O,scriptsType:y})),i?i(F=>{E(e,T,S,()=>{G.rimraf.sync(S),typeof F=="function"&&F()})}):E(e,T,S,()=>{G.rimraf.sync(S)})};var H=b(require("path"),1),_=b(require("fs-extra"),1),Y=require("rimraf");var k="tmp",de=function(e,n,i){let{system:l,type:o,name:t,appType:s,appName:c,version:a,group:$,template:p,variables:u,configName:f,outputName:m,description:O,seePackagePath:y,dockerImage:d=a.indexOf("-")>0?`isee1.0-docker-dev-local/${t}`:`isee1.0-docker-release-local/${t}`}=n;_.default.ensureDirSync(k),_.default.ensureDirSync("docker"),_.default.pathExistsSync(H.default.resolve(process.cwd(),"docker/Dockerfile"))||_.default.outputFileSync(H.default.resolve(process.cwd(),"docker/Dockerfile"),ue({name:t,type:o})),_.default.ensureDirSync(`${k}/scripts`),_.default.ensureDirSync(`${k}/template`),J(m)?_.default.outputFileSync(`./${k}/template/${t}/config.local.js`,p?N(p,u):""):w(m)||w(m,t)?(f="sysconfig",_.default.outputFileSync(`./${k}/template/${t}/sysconfig.js`,p?N(p,u):"")):f&&_.default.outputFileSync(`./${k}/template/${t}/${f}.js`,p?N(p,u):""),_.default.outputFileSync(`./${k}/template/k8s-deploy-res.yaml`,me({configFileName:f})),_.default.outputFileSync(`./${k}/deploy.xml`,fe({system:l,type:o,name:t,appName:c,appType:s,version:a,group:$,configFileName:f,configFileNames:f?[f]:[],variables:u,description:O,web_app_web_service_name:`${t}-web`,dockerImage:d})),i?i(T=>{E(e,y,k,()=>{Y.rimraf.sync(k),typeof T=="function"&&T()})}):E(e,y,k,()=>{Y.rimraf.sync(k)})};var ve=process.cwd();function De(r,e,n){let i="",l,o=r==="bizframe"?`./${n}`:`./${n}/${e}`;return A.default.existsSync(o)&&(i=A.default.readdirSync(o).find(t=>/manifest\.[0-9]+\.json/.test(t)),i&&(l=A.default.readJsonSync(`${o}/${i}`))),{manifest:i,manifestJson:l}}var je=function({system:e="winner-front",type:n="bizframe",name:i,appType:l,appName:o,group:t="bizframe",version:s,configName:c="config.local",outputName:a="dist",templateFunc:$,variablesFunc:p,copyFiles:u,description:f,seePackageName:m,seePackagePath:O="package",seePackageType:y="web",dockerImage:d,scriptsType:T="python",enableObfuscation:D=!1,tplPath:j={}},v){if(!i||!s)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(i=i.replace(/@/gi,"").replace(/\//gi,"-"),typeof m=="string"&&m&&(m=m.replace(/@/gi,"").replace(/\//gi,"-")),l=l||i,o=o||i,p=p||function(){try{let{variables:g}=require($e.default.resolve(ve,"build","package","./variables.js"));return g||[]}catch(g){return console.error(g),[]}},$=$||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${i}/sysconfig.js`},y==="docker"){de(m||`${e}-${i}-${s}`,{system:e,type:n,name:i,appType:l,appName:o,group:t,version:s,configName:c,outputName:a,template:$(),variables:p(),seePackagePath:O,description:f,dockerImage:d},g=>{console.log(),console.log("docker \u5BB9\u5668\u5316\u90E8\u7F72\u7684 SEE \u53D1\u5E03\u7269\u5236\u4F5C\u5B8C\u6210\uFF0C\u60A8\u53EF\u4EE5\u5728 SEE \u5E73\u53F0\u4E0A\u4F20\u5E76\u90E8\u7F72\u5E94\u7528\u3002"),g(v)});return}ge(m||`${e}-${i}-${s}`,{system:e,type:n,name:i,group:t,appType:l,appName:o,version:s,configName:c,outputName:a,template:$(),variables:p(),seePackagePath:O,description:f,scriptsType:T,enableObfuscation:D,tplPath:j},g=>{if(T==="python"){let{manifest:x,manifestJson:P}=De(n,i,a);if(x){for(let F in P)if(P.hasOwnProperty(F)){let{path:I,dir:he}=P[F];A.default.ensureDirSync(`./tmp/source/${he}`),A.default.copyFileSync(`./${a}/${I}`,`./tmp/source/${I}`)}A.default.outputJSONSync(`./tmp/scripts/${i}/conf/${x}`,P)}else A.default.ensureDirSync("./tmp/source"),A.default.copySync(`./${a}`,"./tmp/source")}else A.default.ensureDirSync("./tmp/source"),A.default.copySync(`./${a}`,"./tmp/source");Array.isArray(u)&&u.length&&u.forEach(x=>{A.default.ensureFileSync(`./tmp/source/${i}/${x}`),A.default.copyFileSync(`./${a}/${i}/${x}`,`./tmp/source/${i}/${x}`)}),console.log(),console.log(`\u53D1\u5E03\u7269\u5236\u4F5C\u5B8C\u6210\uFF0C\u60A8\u53EF\u4EE5\u5728 SEE \u5E73\u53F0\u4E0A\u4F20\u5E76\u90E8\u7F72\u5E94\u7528\u3002\u6CE8\u610F\uFF1A${Se.default.yellow("\u5B50\u7CFB\u7EDF\u53D1\u5E03\u7269\u7684\u5B89\u88C5\u76EE\u5F55\u9700\u8981\u6307\u5B9A\u5230\u5177\u4F53\u7684\u5E94\u7528\u76EE\u5F55")}\u3002\u6BD4\u5982/home/hsiar/hsiar-green/html/\u3002
|
|
7
|
+
`),g(v)})};0&&(module.exports={generateSeePackageZip});
|
package/dist/index.d.cts
CHANGED
|
@@ -141,8 +141,12 @@ interface DeployOptions {
|
|
|
141
141
|
*/
|
|
142
142
|
enableObfuscation?: boolean;
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
144
|
+
* 模板文件路径。key 为包内文件名,value 为本地绝对路径。
|
|
145
|
+
* - `deploy.xml`:覆盖自动生成的 deploy.xml(原样拷贝)
|
|
146
|
+
* - `*.js`:经 genTemplate 做 SEE 变量替换后写入 template/,并登记为 deploy.xml 的 `<config>`(可多个)
|
|
147
|
+
* - 其他:原样拷贝到 template/
|
|
148
|
+
* 若未提供任何 `*.js`,仍走 configName + templateFunc 的单文件逻辑。
|
|
149
|
+
* @default {}
|
|
146
150
|
*/
|
|
147
151
|
tplPath?: Record<string, string>;
|
|
148
152
|
}
|
|
@@ -191,7 +195,7 @@ interface DeployOptions {
|
|
|
191
195
|
* @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
|
|
192
196
|
* @param scriptsType 脚本类型 'python' | 'bash'
|
|
193
197
|
* @param enableObfuscation 是否在安装后对配置 .js 做混淆,默认 false
|
|
194
|
-
* @param tplPath
|
|
198
|
+
* @param tplPath 模板文件路径。deploy.xml 可覆盖生成结果;*.js 会做变量解析并登记为多条 SEE config;其他文件原样进 template/
|
|
195
199
|
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
|
|
196
200
|
*/
|
|
197
201
|
declare const generateSeePackageZip: ({ system, type, name, appType, appName, group, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackagePath, seePackageType, dockerImage, scriptsType, enableObfuscation, tplPath }: DeployOptions, cb: () => void) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -141,8 +141,12 @@ interface DeployOptions {
|
|
|
141
141
|
*/
|
|
142
142
|
enableObfuscation?: boolean;
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
144
|
+
* 模板文件路径。key 为包内文件名,value 为本地绝对路径。
|
|
145
|
+
* - `deploy.xml`:覆盖自动生成的 deploy.xml(原样拷贝)
|
|
146
|
+
* - `*.js`:经 genTemplate 做 SEE 变量替换后写入 template/,并登记为 deploy.xml 的 `<config>`(可多个)
|
|
147
|
+
* - 其他:原样拷贝到 template/
|
|
148
|
+
* 若未提供任何 `*.js`,仍走 configName + templateFunc 的单文件逻辑。
|
|
149
|
+
* @default {}
|
|
146
150
|
*/
|
|
147
151
|
tplPath?: Record<string, string>;
|
|
148
152
|
}
|
|
@@ -191,7 +195,7 @@ interface DeployOptions {
|
|
|
191
195
|
* @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
|
|
192
196
|
* @param scriptsType 脚本类型 'python' | 'bash'
|
|
193
197
|
* @param enableObfuscation 是否在安装后对配置 .js 做混淆,默认 false
|
|
194
|
-
* @param tplPath
|
|
198
|
+
* @param tplPath 模板文件路径。deploy.xml 可覆盖生成结果;*.js 会做变量解析并登记为多条 SEE config;其他文件原样进 template/
|
|
195
199
|
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
|
|
196
200
|
*/
|
|
197
201
|
declare const generateSeePackageZip: ({ system, type, name, appType, appName, group, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackagePath, seePackageType, dockerImage, scriptsType, enableObfuscation, tplPath }: DeployOptions, cb: () => void) => void;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** build time:
|
|
2
|
-
var
|
|
3
|
-
`)}else if(t==="switchForm"||t==="division"){let
|
|
4
|
-
`):""}else{if(t==="complexSelect")return H(i);t==="editor"?
|
|
5
|
-
`),description
|
|
6
|
-
`),description
|
|
7
|
-
`),
|
|
1
|
+
/** build time: Mon Sep 07 2026 09:05:55 GMT+0800 (中国标准时间), build version 4.3.10 **/
|
|
2
|
+
var pe=Object.defineProperty;var Z=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var q=(i,t,n)=>t in i?pe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,K=(i,t)=>{for(var n in t||(t={}))fe.call(t,n)&&q(i,n,t[n]);if(Z)for(var n of Z(t))me.call(t,n)&&q(i,n,t[n]);return i};var B=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(t,n)=>(typeof require!="undefined"?require:t)[n]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});import be from"chalk";import Oe from"path";import T from"fs-extra";import $e from"path";import h from"fs-extra";import{rimraf as oe}from"rimraf";import z from"path";import L from"fs-extra";import ue from"archiver";import G from"xml";var W=process.cwd(),Q=function(t){let n={""":'"',"'":"'","<":"<",">":">"},o=/(")|(')|(<)|(>)/g;return t&&t.replace?t.replace(o,function(c){return n[c]}):t},I=function(t,n){let o=n||"",c=z.resolve(W,t,o,"sysconfig.js");return L.pathExistsSync(c)},U=function(t){let n=z.resolve(W,t,"config.local.js");return L.pathExistsSync(n)},w=function(t,n,o,c){let r=z.join(W,n);n!=="/"&&L.ensureDirSync(r);let e=L.createWriteStream(`${n==="/"?".":r}/${t}.zip`);e.on("close",function(){setTimeout(function(){c&&c()})});let l=ue("zip",{zlib:{level:9}});l.on("error",function(s){console.error(),console.error(s.stack||s),s.details&&console.error(s.details)}),l.pipe(e),l.directory(o,!1),l.finalize()},J=function(t,n,o){let{type:c,label:r,name:e,tooltip:l="",visible:s="true",required:a="false",fixed:$="false",fold:p="false",options:u="",validate:f="",upgrade:m="false"}=t,b=t.default;if(o==="form"){let F=G({form:[{_attr:{name:e,tooltip:l,visible:s,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m}},n]});return Q(F)}let y=c==="complexSelect"?{default:t.default}:{},d=G({field:[{_attr:K({type:c,label:r,name:e,tooltip:l,visible:s,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m},y)},n||b]});return Q(d)},H=function(t){let o=t.children.map(c=>{let e=c.children.map(l=>J(l)).join("");return J(c,e,"form")}).join("");return J(t,o)},C=function i(t,n,o="",c=""){for(let r=0;r<t.length;r++){let e=t[r];if(e.type==="complexSelect"?(e.fullName=`${e.name}`,e.fullPath=`${e.type}`):(e.fullName=`${o===""?"":o+"."}${e.name}`,e.fullPath=`${c===""?"":c+"-"}${e.type}`),n(e))return e;if(e.children&&e.children.length>0){let l=i(e.children,n,e.fullName,e.fullPath);if(l)return l}}return null};function Y(i="python"){return i==="python"?"py":"sh"}import M from"fs-extra";import ye from"path";import R from"lodash.template";import ge from"xml";import de from"@babel/core";var Se=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],X=i=>ye.resolve(__dirname,`../templates/see/${i}`),V=i=>{let t=i.type;if(!Se.includes(t))return"";let{label:n,name:o,tooltip:c="",visible:r="true",required:e="false",fixed:l="false",fold:s="false",options:a="",validate:$="",upgrade:p="false",expose:u="",algorithm:f="",merge:m="",isomeris:b="",old_name:y=""}=i,d=i.default;if(t==="table"){let g=i.keys||[];d=(i.columns||g).map(k=>V(k)).join(`
|
|
3
|
+
`)}else if(t==="switchForm"||t==="division"){let g=i.children;d=g?g.map(x=>V(x)).join(`
|
|
4
|
+
`):""}else{if(t==="complexSelect")return H(i);t==="editor"?d=typeof d=="object"?[JSON.stringify(d)]:[d]:d=[d]}let F=t==="switchForm"?{default:i.default}:{},v=K({type:t,label:n,name:o,tooltip:c,visible:r,required:e,fixed:l,fold:s,options:a,validate:$,upgrade:p,expose:u,algorithm:f,merge:m,isomeris:b,old_name:y},F),D=Object.fromEntries(Object.entries(v).filter(([g,x])=>x!==""&&x!==null&&x!==void 0)),N=ge({field:[{_attr:D},...Array.isArray(d)?d:[d]]});return Q(N)},ee=function({system:t,type:n,name:o,appType:c,appName:r,group:e,version:l,configFileName:s="config.local",configFileNames:a,variables:$=[],description:p,scriptsType:u="python"}){let f=Array.isArray(a)?a:s?[s]:[],m=M.readFileSync(X(`${u}/deploy.xml`)).toString();return R(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:o,appName:r,appType:c,group:e,version:l,configFileName:f[0],configFileNames:f,variables:$.map(b=>V(b)).join(`
|
|
5
|
+
`),description:p})},E=function(t,n){let o=`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`;t==="beforeInstall"&&(o=`${n.scriptsType}/scripts/${t}.sh`);let c=M.readFileSync(X(o)).toString();return R(c,{interpolate:/{{([\s\S]+?)}}/g})(n)},P=function(t,n=[]){let{code:o}=de.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(r){if(r.parentPath.isProperty()){let e=r.parentPath.get("key").node,l=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,l=e.value);let s=C(n,a=>l===a.name);if(s){if(s.fullPath.includes("complexSelect")&&(s.name=s.fullName),r.isStringLiteral()){r.node.value=`$!{${s.name}}`;return}if(r.isNumericLiteral()){r.node.value=`$!{${s.name}}`;return}if(r.isBooleanLiteral()){if(r.node.type="StringLiteral",s.fullPath.includes("complexSelect")){r.node.value=`$!{${s.fullName}}`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(r){if(r.parentPath.isProperty()){let e=C(n,l=>r.parentPath.get("key").node.name===l.name);if(e){if(e.fullPath.includes("editor")){r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS]\${${e.name}}[NO_QUOTATION_MARKS]`;return}e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let l="",s=e.keys||[],a=e.columns||s;if(e.options){l=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,r.node.type="StringLiteral",r.node.value=l;return}a&&a.length&&a.forEach(p=>{l+=`${p.name}: '$!{row.${p.name}}',`}),r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${l}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(r){if(r.parentPath.isProperty()){let e=r.parentPath.get("key").node,l=e.name;if(e){let s=C(n,a=>l===a.name);if(s){if(r.node.type="StringLiteral",s.fullPath.includes("editor")){r.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return o.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},te=function({system:t,type:n,name:o,appName:c,appType:r,version:e,group:l,configFileName:s="config.local",configFileNames:a,variables:$=[],description:p,web_app_web_service_name:u,dockerImage:f}){let m=Array.isArray(a)?a:s?[s]:[],b=M.readFileSync(X("docker/deploy.xml")).toString();return R(b,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:o,appName:c,appType:r,version:e,group:l,configFileName:m[0],configFileNames:m,variables:$.map(y=>V(y)).join(`
|
|
6
|
+
`),description:p,web_app_web_service_name:u,dockerImage:f})},ne=function(t){let n=M.readFileSync(X("docker/k8s-deploy-res.yaml")).toString();return R(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},re=function(t){let n=M.readFileSync(X("docker/Dockerfile")).toString();return R(n)(t)};var S="tmp";function he(i){return i.endsWith(".js")}function xe(i){return i.replace(/\.js$/i,"")}var ie=function(t,n,o){let{system:c,type:r,name:e,appType:l,appName:s,group:a,version:$,template:p,variables:u=[],configName:f,outputName:m="dist",description:b,scriptsType:y,enableObfuscation:d=!1,seePackagePath:F,tplPath:v}=n;h.ensureDirSync(S),h.ensureDirSync(`${S}/scripts`),h.ensureDirSync(`${S}/template`);let D=!1,N=[];if(v&&Object.keys(v).length>0)for(let[O,j]of Object.entries(v)){if(O==="deploy.xml"){h.copyFileSync(j,`./${S}/deploy.xml`),D=!0;continue}if(he(O)){h.outputFileSync(`./${S}/template/${O}`,P(j,u)),N.push(xe(O));continue}h.copyFileSync(j,`./${S}/template/${O}`)}let g=[];N.length>0?g=N:U(m)?(g=["config.local"],h.outputFileSync(`./${S}/template/config.local.js`,p?P(p,u):"")):I(m)||I(m,e)?(g=["sysconfig"],h.outputFileSync(`./${S}/template/sysconfig.js`,p?P(p,u):"")):f&&(g=[f],h.outputFileSync(`./${S}/template/${f}.js`,p?P(p,u):""));let x=g[0];if(d&&(y==="bash"||y==="python")){let O=$e.resolve(__dirname,`../templates/see/${y}/scripts/js`);h.pathExistsSync(O)&&h.copySync(O,`./${S}/scripts/${e}/js`)}let k=Y(y);y==="python"&&(h.outputFileSync(`./${S}/scripts/${e}/utils.${k}`,E("utils",{scriptsType:y})),h.outputFileSync(`./${S}/scripts/${e}/beforeInstall.sh`,E("beforeInstall",{scriptsType:y}))),h.outputFileSync(`./${S}/scripts/${e}/install.${k}`,E("install",{name:e,type:r,scriptsType:y})),h.outputFileSync(`./${S}/scripts/${e}/afterInstall.${k}`,E("afterInstall",{name:e,scriptsType:y,configFileName:x,configFileNames:g,enableObfuscation:d})),h.outputFileSync(`./${S}/scripts/${e}/uninstall.${k}`,E("uninstall",{name:e,type:r,scriptsType:y})),D||h.outputFileSync(`./${S}/deploy.xml`,ee({system:c,type:r,name:e,appType:l,appName:s,group:a,version:$,configFileName:x,configFileNames:g,variables:u,description:b,scriptsType:y})),o?o(O=>{w(t,F,S,()=>{oe.sync(S),typeof O=="function"&&O()})}):w(t,F,S,()=>{oe.sync(S)})};import le from"path";import _ from"fs-extra";import{rimraf as se}from"rimraf";var A="tmp",ce=function(t,n,o){let{system:c,type:r,name:e,appType:l,appName:s,version:a,group:$,template:p,variables:u,configName:f,outputName:m,description:b,seePackagePath:y,dockerImage:d=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;_.ensureDirSync(A),_.ensureDirSync("docker"),_.pathExistsSync(le.resolve(process.cwd(),"docker/Dockerfile"))||_.outputFileSync(le.resolve(process.cwd(),"docker/Dockerfile"),re({name:e,type:r})),_.ensureDirSync(`${A}/scripts`),_.ensureDirSync(`${A}/template`),U(m)?_.outputFileSync(`./${A}/template/${e}/config.local.js`,p?P(p,u):""):I(m)||I(m,e)?(f="sysconfig",_.outputFileSync(`./${A}/template/${e}/sysconfig.js`,p?P(p,u):"")):f&&_.outputFileSync(`./${A}/template/${e}/${f}.js`,p?P(p,u):""),_.outputFileSync(`./${A}/template/k8s-deploy-res.yaml`,ne({configFileName:f})),_.outputFileSync(`./${A}/deploy.xml`,te({system:c,type:r,name:e,appName:s,appType:l,version:a,group:$,configFileName:f,configFileNames:f?[f]:[],variables:u,description:b,web_app_web_service_name:`${e}-web`,dockerImage:d})),o?o(F=>{w(t,y,A,()=>{se.sync(A),typeof F=="function"&&F()})}):w(t,y,A,()=>{se.sync(A)})};var Fe=process.cwd();function Ae(i,t,n){let o="",c,r=i==="bizframe"?`./${n}`:`./${n}/${t}`;return T.existsSync(r)&&(o=T.readdirSync(r).find(e=>/manifest\.[0-9]+\.json/.test(e)),o&&(c=T.readJsonSync(`${r}/${o}`))),{manifest:o,manifestJson:c}}var rt=function({system:t="winner-front",type:n="bizframe",name:o,appType:c,appName:r,group:e="bizframe",version:l,configName:s="config.local",outputName:a="dist",templateFunc:$,variablesFunc:p,copyFiles:u,description:f,seePackageName:m,seePackagePath:b="package",seePackageType:y="web",dockerImage:d,scriptsType:F="python",enableObfuscation:v=!1,tplPath:D={}},N){if(!o||!l)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(o=o.replace(/@/gi,"").replace(/\//gi,"-"),typeof m=="string"&&m&&(m=m.replace(/@/gi,"").replace(/\//gi,"-")),c=c||o,r=r||o,p=p||function(){try{let{variables:g}=B(Oe.resolve(Fe,"build","package","./variables.js"));return g||[]}catch(g){return console.error(g),[]}},$=$||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${o}/sysconfig.js`},y==="docker"){ce(m||`${t}-${o}-${l}`,{system:t,type:n,name:o,appType:c,appName:r,group:e,version:l,configName:s,outputName:a,template:$(),variables:p(),seePackagePath:b,description:f,dockerImage:d},g=>{console.log(),console.log("docker \u5BB9\u5668\u5316\u90E8\u7F72\u7684 SEE \u53D1\u5E03\u7269\u5236\u4F5C\u5B8C\u6210\uFF0C\u60A8\u53EF\u4EE5\u5728 SEE \u5E73\u53F0\u4E0A\u4F20\u5E76\u90E8\u7F72\u5E94\u7528\u3002"),g(N)});return}ie(m||`${t}-${o}-${l}`,{system:t,type:n,name:o,group:e,appType:c,appName:r,version:l,configName:s,outputName:a,template:$(),variables:p(),seePackagePath:b,description:f,scriptsType:F,enableObfuscation:v,tplPath:D},g=>{if(F==="python"){let{manifest:x,manifestJson:k}=Ae(n,o,a);if(x){for(let O in k)if(k.hasOwnProperty(O)){let{path:j,dir:ae}=k[O];T.ensureDirSync(`./tmp/source/${ae}`),T.copyFileSync(`./${a}/${j}`,`./tmp/source/${j}`)}T.outputJSONSync(`./tmp/scripts/${o}/conf/${x}`,k)}else T.ensureDirSync("./tmp/source"),T.copySync(`./${a}`,"./tmp/source")}else T.ensureDirSync("./tmp/source"),T.copySync(`./${a}`,"./tmp/source");Array.isArray(u)&&u.length&&u.forEach(x=>{T.ensureFileSync(`./tmp/source/${o}/${x}`),T.copyFileSync(`./${a}/${o}/${x}`,`./tmp/source/${o}/${x}`)}),console.log(),console.log(`\u53D1\u5E03\u7269\u5236\u4F5C\u5B8C\u6210\uFF0C\u60A8\u53EF\u4EE5\u5728 SEE \u5E73\u53F0\u4E0A\u4F20\u5E76\u90E8\u7F72\u5E94\u7528\u3002\u6CE8\u610F\uFF1A${be.yellow("\u5B50\u7CFB\u7EDF\u53D1\u5E03\u7269\u7684\u5B89\u88C5\u76EE\u5F55\u9700\u8981\u6307\u5B9A\u5230\u5177\u4F53\u7684\u5E94\u7528\u76EE\u5F55")}\u3002\u6BD4\u5982/home/hsiar/hsiar-green/html/\u3002
|
|
7
|
+
`),g(N)})};export{rt as generateSeePackageZip};
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winner-fed/winner-deploy",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.10",
|
|
4
4
|
"description": "Generate a publication deployed by the See platform",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"winner",
|
|
7
7
|
"see",
|
|
8
8
|
"deploy"
|
|
9
9
|
],
|
|
10
|
-
"packageManager": "pnpm@10.0.0",
|
|
11
10
|
"main": "dist/index.js",
|
|
12
11
|
"module": "dist/index.js",
|
|
13
12
|
"types": "dist/index.d.ts",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
<% } %>
|
|
37
37
|
{{ variables }}
|
|
38
38
|
</variables>
|
|
39
|
-
<%
|
|
40
|
-
<config path="./${webAppName}
|
|
41
|
-
<% } %>
|
|
39
|
+
<% configFileNames.forEach(function (cf) { %>
|
|
40
|
+
<config path="./${webAppName}/<% print(cf) %>.js" encoding="UTF-8"/>
|
|
41
|
+
<% }) %>
|
|
42
42
|
<config path="./scripts/{{ name }}/install.sh" encoding="UTF-8"/>
|
|
43
43
|
<config path="./scripts/{{ name }}/afterInstall.sh" encoding="UTF-8"/>
|
|
44
44
|
<config path="./scripts/{{ name }}/uninstall.sh" encoding="UTF-8"/>
|
|
@@ -28,22 +28,29 @@ fi
|
|
|
28
28
|
echo -e "${CHECK_ICON} 成功: 应用目录 '${webAppName}' 已找到且不为空。"
|
|
29
29
|
echo -e "${CHECK_ICON} 安装验证通过。"
|
|
30
30
|
|
|
31
|
-
<% if (enableObfuscation) { %>
|
|
31
|
+
<% if (enableObfuscation && configFileNames && configFileNames.length) { %>
|
|
32
32
|
# 混淆配置文件:优先 node(javascript-obfuscator),无 node 时回退 bash 轻量混淆
|
|
33
33
|
echo -e "${CHECK_ICON} 开始混淆配置文件..."
|
|
34
34
|
pkg_root=`pwd`
|
|
35
35
|
cd "$(dirname "$0")"
|
|
36
|
+
use_node=0
|
|
36
37
|
if command -v node >/dev/null 2>&1; then
|
|
38
|
+
use_node=1
|
|
37
39
|
echo -e "${INFO_ICON} 检测到 node,使用 confuse.js 强混淆"
|
|
38
|
-
node ./js/confuse.js "${webAppName}" "{{configFileName}}" "$pkg_root"
|
|
39
40
|
else
|
|
40
41
|
echo -e "${WARNING_ICON} 未检测到 node,使用 confuse.sh 轻量混淆(强度较弱)"
|
|
41
|
-
|
|
42
|
+
fi
|
|
43
|
+
<% configFileNames.forEach(function (cf) { %>
|
|
44
|
+
if [ "$use_node" -eq 1 ]; then
|
|
45
|
+
node ./js/confuse.js "${webAppName}" "<% print(cf) %>" "$pkg_root"
|
|
46
|
+
else
|
|
47
|
+
bash ./js/confuse.sh "${webAppName}" "<% print(cf) %>" "$pkg_root"
|
|
42
48
|
fi
|
|
43
49
|
if [ $? -ne 0 ]; then
|
|
44
|
-
echo -e "${ERROR_ICON} 错误:
|
|
50
|
+
echo -e "${ERROR_ICON} 错误: 混淆配置文件失败 (<% print(cf) %>).js。" >&2
|
|
45
51
|
exit 1
|
|
46
52
|
fi
|
|
53
|
+
<% }) %>
|
|
47
54
|
|
|
48
55
|
echo -e "${CHECK_ICON} 成功: 混淆配置文件完成。"
|
|
49
56
|
<% } %>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# 无 node 时的轻量混淆:整文件 base64 +
|
|
2
|
+
# 无 node 时的轻量混淆:整文件 base64 + TextDecoder/new Function 包裹。
|
|
3
3
|
# 强度远低于 confuse.js(javascript-obfuscator),仅作兼容兜底。
|
|
4
4
|
# 参数:webAppName configBase [pkgRoot]
|
|
5
5
|
|
|
@@ -34,6 +34,7 @@ if grep -q '__WINNER_BASH_OBFUSCATED__' "$filepath" 2>/dev/null; then
|
|
|
34
34
|
exit 0
|
|
35
35
|
fi
|
|
36
36
|
|
|
37
|
+
# 可移植:避免 GNU 专用的 base64 -w 0
|
|
37
38
|
b64=$(base64 < "$filepath" | tr -d '\n\r')
|
|
38
39
|
if [ -z "$b64" ]; then
|
|
39
40
|
echo -e "${ERROR_ICON} base64 编码失败" >&2
|
|
@@ -41,9 +42,10 @@ if [ -z "$b64" ]; then
|
|
|
41
42
|
fi
|
|
42
43
|
|
|
43
44
|
tmpfile="${filepath}.obf.$$"
|
|
45
|
+
# UTF-8 安全:atob → Uint8Array → TextDecoder,再 new Function 执行
|
|
44
46
|
cat > "$tmpfile" <<EOF
|
|
45
47
|
/* __WINNER_BASH_OBFUSCATED__ */
|
|
46
|
-
(
|
|
48
|
+
(new Function(new TextDecoder("utf-8").decode(Uint8Array.from(atob("${b64}"),function(c){return c.charCodeAt(0)}))))();
|
|
47
49
|
EOF
|
|
48
50
|
|
|
49
51
|
if [ $? -ne 0 ]; then
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
依赖 node + javascript-obfuscator(obfuscator.js),强混淆。
|
|
5
5
|
|
|
6
6
|
2. scripts/js/confuse.sh
|
|
7
|
-
无 node 时的 bash 兜底:整文件 base64 + `(
|
|
7
|
+
无 node 时的 bash 兜底:整文件 base64 + `(new Function(new TextDecoder("utf-8").decode(Uint8Array.from(atob("..."), ...))))()` 包裹(UTF-8 安全)。
|
|
8
8
|
参数与 confuse.js 相同。强度远弱于 confuse.js,仅兼容无 node 环境。
|
|
9
|
-
|
|
9
|
+
`base64 | tr -d` 保证 Linux/macOS 可移植;已带 `__WINNER_BASH_OBFUSCATED__` 时跳过。
|
|
10
10
|
|
|
11
11
|
3. scripts/afterInstall.sh
|
|
12
12
|
`enableObfuscation` 为真时:有 node 走 confuse.js,否则走 confuse.sh。
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
{{ variables }}
|
|
40
40
|
|
|
41
41
|
</variables>
|
|
42
|
-
<%
|
|
43
|
-
<config path="./{{ name }}
|
|
44
|
-
<% } %>
|
|
42
|
+
<% configFileNames.forEach(function (cf) { %>
|
|
43
|
+
<config path="./{{ name }}/<% print(cf) %>.js" encoding="UTF-8"/>
|
|
44
|
+
<% }) %>
|
|
45
45
|
<config reference="" encoding="utf-8" path="./k8s-deploy-res.yaml" />
|
|
46
46
|
<node describe="节点私有配置信息" />
|
|
47
47
|
</system>
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
{{ variables }}
|
|
38
38
|
|
|
39
39
|
</variables>
|
|
40
|
-
<%
|
|
41
|
-
<config path="./${webAppName}
|
|
42
|
-
<% } %>
|
|
40
|
+
<% configFileNames.forEach(function (cf) { %>
|
|
41
|
+
<config path="./${webAppName}/<% print(cf) %>.js" encoding="UTF-8"/>
|
|
42
|
+
<% }) %>
|
|
43
43
|
<config path="./scripts/{{ name }}/install.py" encoding="UTF-8"/>
|
|
44
44
|
<config path="./scripts/{{ name }}/afterInstall.py" encoding="UTF-8"/>
|
|
45
45
|
<config path="./scripts/{{ name }}/uninstall.py" encoding="UTF-8"/>
|
|
@@ -32,12 +32,12 @@ if len(os.listdir(webAppName)) == 0:
|
|
|
32
32
|
|
|
33
33
|
chmodPkg()
|
|
34
34
|
|
|
35
|
-
<% if (enableObfuscation) { %>
|
|
35
|
+
<% if (enableObfuscation && configFileNames && configFileNames.length) { %>
|
|
36
36
|
import subprocess
|
|
37
37
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
38
38
|
confuse_js = os.path.normpath(os.path.join(script_dir, 'js', 'confuse.js'))
|
|
39
39
|
confuse_sh = os.path.normpath(os.path.join(script_dir, 'js', 'confuse.sh'))
|
|
40
|
-
|
|
40
|
+
config_names = [<% configFileNames.forEach(function (cf, i) { %>'<% print(cf) %>'<% if (i < configFileNames.length - 1) { %>, <% } %><% }) %>]
|
|
41
41
|
|
|
42
42
|
def which(cmd):
|
|
43
43
|
for p in os.environ.get('PATH', '').split(os.pathsep):
|
|
@@ -46,12 +46,13 @@ def which(cmd):
|
|
|
46
46
|
return f
|
|
47
47
|
return None
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
for config_name in config_names:
|
|
50
|
+
if which('node'):
|
|
51
|
+
cmd = ['node', confuse_js, webAppName, config_name, pkg_root]
|
|
52
|
+
else:
|
|
53
|
+
cmd = ['bash', confuse_sh, webAppName, config_name, pkg_root]
|
|
54
|
+
ret = subprocess.call(cmd)
|
|
55
|
+
if ret != 0:
|
|
56
|
+
sys.stderr.write("错误: 混淆配置文件失败 (%s.js)。\n" % config_name)
|
|
57
|
+
sys.exit(ret)
|
|
57
58
|
<% } %>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# 无 node 时的轻量混淆:整文件 base64 +
|
|
2
|
+
# 无 node 时的轻量混淆:整文件 base64 + TextDecoder/new Function 包裹。
|
|
3
3
|
# 强度远低于 confuse.js(javascript-obfuscator),仅作兼容兜底。
|
|
4
4
|
# 参数:webAppName configBase [pkgRoot]
|
|
5
5
|
|
|
@@ -34,6 +34,7 @@ if grep -q '__WINNER_BASH_OBFUSCATED__' "$filepath" 2>/dev/null; then
|
|
|
34
34
|
exit 0
|
|
35
35
|
fi
|
|
36
36
|
|
|
37
|
+
# 可移植:避免 GNU 专用的 base64 -w 0
|
|
37
38
|
b64=$(base64 < "$filepath" | tr -d '\n\r')
|
|
38
39
|
if [ -z "$b64" ]; then
|
|
39
40
|
echo -e "${ERROR_ICON} base64 编码失败" >&2
|
|
@@ -41,9 +42,10 @@ if [ -z "$b64" ]; then
|
|
|
41
42
|
fi
|
|
42
43
|
|
|
43
44
|
tmpfile="${filepath}.obf.$$"
|
|
45
|
+
# UTF-8 安全:atob → Uint8Array → TextDecoder,再 new Function 执行
|
|
44
46
|
cat > "$tmpfile" <<EOF
|
|
45
47
|
/* __WINNER_BASH_OBFUSCATED__ */
|
|
46
|
-
(
|
|
48
|
+
(new Function(new TextDecoder("utf-8").decode(Uint8Array.from(atob("${b64}"),function(c){return c.charCodeAt(0)}))))();
|
|
47
49
|
EOF
|
|
48
50
|
|
|
49
51
|
if [ $? -ne 0 ]; then
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
依赖 node + javascript-obfuscator(obfuscator.js),强混淆。
|
|
5
5
|
|
|
6
6
|
2. scripts/js/confuse.sh
|
|
7
|
-
无 node 时的 bash 兜底:整文件 base64 + `(
|
|
7
|
+
无 node 时的 bash 兜底:整文件 base64 + `(new Function(new TextDecoder("utf-8").decode(Uint8Array.from(atob("..."), ...))))()` 包裹(UTF-8 安全)。
|
|
8
8
|
参数与 confuse.js 相同。强度远弱于 confuse.js,仅兼容无 node 环境。
|
|
9
|
-
|
|
9
|
+
`base64 | tr -d` 保证 Linux/macOS 可移植;已带 `__WINNER_BASH_OBFUSCATED__` 时跳过。
|
|
10
10
|
|
|
11
11
|
3. scripts/afterInstall.sh
|
|
12
12
|
`enableObfuscation` 为真时:有 node 走 confuse.js,否则走 confuse.sh。
|