@winner-fed/winner-deploy 4.3.5 → 4.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
- /** build time: Thu Jul 24 2025 16:55:53 GMT+0800 (中国标准时间), build version 4.3.5 **/
2
- var $e=Object.create;var M=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames,Y=Object.getOwnPropertySymbols,Oe=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var ee=(o,e,n)=>e in o?M(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,L=(o,e)=>{for(var n in e||(e={}))te.call(e,n)&&ee(o,n,e[n]);if(Y)for(var n of Y(e))be.call(e,n)&&ee(o,n,e[n]);return o};var Te=(o,e)=>{for(var n in e)M(o,n,{get:e[n],enumerable:!0})},ne=(o,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of xe(e))!te.call(o,l)&&l!==n&&M(o,l,{get:()=>e[l],enumerable:!(i=he(e,l))||i.enumerable});return o};var h=(o,e,n)=>(n=o!=null?$e(Oe(o)):{},ne(e||!o||!o.__esModule?M(n,"default",{value:o,enumerable:!0}):n,o)),ke=o=>ne(M({},"__esModule",{value:!0}),o);var je={};Te(je,{generateSeePackageZip:()=>Fe});module.exports=ke(je);var de=h(require("chalk"),1),ge=h(require("path"),1),_=h(require("fs-extra"),1);var O=h(require("fs-extra"),1),B=require("rimraf");var U=h(require("path"),1),R=h(require("fs-extra"),1),re=h(require("archiver"),1),Z=h(require("xml"),1);var q=process.cwd(),Q=function(e){let n={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},i=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/g;return e&&e.replace?e.replace(i,function(l){return n[l]}):e},v=function(e,n){let i=n||"",l=U.default.resolve(q,e,i,"sysconfig.js");return R.default.pathExistsSync(l)},V=function(e){let n=U.default.resolve(q,e,"config.local.js");return R.default.pathExistsSync(n)},N=function(e,n,i,l){let r=U.default.join(q,n);n!=="/"&&R.default.ensureDirSync(r);let t=R.default.createWriteStream(`${n==="/"?".":r}/${e}.zip`);t.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(t),s.directory(i,!1),s.finalize()},J=function(e,n,i){let{type:l,label:r,name:t,tooltip:s="",visible:c="true",required:a="false",fixed:g="false",fold:p="false",options:f="",validate:m="",upgrade:u="false"}=e,P=e.default;if(i==="form"){let b=(0,Z.default)({form:[{_attr:{name:t,tooltip:s,visible:c,required:a,fixed:g,fold:p,options:f,validate:m,upgrade:u}},n]});return Q(b)}let $=l==="complexSelect"?{default:e.default}:{},y=(0,Z.default)({field:[{_attr:L({type:l,label:r,name:t,tooltip:s,visible:c,required:a,fixed:g,fold:p,options:f,validate:m,upgrade:u},$)},n||P]});return Q(y)},oe=function(e){let i=e.children.map(l=>{let t=l.children.map(s=>J(s)).join("");return J(l,t,"form")}).join("");return J(e,i)},C=function o(e,n,i="",l=""){for(let r=0;r<e.length;r++){let t=e[r];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=o(t.children,n,t.fullName,t.fullPath);if(s)return s}}return null};function ie(o="python"){return o==="python"?"py":"sh"}var w=h(require("fs-extra"),1),le=h(require("path"),1),I=h(require("lodash.template"),1),se=h(require("xml"),1),ce=h(require("@babel/core"),1);var Ae=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],E=o=>le.default.resolve(__dirname,`../templates/see/${o}`),z=o=>{let e=o.type;if(!Ae.includes(e))return"";let{label:n,name:i,tooltip:l="",visible:r="true",required:t="false",fixed:s="false",fold:c="false",options:a="",validate:g="",upgrade:p="false",expose:f="",algorithm:m="",merge:u="",isomeris:P="",old_name:$=""}=o,y=o.default;if(e==="table"){let d=o.keys||[];y=(o.columns||d).map(K=>z(K)).join(`
3
- `)}else if(e==="switchForm"||e==="division"){let d=o.children;y=d?d.map(x=>z(x)).join(`
4
- `):""}else{if(e==="complexSelect")return oe(o);e==="editor"?y=typeof y=="object"?[JSON.stringify(y)]:[y]:y=[y]}let b=e==="switchForm"?{default:o.default}:{},F=L({type:e,label:n,name:i,tooltip:l,visible:r,required:t,fixed:s,fold:c,options:a,validate:g,upgrade:p,expose:f,algorithm:m,merge:u,isomeris:P,old_name:$},b),D=Object.fromEntries(Object.entries(F).filter(([d,x])=>x!==""&&x!==null&&x!==void 0)),T=(0,se.default)({field:[{_attr:D},...Array.isArray(y)?y:[y]]});return Q(T)},ae=function({system:e,type:n,name:i,appType:l,appName:r,group:t,version:s,configFileName:c="config.local",variables:a=[],description:g,scriptsType:p="python"}){let f=w.default.readFileSync(E(`${p}/deploy.xml`)).toString();return(0,I.default)(f,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:r,appType:l,group:t,version:s,configFileName:c,variables:a.map(m=>z(m)).join(`
5
- `),description:g})},X=function(e,n){let i=w.default.readFileSync(E(`${n.scriptsType}/scripts/${e}.${n.scriptsType==="python"?"py":"sh"}`)).toString();return(0,I.default)(i,{interpolate:/{{([\s\S]+?)}}/g})(n)},j=function(e,n=[]){let{code:i}=ce.default.transformFileSync(e,{babelrc:!1,plugins:[function(){return{visitor:{Literal(r){if(r.parentPath.isProperty()){let t=r.parentPath.get("key").node,s=t.name;t.type==="StringLiteral"&&(t.type="Identifier",t.name=t.value,s=t.value);let c=C(n,a=>s===a.name);if(c){if(c.fullPath.includes("complexSelect")&&(c.name=c.fullName),r.isStringLiteral()){r.node.value=`$!{${c.name}}`;return}if(r.isNumericLiteral()){r.node.value=`$!{${c.name}}`;return}if(r.isBooleanLiteral()){if(r.node.type="StringLiteral",c.fullPath.includes("complexSelect")){r.node.value=`$!{${c.fullName}}`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(r){if(r.parentPath.isProperty()){let t=C(n,s=>r.parentPath.get("key").node.name===s.name);if(t){if(t.fullPath.includes("editor")){r.node.type="StringLiteral",r.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]`,r.node.type="StringLiteral",r.node.value=s;return}a&&a.length&&a.forEach(p=>{s+=`${p.name}: '$!{row.${p.name}}',`}),r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) {${s}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(r){if(r.parentPath.isProperty()){let t=r.parentPath.get("key").node,s=t.name;if(t){let c=C(n,a=>s===a.name);if(c){if(r.node.type="StringLiteral",c.fullPath.includes("editor")){r.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`;return}r.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:e,type:n,name:i,appName:l,appType:r,version:t,group:s,configFileName:c="config.local",variables:a=[],description:g,web_app_web_service_name:p,dockerImage:f}){let m=w.default.readFileSync(E("docker/deploy.xml")).toString();return(0,I.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:l,appType:r,version:t,group:s,configFileName:c,variables:a.map(u=>z(u)).join(`
6
- `),description:g,web_app_web_service_name:p,dockerImage:f})},fe=function(e){let n=w.default.readFileSync(E("docker/k8s-deploy-res.yaml")).toString();return(0,I.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(e)},me=function(e){let n=w.default.readFileSync(E("docker/Dockerfile")).toString();return(0,I.default)(n)(e)};var S="tmp",ue=function(e,n,i){let{system:l,type:r,name:t,appType:s,appName:c,group:a,version:g,template:p,variables:f=[],configName:m,outputName:u="dist",description:P,scriptsType:$,seePackagePath:y,tplPath:b}=n;O.default.ensureDirSync(S),O.default.ensureDirSync(`${S}/scripts`),O.default.ensureDirSync(`${S}/template`);let F=ie($);$==="python"&&O.default.outputFileSync(`./${S}/scripts/${t}/utils.${F}`,X("utils",{scriptsType:$})),O.default.outputFileSync(`./${S}/scripts/${t}/install.${F}`,X("install",{name:t,type:r,scriptsType:$})),O.default.outputFileSync(`./${S}/scripts/${t}/afterInstall.${F}`,X("afterInstall",{name:t,scriptsType:$})),O.default.outputFileSync(`./${S}/scripts/${t}/uninstall.${F}`,X("uninstall",{name:t,type:r,scriptsType:$}));let D=!1,T=!1;if(b&&Object.keys(b).length>0)for(let[d,x]of Object.entries(b))d==="deploy.xml"?(O.default.copyFileSync(x,`./${S}/deploy.xml`),D=!0):O.default.copyFileSync(x,`./${S}/template/${d}`),(d==="sysconfig.js"||d==="config.local.js")&&(T=!0);D||O.default.outputFileSync(`./${S}/deploy.xml`,ae({system:l,type:r,name:t,appType:s,appName:c,group:a,version:g,configFileName:m,variables:f,description:P,scriptsType:$})),T||(V(u)?O.default.outputFileSync(`./${S}/template/config.local.js`,p?j(p,f):""):v(u)||v(u,t)?(m="sysconfig",O.default.outputFileSync(`./${S}/template/sysconfig.js`,p?j(p,f):"")):m&&O.default.outputFileSync(`./${S}/template/${m}.js`,p?j(p,f):"")),i?i(d=>{N(e,y,S,()=>{B.rimraf.sync(S),typeof d=="function"&&d()})}):N(e,y,S,()=>{B.rimraf.sync(S)})};var W=h(require("path"),1),A=h(require("fs-extra"),1),G=require("rimraf");var k="tmp",ye=function(e,n,i){let{system:l,type:r,name:t,appType:s,appName:c,version:a,group:g,template:p,variables:f,configName:m,outputName:u,description:P,seePackagePath:$,dockerImage:y=a.indexOf("-")>0?`isee1.0-docker-dev-local/${t}`:`isee1.0-docker-release-local/${t}`}=n;A.default.ensureDirSync(k),A.default.ensureDirSync("docker"),A.default.pathExistsSync(W.default.resolve(process.cwd(),"docker/Dockerfile"))||A.default.outputFileSync(W.default.resolve(process.cwd(),"docker/Dockerfile"),me({name:t,type:r})),A.default.ensureDirSync(`${k}/scripts`),A.default.ensureDirSync(`${k}/template`),V(u)?A.default.outputFileSync(`./${k}/template/${t}/config.local.js`,p?j(p,f):""):v(u)||v(u,t)?(m="sysconfig",A.default.outputFileSync(`./${k}/template/${t}/sysconfig.js`,p?j(p,f):"")):m&&A.default.outputFileSync(`./${k}/template/${t}/${m}.js`,p?j(p,f):""),A.default.outputFileSync(`./${k}/template/k8s-deploy-res.yaml`,fe({configFileName:m})),A.default.outputFileSync(`./${k}/deploy.xml`,pe({system:l,type:r,name:t,appName:c,appType:s,version:a,group:g,configFileName:m,variables:f,description:P,web_app_web_service_name:`${t}-web`,dockerImage:y})),i?i(b=>{N(e,$,k,()=>{G.rimraf.sync(k),typeof b=="function"&&b()})}):N(e,$,k,()=>{G.rimraf.sync(k)})};var _e=process.cwd();function Pe(o,e,n){let i="",l;if(o==="bizframe"){i=_.default.readdirSync(`./${n}`).find(r=>/manifest\.[0-9]+\.json/.test(r));try{l=_.default.readJsonSync(`./${n}/${i}`)}catch(r){console.error(`${n} \u76EE\u5F55\u4E0B\u7684 manifest.xxx.json \u89E3\u6790\u5931\u8D25\uFF01\u8BF7\u786E\u8BA4\u6B64\u6587\u4EF6\u662F\u5426\u5B58\u5728\u3002\u6216\u53EF\u4EE5\u5C06 scriptsType \u8BBE\u7F6E\u4E3A bash \u8BD5\u8BD5\u770B\u3002`),process.exit(0)}}return o==="subsystem"&&(i=_.default.readdirSync(`./${n}/${e}`).find(r=>/manifest\.[0-9]+\.json/.test(r)),l=_.default.readJsonSync(`./${n}/${e}/${i}`)),{manifest:i,manifestJson:l}}var Fe=function({system:e="winner-front",type:n="bizframe",name:i,appType:l,appName:r,group:t="bizframe",version:s,configName:c="config.local",outputName:a="dist",templateFunc:g,variablesFunc:p,copyFiles:f,description:m,seePackageName:u,seePackagePath:P="package",seePackageType:$="web",dockerImage:y,scriptsType:b="python",tplPath:F={}},D){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 u=="string"&&u&&(u=u.replace(/@/gi,"").replace(/\//gi,"-")),l=l||i,r=r||i,p=p||function(){try{let{variables:T}=require(ge.default.resolve(_e,"build","package","./variables.js"));return T||[]}catch(T){return console.error(T),[]}},g=g||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${i}/sysconfig.js`},$==="docker"){ye(u||`${e}-${i}-${s}`,{system:e,type:n,name:i,appType:l,appName:r,group:t,version:s,configName:c,outputName:a,template:g(),variables:p(),seePackagePath:P,description:m,dockerImage:y},T=>{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"),T(D)});return}ue(u||`${e}-${i}-${s}`,{system:e,type:n,name:i,group:t,appType:l,appName:r,version:s,configName:c,outputName:a,template:g(),variables:p(),seePackagePath:P,description:m,scriptsType:b,tplPath:F},T=>{if(b==="python"){let{manifest:d,manifestJson:x}=Pe(n,i,a);for(let K in x)if(x.hasOwnProperty(K)){let{path:H,dir:Se}=x[K];_.default.ensureDirSync(`./tmp/source/${Se}`),_.default.copyFileSync(`./${a}/${H}`,`./tmp/source/${H}`)}_.default.outputJSONSync(`./tmp/scripts/${i}/conf/${d}`,x)}else _.default.ensureDirSync("./tmp/source"),_.default.copySync(`./${a}`,"./tmp/source");Array.isArray(f)&&f.length&&f.forEach(d=>{_.default.ensureFileSync(`./tmp/source/${i}/${d}`),_.default.copyFileSync(`./${a}/${i}/${d}`,`./tmp/source/${i}/${d}`)}),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${de.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
- `),T(D)})};0&&(module.exports={generateSeePackageZip});
1
+ /** build time: Wed Oct 15 2025 11:45:02 GMT+0800 (中国标准时间), build version 4.3.6 **/
2
+ var $e=Object.create;var R=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames,Y=Object.getOwnPropertySymbols,Oe=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var ee=(o,e,n)=>e in o?R(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,L=(o,e)=>{for(var n in e||(e={}))te.call(e,n)&&ee(o,n,e[n]);if(Y)for(var n of Y(e))be.call(e,n)&&ee(o,n,e[n]);return o};var Te=(o,e)=>{for(var n in e)R(o,n,{get:e[n],enumerable:!0})},ne=(o,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of xe(e))!te.call(o,l)&&l!==n&&R(o,l,{get:()=>e[l],enumerable:!(i=he(e,l))||i.enumerable});return o};var h=(o,e,n)=>(n=o!=null?$e(Oe(o)):{},ne(e||!o||!o.__esModule?R(n,"default",{value:o,enumerable:!0}):n,o)),ke=o=>ne(R({},"__esModule",{value:!0}),o);var Fe={};Te(Fe,{generateSeePackageZip:()=>De});module.exports=ke(Fe);var ge=h(require("chalk"),1),de=h(require("path"),1),T=h(require("fs-extra"),1);var x=h(require("fs-extra"),1),B=require("rimraf");var U=h(require("path"),1),E=h(require("fs-extra"),1),re=h(require("archiver"),1),Z=h(require("xml"),1);var q=process.cwd(),Q=function(e){let n={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},i=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/g;return e&&e.replace?e.replace(i,function(l){return n[l]}):e},v=function(e,n){let i=n||"",l=U.default.resolve(q,e,i,"sysconfig.js");return E.default.pathExistsSync(l)},V=function(e){let n=U.default.resolve(q,e,"config.local.js");return E.default.pathExistsSync(n)},N=function(e,n,i,l){let r=U.default.join(q,n);n!=="/"&&E.default.ensureDirSync(r);let t=E.default.createWriteStream(`${n==="/"?".":r}/${e}.zip`);t.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(t),s.directory(i,!1),s.finalize()},J=function(e,n,i){let{type:l,label:r,name:t,tooltip:s="",visible:c="true",required:a="false",fixed:d="false",fold:p="false",options:f="",validate:m="",upgrade:u="false"}=e,_=e.default;if(i==="form"){let b=(0,Z.default)({form:[{_attr:{name:t,tooltip:s,visible:c,required:a,fixed:d,fold:p,options:f,validate:m,upgrade:u}},n]});return Q(b)}let $=l==="complexSelect"?{default:e.default}:{},y=(0,Z.default)({field:[{_attr:L({type:l,label:r,name:t,tooltip:s,visible:c,required:a,fixed:d,fold:p,options:f,validate:m,upgrade:u},$)},n||_]});return Q(y)},oe=function(e){let i=e.children.map(l=>{let t=l.children.map(s=>J(s)).join("");return J(l,t,"form")}).join("");return J(e,i)},C=function o(e,n,i="",l=""){for(let r=0;r<e.length;r++){let t=e[r];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=o(t.children,n,t.fullName,t.fullPath);if(s)return s}}return null};function ie(o="python"){return o==="python"?"py":"sh"}var I=h(require("fs-extra"),1),le=h(require("path"),1),w=h(require("lodash.template"),1),se=h(require("xml"),1),ce=h(require("@babel/core"),1);var Ae=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],X=o=>le.default.resolve(__dirname,`../templates/see/${o}`),z=o=>{let e=o.type;if(!Ae.includes(e))return"";let{label:n,name:i,tooltip:l="",visible:r="true",required:t="false",fixed:s="false",fold:c="false",options:a="",validate:d="",upgrade:p="false",expose:f="",algorithm:m="",merge:u="",isomeris:_="",old_name:$=""}=o,y=o.default;if(e==="table"){let g=o.keys||[];y=(o.columns||g).map(K=>z(K)).join(`
3
+ `)}else if(e==="switchForm"||e==="division"){let g=o.children;y=g?g.map(O=>z(O)).join(`
4
+ `):""}else{if(e==="complexSelect")return oe(o);e==="editor"?y=typeof y=="object"?[JSON.stringify(y)]:[y]:y=[y]}let b=e==="switchForm"?{default:o.default}:{},D=L({type:e,label:n,name:i,tooltip:l,visible:r,required:t,fixed:s,fold:c,options:a,validate:d,upgrade:p,expose:f,algorithm:m,merge:u,isomeris:_,old_name:$},b),j=Object.fromEntries(Object.entries(D).filter(([g,O])=>O!==""&&O!==null&&O!==void 0)),k=(0,se.default)({field:[{_attr:j},...Array.isArray(y)?y:[y]]});return Q(k)},ae=function({system:e,type:n,name:i,appType:l,appName:r,group:t,version:s,configFileName:c="config.local",variables:a=[],description:d,scriptsType:p="python"}){let f=I.default.readFileSync(X(`${p}/deploy.xml`)).toString();return(0,w.default)(f,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:r,appType:l,group:t,version:s,configFileName:c,variables:a.map(m=>z(m)).join(`
5
+ `),description:d})},M=function(e,n){let i=`${n.scriptsType}/scripts/${e}.${n.scriptsType==="python"?"py":"sh"}`;e==="beforeInstall"&&(i=`${n.scriptsType}/scripts/${e}.sh`);let l=I.default.readFileSync(X(i)).toString();return(0,w.default)(l,{interpolate:/{{([\s\S]+?)}}/g})(n)},F=function(e,n=[]){let{code:i}=ce.default.transformFileSync(e,{babelrc:!1,plugins:[function(){return{visitor:{Literal(r){if(r.parentPath.isProperty()){let t=r.parentPath.get("key").node,s=t.name;t.type==="StringLiteral"&&(t.type="Identifier",t.name=t.value,s=t.value);let c=C(n,a=>s===a.name);if(c){if(c.fullPath.includes("complexSelect")&&(c.name=c.fullName),r.isStringLiteral()){r.node.value=`$!{${c.name}}`;return}if(r.isNumericLiteral()){r.node.value=`$!{${c.name}}`;return}if(r.isBooleanLiteral()){if(r.node.type="StringLiteral",c.fullPath.includes("complexSelect")){r.node.value=`$!{${c.fullName}}`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(r){if(r.parentPath.isProperty()){let t=C(n,s=>r.parentPath.get("key").node.name===s.name);if(t){if(t.fullPath.includes("editor")){r.node.type="StringLiteral",r.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]`,r.node.type="StringLiteral",r.node.value=s;return}a&&a.length&&a.forEach(p=>{s+=`${p.name}: '$!{row.${p.name}}',`}),r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) {${s}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(r){if(r.parentPath.isProperty()){let t=r.parentPath.get("key").node,s=t.name;if(t){let c=C(n,a=>s===a.name);if(c){if(r.node.type="StringLiteral",c.fullPath.includes("editor")){r.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`;return}r.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:e,type:n,name:i,appName:l,appType:r,version:t,group:s,configFileName:c="config.local",variables:a=[],description:d,web_app_web_service_name:p,dockerImage:f}){let m=I.default.readFileSync(X("docker/deploy.xml")).toString();return(0,w.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:l,appType:r,version:t,group:s,configFileName:c,variables:a.map(u=>z(u)).join(`
6
+ `),description:d,web_app_web_service_name:p,dockerImage:f})},fe=function(e){let n=I.default.readFileSync(X("docker/k8s-deploy-res.yaml")).toString();return(0,w.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(e)},me=function(e){let n=I.default.readFileSync(X("docker/Dockerfile")).toString();return(0,w.default)(n)(e)};var S="tmp",ue=function(e,n,i){let{system:l,type:r,name:t,appType:s,appName:c,group:a,version:d,template:p,variables:f=[],configName:m,outputName:u="dist",description:_,scriptsType:$,seePackagePath:y,tplPath:b}=n;x.default.ensureDirSync(S),x.default.ensureDirSync(`${S}/scripts`),x.default.ensureDirSync(`${S}/template`);let D=ie($);$==="python"&&(x.default.outputFileSync(`./${S}/scripts/${t}/utils.${D}`,M("utils",{scriptsType:$})),x.default.outputFileSync(`./${S}/scripts/${t}/beforeInstall.sh`,M("beforeInstall",{scriptsType:$}))),x.default.outputFileSync(`./${S}/scripts/${t}/install.${D}`,M("install",{name:t,type:r,scriptsType:$})),x.default.outputFileSync(`./${S}/scripts/${t}/afterInstall.${D}`,M("afterInstall",{name:t,scriptsType:$})),x.default.outputFileSync(`./${S}/scripts/${t}/uninstall.${D}`,M("uninstall",{name:t,type:r,scriptsType:$}));let j=!1,k=!1;if(b&&Object.keys(b).length>0)for(let[g,O]of Object.entries(b))g==="deploy.xml"?(x.default.copyFileSync(O,`./${S}/deploy.xml`),j=!0):x.default.copyFileSync(O,`./${S}/template/${g}`),(g==="sysconfig.js"||g==="config.local.js")&&(k=!0);j||x.default.outputFileSync(`./${S}/deploy.xml`,ae({system:l,type:r,name:t,appType:s,appName:c,group:a,version:d,configFileName:m,variables:f,description:_,scriptsType:$})),k||(V(u)?x.default.outputFileSync(`./${S}/template/config.local.js`,p?F(p,f):""):v(u)||v(u,t)?(m="sysconfig",x.default.outputFileSync(`./${S}/template/sysconfig.js`,p?F(p,f):"")):m&&x.default.outputFileSync(`./${S}/template/${m}.js`,p?F(p,f):"")),i?i(g=>{N(e,y,S,()=>{B.rimraf.sync(S),typeof g=="function"&&g()})}):N(e,y,S,()=>{B.rimraf.sync(S)})};var W=h(require("path"),1),P=h(require("fs-extra"),1),G=require("rimraf");var A="tmp",ye=function(e,n,i){let{system:l,type:r,name:t,appType:s,appName:c,version:a,group:d,template:p,variables:f,configName:m,outputName:u,description:_,seePackagePath:$,dockerImage:y=a.indexOf("-")>0?`isee1.0-docker-dev-local/${t}`:`isee1.0-docker-release-local/${t}`}=n;P.default.ensureDirSync(A),P.default.ensureDirSync("docker"),P.default.pathExistsSync(W.default.resolve(process.cwd(),"docker/Dockerfile"))||P.default.outputFileSync(W.default.resolve(process.cwd(),"docker/Dockerfile"),me({name:t,type:r})),P.default.ensureDirSync(`${A}/scripts`),P.default.ensureDirSync(`${A}/template`),V(u)?P.default.outputFileSync(`./${A}/template/${t}/config.local.js`,p?F(p,f):""):v(u)||v(u,t)?(m="sysconfig",P.default.outputFileSync(`./${A}/template/${t}/sysconfig.js`,p?F(p,f):"")):m&&P.default.outputFileSync(`./${A}/template/${t}/${m}.js`,p?F(p,f):""),P.default.outputFileSync(`./${A}/template/k8s-deploy-res.yaml`,fe({configFileName:m})),P.default.outputFileSync(`./${A}/deploy.xml`,pe({system:l,type:r,name:t,appName:c,appType:s,version:a,group:d,configFileName:m,variables:f,description:_,web_app_web_service_name:`${t}-web`,dockerImage:y})),i?i(b=>{N(e,$,A,()=>{G.rimraf.sync(A),typeof b=="function"&&b()})}):N(e,$,A,()=>{G.rimraf.sync(A)})};var Pe=process.cwd();function _e(o,e,n){let i="",l,r=o==="bizframe"?`./${n}`:`./${n}/${e}`;return T.default.existsSync(r)&&(i=T.default.readdirSync(r).find(t=>/manifest\.[0-9]+\.json/.test(t)),i&&(l=T.default.readJsonSync(`${r}/${i}`))),{manifest:i,manifestJson:l}}var De=function({system:e="winner-front",type:n="bizframe",name:i,appType:l,appName:r,group:t="bizframe",version:s,configName:c="config.local",outputName:a="dist",templateFunc:d,variablesFunc:p,copyFiles:f,description:m,seePackageName:u,seePackagePath:_="package",seePackageType:$="web",dockerImage:y,scriptsType:b="python",tplPath:D={}},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 u=="string"&&u&&(u=u.replace(/@/gi,"").replace(/\//gi,"-")),l=l||i,r=r||i,p=p||function(){try{let{variables:k}=require(de.default.resolve(Pe,"build","package","./variables.js"));return k||[]}catch(k){return console.error(k),[]}},d=d||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${i}/sysconfig.js`},$==="docker"){ye(u||`${e}-${i}-${s}`,{system:e,type:n,name:i,appType:l,appName:r,group:t,version:s,configName:c,outputName:a,template:d(),variables:p(),seePackagePath:_,description:m,dockerImage:y},k=>{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"),k(j)});return}ue(u||`${e}-${i}-${s}`,{system:e,type:n,name:i,group:t,appType:l,appName:r,version:s,configName:c,outputName:a,template:d(),variables:p(),seePackagePath:_,description:m,scriptsType:b,tplPath:D},k=>{if(b==="python"){let{manifest:g,manifestJson:O}=_e(n,i,a);if(g){for(let K in O)if(O.hasOwnProperty(K)){let{path:H,dir:Se}=O[K];T.default.ensureDirSync(`./tmp/source/${Se}`),T.default.copyFileSync(`./${a}/${H}`,`./tmp/source/${H}`)}T.default.outputJSONSync(`./tmp/scripts/${i}/conf/${g}`,O)}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(f)&&f.length&&f.forEach(g=>{T.default.ensureFileSync(`./tmp/source/${i}/${g}`),T.default.copyFileSync(`./${a}/${i}/${g}`,`./tmp/source/${i}/${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${ge.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
+ `),k(j)})};0&&(module.exports={generateSeePackageZip});
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- /** build time: Thu Jul 24 2025 16:55:53 GMT+0800 (中国标准时间), build version 4.3.5 **/
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 A from"fs-extra";import O 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},D=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:g="false",fold:p="false",options:f="",validate:m="",upgrade:u="false"}=t,_=t.default;if(o==="form"){let x=W({form:[{_attr:{name:e,tooltip:l,visible:s,required:a,fixed:g,fold:p,options:f,validate:m,upgrade:u}},n]});return K(x)}let $=c==="complexSelect"?{default:t.default}:{},y=W({field:[{_attr:E({type:c,label:r,name:e,tooltip:l,visible:s,required:a,fixed:g,fold:p,options:f,validate:m,upgrade:u},$)},n||_]});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 N from"fs-extra";import ue from"path";import w from"lodash.template";import ye from"xml";import de from"@babel/core";var ge=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],I=i=>ue.resolve(__dirname,`../templates/see/${i}`),U=i=>{let t=i.type;if(!ge.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:g="",upgrade:p="false",expose:f="",algorithm:m="",merge:u="",isomeris:_="",old_name:$=""}=i,y=i.default;if(t==="table"){let d=i.keys||[];y=(i.columns||d).map(R=>U(R)).join(`
3
- `)}else if(t==="switchForm"||t==="division"){let d=i.children;y=d?d.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 x=t==="switchForm"?{default:i.default}:{},P=E({type:t,label:n,name:o,tooltip:c,visible:r,required:e,fixed:l,fold:s,options:a,validate:g,upgrade:p,expose:f,algorithm:m,merge:u,isomeris:_,old_name:$},x),j=Object.fromEntries(Object.entries(P).filter(([d,h])=>h!==""&&h!==null&&h!==void 0)),b=ye({field:[{_attr:j},...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:g,scriptsType:p="python"}){let f=N.readFileSync(I(`${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:g})},M=function(t,n){let o=N.readFileSync(I(`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`)).toString();return w(o,{interpolate:/{{([\s\S]+?)}}/g})(n)},F=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=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:g,web_app_web_service_name:p,dockerImage:f}){let m=N.readFileSync(I("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:g,web_app_web_service_name:p,dockerImage:f})},te=function(t){let n=N.readFileSync(I("docker/k8s-deploy-res.yaml")).toString();return w(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},ne=function(t){let n=N.readFileSync(I("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:g,template:p,variables:f=[],configName:m,outputName:u="dist",description:_,scriptsType:$,seePackagePath:y,tplPath:x}=n;O.ensureDirSync(S),O.ensureDirSync(`${S}/scripts`),O.ensureDirSync(`${S}/template`);let P=H($);$==="python"&&O.outputFileSync(`./${S}/scripts/${e}/utils.${P}`,M("utils",{scriptsType:$})),O.outputFileSync(`./${S}/scripts/${e}/install.${P}`,M("install",{name:e,type:r,scriptsType:$})),O.outputFileSync(`./${S}/scripts/${e}/afterInstall.${P}`,M("afterInstall",{name:e,scriptsType:$})),O.outputFileSync(`./${S}/scripts/${e}/uninstall.${P}`,M("uninstall",{name:e,type:r,scriptsType:$}));let j=!1,b=!1;if(x&&Object.keys(x).length>0)for(let[d,h]of Object.entries(x))d==="deploy.xml"?(O.copyFileSync(h,`./${S}/deploy.xml`),j=!0):O.copyFileSync(h,`./${S}/template/${d}`),(d==="sysconfig.js"||d==="config.local.js")&&(b=!0);j||O.outputFileSync(`./${S}/deploy.xml`,Y({system:c,type:r,name:e,appType:l,appName:s,group:a,version:g,configFileName:m,variables:f,description:_,scriptsType:$})),b||(L(u)?O.outputFileSync(`./${S}/template/config.local.js`,p?F(p,f):""):D(u)||D(u,e)?(m="sysconfig",O.outputFileSync(`./${S}/template/sysconfig.js`,p?F(p,f):"")):m&&O.outputFileSync(`./${S}/template/${m}.js`,p?F(p,f):"")),o?o(d=>{v(t,y,S,()=>{re.sync(S),typeof d=="function"&&d()})}):v(t,y,S,()=>{re.sync(S)})};import ie from"path";import k 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:g,template:p,variables:f,configName:m,outputName:u,description:_,seePackagePath:$,dockerImage:y=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;k.ensureDirSync(T),k.ensureDirSync("docker"),k.pathExistsSync(ie.resolve(process.cwd(),"docker/Dockerfile"))||k.outputFileSync(ie.resolve(process.cwd(),"docker/Dockerfile"),ne({name:e,type:r})),k.ensureDirSync(`${T}/scripts`),k.ensureDirSync(`${T}/template`),L(u)?k.outputFileSync(`./${T}/template/${e}/config.local.js`,p?F(p,f):""):D(u)||D(u,e)?(m="sysconfig",k.outputFileSync(`./${T}/template/${e}/sysconfig.js`,p?F(p,f):"")):m&&k.outputFileSync(`./${T}/template/${e}/${m}.js`,p?F(p,f):""),k.outputFileSync(`./${T}/template/k8s-deploy-res.yaml`,te({configFileName:m})),k.outputFileSync(`./${T}/deploy.xml`,ee({system:c,type:r,name:e,appName:s,appType:l,version:a,group:g,configFileName:m,variables:f,description:_,web_app_web_service_name:`${e}-web`,dockerImage:y})),o?o(x=>{v(t,$,T,()=>{le.sync(T),typeof x=="function"&&x()})}):v(t,$,T,()=>{le.sync(T)})};var he=process.cwd();function xe(i,t,n){let o="",c;if(i==="bizframe"){o=A.readdirSync(`./${n}`).find(r=>/manifest\.[0-9]+\.json/.test(r));try{c=A.readJsonSync(`./${n}/${o}`)}catch(r){console.error(`${n} \u76EE\u5F55\u4E0B\u7684 manifest.xxx.json \u89E3\u6790\u5931\u8D25\uFF01\u8BF7\u786E\u8BA4\u6B64\u6587\u4EF6\u662F\u5426\u5B58\u5728\u3002\u6216\u53EF\u4EE5\u5C06 scriptsType \u8BBE\u7F6E\u4E3A bash \u8BD5\u8BD5\u770B\u3002`),process.exit(0)}}return i==="subsystem"&&(o=A.readdirSync(`./${n}/${t}`).find(r=>/manifest\.[0-9]+\.json/.test(r)),c=A.readJsonSync(`./${n}/${t}/${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:g,variablesFunc:p,copyFiles:f,description:m,seePackageName:u,seePackagePath:_="package",seePackageType:$="web",dockerImage:y,scriptsType:x="python",tplPath:P={}},j){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),[]}},g=g||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:g(),variables:p(),seePackagePath:_,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(j)});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:g(),variables:p(),seePackagePath:_,description:m,scriptsType:x,tplPath:P},b=>{if(x==="python"){let{manifest:d,manifestJson:h}=xe(n,o,a);for(let R in h)if(h.hasOwnProperty(R)){let{path:J,dir:ce}=h[R];A.ensureDirSync(`./tmp/source/${ce}`),A.copyFileSync(`./${a}/${J}`,`./tmp/source/${J}`)}A.outputJSONSync(`./tmp/scripts/${o}/conf/${d}`,h)}else A.ensureDirSync("./tmp/source"),A.copySync(`./${a}`,"./tmp/source");Array.isArray(f)&&f.length&&f.forEach(d=>{A.ensureFileSync(`./tmp/source/${o}/${d}`),A.copyFileSync(`./${a}/${o}/${d}`,`./tmp/source/${o}/${d}`)}),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(j)})};export{He as generateSeePackageZip};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winner-fed/winner-deploy",
3
- "version": "4.3.5",
3
+ "version": "4.3.6",
4
4
  "description": "Generate a publication deployed by the See platform",
5
5
  "keywords": [
6
6
  "winner",
@@ -15,7 +15,7 @@
15
15
  <system id="{{ name }}" type="{{ type }}" name="{{ name }}" mode="cluster" front="">
16
16
  <scale describe="集群规模" />
17
17
  <scripts describe="集群脚本集">
18
- <script name="beforeInstall" path="" describe="安装前处理"/>
18
+ <script name="beforeInstall" path="./scripts/{{ name }}/beforeInstall.sh" describe="安装前处理"/>
19
19
  <script name="install" path="./scripts/{{ name }}/install.py" describe="部署"/>
20
20
  <script name="afterInstall" path="./scripts/{{ name }}/afterInstall.py" describe="安装后处理"/>
21
21
  <script name="start" path="" describe="启动" />
@@ -0,0 +1,85 @@
1
+ #!/bin/bash
2
+
3
+ # 定义图标
4
+ CHECK_ICON="✅"
5
+ ERROR_ICON="❌"
6
+ INFO_ICON="ℹ️"
7
+ WARNING_ICON="⚠️"
8
+
9
+ echo -e "${INFO_ICON} 开始检查 Python 环境..."
10
+
11
+ # 检查 python 命令是否可用(因为实际运行时调用的就是这个命令)
12
+ if command -v python &> /dev/null
13
+ then
14
+ # 尝试获取 Python 版本
15
+ if PYTHON_VERSION=$(python --version 2>&1)
16
+ then
17
+ echo -e "${CHECK_ICON} Python 命令检测成功: ${PYTHON_VERSION}"
18
+
19
+ # 执行一段简单的 Python 脚本来验证环境是否真正可用
20
+ echo -e "${INFO_ICON} 正在验证 Python 环境可执行性..."
21
+
22
+ # 创建一个简单的测试脚本
23
+ TEST_SCRIPT='
24
+ import sys
25
+ import os
26
+ print("Python version:", sys.version.split()[0])
27
+ print("Python executable:", sys.executable)
28
+ print("Platform:", sys.platform)
29
+ try:
30
+ import json
31
+ print("JSON module: OK")
32
+ except ImportError as e:
33
+ print("JSON module: FAILED -", str(e))
34
+ sys.exit(1)
35
+ print("Environment test: PASSED")
36
+ '
37
+
38
+ # 执行测试脚本
39
+ PYTHON_TEST_OUTPUT=$(python -c "$TEST_SCRIPT" 2>&1)
40
+ if [ $? -eq 0 ]; then
41
+ echo -e "${CHECK_ICON} Python 环境验证成功:"
42
+ echo "$PYTHON_TEST_OUTPUT" | while IFS= read -r line; do
43
+ echo -e " ${line}"
44
+ done
45
+ exit 0
46
+ else
47
+ echo -e "${ERROR_ICON} 错误: Python 环境验证失败。详细信息:" >&2
48
+ echo "$PYTHON_TEST_OUTPUT" | while IFS= read -r line; do
49
+ echo -e " ${line}" >&2
50
+ done
51
+ echo -e "${ERROR_ICON} 部署无法继续,请检查您的 Python 环境。" >&2
52
+ exit 1
53
+ fi
54
+ else
55
+ echo -e "${ERROR_ICON} 错误: python 命令存在但无法正常运行。错误信息: ${PYTHON_VERSION}" >&2
56
+ echo -e "${ERROR_ICON} 部署无法继续,请检查您的 Python 安装。" >&2
57
+ exit 1
58
+ fi
59
+ else
60
+ # python 命令不存在,给出操作建议
61
+ echo -e "${ERROR_ICON} 错误: 系统中未找到 'python' 命令。" >&2
62
+ echo -e "${INFO_ICON} 部署需要 'python' 命令才能继续。" >&2
63
+ echo -e "${INFO_ICON} 解决方案:" >&2
64
+ echo -e " 1. 如果您已安装了 Python 3,可以创建软链接: 参考示例" >&2
65
+ echo -e " sudo ln -s \$(which python3) /usr/local/bin/python" >&2
66
+ echo -e "" >&2
67
+ echo -e " 2. 安装 Python 3 (推荐) 参考示例如下:" >&2
68
+ echo -e " # Ubuntu/Debian:" >&2
69
+ echo -e " sudo apt-get update && sudo apt-get install python3 python3-pip" >&2
70
+ echo -e " sudo ln -s /usr/bin/python3 /usr/bin/python" >&2
71
+ echo -e "" >&2
72
+ echo -e " # CentOS/RHEL 8+ 参考示例如下:" >&2
73
+ echo -e " sudo dnf install python3 python3-pip" >&2
74
+ echo -e " sudo alternatives --install /usr/bin/python python /usr/bin/python3 1" >&2
75
+ echo -e "" >&2
76
+ echo -e " # CentOS/RHEL 7 参考示例如下:" >&2
77
+ echo -e " sudo yum install python3 python3-pip" >&2
78
+ echo -e " sudo ln -s /usr/bin/python3 /usr/bin/python" >&2
79
+ echo -e "" >&2
80
+ echo -e " 3. 或者安装 Python 2.7 (不推荐,已停止维护):" >&2
81
+ echo -e " # Ubuntu/Debian: sudo apt-get install python2.7" >&2
82
+ echo -e " # CentOS/RHEL: sudo yum install python2" >&2
83
+ echo -e "${WARNING_ICON} 请安装 Python 后重新运行部署。" >&2
84
+ exit 1
85
+ fi
@@ -12,60 +12,70 @@ import re
12
12
  import sys
13
13
  import utils
14
14
 
15
- try:
16
- reload(sys)
17
- sys.setdefaultencoding("utf8")
18
- except:
19
- print("Failed to perform module reload, continue installation")
20
-
15
+ # 在 Python 2 中导入额外模块
16
+ if sys.version_info[0] == 2:
17
+ try:
18
+ from io import open
19
+ except ImportError:
20
+ pass
21
+ # 仅在Python 2中设置默认编码
22
+ if sys.version_info[0] == 2:
23
+ try:
24
+ reload(sys)
25
+ sys.setdefaultencoding("utf8")
26
+ except Exception as e:
27
+ print("执行模块重载失败,原因:", e)
28
+ print("继续安装...")
21
29
 
22
30
  name = "{{name}}"
23
- type = "{{type}}"
31
+ deploy_type = "{{type}}"
24
32
  # 读取 deploy.xml 配置文件定义的 webAppName
25
33
  webAppName = "${webAppName}"
26
34
 
27
- def install(name, type):
28
- conf = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "conf")
35
+ def copy_source(deploy_type, name):
36
+ if deploy_type == "bizframe":
37
+ os.system("cp -rf ./tmp/source ./" + name)
38
+ elif deploy_type == "subsystem":
39
+ os.system("cp -rf ./tmp/source ./")
29
40
 
41
+ def install(name, deploy_type):
42
+ conf = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "conf")
30
43
  manifest = ""
31
44
 
32
- for file in os.listdir(conf):
33
- if(re.match(r'manifest\.[0-9]+\.json', file)):
34
- manifest = file
45
+ if os.path.exists(conf):
46
+ for file in os.listdir(conf):
47
+ if re.match(r'manifest\.[0-9]+\.json', file):
48
+ manifest = file
49
+ break
35
50
 
36
- if(manifest == ""):
37
- if(type == "bizframe"):
38
- os.popen("cp -rf ./tmp/source ./" + name)
39
- elif(type == "subsystem"):
40
- os.popen("cp -rf ./tmp/source ./")
51
+ if not manifest:
52
+ copy_source(deploy_type, name)
41
53
  else:
42
- file = open(os.path.join(conf, manifest), "rb")
43
- fileJson = json.load(file)
54
+ with open(os.path.join(conf, manifest), "rb") as f:
55
+ fileJson = json.load(f)
44
56
 
45
57
  for x in fileJson:
46
- destinationdir = ""
47
- source = ""
48
-
49
- if(type == "bizframe"):
58
+ if deploy_type == "bizframe":
50
59
  destinationdir = "./" + webAppName + "/" + fileJson[x]["dir"]
51
60
  source = "./tmp/source/" + fileJson[x]["path"]
52
- elif(type == "subsystem"):
61
+ elif deploy_type == "subsystem":
53
62
  destinationdir = "./" + fileJson[x]["dir"]
54
63
  source = "./tmp/source/" + fileJson[x]["path"]
64
+ else:
65
+ continue
55
66
 
56
- if not (os.path.exists(destinationdir)):
67
+ if not os.path.exists(destinationdir):
57
68
  os.makedirs(destinationdir)
58
69
 
59
- if(os.path.exists(source)):
60
- os.popen("cp -rf " + source + ' ' + destinationdir)
61
-
62
- os.popen("rm -rf tmp")
70
+ if os.path.exists(source):
71
+ os.system("cp -rf " + source + ' ' + destinationdir)
63
72
 
73
+ os.system("rm -rf tmp")
64
74
 
65
- utils.clear(webAppName, type)
75
+ utils.clear(webAppName, deploy_type)
66
76
 
67
77
  # SEE 在脚本下发的时候会保留 scripts 目录下的内容,造成 conf 中存在多份 manifest
68
- os.popen("rm -rf ./scripts/" + name)
69
- os.popen("cp -rf ./tmp/scripts/" + name + " ./scripts/" + name)
78
+ os.system("rm -rf ./scripts/" + name)
79
+ os.system("cp -rf ./tmp/scripts/" + name + " ./scripts/" + name)
70
80
 
71
- install(name, type)
81
+ install(name, deploy_type)
@@ -8,62 +8,60 @@ import sys
8
8
  import stat
9
9
 
10
10
 
11
- def clear(name, type):
11
+ def clear(name, deploy_type):
12
12
  conf = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "conf")
13
-
14
13
  manifest = ""
15
14
 
16
- for file in os.listdir(conf):
17
- if(re.match(r'manifest\.[0-9]+\.json', file)):
18
- manifest = file
15
+ if os.path.exists(conf):
16
+ for file in os.listdir(conf):
17
+ if re.match(r'manifest\.[0-9]+\.json', file):
18
+ manifest = file
19
+ break
19
20
 
20
- if(manifest == ""):
21
- os.popen("rm -rf ./" + name)
21
+ if not manifest:
22
+ os.system("rm -rf ./" + name)
22
23
  else:
23
- file = open(os.path.join(conf, manifest), "rb")
24
- fileJson = json.load(file)
24
+ with open(os.path.join(conf, manifest), "rb") as f:
25
+ fileJson = json.load(f)
25
26
 
26
27
  dirs = []
27
-
28
- prefix = ""
29
-
30
- if(type == "bizframe"):
31
- prefix = "./" + name + "/"
32
- elif(type == "subsystem"):
33
- prefix = "./"
28
+ prefix = "./" + name + "/" if deploy_type == "bizframe" else "./"
34
29
 
35
30
  for x in fileJson:
36
31
  if fileJson[x]["dir"] not in dirs:
37
32
  dirs.append(fileJson[x]["dir"])
38
33
 
39
- if(os.path.exists(prefix + fileJson[x]["path"])):
40
- os.remove(prefix + fileJson[x]["path"])
34
+ file_path = prefix + fileJson[x]["path"]
35
+ if os.path.exists(file_path):
36
+ os.remove(file_path)
41
37
 
42
38
  for x in dirs:
43
- if(type == "bizframe" and x != "" or type == "subsystem" and x != name):
44
- if(os.path.exists(prefix + x)):
39
+ should_remove = (deploy_type == "bizframe" and x != "") or (deploy_type == "subsystem" and x != name)
40
+ if should_remove:
41
+ dir_path = prefix + x
42
+ if os.path.exists(dir_path):
45
43
  try:
46
- os.removedirs(prefix + x)
44
+ os.removedirs(dir_path)
47
45
  except OSError:
48
46
  pass
49
47
 
50
48
  RD, WD, XD = 4, 2, 1
51
49
  BNS = [RD, WD, XD]
52
50
  MDS = [
53
- [stat.S_IRUSR, stat.S_IRGRP, stat.S_IROTH],
54
- [stat.S_IWUSR, stat.S_IWGRP, stat.S_IWOTH],
55
- [stat.S_IXUSR, stat.S_IXGRP, stat.S_IXOTH]
51
+ [stat.S_IRUSR, stat.S_IRGRP, stat.S_IROTH],
52
+ [stat.S_IWUSR, stat.S_IWGRP, stat.S_IWOTH],
53
+ [stat.S_IXUSR, stat.S_IXGRP, stat.S_IXOTH]
56
54
  ]
57
55
 
58
56
  def chmod(path, mode):
59
- if isinstance(mode, int):
60
- mode = str(mode)
61
- if not re.match("^[0-7]{1,3}$", mode):
62
- raise Exception("mode does not conform to ^[0-7]{1,3}$ pattern")
63
- mode = "{0:0>3}".format(mode)
64
- mode_num = 0
65
- for midx, m in enumerate(mode):
66
- for bnidx, bn in enumerate(BNS):
67
- if (int(m) & bn) > 0:
68
- mode_num += MDS[bnidx][midx]
69
- os.chmod(path, mode_num)
57
+ if isinstance(mode, int):
58
+ mode = str(mode)
59
+ if not re.match("^[0-7]{1,3}$", mode):
60
+ raise Exception("mode does not conform to ^[0-7]{1,3}$ pattern")
61
+ mode = "{0:0>3}".format(mode)
62
+ mode_num = 0
63
+ for midx, m in enumerate(mode):
64
+ for bnidx, bn in enumerate(BNS):
65
+ if (int(m) & bn) > 0:
66
+ mode_num += MDS[bnidx][midx]
67
+ os.chmod(path, mode_num)