@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 +7 -7
- package/dist/index.js +7 -7
- package/package.json +1 -1
- package/templates/see/python/deploy.xml +1 -1
- package/templates/see/python/scripts/beforeInstall.sh +85 -0
- package/templates/see/python/scripts/install.py +43 -33
- package/templates/see/python/scripts/utils.py +33 -35
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** build time:
|
|
2
|
-
var $e=Object.create;var
|
|
3
|
-
`)}else if(e==="switchForm"||e==="division"){let
|
|
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}:{},
|
|
5
|
-
`),description:
|
|
6
|
-
`),description:
|
|
7
|
-
`),
|
|
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={""":'"',"'":"'","<":"<",">":">"},i=/(")|(')|(<)|(>)/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:
|
|
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
|
|
3
|
-
`)}else if(t==="switchForm"||t==="division"){let
|
|
4
|
-
`):""}else{if(t==="complexSelect")return G(i);t==="editor"?y=typeof y=="object"?[JSON.stringify(y)]:[y]:y=[y]}let
|
|
5
|
-
`),description:
|
|
6
|
-
`),description:
|
|
7
|
-
`),b(
|
|
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={""":'"',"'":"'","<":"<",">":">"},o=/(")|(')|(<)|(>)/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
|
@@ -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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
31
|
+
deploy_type = "{{type}}"
|
|
24
32
|
# 读取 deploy.xml 配置文件定义的 webAppName
|
|
25
33
|
webAppName = "${webAppName}"
|
|
26
34
|
|
|
27
|
-
def
|
|
28
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
manifest
|
|
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
|
|
37
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
67
|
+
if not os.path.exists(destinationdir):
|
|
57
68
|
os.makedirs(destinationdir)
|
|
58
69
|
|
|
59
|
-
if
|
|
60
|
-
os.
|
|
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,
|
|
75
|
+
utils.clear(webAppName, deploy_type)
|
|
66
76
|
|
|
67
77
|
# SEE 在脚本下发的时候会保留 scripts 目录下的内容,造成 conf 中存在多份 manifest
|
|
68
|
-
os.
|
|
69
|
-
os.
|
|
78
|
+
os.system("rm -rf ./scripts/" + name)
|
|
79
|
+
os.system("cp -rf ./tmp/scripts/" + name + " ./scripts/" + name)
|
|
70
80
|
|
|
71
|
-
install(name,
|
|
81
|
+
install(name, deploy_type)
|
|
@@ -8,62 +8,60 @@ import sys
|
|
|
8
8
|
import stat
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def clear(name,
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
manifest
|
|
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
|
|
21
|
-
os.
|
|
21
|
+
if not manifest:
|
|
22
|
+
os.system("rm -rf ./" + name)
|
|
22
23
|
else:
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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(
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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)
|