@winner-fed/winner-deploy 4.3.6 → 4.3.8

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.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 false
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 Oct 15 2025 11:45:02 GMT+0800 (中国标准时间), build version 4.3.6 **/
2
- var ae=Object.defineProperty;var Z=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var q=(i,t,n)=>t in i?ae(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,E=(i,t)=>{for(var n in t||(t={}))pe.call(t,n)&&q(i,n,t[n]);if(Z)for(var n of Z(t))fe.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 Se from"chalk";import $e from"path";import k from"fs-extra";import x from"fs-extra";import{rimraf as re}from"rimraf";import C from"path";import X from"fs-extra";import me from"archiver";import W from"xml";var z=process.cwd(),K=function(t){let n={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},o=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/g;return t&&t.replace?t.replace(o,function(c){return n[c]}):t},j=function(t,n){let o=n||"",c=C.resolve(z,t,o,"sysconfig.js");return X.pathExistsSync(c)},L=function(t){let n=C.resolve(z,t,"config.local.js");return X.pathExistsSync(n)},v=function(t,n,o,c){let r=C.join(z,n);n!=="/"&&X.ensureDirSync(r);let e=X.createWriteStream(`${n==="/"?".":r}/${t}.zip`);e.on("close",function(){setTimeout(function(){c&&c()})});let l=me("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()},V=function(t,n,o){let{type:c,label:r,name:e,tooltip:l="",visible:s="true",required:a="false",fixed:d="false",fold:p="false",options:f="",validate:m="",upgrade:u="false"}=t,P=t.default;if(o==="form"){let O=W({form:[{_attr:{name:e,tooltip:l,visible:s,required:a,fixed:d,fold:p,options:f,validate:m,upgrade:u}},n]});return K(O)}let $=c==="complexSelect"?{default:t.default}:{},y=W({field:[{_attr:E({type:c,label:r,name:e,tooltip:l,visible:s,required:a,fixed:d,fold:p,options:f,validate:m,upgrade:u},$)},n||P]});return K(y)},G=function(t){let o=t.children.map(c=>{let e=c.children.map(l=>V(l)).join("");return V(c,e,"form")}).join("");return V(t,o)},Q=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 H(i="python"){return i==="python"?"py":"sh"}import I from"fs-extra";import ue from"path";import w from"lodash.template";import ye from"xml";import ge from"@babel/core";var de=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],M=i=>ue.resolve(__dirname,`../templates/see/${i}`),U=i=>{let t=i.type;if(!de.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:d="",upgrade:p="false",expose:f="",algorithm:m="",merge:u="",isomeris:P="",old_name:$=""}=i,y=i.default;if(t==="table"){let g=i.keys||[];y=(i.columns||g).map(R=>U(R)).join(`
3
- `)}else if(t==="switchForm"||t==="division"){let g=i.children;y=g?g.map(h=>U(h)).join(`
4
- `):""}else{if(t==="complexSelect")return G(i);t==="editor"?y=typeof y=="object"?[JSON.stringify(y)]:[y]:y=[y]}let O=t==="switchForm"?{default:i.default}:{},_=E({type:t,label:n,name:o,tooltip:c,visible:r,required:e,fixed:l,fold:s,options:a,validate:d,upgrade:p,expose:f,algorithm:m,merge:u,isomeris:P,old_name:$},O),F=Object.fromEntries(Object.entries(_).filter(([g,h])=>h!==""&&h!==null&&h!==void 0)),b=ye({field:[{_attr:F},...Array.isArray(y)?y:[y]]});return K(b)},Y=function({system:t,type:n,name:o,appType:c,appName:r,group:e,version:l,configFileName:s="config.local",variables:a=[],description:d,scriptsType:p="python"}){let f=I.readFileSync(M(`${p}/deploy.xml`)).toString();return w(f,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:o,appName:r,appType:c,group:e,version:l,configFileName:s,variables:a.map(m=>U(m)).join(`
5
- `),description:d})},N=function(t,n){let o=`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`;t==="beforeInstall"&&(o=`${n.scriptsType}/scripts/${t}.sh`);let c=I.readFileSync(M(o)).toString();return w(c,{interpolate:/{{([\s\S]+?)}}/g})(n)},D=function(t,n=[]){let{code:o}=ge.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=Q(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=Q(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=Q(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")},ee=function({system:t,type:n,name:o,appName:c,appType:r,version:e,group:l,configFileName:s="config.local",variables:a=[],description:d,web_app_web_service_name:p,dockerImage:f}){let m=I.readFileSync(M("docker/deploy.xml")).toString();return w(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:o,appName:c,appType:r,version:e,group:l,configFileName:s,variables:a.map(u=>U(u)).join(`
6
- `),description:d,web_app_web_service_name:p,dockerImage:f})},te=function(t){let n=I.readFileSync(M("docker/k8s-deploy-res.yaml")).toString();return w(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},ne=function(t){let n=I.readFileSync(M("docker/Dockerfile")).toString();return w(n)(t)};var S="tmp",oe=function(t,n,o){let{system:c,type:r,name:e,appType:l,appName:s,group:a,version:d,template:p,variables:f=[],configName:m,outputName:u="dist",description:P,scriptsType:$,seePackagePath:y,tplPath:O}=n;x.ensureDirSync(S),x.ensureDirSync(`${S}/scripts`),x.ensureDirSync(`${S}/template`);let _=H($);$==="python"&&(x.outputFileSync(`./${S}/scripts/${e}/utils.${_}`,N("utils",{scriptsType:$})),x.outputFileSync(`./${S}/scripts/${e}/beforeInstall.sh`,N("beforeInstall",{scriptsType:$}))),x.outputFileSync(`./${S}/scripts/${e}/install.${_}`,N("install",{name:e,type:r,scriptsType:$})),x.outputFileSync(`./${S}/scripts/${e}/afterInstall.${_}`,N("afterInstall",{name:e,scriptsType:$})),x.outputFileSync(`./${S}/scripts/${e}/uninstall.${_}`,N("uninstall",{name:e,type:r,scriptsType:$}));let F=!1,b=!1;if(O&&Object.keys(O).length>0)for(let[g,h]of Object.entries(O))g==="deploy.xml"?(x.copyFileSync(h,`./${S}/deploy.xml`),F=!0):x.copyFileSync(h,`./${S}/template/${g}`),(g==="sysconfig.js"||g==="config.local.js")&&(b=!0);F||x.outputFileSync(`./${S}/deploy.xml`,Y({system:c,type:r,name:e,appType:l,appName:s,group:a,version:d,configFileName:m,variables:f,description:P,scriptsType:$})),b||(L(u)?x.outputFileSync(`./${S}/template/config.local.js`,p?D(p,f):""):j(u)||j(u,e)?(m="sysconfig",x.outputFileSync(`./${S}/template/sysconfig.js`,p?D(p,f):"")):m&&x.outputFileSync(`./${S}/template/${m}.js`,p?D(p,f):"")),o?o(g=>{v(t,y,S,()=>{re.sync(S),typeof g=="function"&&g()})}):v(t,y,S,()=>{re.sync(S)})};import ie from"path";import A from"fs-extra";import{rimraf as le}from"rimraf";var T="tmp",se=function(t,n,o){let{system:c,type:r,name:e,appType:l,appName:s,version:a,group:d,template:p,variables:f,configName:m,outputName:u,description:P,seePackagePath:$,dockerImage:y=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;A.ensureDirSync(T),A.ensureDirSync("docker"),A.pathExistsSync(ie.resolve(process.cwd(),"docker/Dockerfile"))||A.outputFileSync(ie.resolve(process.cwd(),"docker/Dockerfile"),ne({name:e,type:r})),A.ensureDirSync(`${T}/scripts`),A.ensureDirSync(`${T}/template`),L(u)?A.outputFileSync(`./${T}/template/${e}/config.local.js`,p?D(p,f):""):j(u)||j(u,e)?(m="sysconfig",A.outputFileSync(`./${T}/template/${e}/sysconfig.js`,p?D(p,f):"")):m&&A.outputFileSync(`./${T}/template/${e}/${m}.js`,p?D(p,f):""),A.outputFileSync(`./${T}/template/k8s-deploy-res.yaml`,te({configFileName:m})),A.outputFileSync(`./${T}/deploy.xml`,ee({system:c,type:r,name:e,appName:s,appType:l,version:a,group:d,configFileName:m,variables:f,description:P,web_app_web_service_name:`${e}-web`,dockerImage:y})),o?o(O=>{v(t,$,T,()=>{le.sync(T),typeof O=="function"&&O()})}):v(t,$,T,()=>{le.sync(T)})};var he=process.cwd();function xe(i,t,n){let o="",c,r=i==="bizframe"?`./${n}`:`./${n}/${t}`;return k.existsSync(r)&&(o=k.readdirSync(r).find(e=>/manifest\.[0-9]+\.json/.test(e)),o&&(c=k.readJsonSync(`${r}/${o}`))),{manifest:o,manifestJson:c}}var He=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:d,variablesFunc:p,copyFiles:f,description:m,seePackageName:u,seePackagePath:P="package",seePackageType:$="web",dockerImage:y,scriptsType:O="python",tplPath:_={}},F){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 u=="string"&&u&&(u=u.replace(/@/gi,"").replace(/\//gi,"-")),c=c||o,r=r||o,p=p||function(){try{let{variables:b}=B($e.resolve(he,"build","package","./variables.js"));return b||[]}catch(b){return console.error(b),[]}},d=d||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${o}/sysconfig.js`},$==="docker"){se(u||`${t}-${o}-${l}`,{system:t,type:n,name:o,appType:c,appName:r,group:e,version:l,configName:s,outputName:a,template:d(),variables:p(),seePackagePath:P,description:m,dockerImage:y},b=>{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"),b(F)});return}oe(u||`${t}-${o}-${l}`,{system:t,type:n,name:o,group:e,appType:c,appName:r,version:l,configName:s,outputName:a,template:d(),variables:p(),seePackagePath:P,description:m,scriptsType:O,tplPath:_},b=>{if(O==="python"){let{manifest:g,manifestJson:h}=xe(n,o,a);if(g){for(let R in h)if(h.hasOwnProperty(R)){let{path:J,dir:ce}=h[R];k.ensureDirSync(`./tmp/source/${ce}`),k.copyFileSync(`./${a}/${J}`,`./tmp/source/${J}`)}k.outputJSONSync(`./tmp/scripts/${o}/conf/${g}`,h)}else k.ensureDirSync("./tmp/source"),k.copySync(`./${a}`,"./tmp/source")}else k.ensureDirSync("./tmp/source"),k.copySync(`./${a}`,"./tmp/source");Array.isArray(f)&&f.length&&f.forEach(g=>{k.ensureFileSync(`./tmp/source/${o}/${g}`),k.copyFileSync(`./${a}/${o}/${g}`,`./tmp/source/${o}/${g}`)}),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.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
- `),b(F)})};export{He as generateSeePackageZip};
1
+ /** build time: Thu Jul 30 2026 10:40:12 GMT+0800 (中国标准时间), build version 4.3.8 **/
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={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},r=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/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,6 +1,6 @@
1
1
  {
2
2
  "name": "@winner-fed/winner-deploy",
3
- "version": "4.3.6",
3
+ "version": "4.3.8",
4
4
  "description": "Generate a publication deployed by the See platform",
5
5
  "keywords": [
6
6
  "winner",
@@ -1,3 +1,51 @@
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
+ # 混淆配置文件:优先 node(javascript-obfuscator),无 node 时回退 bash 轻量混淆
33
+ echo -e "${CHECK_ICON} 开始混淆配置文件..."
34
+ pkg_root=`pwd`
35
+ cd "$(dirname "$0")"
36
+ if command -v node >/dev/null 2>&1; then
37
+ echo -e "${INFO_ICON} 检测到 node,使用 confuse.js 强混淆"
38
+ node ./js/confuse.js "${webAppName}" "{{configFileName}}" "$pkg_root"
39
+ else
40
+ echo -e "${WARNING_ICON} 未检测到 node,使用 confuse.sh 轻量混淆(强度较弱)"
41
+ bash ./js/confuse.sh "${webAppName}" "{{configFileName}}" "$pkg_root"
42
+ fi
43
+ if [ $? -ne 0 ]; then
44
+ echo -e "${ERROR_ICON} 错误: 混淆配置文件失败。" >&2
45
+ exit 1
46
+ fi
47
+
48
+ echo -e "${CHECK_ICON} 成功: 混淆配置文件完成。"
49
+ <% } %>
50
+
51
+ 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
+ }
@@ -0,0 +1,58 @@
1
+ #!/bin/bash
2
+ # 无 node 时的轻量混淆:整文件 base64 + atob/eval 包裹。
3
+ # 强度远低于 confuse.js(javascript-obfuscator),仅作兼容兜底。
4
+ # 参数:webAppName configBase [pkgRoot]
5
+
6
+ ERROR_ICON="❌"
7
+ INFO_ICON="ℹ️"
8
+ CHECK_ICON="✅"
9
+
10
+ webAppName="${1:-${WEB_APP_NAME}}"
11
+ configBase="${2:-${CONFIG_FILE_NAME:-sysconfig}}"
12
+ pkgRoot="${3:-}"
13
+
14
+ if [ -z "$pkgRoot" ]; then
15
+ pkgRoot="$(cd "$(dirname "$0")/../.." && pwd)"
16
+ fi
17
+
18
+ if [ -z "$webAppName" ]; then
19
+ echo -e "${ERROR_ICON} 缺少前端应用目录名:请传入第 1 个参数或设置 WEB_APP_NAME" >&2
20
+ exit 1
21
+ fi
22
+
23
+ filepath="${pkgRoot}/${webAppName}/${configBase}.js"
24
+ echo -e "${INFO_ICON} 文件路径:${filepath}"
25
+
26
+ if [ ! -f "$filepath" ]; then
27
+ echo -e "${ERROR_ICON} 文件不存在: ${filepath}" >&2
28
+ exit 1
29
+ fi
30
+
31
+ # 已混淆过则跳过,避免重复包裹
32
+ if grep -q '__WINNER_BASH_OBFUSCATED__' "$filepath" 2>/dev/null; then
33
+ echo -e "${CHECK_ICON} 配置文件已混淆,跳过"
34
+ exit 0
35
+ fi
36
+
37
+ b64=$(base64 < "$filepath" | tr -d '\n\r')
38
+ if [ -z "$b64" ]; then
39
+ echo -e "${ERROR_ICON} base64 编码失败" >&2
40
+ exit 1
41
+ fi
42
+
43
+ tmpfile="${filepath}.obf.$$"
44
+ cat > "$tmpfile" <<EOF
45
+ /* __WINNER_BASH_OBFUSCATED__ */
46
+ (function(_0x){eval(atob(_0x))})('${b64}');
47
+ EOF
48
+
49
+ if [ $? -ne 0 ]; then
50
+ rm -f "$tmpfile"
51
+ echo -e "${ERROR_ICON} 写入临时文件失败" >&2
52
+ exit 1
53
+ fi
54
+
55
+ mv "$tmpfile" "$filepath"
56
+ echo -e "${CHECK_ICON} bash 轻量混淆完成"
57
+ echo -e "${INFO_ICON} 更新路径:${filepath}"
58
+ exit 0