@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
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** build time: Wed
|
|
2
|
-
var
|
|
3
|
-
`)}else if(
|
|
4
|
-
`):""}else{if(
|
|
5
|
-
`),description
|
|
6
|
-
`),description
|
|
7
|
-
`),
|
|
1
|
+
/** build time: Wed Apr 15 2026 10:38:51 GMT+0800 (中国标准时间), build version 4.3.7 **/
|
|
2
|
+
var xe=Object.create;var X=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames,ee=Object.getOwnPropertySymbols,Te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable;var te=(r,t,n)=>t in r?X(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,U=(r,t)=>{for(var n in t||(t={}))ne.call(t,n)&&te(r,n,t[n]);if(ee)for(var n of ee(t))ke.call(t,n)&&te(r,n,t[n]);return r};var _e=(r,t)=>{for(var n in t)X(r,n,{get:t[n],enumerable:!0})},oe=(r,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of Oe(t))!ne.call(r,l)&&l!==n&&X(r,l,{get:()=>t[l],enumerable:!(i=be(t,l))||i.enumerable});return r};var O=(r,t,n)=>(n=r!=null?xe(Te(r)):{},oe(t||!r||!r.__esModule?X(n,"default",{value:r,enumerable:!0}):n,r)),Ae=r=>oe(X({},"__esModule",{value:!0}),r);var ve={};_e(ve,{generateSeePackageZip:()=>De});module.exports=Ae(ve);var Se=O(require("chalk"),1),$e=O(require("path"),1),T=O(require("fs-extra"),1);var ye=O(require("path"),1),b=O(require("fs-extra"),1),W=require("rimraf");var C=O(require("path"),1),K=O(require("fs-extra"),1),re=O(require("archiver"),1),q=O(require("xml"),1);var B=process.cwd(),V=function(t){let n={""":'"',"'":"'","<":"<",">":">"},i=/(")|(')|(<)|(>)/g;return t&&t.replace?t.replace(i,function(l){return n[l]}):t},D=function(t,n){let i=n||"",l=C.default.resolve(B,t,i,"sysconfig.js");return K.default.pathExistsSync(l)},L=function(t){let n=C.default.resolve(B,t,"config.local.js");return K.default.pathExistsSync(n)},I=function(t,n,i,l){let o=C.default.join(B,n);n!=="/"&&K.default.ensureDirSync(o);let e=K.default.createWriteStream(`${n==="/"?".":o}/${t}.zip`);e.on("close",function(){setTimeout(function(){l&&l()})});let s=(0,re.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(e),s.directory(i,!1),s.finalize()},Z=function(t,n,i){let{type:l,label:o,name:e,tooltip:s="",visible:c="true",required:a="false",fixed:$="false",fold:f="false",options:m="",validate:d="",upgrade:p="false"}=t,P=t.default;if(i==="form"){let k=(0,q.default)({form:[{_attr:{name:e,tooltip:s,visible:c,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p}},n]});return V(k)}let y=l==="complexSelect"?{default:t.default}:{},g=(0,q.default)({field:[{_attr:U({type:l,label:o,name:e,tooltip:s,visible:c,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p},y)},n||P]});return V(g)},ie=function(t){let i=t.children.map(l=>{let e=l.children.map(s=>Z(s)).join("");return Z(l,e,"form")}).join("");return Z(t,i)},z=function r(t,n,i="",l=""){for(let o=0;o<t.length;o++){let e=t[o];if(e.type==="complexSelect"?(e.fullName=`${e.name}`,e.fullPath=`${e.type}`):(e.fullName=`${i===""?"":i+"."}${e.name}`,e.fullPath=`${l===""?"":l+"-"}${e.type}`),n(e))return e;if(e.children&&e.children.length>0){let s=r(e.children,n,e.fullName,e.fullPath);if(s)return s}}return null};function le(r="python"){return r==="python"?"py":"sh"}var w=O(require("fs-extra"),1),se=O(require("path"),1),E=O(require("lodash.template"),1),ce=O(require("xml"),1),ae=O(require("@babel/core"),1);var Pe=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],Q=r=>se.default.resolve(__dirname,`../templates/see/${r}`),J=r=>{let t=r.type;if(!Pe.includes(t))return"";let{label:n,name:i,tooltip:l="",visible:o="true",required:e="false",fixed:s="false",fold:c="false",options:a="",validate:$="",upgrade:f="false",expose:m="",algorithm:d="",merge:p="",isomeris:P="",old_name:y=""}=r,g=r.default;if(t==="table"){let u=r.keys||[];g=(r.columns||u).map(x=>J(x)).join(`
|
|
3
|
+
`)}else if(t==="switchForm"||t==="division"){let u=r.children;g=u?u.map(h=>J(h)).join(`
|
|
4
|
+
`):""}else{if(t==="complexSelect")return ie(r);t==="editor"?g=typeof g=="object"?[JSON.stringify(g)]:[g]:g=[g]}let k=t==="switchForm"?{default:r.default}:{},F=U({type:t,label:n,name:i,tooltip:l,visible:o,required:e,fixed:s,fold:c,options:a,validate:$,upgrade:f,expose:m,algorithm:d,merge:p,isomeris:P,old_name:y},k),N=Object.fromEntries(Object.entries(F).filter(([u,h])=>h!==""&&h!==null&&h!==void 0)),j=(0,ce.default)({field:[{_attr:N},...Array.isArray(g)?g:[g]]});return V(j)},fe=function({system:t,type:n,name:i,appType:l,appName:o,group:e,version:s,configFileName:c="config.local",variables:a=[],description:$,scriptsType:f="python"}){let m=w.default.readFileSync(Q(`${f}/deploy.xml`)).toString();return(0,E.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:i,appName:o,appType:l,group:e,version:s,configFileName:c,variables:a.map(d=>J(d)).join(`
|
|
5
|
+
`),description:$})},M=function(t,n){let i=`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`;t==="beforeInstall"&&(i=`${n.scriptsType}/scripts/${t}.sh`);let l=w.default.readFileSync(Q(i)).toString();return(0,E.default)(l,{interpolate:/{{([\s\S]+?)}}/g})(n)},v=function(t,n=[]){let{code:i}=ae.default.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(o){if(o.parentPath.isProperty()){let e=o.parentPath.get("key").node,s=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,s=e.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 e=z(n,s=>o.parentPath.get("key").node.name===s.name);if(e){if(e.fullPath.includes("editor")){o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS]\${${e.name}}[NO_QUOTATION_MARKS]`;return}e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let s="",c=e.keys||[],a=e.columns||c;if(e.options){s=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,o.node.type="StringLiteral",o.node.value=s;return}a&&a.length&&a.forEach(f=>{s+=`${f.name}: '$!{row.${f.name}}',`}),o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${s}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(o){if(o.parentPath.isProperty()){let e=o.parentPath.get("key").node,s=e.name;if(e){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")},pe=function({system:t,type:n,name:i,appName:l,appType:o,version:e,group:s,configFileName:c="config.local",variables:a=[],description:$,web_app_web_service_name:f,dockerImage:m}){let d=w.default.readFileSync(Q("docker/deploy.xml")).toString();return(0,E.default)(d,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:i,appName:l,appType:o,version:e,group:s,configFileName:c,variables:a.map(p=>J(p)).join(`
|
|
6
|
+
`),description:$,web_app_web_service_name:f,dockerImage:m})},me=function(t){let n=w.default.readFileSync(Q("docker/k8s-deploy-res.yaml")).toString();return(0,E.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},ue=function(t){let n=w.default.readFileSync(Q("docker/Dockerfile")).toString();return(0,E.default)(n)(t)};var S="tmp",ge=function(t,n,i){let{system:l,type:o,name:e,appType:s,appName:c,group:a,version:$,template:f,variables:m=[],configName:d,outputName:p="dist",description:P,scriptsType:y,enableObfuscation:g=!1,seePackagePath:k,tplPath:F}=n;b.default.ensureDirSync(S),b.default.ensureDirSync(`${S}/scripts`),b.default.ensureDirSync(`${S}/template`);let N=!1,j=!1;if(F&&Object.keys(F).length>0)for(let[x,R]of Object.entries(F))x==="deploy.xml"?(b.default.copyFileSync(R,`./${S}/deploy.xml`),N=!0):b.default.copyFileSync(R,`./${S}/template/${x}`),(x==="sysconfig.js"||x==="config.local.js")&&(j=!0);let u=d;if(j&&F?F["sysconfig.js"]?u="sysconfig":F["config.local.js"]&&(u="config.local"):j||(L(p)?u="config.local":(D(p)||D(p,e))&&(u="sysconfig")),g&&(y==="bash"||y==="python")){let x=ye.default.resolve(__dirname,`../templates/see/${y}/scripts/js`);b.default.pathExistsSync(x)&&b.default.copySync(x,`./${S}/scripts/${e}/js`)}let h=le(y);y==="python"&&(b.default.outputFileSync(`./${S}/scripts/${e}/utils.${h}`,M("utils",{scriptsType:y})),b.default.outputFileSync(`./${S}/scripts/${e}/beforeInstall.sh`,M("beforeInstall",{scriptsType:y}))),b.default.outputFileSync(`./${S}/scripts/${e}/install.${h}`,M("install",{name:e,type:o,scriptsType:y})),b.default.outputFileSync(`./${S}/scripts/${e}/afterInstall.${h}`,M("afterInstall",{name:e,scriptsType:y,configFileName:u,enableObfuscation:g})),b.default.outputFileSync(`./${S}/scripts/${e}/uninstall.${h}`,M("uninstall",{name:e,type:o,scriptsType:y})),N||b.default.outputFileSync(`./${S}/deploy.xml`,fe({system:l,type:o,name:e,appType:s,appName:c,group:a,version:$,configFileName:u,variables:m,description:P,scriptsType:y})),j||(L(p)?b.default.outputFileSync(`./${S}/template/config.local.js`,f?v(f,m):""):D(p)||D(p,e)?b.default.outputFileSync(`./${S}/template/sysconfig.js`,f?v(f,m):""):u&&b.default.outputFileSync(`./${S}/template/${u}.js`,f?v(f,m):"")),i?i(x=>{I(t,k,S,()=>{W.rimraf.sync(S),typeof x=="function"&&x()})}):I(t,k,S,()=>{W.rimraf.sync(S)})};var G=O(require("path"),1),A=O(require("fs-extra"),1),H=require("rimraf");var _="tmp",de=function(t,n,i){let{system:l,type:o,name:e,appType:s,appName:c,version:a,group:$,template:f,variables:m,configName:d,outputName:p,description:P,seePackagePath:y,dockerImage:g=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;A.default.ensureDirSync(_),A.default.ensureDirSync("docker"),A.default.pathExistsSync(G.default.resolve(process.cwd(),"docker/Dockerfile"))||A.default.outputFileSync(G.default.resolve(process.cwd(),"docker/Dockerfile"),ue({name:e,type:o})),A.default.ensureDirSync(`${_}/scripts`),A.default.ensureDirSync(`${_}/template`),L(p)?A.default.outputFileSync(`./${_}/template/${e}/config.local.js`,f?v(f,m):""):D(p)||D(p,e)?(d="sysconfig",A.default.outputFileSync(`./${_}/template/${e}/sysconfig.js`,f?v(f,m):"")):d&&A.default.outputFileSync(`./${_}/template/${e}/${d}.js`,f?v(f,m):""),A.default.outputFileSync(`./${_}/template/k8s-deploy-res.yaml`,me({configFileName:d})),A.default.outputFileSync(`./${_}/deploy.xml`,pe({system:l,type:o,name:e,appName:c,appType:s,version:a,group:$,configFileName:d,variables:m,description:P,web_app_web_service_name:`${e}-web`,dockerImage:g})),i?i(k=>{I(t,y,_,()=>{H.rimraf.sync(_),typeof k=="function"&&k()})}):I(t,y,_,()=>{H.rimraf.sync(_)})};var Fe=process.cwd();function je(r,t,n){let i="",l,o=r==="bizframe"?`./${n}`:`./${n}/${t}`;return T.default.existsSync(o)&&(i=T.default.readdirSync(o).find(e=>/manifest\.[0-9]+\.json/.test(e)),i&&(l=T.default.readJsonSync(`${o}/${i}`))),{manifest:i,manifestJson:l}}var De=function({system:t="winner-front",type:n="bizframe",name:i,appType:l,appName:o,group:e="bizframe",version:s,configName:c="config.local",outputName:a="dist",templateFunc:$,variablesFunc:f,copyFiles:m,description:d,seePackageName:p,seePackagePath:P="package",seePackageType:y="web",dockerImage:g,scriptsType:k="python",enableObfuscation:F=!1,tplPath:N={}},j){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 p=="string"&&p&&(p=p.replace(/@/gi,"").replace(/\//gi,"-")),l=l||i,o=o||i,f=f||function(){try{let{variables:u}=require($e.default.resolve(Fe,"build","package","./variables.js"));return u||[]}catch(u){return console.error(u),[]}},$=$||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${i}/sysconfig.js`},y==="docker"){de(p||`${t}-${i}-${s}`,{system:t,type:n,name:i,appType:l,appName:o,group:e,version:s,configName:c,outputName:a,template:$(),variables:f(),seePackagePath:P,description:d,dockerImage:g},u=>{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"),u(j)});return}ge(p||`${t}-${i}-${s}`,{system:t,type:n,name:i,group:e,appType:l,appName:o,version:s,configName:c,outputName:a,template:$(),variables:f(),seePackagePath:P,description:d,scriptsType:k,enableObfuscation:F,tplPath:N},u=>{if(k==="python"){let{manifest:h,manifestJson:x}=je(n,i,a);if(h){for(let R in x)if(x.hasOwnProperty(R)){let{path:Y,dir:he}=x[R];T.default.ensureDirSync(`./tmp/source/${he}`),T.default.copyFileSync(`./${a}/${Y}`,`./tmp/source/${Y}`)}T.default.outputJSONSync(`./tmp/scripts/${i}/conf/${h}`,x)}else T.default.ensureDirSync("./tmp/source"),T.default.copySync(`./${a}`,"./tmp/source")}else T.default.ensureDirSync("./tmp/source"),T.default.copySync(`./${a}`,"./tmp/source");Array.isArray(m)&&m.length&&m.forEach(h=>{T.default.ensureFileSync(`./tmp/source/${i}/${h}`),T.default.copyFileSync(`./${a}/${i}/${h}`,`./tmp/source/${i}/${h}`)}),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
|
+
`),u(j)})};0&&(module.exports={generateSeePackageZip});
|
package/dist/index.d.cts
CHANGED
|
@@ -135,6 +135,11 @@ interface DeployOptions {
|
|
|
135
135
|
* @default python
|
|
136
136
|
*/
|
|
137
137
|
scriptsType?: 'python' | 'bash';
|
|
138
|
+
/**
|
|
139
|
+
* 是否在安装后对 template 中的配置 .js 做混淆;为 false 时不拷贝 scripts/js,afterInstall 不执行 node 混淆
|
|
140
|
+
* @default true
|
|
141
|
+
*/
|
|
142
|
+
enableObfuscation?: boolean;
|
|
138
143
|
/**
|
|
139
144
|
* 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
|
|
140
145
|
* @default null
|
|
@@ -185,9 +190,10 @@ interface DeployOptions {
|
|
|
185
190
|
* @param seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
|
|
186
191
|
* @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
|
|
187
192
|
* @param scriptsType 脚本类型 'python' | 'bash'
|
|
193
|
+
* @param enableObfuscation 是否在安装后对配置 .js 做混淆,默认 false
|
|
188
194
|
* @param tplPath 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
|
|
189
195
|
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
|
|
190
196
|
*/
|
|
191
|
-
declare const generateSeePackageZip: ({ system, type, name, appType, appName, group, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackagePath, seePackageType, dockerImage, scriptsType, tplPath }: DeployOptions, cb: () => void) => void;
|
|
197
|
+
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;
|
|
192
198
|
|
|
193
199
|
export { generateSeePackageZip };
|
package/dist/index.d.ts
CHANGED
|
@@ -135,6 +135,11 @@ interface DeployOptions {
|
|
|
135
135
|
* @default python
|
|
136
136
|
*/
|
|
137
137
|
scriptsType?: 'python' | 'bash';
|
|
138
|
+
/**
|
|
139
|
+
* 是否在安装后对 template 中的配置 .js 做混淆;为 false 时不拷贝 scripts/js,afterInstall 不执行 node 混淆
|
|
140
|
+
* @default true
|
|
141
|
+
*/
|
|
142
|
+
enableObfuscation?: boolean;
|
|
138
143
|
/**
|
|
139
144
|
* 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
|
|
140
145
|
* @default null
|
|
@@ -185,9 +190,10 @@ interface DeployOptions {
|
|
|
185
190
|
* @param seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
|
|
186
191
|
* @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
|
|
187
192
|
* @param scriptsType 脚本类型 'python' | 'bash'
|
|
193
|
+
* @param enableObfuscation 是否在安装后对配置 .js 做混淆,默认 false
|
|
188
194
|
* @param tplPath 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
|
|
189
195
|
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
|
|
190
196
|
*/
|
|
191
|
-
declare const generateSeePackageZip: ({ system, type, name, appType, appName, group, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackagePath, seePackageType, dockerImage, scriptsType, tplPath }: DeployOptions, cb: () => void) => void;
|
|
197
|
+
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;
|
|
192
198
|
|
|
193
199
|
export { generateSeePackageZip };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** build time: Wed
|
|
2
|
-
var
|
|
3
|
-
`)}else if(t==="switchForm"||t==="division"){let
|
|
4
|
-
`):""}else{if(t==="complexSelect")return
|
|
5
|
-
`),description
|
|
6
|
-
`),description
|
|
7
|
-
`),
|
|
1
|
+
/** build time: Wed Apr 15 2026 10:38:51 GMT+0800 (中国标准时间), build version 4.3.7 **/
|
|
2
|
+
var fe=Object.defineProperty;var q=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var B=(i,t,n)=>t in i?fe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,K=(i,t)=>{for(var n in t||(t={}))pe.call(t,n)&&B(i,n,t[n]);if(q)for(var n of q(t))me.call(t,n)&&B(i,n,t[n]);return i};var W=(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 he from"chalk";import xe from"path";import k from"fs-extra";import $e from"path";import b from"fs-extra";import{rimraf as re}from"rimraf";import z from"path";import L from"fs-extra";import ue from"archiver";import G from"xml";var J=process.cwd(),Q=function(t){let n={""":'"',"'":"'","<":"<",">":">"},r=/(")|(')|(<)|(>)/g;return t&&t.replace?t.replace(r,function(c){return n[c]}):t},j=function(t,n){let r=n||"",c=z.resolve(J,t,r,"sysconfig.js");return L.pathExistsSync(c)},E=function(t){let n=z.resolve(J,t,"config.local.js");return L.pathExistsSync(n)},N=function(t,n,r,c){let o=z.join(J,n);n!=="/"&&L.ensureDirSync(o);let e=L.createWriteStream(`${n==="/"?".":o}/${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(r,!1),l.finalize()},C=function(t,n,r){let{type:c,label:o,name:e,tooltip:l="",visible:s="true",required:a="false",fixed:$="false",fold:f="false",options:m="",validate:d="",upgrade:p="false"}=t,A=t.default;if(r==="form"){let O=G({form:[{_attr:{name:e,tooltip:l,visible:s,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p}},n]});return Q(O)}let y=c==="complexSelect"?{default:t.default}:{},g=G({field:[{_attr:K({type:c,label:o,name:e,tooltip:l,visible:s,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p},y)},n||A]});return Q(g)},H=function(t){let r=t.children.map(c=>{let e=c.children.map(l=>C(l)).join("");return C(c,e,"form")}).join("");return C(t,r)},U=function i(t,n,r="",c=""){for(let o=0;o<t.length;o++){let e=t[o];if(e.type==="complexSelect"?(e.fullName=`${e.name}`,e.fullPath=`${e.type}`):(e.fullName=`${r===""?"":r+"."}${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:r,tooltip:c="",visible:o="true",required:e="false",fixed:l="false",fold:s="false",options:a="",validate:$="",upgrade:f="false",expose:m="",algorithm:d="",merge:p="",isomeris:A="",old_name:y=""}=i,g=i.default;if(t==="table"){let u=i.keys||[];g=(i.columns||u).map(x=>V(x)).join(`
|
|
3
|
+
`)}else if(t==="switchForm"||t==="division"){let u=i.children;g=u?u.map(h=>V(h)).join(`
|
|
4
|
+
`):""}else{if(t==="complexSelect")return H(i);t==="editor"?g=typeof g=="object"?[JSON.stringify(g)]:[g]:g=[g]}let O=t==="switchForm"?{default:i.default}:{},P=K({type:t,label:n,name:r,tooltip:c,visible:o,required:e,fixed:l,fold:s,options:a,validate:$,upgrade:f,expose:m,algorithm:d,merge:p,isomeris:A,old_name:y},O),v=Object.fromEntries(Object.entries(P).filter(([u,h])=>h!==""&&h!==null&&h!==void 0)),F=ge({field:[{_attr:v},...Array.isArray(g)?g:[g]]});return Q(F)},ee=function({system:t,type:n,name:r,appType:c,appName:o,group:e,version:l,configFileName:s="config.local",variables:a=[],description:$,scriptsType:f="python"}){let m=M.readFileSync(X(`${f}/deploy.xml`)).toString();return R(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:r,appName:o,appType:c,group:e,version:l,configFileName:s,variables:a.map(d=>V(d)).join(`
|
|
5
|
+
`),description:$})},I=function(t,n){let r=`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`;t==="beforeInstall"&&(r=`${n.scriptsType}/scripts/${t}.sh`);let c=M.readFileSync(X(r)).toString();return R(c,{interpolate:/{{([\s\S]+?)}}/g})(n)},D=function(t,n=[]){let{code:r}=de.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(o){if(o.parentPath.isProperty()){let e=o.parentPath.get("key").node,l=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,l=e.value);let s=U(n,a=>l===a.name);if(s){if(s.fullPath.includes("complexSelect")&&(s.name=s.fullName),o.isStringLiteral()){o.node.value=`$!{${s.name}}`;return}if(o.isNumericLiteral()){o.node.value=`$!{${s.name}}`;return}if(o.isBooleanLiteral()){if(o.node.type="StringLiteral",s.fullPath.includes("complexSelect")){o.node.value=`$!{${s.fullName}}`;return}o.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(o){if(o.parentPath.isProperty()){let e=U(n,l=>o.parentPath.get("key").node.name===l.name);if(e){if(e.fullPath.includes("editor")){o.node.type="StringLiteral",o.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]`,o.node.type="StringLiteral",o.node.value=l;return}a&&a.length&&a.forEach(f=>{l+=`${f.name}: '$!{row.${f.name}}',`}),o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${l}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(o){if(o.parentPath.isProperty()){let e=o.parentPath.get("key").node,l=e.name;if(e){let s=U(n,a=>l===a.name);if(s){if(o.node.type="StringLiteral",s.fullPath.includes("editor")){o.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}o.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return r.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},te=function({system:t,type:n,name:r,appName:c,appType:o,version:e,group:l,configFileName:s="config.local",variables:a=[],description:$,web_app_web_service_name:f,dockerImage:m}){let d=M.readFileSync(X("docker/deploy.xml")).toString();return R(d,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:r,appName:c,appType:o,version:e,group:l,configFileName:s,variables:a.map(p=>V(p)).join(`
|
|
6
|
+
`),description:$,web_app_web_service_name:f,dockerImage:m})},ne=function(t){let n=M.readFileSync(X("docker/k8s-deploy-res.yaml")).toString();return R(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},oe=function(t){let n=M.readFileSync(X("docker/Dockerfile")).toString();return R(n)(t)};var S="tmp",ie=function(t,n,r){let{system:c,type:o,name:e,appType:l,appName:s,group:a,version:$,template:f,variables:m=[],configName:d,outputName:p="dist",description:A,scriptsType:y,enableObfuscation:g=!1,seePackagePath:O,tplPath:P}=n;b.ensureDirSync(S),b.ensureDirSync(`${S}/scripts`),b.ensureDirSync(`${S}/template`);let v=!1,F=!1;if(P&&Object.keys(P).length>0)for(let[x,w]of Object.entries(P))x==="deploy.xml"?(b.copyFileSync(w,`./${S}/deploy.xml`),v=!0):b.copyFileSync(w,`./${S}/template/${x}`),(x==="sysconfig.js"||x==="config.local.js")&&(F=!0);let u=d;if(F&&P?P["sysconfig.js"]?u="sysconfig":P["config.local.js"]&&(u="config.local"):F||(E(p)?u="config.local":(j(p)||j(p,e))&&(u="sysconfig")),g&&(y==="bash"||y==="python")){let x=$e.resolve(__dirname,`../templates/see/${y}/scripts/js`);b.pathExistsSync(x)&&b.copySync(x,`./${S}/scripts/${e}/js`)}let h=Y(y);y==="python"&&(b.outputFileSync(`./${S}/scripts/${e}/utils.${h}`,I("utils",{scriptsType:y})),b.outputFileSync(`./${S}/scripts/${e}/beforeInstall.sh`,I("beforeInstall",{scriptsType:y}))),b.outputFileSync(`./${S}/scripts/${e}/install.${h}`,I("install",{name:e,type:o,scriptsType:y})),b.outputFileSync(`./${S}/scripts/${e}/afterInstall.${h}`,I("afterInstall",{name:e,scriptsType:y,configFileName:u,enableObfuscation:g})),b.outputFileSync(`./${S}/scripts/${e}/uninstall.${h}`,I("uninstall",{name:e,type:o,scriptsType:y})),v||b.outputFileSync(`./${S}/deploy.xml`,ee({system:c,type:o,name:e,appType:l,appName:s,group:a,version:$,configFileName:u,variables:m,description:A,scriptsType:y})),F||(E(p)?b.outputFileSync(`./${S}/template/config.local.js`,f?D(f,m):""):j(p)||j(p,e)?b.outputFileSync(`./${S}/template/sysconfig.js`,f?D(f,m):""):u&&b.outputFileSync(`./${S}/template/${u}.js`,f?D(f,m):"")),r?r(x=>{N(t,O,S,()=>{re.sync(S),typeof x=="function"&&x()})}):N(t,O,S,()=>{re.sync(S)})};import le from"path";import _ from"fs-extra";import{rimraf as se}from"rimraf";var T="tmp",ce=function(t,n,r){let{system:c,type:o,name:e,appType:l,appName:s,version:a,group:$,template:f,variables:m,configName:d,outputName:p,description:A,seePackagePath:y,dockerImage:g=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;_.ensureDirSync(T),_.ensureDirSync("docker"),_.pathExistsSync(le.resolve(process.cwd(),"docker/Dockerfile"))||_.outputFileSync(le.resolve(process.cwd(),"docker/Dockerfile"),oe({name:e,type:o})),_.ensureDirSync(`${T}/scripts`),_.ensureDirSync(`${T}/template`),E(p)?_.outputFileSync(`./${T}/template/${e}/config.local.js`,f?D(f,m):""):j(p)||j(p,e)?(d="sysconfig",_.outputFileSync(`./${T}/template/${e}/sysconfig.js`,f?D(f,m):"")):d&&_.outputFileSync(`./${T}/template/${e}/${d}.js`,f?D(f,m):""),_.outputFileSync(`./${T}/template/k8s-deploy-res.yaml`,ne({configFileName:d})),_.outputFileSync(`./${T}/deploy.xml`,te({system:c,type:o,name:e,appName:s,appType:l,version:a,group:$,configFileName:d,variables:m,description:A,web_app_web_service_name:`${e}-web`,dockerImage:g})),r?r(O=>{N(t,y,T,()=>{se.sync(T),typeof O=="function"&&O()})}):N(t,y,T,()=>{se.sync(T)})};var be=process.cwd();function Oe(i,t,n){let r="",c,o=i==="bizframe"?`./${n}`:`./${n}/${t}`;return k.existsSync(o)&&(r=k.readdirSync(o).find(e=>/manifest\.[0-9]+\.json/.test(e)),r&&(c=k.readJsonSync(`${o}/${r}`))),{manifest:r,manifestJson:c}}var tt=function({system:t="winner-front",type:n="bizframe",name:r,appType:c,appName:o,group:e="bizframe",version:l,configName:s="config.local",outputName:a="dist",templateFunc:$,variablesFunc:f,copyFiles:m,description:d,seePackageName:p,seePackagePath:A="package",seePackageType:y="web",dockerImage:g,scriptsType:O="python",enableObfuscation:P=!1,tplPath:v={}},F){if(!r||!l)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(r=r.replace(/@/gi,"").replace(/\//gi,"-"),typeof p=="string"&&p&&(p=p.replace(/@/gi,"").replace(/\//gi,"-")),c=c||r,o=o||r,f=f||function(){try{let{variables:u}=W(xe.resolve(be,"build","package","./variables.js"));return u||[]}catch(u){return console.error(u),[]}},$=$||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${r}/sysconfig.js`},y==="docker"){ce(p||`${t}-${r}-${l}`,{system:t,type:n,name:r,appType:c,appName:o,group:e,version:l,configName:s,outputName:a,template:$(),variables:f(),seePackagePath:A,description:d,dockerImage:g},u=>{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"),u(F)});return}ie(p||`${t}-${r}-${l}`,{system:t,type:n,name:r,group:e,appType:c,appName:o,version:l,configName:s,outputName:a,template:$(),variables:f(),seePackagePath:A,description:d,scriptsType:O,enableObfuscation:P,tplPath:v},u=>{if(O==="python"){let{manifest:h,manifestJson:x}=Oe(n,r,a);if(h){for(let w in x)if(x.hasOwnProperty(w)){let{path:Z,dir:ae}=x[w];k.ensureDirSync(`./tmp/source/${ae}`),k.copyFileSync(`./${a}/${Z}`,`./tmp/source/${Z}`)}k.outputJSONSync(`./tmp/scripts/${r}/conf/${h}`,x)}else k.ensureDirSync("./tmp/source"),k.copySync(`./${a}`,"./tmp/source")}else k.ensureDirSync("./tmp/source"),k.copySync(`./${a}`,"./tmp/source");Array.isArray(m)&&m.length&&m.forEach(h=>{k.ensureFileSync(`./tmp/source/${r}/${h}`),k.copyFileSync(`./${a}/${r}/${h}`,`./tmp/source/${r}/${h}`)}),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${he.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
|
+
`),u(F)})};export{tt 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.7",
|
|
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",
|
|
@@ -1,3 +1,45 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
+
# 定义图标
|
|
3
|
+
CHECK_ICON="✅"
|
|
4
|
+
ERROR_ICON="❌"
|
|
5
|
+
INFO_ICON="ℹ️"
|
|
6
|
+
WARNING_ICON="⚠️"
|
|
7
|
+
|
|
2
8
|
wk=`pwd`
|
|
3
9
|
chmod -R 755 $wk/${webAppName}
|
|
10
|
+
|
|
11
|
+
echo -e "${INFO_ICON} 开始执行安装后检查,应用: '${webAppName}'..."
|
|
12
|
+
|
|
13
|
+
# 1. 检查应用的主目录是否存在。
|
|
14
|
+
# -d 表示检查目标是否为一个目录。
|
|
15
|
+
if [ ! -d "${webAppName}" ]; then
|
|
16
|
+
echo -e "${ERROR_ICON} 错误: 安装检查失败。应用目录 '${webAppName}' 不存在。" >&2
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# 2. 检查目录是否为空。
|
|
21
|
+
# ls -A 会列出除 . 和 .. 之外的所有条目。
|
|
22
|
+
# -z 会检查命令输出的字符串是否为空。
|
|
23
|
+
if [ -z "$(ls -A "${webAppName}")" ]; then
|
|
24
|
+
echo -e "${ERROR_ICON} 错误: 安装检查失败。应用目录 '${webAppName}' 存在但为空。" >&2
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
echo -e "${CHECK_ICON} 成功: 应用目录 '${webAppName}' 已找到且不为空。"
|
|
29
|
+
echo -e "${CHECK_ICON} 安装验证通过。"
|
|
30
|
+
|
|
31
|
+
<% if (enableObfuscation) { %>
|
|
32
|
+
# 混淆配置文件(第 1 参数为 SEE 变量 webAppName,第 2 参数为打包时写入的配置文件名不含 .js)
|
|
33
|
+
echo -e "${CHECK_ICON} 开始混淆配置文件..."
|
|
34
|
+
pkg_root=`pwd`
|
|
35
|
+
cd "$(dirname "$0")"
|
|
36
|
+
node ./js/confuse.js "${webAppName}" "{{configFileName}}" "$pkg_root"
|
|
37
|
+
if [ $? -ne 0 ]; then
|
|
38
|
+
echo -e "${ERROR_ICON} 错误: 混淆配置文件失败。" >&2
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
echo -e "${CHECK_ICON} 成功: 混淆配置文件完成。"
|
|
43
|
+
<% } %>
|
|
44
|
+
|
|
45
|
+
exit 0
|
|
@@ -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
|
+
}
|