@winner-fed/winner-deploy 4.0.0 → 4.0.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/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # winner-deploy
2
2
 
3
3
  ## 功能接口说明
4
+
4
5
  ```javscript
5
6
  /**
6
7
  * 生成 see 平台部署包
@@ -10,6 +11,7 @@
10
11
  * @param options.appType {string} 发布物类型, 默认为 应用名称 - name
11
12
  * @param options.version {string} 发布包版本
12
13
  * @param options.configName {string} 配置文件名称,不带有 .js, 默认为 config.local
14
+ * @param options.outputName {string} 输出的目录名称,默认为 dist
13
15
  * @param options.templateFunc {function} 自定义变量配置文件, 默认为
14
16
  * function () {
15
17
  if (type === 'bizframe') {
@@ -43,7 +45,7 @@
43
45
  * @param options.scriptsType 脚本类型 'python'(默认的) | 'bash'
44
46
  * @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
45
47
  */
46
- export const generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc, copyFiles, description, seePackageType, dockerImage, scriptsType}, cb) {
48
+ export const generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageType, dockerImage, scriptsType}, cb) {
47
49
  ...
48
50
  }
49
51
  ```
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- var pe=Object.create;var I=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty;var de=i=>I(i,"__esModule",{value:!0});var ge=(i,t,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of me(t))!ye.call(i,n)&&n!=="default"&&I(i,n,{get:()=>t[n],enumerable:!(o=fe(t,n))||o.enumerable});return i},m=i=>ge(de(I(i!=null?pe(ue(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var se=m(require("chalk")),ce=m(require("path")),Q=m(require("ora")),h=m(require("fs-extra"));var y=m(require("fs-extra")),V=m(require("rimraf"));var L=m(require("path")),Se=m(require("chalk")),$e=m(require("ora")),O=m(require("fs-extra")),J=m(require("archiver")),M=m(require("xml")),W=process.cwd();var Z=function(t){let o={"&amp;":"&","&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"};return t&&t.replace?t.replace(/(&amp;)|(&quot;)|(&apos;)|(&lt;)|(&gt;)/g,function(n){return o[n]}):t},v=function(t){let o=t||"",n=L.default.resolve(W,"dist",o,"sysconfig.js");return O.default.pathExistsSync(n)},E=function(){let t=L.default.resolve(W,"dist","config.local.js");return O.default.pathExistsSync(t)},_=function(t,o,n){let c="package";O.default.ensureDirSync(c);let r=O.default.createWriteStream(`${c}/${t}.zip`);r.on("close",function(){setTimeout(function(){n&&n()})});let e=(0,J.default)("zip",{zlib:{level:9}});e.on("error",function(l){console.error(),console.error(l.stack||l),l.details&&console.error(l.details)}),e.pipe(r),e.directory(o,!1),e.finalize()},R=function(t,o,n){let{type:c,label:r,name:e,tooltip:l="",visible:a="true",required:s="false",fixed:p="false",fold:f="false",options:d=""}=t,x=t.default;if(n==="form"){let w=(0,M.default)({form:[{_attr:{name:e,tooltip:l,visible:a,required:s,fixed:p,fold:f,options:d}},o]});return exports.unEscapeForXML(w)}let g=(0,M.default)({field:[{_attr:{type:c,label:r,name:e,tooltip:l,visible:a,required:s,fixed:p,fold:f,options:d}},x||o]});return exports.unEscapeForXML(g)},q=function(t){let n=t.children.map(c=>{let e=c.children.map(l=>R(l)).join("");return R(c,e,"form")}).join("");return R(t,n)},K=function i(t,o,n="",c=""){for(let r=0;r<t.length;r++){let e=t[r];if(e.fullName=`${n===""?"":n+"."}${e.name}`,e.fullPath=`${c===""?"":c+"-"}${e.type}`,o(e))return e;if(e.children&&e.children.length>0){let l=i(e.children,o,e.fullName,e.fullPath);if(l)return l}}return null};var k=m(require("fs-extra")),H=m(require("path")),P=m(require("lodash.template")),Y=m(require("xml")),G=m(require("@babel/core"));var he=["input","select","switch","smallfile","table","mselect","switchForm","complexSelect","division"],F=i=>H.default.resolve(__dirname,`../templates/see/${i}`),N=i=>{let t=i.type;if(!he.includes(t))return"";let{label:o,name:n,tooltip:c="",visible:r="true",required:e="false",fixed:l="false",fold:a="false",options:s=""}=i,p=i.default;if(t==="table"){let d=i.keys||[];p=(i.columns||d).map(g=>N(g)).join(`
2
- `)}else if(t==="switchForm"||t==="division")p=i.children.map(x=>N(x)).join(`
3
- `);else{if(t==="complexSelect")return q(i);p=[p]}let f=(0,Y.default)({field:[{_attr:{type:t,label:o,name:n,tooltip:c,visible:r,required:e,fixed:l,fold:a,options:s}},p].concat(p)});return Z(`${f}`)},ee=function({system:t,type:o,name:n,appType:c,version:r,configFileName:e="config.local",variables:l=[],description:a}){let s=k.default.readFileSync(F("python/deploy.xml")).toString();return(0,P.default)(s,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:n,appType:c,version:r,configFileName:e,variables:(()=>l.map(p=>N(p)).join(`
4
- `))(),description:a})},T=function(t,o){let n=k.default.readFileSync(F(`python/scripts/${t}.py`)).toString();return(0,P.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(o)},D=function(t,o=[]){let{code:n}=G.default.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 a=K(o,s=>l===s.name);if(a){if(a.fullPath.includes("complexSelect")&&(a.name=a.fullName),r.isStringLiteral()){r.node.value=`$!{${a.name}}`;return}if(r.isNumericLiteral()){r.node.value=`$!{${a.name}}`;return}if(r.isBooleanLiteral()){if(r.node.type="StringLiteral",a.fullPath.includes("complexSelect")){r.node.value=`$!{${a.fullName}}`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${a.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(r){if(r.parentPath.isProperty()){let e=K(o,l=>r.parentPath.get("key").node.name===l.name);if(e){e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let l="",a=e.keys||[],s=e.columns||a;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}s&&s.length&&s.forEach(f=>{l+=`${f.name}: '$!{row.${f.name}}',`}),r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${l}}, #end][NO_QUOTATION_MARKS]`}}}}}}],retainLines:!0});return n.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},te=function({system:t,type:o,name:n,appType:c,version:r,configFileName:e="config.local",variables:l=[],description:a,web_app_web_service_name:s,dockerImage:p}){let f=k.default.readFileSync(F("docker/deploy.xml")).toString();return(0,P.default)(f,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:n,appType:c,version:r,configFileName:e,variables:(()=>l.map(d=>N(d)).join(`
5
- `))(),description:a,web_app_web_service_name:s,dockerImage:p})},ne=function(t){let o=k.default.readFileSync(F("docker/k8s-deploy-res.yaml")).toString();return(0,P.default)(o,{interpolate:/{{([\s\S]+?)}}/g})(t)},oe=function(t){let o=k.default.readFileSync(F("docker/Dockerfile")).toString();return(0,P.default)(o)(t)},re=function({system:t,type:o,name:n,appType:c,version:r,configFileName:e="config.local",variables:l=[],description:a}){let s=k.default.readFileSync(F("bash/deploy.xml")).toString();return(0,P.default)(s,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:n,appType:c,version:r,configFileName:e,variables:(()=>l.map(p=>N(p)).join(`
6
- `))(),description:a})},X=function(t,o){let n=k.default.readFileSync(F(`bash/scripts/${t}.sh`)).toString();return(0,P.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(o)};var u="tmp",ie=function(t,o,n){let{system:c,type:r,name:e,appType:l,version:a,template:s,variables:p,configName:f,description:d,scriptsType:x}=o;y.default.ensureDirSync(u),y.default.ensureDirSync(`${u}/scripts`),y.default.ensureDirSync(`${u}/template`),E()?y.default.outputFileSync(`./${u}/template/config.local.js`,s?D(s,p):""):v()||v(e)?(f="sysconfig",y.default.outputFileSync(`./${u}/template/sysconfig.js`,s?D(s,p):"")):y.default.outputFileSync(`./${u}/template/${f}.js`,s?D(s,p):""),x==="python"?(y.default.outputFileSync(`./${u}/scripts/${e}/utils.py`,T("utils")),y.default.outputFileSync(`./${u}/scripts/${e}/install.py`,T("install",{name:e,type:r})),y.default.outputFileSync(`./${u}/scripts/${e}/afterInstall.py`,T("afterInstall",{name:e})),y.default.outputFileSync(`./${u}/scripts/${e}/uninstall.py`,T("uninstall",{name:e,type:r})),y.default.outputFileSync(`./${u}/deploy.xml`,ee({system:c,type:r,name:e,appType:l,version:a,configFileName:f,variables:p,description:d}))):(y.default.outputFileSync(`./${u}/scripts/${e}/install.sh`,X("install",{name:e,type:r})),y.default.outputFileSync(`./${u}/scripts/${e}/afterInstall.sh`,X("afterInstall",{name:e})),y.default.outputFileSync(`./${u}/scripts/${e}/uninstall.sh`,X("uninstall",{name:e,type:r})),y.default.outputFileSync(`./${u}/deploy.xml`,re({system:c,type:r,name:e,appType:l,version:a,configFileName:f,variables:p,description:d}))),n?n(g=>{_(t,u,()=>{V.default.sync(u),typeof g=="function"&&g()})}):_(t,u,()=>{V.default.sync(u)})};var z=m(require("path")),S=m(require("fs-extra")),B=m(require("rimraf"));var $="tmp",le=function(t,o,n){let{system:c,type:r,name:e,appType:l,version:a,template:s,variables:p,configName:f,description:d,dockerImage:x=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=o;S.default.ensureDirSync($),S.default.ensureDirSync("docker"),S.default.pathExistsSync(z.default.resolve(process.cwd(),"docker/Dockerfile"))||S.default.outputFileSync(z.default.resolve(process.cwd(),"docker/Dockerfile"),oe({name:e,type:r})),S.default.ensureDirSync(`${$}/scripts`),S.default.ensureDirSync(`${$}/template`),E()?S.default.outputFileSync(`./${$}/template/${e}/config.local.js`,s?D(s,p):""):v()||v(e)?(f="sysconfig",S.default.outputFileSync(`./${$}/template/${e}/sysconfig.js`,s?D(s,p):"")):S.default.outputFileSync(`./${$}/template/${e}/${f}.js`,s?D(s,p):""),S.default.outputFileSync(`./${$}/template/k8s-deploy-res.yaml`,ne({configFileName:f})),S.default.outputFileSync(`./${$}/deploy.xml`,te({system:c,type:r,name:e,appType:l,version:a,configFileName:f,variables:p,description:d,web_app_web_service_name:`${e}-web`,dockerImage:x})),n?n(g=>{_(t,$,()=>{B.default.sync($),typeof g=="function"&&g()})}):_(t,$,()=>{B.default.sync($)})};var xe=process.cwd();function ke(i,t){let o="",n;return i==="bizframe"&&(o=h.default.readdirSync("./dist").find(c=>/manifest\.[0-9]+\.json/.test(c)),n=h.default.readJsonSync(`./dist/${o}`)),i==="subsystem"&&(o=h.default.readdirSync(`./dist/${t}`).find(c=>/manifest\.[0-9]+\.json/.test(c)),n=h.default.readJsonSync(`./dist/${t}/${o}`)),{manifest:o,manifestJson:n}}exports.generateSeePackageZip=function({system:t,type:o,name:n,appType:c,version:r,configName:e,templateFunc:l,variablesFunc:a,copyFiles:s,description:p,seePackageName:f,seePackageType:d="web",dockerImage:x,scriptsType:g="python"},w){if(!n||!r)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(t=t||"winner-front",o=o||"bizframe",c=c||n,a=a||function(){if(o==="bizframe")try{let{variables:b}=require(ce.default.resolve(xe,"build","package","./variables.js"));return b||[]}catch(b){return console.error(b),[]}},l=l||function(){if(o==="bizframe")return"./dist/config.local.js"},d==="docker"){le(f||`${t}-${n}-${r}`,{system:t,type:o,name:n,appType:c,version:r,configName:e,template:l(),variables:a(),description:p,dockerImage:x},b=>{console.log(),(0,Q.default)("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").succeed(),b(w)});return}ie(f||`${t}-${n}-${r}`,{system:t,type:o,name:n,appType:c,version:r,configName:e,template:l(),variables:a(),description:p,scriptsType:g},b=>{if(g==="python"){let{manifest:j,manifestJson:A}=ke(o,n);for(let U in A)if(A.hasOwnProperty(U)){let{path:C,dir:ae}=A[U];h.default.ensureDirSync(`./tmp/source/${ae}`),h.default.copyFileSync(`./dist/${C}`,`./tmp/source/${C}`)}h.default.outputJSONSync(`./tmp/scripts/${n}/conf/${j}`,A)}else h.default.ensureDirSync("./tmp/source"),h.default.copySync("./dist","./tmp/source");Array.isArray(s)&&s.length&&s.forEach(j=>{h.default.ensureFileSync(`./tmp/source/${n}/${j}`),h.default.copyFileSync(`./dist/${n}/${j}`,`./tmp/source/${n}/${j}`)}),console.log(),(0,Q.default)(`\u53D1\u5E03\u7269\u5236\u4F5C\u5B8C\u6210\uFF0C\u60A8\u53EF\u4EE5\u5728 SEE \u5E73\u53F0\u4E0A\u4F20\u5E76\u90E8\u7F72\u5E94\u7528\u3002\u6CE8\u610F\uFF1A${se.default.yellow("\u5B50\u7CFB\u7EDF\u53D1\u5E03\u7269\u7684\u5B89\u88C5\u76EE\u5F55\u9700\u8981\u6307\u5B9A\u5230\u5177\u4F53\u7684\u5E94\u7528\u76EE\u5F55")}\u3002\u6BD4\u5982/home/hsiar/hsiar-green/html/\u3002
7
- `).succeed(),b(w)})};
1
+ var me=Object.create;var w=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var q=i=>w(i,"__esModule",{value:!0});var Se=(i,t)=>{q(i);for(var o in t)w(i,o,{get:t[o],enumerable:!0})},$e=(i,t,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ye(t))!de.call(i,r)&&r!=="default"&&w(i,r,{get:()=>t[r],enumerable:!(o=ue(t,r))||o.enumerable});return i},y=i=>$e(q(w(i!=null?me(ge(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);Se(exports,{generateSeePackageZip:()=>ke});var ae=y(require("chalk")),pe=y(require("path")),z=y(require("ora")),h=y(require("fs-extra"));var g=y(require("fs-extra")),Q=y(require("rimraf"));var X=y(require("path")),D=y(require("fs-extra")),W=y(require("archiver")),K=y(require("xml")),Z=process.cwd(),H=function(t){let o={"&amp;":"&","&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"};return t&&t.replace?t.replace(/(&amp;)|(&quot;)|(&apos;)|(&lt;)|(&gt;)/g,function(r){return o[r]}):t},v=function(t,o){let r=o||"",a=X.default.resolve(Z,t,r,"sysconfig.js");return D.default.pathExistsSync(a)},E=function(t){let o=X.default.resolve(Z,t,"config.local.js");return D.default.pathExistsSync(o)},F=function(t,o,r){let a="package";D.default.ensureDirSync(a);let n=D.default.createWriteStream(`${a}/${t}.zip`);n.on("close",function(){setTimeout(function(){r&&r()})});let e=(0,W.default)("zip",{zlib:{level:9}});e.on("error",function(l){console.error(),console.error(l.stack||l),l.details&&console.error(l.details)}),e.pipe(n),e.directory(o,!1),e.finalize()},L=function(t,o,r){let{type:a,label:n,name:e,tooltip:l="",visible:s="true",required:c="false",fixed:p="false",fold:f="false",options:m=""}=t,d=t.default;if(r==="form"){let x=(0,K.default)({form:[{_attr:{name:e,tooltip:l,visible:s,required:c,fixed:p,fold:f,options:m}},o]});return exports.unEscapeForXML(x)}let O=(0,K.default)({field:[{_attr:{type:a,label:n,name:e,tooltip:l,visible:s,required:c,fixed:p,fold:f,options:m}},d||o]});return exports.unEscapeForXML(O)},Y=function(t){let r=t.children.map(a=>{let e=a.children.map(l=>L(l)).join("");return L(a,e,"form")}).join("");return L(t,r)},M=function i(t,o,r="",a=""){for(let n=0;n<t.length;n++){let e=t[n];if(e.fullName=`${r===""?"":r+"."}${e.name}`,e.fullPath=`${a===""?"":a+"-"}${e.type}`,o(e))return e;if(e.children&&e.children.length>0){let l=i(e.children,o,e.fullName,e.fullPath);if(l)return l}}return null};var k=y(require("fs-extra")),G=y(require("path")),b=y(require("lodash.template")),ee=y(require("xml")),te=y(require("@babel/core"));var he=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division"],P=i=>G.default.resolve(__dirname,`../templates/see/${i}`),N=i=>{let t=i.type;if(!he.includes(t))return"";let{label:o,name:r,tooltip:a="",visible:n="true",required:e="false",fixed:l="false",fold:s="false",options:c=""}=i,p=i.default;if(t==="table"){let m=i.keys||[];p=(i.columns||m).map(O=>N(O)).join(`
2
+ `)}else if(t==="switchForm"||t==="division")p=i.children.map(d=>N(d)).join(`
3
+ `);else{if(t==="complexSelect")return Y(i);t==="editor"?p=[JSON.stringify(p)]:p=[p]}let f=(0,ee.default)({field:[{_attr:{type:t,label:o,name:r,tooltip:a,visible:n,required:e,fixed:l,fold:s,options:c}},p].concat(p)});return H(`${f}`)},ne=function({system:t,type:o,name:r,appType:a,version:n,configFileName:e="config.local",variables:l=[],description:s}){let c=k.default.readFileSync(P("python/deploy.xml")).toString();return(0,b.default)(c,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:r,appType:a,version:n,configFileName:e,variables:(()=>l.map(p=>N(p)).join(`
4
+ `))(),description:s})},j=function(t,o){let r=k.default.readFileSync(P(`python/scripts/${t}.py`)).toString();return(0,b.default)(r,{interpolate:/{{([\s\S]+?)}}/g})(o)},T=function(t,o=[]){let{code:r}=te.default.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(n){if(n.parentPath.isProperty()){let e=n.parentPath.get("key").node,l=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,l=e.value);let s=M(o,c=>l===c.name);if(s){if(s.fullPath.includes("complexSelect")&&(s.name=s.fullName),n.isObjectExpression()){n.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}if(n.isNumericLiteral()){n.node.value=`$!{${s.name}}`;return}if(n.isBooleanLiteral()){if(n.node.type="StringLiteral",s.fullPath.includes("complexSelect")){n.node.value=`$!{${s.fullName}}`;return}n.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`}if(n.isObjectExpression()){n.node.value=`$!{${s.name}}`;return}}}},ArrayExpression(n){if(n.parentPath.isProperty()){let e=M(o,l=>n.parentPath.get("key").node.name===l.name);if(e){e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let l="",s=e.keys||[],c=e.columns||s;if(e.options){l=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,n.node.type="StringLiteral",n.node.value=l;return}c&&c.length&&c.forEach(f=>{l+=`${f.name}: '$!{row.${f.name}}',`}),n.node.type="StringLiteral",n.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${l}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(n){if(n.parentPath.isProperty()){let e=n.parentPath.get("key").node,l=e.name;if(e){let s=M(o,c=>l===c.name);if(s){if(n.node.type="StringLiteral",s.fullPath.includes("editor")){n.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}n.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return r.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},re=function({system:t,type:o,name:r,appType:a,version:n,configFileName:e="config.local",variables:l=[],description:s,web_app_web_service_name:c,dockerImage:p}){let f=k.default.readFileSync(P("docker/deploy.xml")).toString();return(0,b.default)(f,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:r,appType:a,version:n,configFileName:e,variables:(()=>l.map(m=>N(m)).join(`
5
+ `))(),description:s,web_app_web_service_name:c,dockerImage:p})},oe=function(t){let o=k.default.readFileSync(P("docker/k8s-deploy-res.yaml")).toString();return(0,b.default)(o,{interpolate:/{{([\s\S]+?)}}/g})(t)},ie=function(t){let o=k.default.readFileSync(P("docker/Dockerfile")).toString();return(0,b.default)(o)(t)},le=function({system:t,type:o,name:r,appType:a,version:n,configFileName:e="config.local",variables:l=[],description:s}){let c=k.default.readFileSync(P("bash/deploy.xml")).toString();return(0,b.default)(c,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:r,appType:a,version:n,configFileName:e,variables:(()=>l.map(p=>N(p)).join(`
6
+ `))(),description:s})},R=function(t,o){let r=k.default.readFileSync(P(`bash/scripts/${t}.sh`)).toString();return(0,b.default)(r,{interpolate:/{{([\s\S]+?)}}/g})(o)};var u="tmp",se=function(t,o,r){let{system:a,type:n,name:e,appType:l,version:s,template:c,variables:p,configName:f,outputName:m,description:d,scriptsType:O}=o;g.default.ensureDirSync(u),g.default.ensureDirSync(`${u}/scripts`),g.default.ensureDirSync(`${u}/template`),E(m)?g.default.outputFileSync(`./${u}/template/config.local.js`,c?T(c,p):""):v(m)||v(m,e)?(f="sysconfig",g.default.outputFileSync(`./${u}/template/sysconfig.js`,c?T(c,p):"")):f&&g.default.outputFileSync(`./${u}/template/${f}.js`,c?T(c,p):""),O==="python"?(g.default.outputFileSync(`./${u}/scripts/${e}/utils.py`,j("utils")),g.default.outputFileSync(`./${u}/scripts/${e}/install.py`,j("install",{name:e,type:n})),g.default.outputFileSync(`./${u}/scripts/${e}/afterInstall.py`,j("afterInstall",{name:e})),g.default.outputFileSync(`./${u}/scripts/${e}/uninstall.py`,j("uninstall",{name:e,type:n})),g.default.outputFileSync(`./${u}/deploy.xml`,ne({system:a,type:n,name:e,appType:l,version:s,configFileName:f,variables:p,description:d}))):(g.default.outputFileSync(`./${u}/scripts/${e}/install.sh`,R("install",{name:e,type:n})),g.default.outputFileSync(`./${u}/scripts/${e}/afterInstall.sh`,R("afterInstall",{name:e})),g.default.outputFileSync(`./${u}/scripts/${e}/uninstall.sh`,R("uninstall",{name:e,type:n})),g.default.outputFileSync(`./${u}/deploy.xml`,le({system:a,type:n,name:e,appType:l,version:s,configFileName:f,variables:p,description:d}))),r?r(x=>{F(t,u,()=>{Q.default.sync(u),typeof x=="function"&&x()})}):F(t,u,()=>{Q.default.sync(u)})};var U=y(require("path")),S=y(require("fs-extra")),V=y(require("rimraf"));var $="tmp",ce=function(t,o,r){let{system:a,type:n,name:e,appType:l,version:s,template:c,variables:p,configName:f,outputName:m,description:d,dockerImage:O=s.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=o;S.default.ensureDirSync($),S.default.ensureDirSync("docker"),S.default.pathExistsSync(U.default.resolve(process.cwd(),"docker/Dockerfile"))||S.default.outputFileSync(U.default.resolve(process.cwd(),"docker/Dockerfile"),ie({name:e,type:n})),S.default.ensureDirSync(`${$}/scripts`),S.default.ensureDirSync(`${$}/template`),E(m)?S.default.outputFileSync(`./${$}/template/${e}/config.local.js`,c?T(c,p):""):v(m)||v(m,e)?(f="sysconfig",S.default.outputFileSync(`./${$}/template/${e}/sysconfig.js`,c?T(c,p):"")):f&&S.default.outputFileSync(`./${$}/template/${e}/${f}.js`,c?T(c,p):""),S.default.outputFileSync(`./${$}/template/k8s-deploy-res.yaml`,oe({configFileName:f})),S.default.outputFileSync(`./${$}/deploy.xml`,re({system:a,type:n,name:e,appType:l,version:s,configFileName:f,variables:p,description:d,web_app_web_service_name:`${e}-web`,dockerImage:O})),r?r(x=>{F(t,$,()=>{V.default.sync($),typeof x=="function"&&x()})}):F(t,$,()=>{V.default.sync($)})};var xe=process.cwd();function Oe(i,t,o){let r="",a;if(i==="bizframe"){r=h.default.readdirSync(`./${o}`).find(n=>/manifest\.[0-9]+\.json/.test(n));try{a=h.default.readJsonSync(`./${o}/${r}`)}catch(n){process.exit(0)}}return i==="subsystem"&&(r=h.default.readdirSync(`./${o}/${t}`).find(n=>/manifest\.[0-9]+\.json/.test(n)),a=h.default.readJsonSync(`./${o}/${t}/${r}`)),{manifest:r,manifestJson:a}}var ke=function({system:t="winner-front",type:o="bizframe",name:r,appType:a,version:n,configName:e="config.local",outputName:l="dist",templateFunc:s,variablesFunc:c,copyFiles:p,description:f,seePackageName:m,seePackageType:d="web",dockerImage:O,scriptsType:x="python"},J){if(!r||!n)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(r=r.replace(/@/gi,"").replace(/\//gi,"-"),typeof m=="string"&&m&&(m=m.replace(/@/gi,"").replace(/\//gi,"-")),a=a||r,c=c||function(){try{let{variables:_}=require(pe.default.resolve(xe,"build","package","./variables.js"));return _||[]}catch(_){return console.error(_),[]}},s=s||function(){return o==="bizframe"?`./${l}/config.local.js`:`./${l}/${r}/sysconfig.js`},d==="docker"){ce(m||`${t}-${r}-${n}`,{system:t,type:o,name:r,appType:a,version:n,configName:e,outputName:l,template:s(),variables:c(),description:f,dockerImage:O},_=>{console.log(),(0,z.default)("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").succeed(),_(J)});return}se(m||`${t}-${r}-${n}`,{system:t,type:o,name:r,appType:a,version:n,configName:e,outputName:l,template:s(),variables:c(),description:f,scriptsType:x},_=>{if(x==="python"){let{manifest:A,manifestJson:I}=Oe(o,r,l);for(let B in I)if(I.hasOwnProperty(B)){let{path:C,dir:fe}=I[B];h.default.ensureDirSync(`./tmp/source/${fe}`),h.default.copyFileSync(`./${l}/${C}`,`./tmp/source/${C}`)}h.default.outputJSONSync(`./tmp/scripts/${r}/conf/${A}`,I)}else h.default.ensureDirSync("./tmp/source"),h.default.copySync(`./${l}`,"./tmp/source");Array.isArray(p)&&p.length&&p.forEach(A=>{h.default.ensureFileSync(`./tmp/source/${r}/${A}`),h.default.copyFileSync(`./${l}/${r}/${A}`,`./tmp/source/${r}/${A}`)}),console.log(),(0,z.default)(`\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${ae.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
+ `).succeed(),_(J)})};0&&(module.exports={generateSeePackageZip});
@@ -0,0 +1,130 @@
1
+ declare type variablesType = 'input' | 'select' | 'switch' | 'smallfile' | 'table' | 'mselect' | 'switchForm' | 'complexSelect' | 'division';
2
+ interface variables {
3
+ type: variablesType;
4
+ label: string;
5
+ name: string;
6
+ options: string;
7
+ required: boolean;
8
+ fold: boolean;
9
+ children: Array<variables>;
10
+ tooltip: string;
11
+ default: string;
12
+ }
13
+ interface deployOptions {
14
+ /**
15
+ * 系统类型, SEE 平台的分组是以系统类型字段纬度来的
16
+ * @default winner-front
17
+ */
18
+ system: string;
19
+ /**
20
+ * 应用类型, 外框架 - bizframe | 子系统 - subsystem
21
+ * @default bizframe
22
+ */
23
+ type: 'bizframe' | 'subsystem';
24
+ /**
25
+ * 发布物名称。当包含 scope 时,如字符 @、/ 。会做自动的转换。如@winner-fed/winner-deploy 转换为 winner-fed-winner-deploy
26
+ * @default package.json -> name
27
+ */
28
+ name: string;
29
+ /**
30
+ * 发布包版本
31
+ * @default package.json -> version
32
+ */
33
+ version: string;
34
+ /**
35
+ * 发布包的描述说明
36
+ * @default package.json -> description
37
+ */
38
+ description: string;
39
+ /**
40
+ * 发布物类型, 默认为 应用名称
41
+ * @default name
42
+ */
43
+ appType?: string;
44
+ /**
45
+ * 配置文件名称,不带有 .js。当强制为空时,可以理解成,是构建静态资源的 see 包,不包含 index.html,config.local.js 文件等,此时 scriptsType 只能使用 bash
46
+ * @default config.local
47
+ */
48
+ configName?: string;
49
+ /**
50
+ * 输出的目录名称
51
+ * @default dist
52
+ */
53
+ outputName?: string;
54
+ /**
55
+ * 自定义变量配置文件
56
+ */
57
+ templateFunc?: () => string | undefined;
58
+ /**
59
+ * deploy.xml模板变量, 可以动态配置
60
+ */
61
+ variablesFunc?: () => Array<variables> | undefined;
62
+ /**
63
+ * 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
64
+ */
65
+ copyFiles?: string[];
66
+ /**
67
+ * see发布物的包名,也就是 zip 包的命名
68
+ * @default `${system}-${name}-${version}`
69
+ */
70
+ seePackageName?: string;
71
+ /**
72
+ * see平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
73
+ * @default web
74
+ */
75
+ seePackageType?: 'web' | 'docker';
76
+ /**
77
+ * docker 容器化镜像名,seePackageType 为 docker 时生效
78
+ */
79
+ dockerImage?: string;
80
+ /**
81
+ * 脚本类型
82
+ * @default python
83
+ */
84
+ scriptsType?: 'python' | 'bash';
85
+ }
86
+ /**
87
+ * 生成 see 平台部署包
88
+ * @param system {string} 系统类型, SEE 平台的分组是以系统类型字段纬度来的, 默认为 winner-front
89
+ * @param type {string} 应用类型, 外框架 - bizframe | 子系统 - subsystem, 默认为 主系统 - bizframe
90
+ * @param name {string} 发布物名称。当包含 scope 时,如字符 @、/ 。会做自动的转换。如@winner-fed/winner-deploy 转换为 winner-fed-winner-deploy
91
+ * @param appType {string} 发布物类型, 默认为 应用名称 - name
92
+ * @param version {string} 发布包版本
93
+ * @param configName {string} 配置文件名称,不带有 .js, 默认为 config.local
94
+ * @param outputName {string} 输出的目录名称,默认为 dist
95
+ * @param templateFunc {function} 自定义变量配置文件, 默认为
96
+ * function () {
97
+ if (type === 'bizframe') {
98
+ return `./dist/config.local.js`;
99
+ }
100
+ }
101
+ * @param variablesFunc {function} deploy.xml模板变量, 可以动态配置, 默认为
102
+ * function () {
103
+ * const context = process.cwd()
104
+ if (type === 'bizframe') {
105
+ try {
106
+ const {variables} = require(path.resolve(
107
+ context,
108
+ 'build',
109
+ 'package',
110
+ `./variables.js`
111
+ ));
112
+
113
+ return variables || [];
114
+ } catch (error) {
115
+ console.error(error);
116
+ return [];
117
+ }
118
+ }
119
+ }
120
+ * @param copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
121
+ * @param description {string} 发布包说明
122
+ * @param seePackageName {string} see发布物的包名,也就是 zip 包的命名,默认为 `${system}-${name}-${version}`
123
+ * @param seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
124
+ * @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
125
+ * @param scriptsType 脚本类型 'python' | 'bash'
126
+ * @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
127
+ */
128
+ declare const generateSeePackageZip: ({ system, type, name, appType, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackageType, dockerImage, scriptsType }: deployOptions, cb: () => void) => void;
129
+
130
+ export { deployOptions, generateSeePackageZip, variables, variablesType };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var R=(l=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(l,{get:(t,n)=>(typeof require!="undefined"?require:t)[n]}):l)(function(l){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+l+'" is not supported')});import ce from"chalk";import ae from"path";import te from"ora";import h from"fs-extra";import u from"fs-extra";import q from"rimraf";import K from"path";import de from"chalk";import Se from"ora";import w from"fs-extra";import oe from"archiver";import V from"xml";var z=process.cwd();var B=function(t){let n={"&amp;":"&","&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"};return t&&t.replace?t.replace(/(&amp;)|(&quot;)|(&apos;)|(&lt;)|(&gt;)/g,function(r){return n[r]}):t},F=function(t){let n=t||"",r=K.resolve(z,"dist",n,"sysconfig.js");return w.pathExistsSync(r)},A=function(){let t=K.resolve(z,"dist","config.local.js");return w.pathExistsSync(t)},v=function(t,n,r){let c="package";w.ensureDirSync(c);let o=w.createWriteStream(`${c}/${t}.zip`);o.on("close",function(){setTimeout(function(){r&&r()})});let e=oe("zip",{zlib:{level:9}});e.on("error",function(i){console.error(),console.error(i.stack||i),i.details&&console.error(i.details)}),e.pipe(o),e.directory(n,!1),e.finalize()},X=function(t,n,r){let{type:c,label:o,name:e,tooltip:i="",visible:a="true",required:s="false",fixed:p="false",fold:f="false",options:y=""}=t,S=t.default;if(r==="form"){let N=V({form:[{_attr:{name:e,tooltip:i,visible:a,required:s,fixed:p,fold:f,options:y}},n]});return exports.unEscapeForXML(N)}let d=V({field:[{_attr:{type:c,label:o,name:e,tooltip:i,visible:a,required:s,fixed:p,fold:f,options:y}},S||n]});return exports.unEscapeForXML(d)},Q=function(t){let r=t.children.map(c=>{let e=c.children.map(i=>X(i)).join("");return X(c,e,"form")}).join("");return X(t,r)},I=function l(t,n,r="",c=""){for(let o=0;o<t.length;o++){let e=t[o];if(e.fullName=`${r===""?"":r+"."}${e.name}`,e.fullPath=`${c===""?"":c+"-"}${e.type}`,n(e))return e;if(e.children&&e.children.length>0){let i=l(e.children,n,e.fullName,e.fullPath);if(i)return i}}return null};import P from"fs-extra";import re from"path";import D from"lodash.template";import ie from"xml";import le from"@babel/core";var se=["input","select","switch","smallfile","table","mselect","switchForm","complexSelect","division"],b=l=>re.resolve(__dirname,`../templates/see/${l}`),j=l=>{let t=l.type;if(!se.includes(t))return"";let{label:n,name:r,tooltip:c="",visible:o="true",required:e="false",fixed:i="false",fold:a="false",options:s=""}=l,p=l.default;if(t==="table"){let y=l.keys||[];p=(l.columns||y).map(d=>j(d)).join(`
2
- `)}else if(t==="switchForm"||t==="division")p=l.children.map(S=>j(S)).join(`
3
- `);else{if(t==="complexSelect")return Q(l);p=[p]}let f=ie({field:[{_attr:{type:t,label:n,name:r,tooltip:c,visible:o,required:e,fixed:i,fold:a,options:s}},p].concat(p)});return B(`${f}`)},U=function({system:t,type:n,name:r,appType:c,version:o,configFileName:e="config.local",variables:i=[],description:a}){let s=P.readFileSync(b("python/deploy.xml")).toString();return D(s,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:r,appType:c,version:o,configFileName:e,variables:(()=>i.map(p=>j(p)).join(`
4
- `))(),description:a})},O=function(t,n){let r=P.readFileSync(b(`python/scripts/${t}.py`)).toString();return D(r,{interpolate:/{{([\s\S]+?)}}/g})(n)},x=function(t,n=[]){let{code:r}=le.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(o){if(o.parentPath.isProperty()){let e=o.parentPath.get("key").node,i=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,i=e.value);let a=I(n,s=>i===s.name);if(a){if(a.fullPath.includes("complexSelect")&&(a.name=a.fullName),o.isStringLiteral()){o.node.value=`$!{${a.name}}`;return}if(o.isNumericLiteral()){o.node.value=`$!{${a.name}}`;return}if(o.isBooleanLiteral()){if(o.node.type="StringLiteral",a.fullPath.includes("complexSelect")){o.node.value=`$!{${a.fullName}}`;return}o.node.value=`[NO_QUOTATION_MARKS]\${${a.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(o){if(o.parentPath.isProperty()){let e=I(n,i=>o.parentPath.get("key").node.name===i.name);if(e){e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let i="",a=e.keys||[],s=e.columns||a;if(e.options){i=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,o.node.type="StringLiteral",o.node.value=i;return}s&&s.length&&s.forEach(f=>{i+=`${f.name}: '$!{row.${f.name}}',`}),o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${i}}, #end][NO_QUOTATION_MARKS]`}}}}}}],retainLines:!0});return r.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},C=function({system:t,type:n,name:r,appType:c,version:o,configFileName:e="config.local",variables:i=[],description:a,web_app_web_service_name:s,dockerImage:p}){let f=P.readFileSync(b("docker/deploy.xml")).toString();return D(f,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:r,appType:c,version:o,configFileName:e,variables:(()=>i.map(y=>j(y)).join(`
5
- `))(),description:a,web_app_web_service_name:s,dockerImage:p})},J=function(t){let n=P.readFileSync(b("docker/k8s-deploy-res.yaml")).toString();return D(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},W=function(t){let n=P.readFileSync(b("docker/Dockerfile")).toString();return D(n)(t)},Z=function({system:t,type:n,name:r,appType:c,version:o,configFileName:e="config.local",variables:i=[],description:a}){let s=P.readFileSync(b("bash/deploy.xml")).toString();return D(s,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:r,appType:c,version:o,configFileName:e,variables:(()=>i.map(p=>j(p)).join(`
6
- `))(),description:a})},E=function(t,n){let r=P.readFileSync(b(`bash/scripts/${t}.sh`)).toString();return D(r,{interpolate:/{{([\s\S]+?)}}/g})(n)};var m="tmp",H=function(t,n,r){let{system:c,type:o,name:e,appType:i,version:a,template:s,variables:p,configName:f,description:y,scriptsType:S}=n;u.ensureDirSync(m),u.ensureDirSync(`${m}/scripts`),u.ensureDirSync(`${m}/template`),A()?u.outputFileSync(`./${m}/template/config.local.js`,s?x(s,p):""):F()||F(e)?(f="sysconfig",u.outputFileSync(`./${m}/template/sysconfig.js`,s?x(s,p):"")):u.outputFileSync(`./${m}/template/${f}.js`,s?x(s,p):""),S==="python"?(u.outputFileSync(`./${m}/scripts/${e}/utils.py`,O("utils")),u.outputFileSync(`./${m}/scripts/${e}/install.py`,O("install",{name:e,type:o})),u.outputFileSync(`./${m}/scripts/${e}/afterInstall.py`,O("afterInstall",{name:e})),u.outputFileSync(`./${m}/scripts/${e}/uninstall.py`,O("uninstall",{name:e,type:o})),u.outputFileSync(`./${m}/deploy.xml`,U({system:c,type:o,name:e,appType:i,version:a,configFileName:f,variables:p,description:y}))):(u.outputFileSync(`./${m}/scripts/${e}/install.sh`,E("install",{name:e,type:o})),u.outputFileSync(`./${m}/scripts/${e}/afterInstall.sh`,E("afterInstall",{name:e})),u.outputFileSync(`./${m}/scripts/${e}/uninstall.sh`,E("uninstall",{name:e,type:o})),u.outputFileSync(`./${m}/deploy.xml`,Z({system:c,type:o,name:e,appType:i,version:a,configFileName:f,variables:p,description:y}))),r?r(d=>{v(t,m,()=>{q.sync(m),typeof d=="function"&&d()})}):v(t,m,()=>{q.sync(m)})};import Y from"path";import $ from"fs-extra";import G from"rimraf";var g="tmp",ee=function(t,n,r){let{system:c,type:o,name:e,appType:i,version:a,template:s,variables:p,configName:f,description:y,dockerImage:S=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;$.ensureDirSync(g),$.ensureDirSync("docker"),$.pathExistsSync(Y.resolve(process.cwd(),"docker/Dockerfile"))||$.outputFileSync(Y.resolve(process.cwd(),"docker/Dockerfile"),W({name:e,type:o})),$.ensureDirSync(`${g}/scripts`),$.ensureDirSync(`${g}/template`),A()?$.outputFileSync(`./${g}/template/${e}/config.local.js`,s?x(s,p):""):F()||F(e)?(f="sysconfig",$.outputFileSync(`./${g}/template/${e}/sysconfig.js`,s?x(s,p):"")):$.outputFileSync(`./${g}/template/${e}/${f}.js`,s?x(s,p):""),$.outputFileSync(`./${g}/template/k8s-deploy-res.yaml`,J({configFileName:f})),$.outputFileSync(`./${g}/deploy.xml`,C({system:c,type:o,name:e,appType:i,version:a,configFileName:f,variables:p,description:y,web_app_web_service_name:`${e}-web`,dockerImage:S})),r?r(d=>{v(t,g,()=>{G.sync(g),typeof d=="function"&&d()})}):v(t,g,()=>{G.sync(g)})};var pe=process.cwd();function fe(l,t){let n="",r;return l==="bizframe"&&(n=h.readdirSync("./dist").find(c=>/manifest\.[0-9]+\.json/.test(c)),r=h.readJsonSync(`./dist/${n}`)),l==="subsystem"&&(n=h.readdirSync(`./dist/${t}`).find(c=>/manifest\.[0-9]+\.json/.test(c)),r=h.readJsonSync(`./dist/${t}/${n}`)),{manifest:n,manifestJson:r}}exports.generateSeePackageZip=function({system:t,type:n,name:r,appType:c,version:o,configName:e,templateFunc:i,variablesFunc:a,copyFiles:s,description:p,seePackageName:f,seePackageType:y="web",dockerImage:S,scriptsType:d="python"},N){if(!r||!o)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(t=t||"winner-front",n=n||"bizframe",c=c||r,a=a||function(){if(n==="bizframe")try{let{variables:k}=R(ae.resolve(pe,"build","package","./variables.js"));return k||[]}catch(k){return console.error(k),[]}},i=i||function(){if(n==="bizframe")return"./dist/config.local.js"},y==="docker"){ee(f||`${t}-${r}-${o}`,{system:t,type:n,name:r,appType:c,version:o,configName:e,template:i(),variables:a(),description:p,dockerImage:S},k=>{console.log(),te("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").succeed(),k(N)});return}H(f||`${t}-${r}-${o}`,{system:t,type:n,name:r,appType:c,version:o,configName:e,template:i(),variables:a(),description:p,scriptsType:d},k=>{if(d==="python"){let{manifest:_,manifestJson:T}=fe(n,r);for(let L in T)if(T.hasOwnProperty(L)){let{path:M,dir:ne}=T[L];h.ensureDirSync(`./tmp/source/${ne}`),h.copyFileSync(`./dist/${M}`,`./tmp/source/${M}`)}h.outputJSONSync(`./tmp/scripts/${r}/conf/${_}`,T)}else h.ensureDirSync("./tmp/source"),h.copySync("./dist","./tmp/source");Array.isArray(s)&&s.length&&s.forEach(_=>{h.ensureFileSync(`./tmp/source/${r}/${_}`),h.copyFileSync(`./dist/${r}/${_}`,`./tmp/source/${r}/${_}`)}),console.log(),te(`\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${ce.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
- `).succeed(),k(N)})};
1
+ var L=(c=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(c,{get:(n,o)=>(typeof require!="undefined"?require:n)[o]}):c)(function(c){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+c+'" is not supported')});import ae from"chalk";import pe from"path";import ne from"ora";import $ from"fs-extra";import y from"fs-extra";import H from"rimraf";import Q from"path";import j from"fs-extra";import oe from"archiver";import U from"xml";var V=process.cwd(),z=function(n){let o={"&amp;":"&","&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"};return n&&n.replace?n.replace(/(&amp;)|(&quot;)|(&apos;)|(&lt;)|(&gt;)/g,function(r){return o[r]}):n},P=function(n,o){let r=o||"",a=Q.resolve(V,n,r,"sysconfig.js");return j.pathExistsSync(a)},I=function(n){let o=Q.resolve(V,n,"config.local.js");return j.pathExistsSync(o)},v=function(n,o,r){let a="package";j.ensureDirSync(a);let t=j.createWriteStream(`${a}/${n}.zip`);t.on("close",function(){setTimeout(function(){r&&r()})});let e=oe("zip",{zlib:{level:9}});e.on("error",function(i){console.error(),console.error(i.stack||i),i.details&&console.error(i.details)}),e.pipe(t),e.directory(o,!1),e.finalize()},M=function(n,o,r){let{type:a,label:t,name:e,tooltip:i="",visible:l="true",required:s="false",fixed:p="false",fold:f="false",options:m=""}=n,g=n.default;if(r==="form"){let h=U({form:[{_attr:{name:e,tooltip:i,visible:l,required:s,fixed:p,fold:f,options:m}},o]});return exports.unEscapeForXML(h)}let x=U({field:[{_attr:{type:a,label:t,name:e,tooltip:i,visible:l,required:s,fixed:p,fold:f,options:m}},g||o]});return exports.unEscapeForXML(x)},J=function(n){let r=n.children.map(a=>{let e=a.children.map(i=>M(i)).join("");return M(a,e,"form")}).join("");return M(n,r)},w=function c(n,o,r="",a=""){for(let t=0;t<n.length;t++){let e=n[t];if(e.fullName=`${r===""?"":r+"."}${e.name}`,e.fullPath=`${a===""?"":a+"-"}${e.type}`,o(e))return e;if(e.children&&e.children.length>0){let i=c(e.children,o,e.fullName,e.fullPath);if(i)return i}}return null};import b from"fs-extra";import ie from"path";import T from"lodash.template";import le from"xml";import se from"@babel/core";var ce=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division"],_=c=>ie.resolve(__dirname,`../templates/see/${c}`),A=c=>{let n=c.type;if(!ce.includes(n))return"";let{label:o,name:r,tooltip:a="",visible:t="true",required:e="false",fixed:i="false",fold:l="false",options:s=""}=c,p=c.default;if(n==="table"){let m=c.keys||[];p=(c.columns||m).map(x=>A(x)).join(`
2
+ `)}else if(n==="switchForm"||n==="division")p=c.children.map(g=>A(g)).join(`
3
+ `);else{if(n==="complexSelect")return J(c);n==="editor"?p=[JSON.stringify(p)]:p=[p]}let f=le({field:[{_attr:{type:n,label:o,name:r,tooltip:a,visible:t,required:e,fixed:i,fold:l,options:s}},p].concat(p)});return z(`${f}`)},B=function({system:n,type:o,name:r,appType:a,version:t,configFileName:e="config.local",variables:i=[],description:l}){let s=b.readFileSync(_("python/deploy.xml")).toString();return T(s,{interpolate:/{{([\s\S]+?)}}/g})({system:n,type:o,name:r,appType:a,version:t,configFileName:e,variables:(()=>i.map(p=>A(p)).join(`
4
+ `))(),description:l})},D=function(n,o){let r=b.readFileSync(_(`python/scripts/${n}.py`)).toString();return T(r,{interpolate:/{{([\s\S]+?)}}/g})(o)},O=function(n,o=[]){let{code:r}=se.transformFileSync(n,{babelrc:!1,plugins:[function(){return{visitor:{Literal(t){if(t.parentPath.isProperty()){let e=t.parentPath.get("key").node,i=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,i=e.value);let l=w(o,s=>i===s.name);if(l){if(l.fullPath.includes("complexSelect")&&(l.name=l.fullName),t.isObjectExpression()){t.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`;return}if(t.isNumericLiteral()){t.node.value=`$!{${l.name}}`;return}if(t.isBooleanLiteral()){if(t.node.type="StringLiteral",l.fullPath.includes("complexSelect")){t.node.value=`$!{${l.fullName}}`;return}t.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`}if(t.isObjectExpression()){t.node.value=`$!{${l.name}}`;return}}}},ArrayExpression(t){if(t.parentPath.isProperty()){let e=w(o,i=>t.parentPath.get("key").node.name===i.name);if(e){e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let i="",l=e.keys||[],s=e.columns||l;if(e.options){i=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,t.node.type="StringLiteral",t.node.value=i;return}s&&s.length&&s.forEach(f=>{i+=`${f.name}: '$!{row.${f.name}}',`}),t.node.type="StringLiteral",t.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${i}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(t){if(t.parentPath.isProperty()){let e=t.parentPath.get("key").node,i=e.name;if(e){let l=w(o,s=>i===s.name);if(l){if(t.node.type="StringLiteral",l.fullPath.includes("editor")){t.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`;return}t.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return r.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},C=function({system:n,type:o,name:r,appType:a,version:t,configFileName:e="config.local",variables:i=[],description:l,web_app_web_service_name:s,dockerImage:p}){let f=b.readFileSync(_("docker/deploy.xml")).toString();return T(f,{interpolate:/{{([\s\S]+?)}}/g})({system:n,type:o,name:r,appType:a,version:t,configFileName:e,variables:(()=>i.map(m=>A(m)).join(`
5
+ `))(),description:l,web_app_web_service_name:s,dockerImage:p})},q=function(n){let o=b.readFileSync(_("docker/k8s-deploy-res.yaml")).toString();return T(o,{interpolate:/{{([\s\S]+?)}}/g})(n)},W=function(n){let o=b.readFileSync(_("docker/Dockerfile")).toString();return T(o)(n)},Z=function({system:n,type:o,name:r,appType:a,version:t,configFileName:e="config.local",variables:i=[],description:l}){let s=b.readFileSync(_("bash/deploy.xml")).toString();return T(s,{interpolate:/{{([\s\S]+?)}}/g})({system:n,type:o,name:r,appType:a,version:t,configFileName:e,variables:(()=>i.map(p=>A(p)).join(`
6
+ `))(),description:l})},E=function(n,o){let r=b.readFileSync(_(`bash/scripts/${n}.sh`)).toString();return T(r,{interpolate:/{{([\s\S]+?)}}/g})(o)};var u="tmp",Y=function(n,o,r){let{system:a,type:t,name:e,appType:i,version:l,template:s,variables:p,configName:f,outputName:m,description:g,scriptsType:x}=o;y.ensureDirSync(u),y.ensureDirSync(`${u}/scripts`),y.ensureDirSync(`${u}/template`),I(m)?y.outputFileSync(`./${u}/template/config.local.js`,s?O(s,p):""):P(m)||P(m,e)?(f="sysconfig",y.outputFileSync(`./${u}/template/sysconfig.js`,s?O(s,p):"")):f&&y.outputFileSync(`./${u}/template/${f}.js`,s?O(s,p):""),x==="python"?(y.outputFileSync(`./${u}/scripts/${e}/utils.py`,D("utils")),y.outputFileSync(`./${u}/scripts/${e}/install.py`,D("install",{name:e,type:t})),y.outputFileSync(`./${u}/scripts/${e}/afterInstall.py`,D("afterInstall",{name:e})),y.outputFileSync(`./${u}/scripts/${e}/uninstall.py`,D("uninstall",{name:e,type:t})),y.outputFileSync(`./${u}/deploy.xml`,B({system:a,type:t,name:e,appType:i,version:l,configFileName:f,variables:p,description:g}))):(y.outputFileSync(`./${u}/scripts/${e}/install.sh`,E("install",{name:e,type:t})),y.outputFileSync(`./${u}/scripts/${e}/afterInstall.sh`,E("afterInstall",{name:e})),y.outputFileSync(`./${u}/scripts/${e}/uninstall.sh`,E("uninstall",{name:e,type:t})),y.outputFileSync(`./${u}/deploy.xml`,Z({system:a,type:t,name:e,appType:i,version:l,configFileName:f,variables:p,description:g}))),r?r(h=>{v(n,u,()=>{H.sync(u),typeof h=="function"&&h()})}):v(n,u,()=>{H.sync(u)})};import G from"path";import S from"fs-extra";import ee from"rimraf";var d="tmp",te=function(n,o,r){let{system:a,type:t,name:e,appType:i,version:l,template:s,variables:p,configName:f,outputName:m,description:g,dockerImage:x=l.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=o;S.ensureDirSync(d),S.ensureDirSync("docker"),S.pathExistsSync(G.resolve(process.cwd(),"docker/Dockerfile"))||S.outputFileSync(G.resolve(process.cwd(),"docker/Dockerfile"),W({name:e,type:t})),S.ensureDirSync(`${d}/scripts`),S.ensureDirSync(`${d}/template`),I(m)?S.outputFileSync(`./${d}/template/${e}/config.local.js`,s?O(s,p):""):P(m)||P(m,e)?(f="sysconfig",S.outputFileSync(`./${d}/template/${e}/sysconfig.js`,s?O(s,p):"")):f&&S.outputFileSync(`./${d}/template/${e}/${f}.js`,s?O(s,p):""),S.outputFileSync(`./${d}/template/k8s-deploy-res.yaml`,q({configFileName:f})),S.outputFileSync(`./${d}/deploy.xml`,C({system:a,type:t,name:e,appType:i,version:l,configFileName:f,variables:p,description:g,web_app_web_service_name:`${e}-web`,dockerImage:x})),r?r(h=>{v(n,d,()=>{ee.sync(d),typeof h=="function"&&h()})}):v(n,d,()=>{ee.sync(d)})};var fe=process.cwd();function me(c,n,o){let r="",a;if(c==="bizframe"){r=$.readdirSync(`./${o}`).find(t=>/manifest\.[0-9]+\.json/.test(t));try{a=$.readJsonSync(`./${o}/${r}`)}catch(t){process.exit(0)}}return c==="subsystem"&&(r=$.readdirSync(`./${o}/${n}`).find(t=>/manifest\.[0-9]+\.json/.test(t)),a=$.readJsonSync(`./${o}/${n}/${r}`)),{manifest:r,manifestJson:a}}var Ve=function({system:n="winner-front",type:o="bizframe",name:r,appType:a,version:t,configName:e="config.local",outputName:i="dist",templateFunc:l,variablesFunc:s,copyFiles:p,description:f,seePackageName:m,seePackageType:g="web",dockerImage:x,scriptsType:h="python"},R){if(!r||!t)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(r=r.replace(/@/gi,"").replace(/\//gi,"-"),typeof m=="string"&&m&&(m=m.replace(/@/gi,"").replace(/\//gi,"-")),a=a||r,s=s||function(){try{let{variables:k}=L(pe.resolve(fe,"build","package","./variables.js"));return k||[]}catch(k){return console.error(k),[]}},l=l||function(){return o==="bizframe"?`./${i}/config.local.js`:`./${i}/${r}/sysconfig.js`},g==="docker"){te(m||`${n}-${r}-${t}`,{system:n,type:o,name:r,appType:a,version:t,configName:e,outputName:i,template:l(),variables:s(),description:f,dockerImage:x},k=>{console.log(),ne("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").succeed(),k(R)});return}Y(m||`${n}-${r}-${t}`,{system:n,type:o,name:r,appType:a,version:t,configName:e,outputName:i,template:l(),variables:s(),description:f,scriptsType:h},k=>{if(h==="python"){let{manifest:F,manifestJson:N}=me(o,r,i);for(let X in N)if(N.hasOwnProperty(X)){let{path:K,dir:re}=N[X];$.ensureDirSync(`./tmp/source/${re}`),$.copyFileSync(`./${i}/${K}`,`./tmp/source/${K}`)}$.outputJSONSync(`./tmp/scripts/${r}/conf/${F}`,N)}else $.ensureDirSync("./tmp/source"),$.copySync(`./${i}`,"./tmp/source");Array.isArray(p)&&p.length&&p.forEach(F=>{$.ensureFileSync(`./tmp/source/${r}/${F}`),$.copyFileSync(`./${i}/${r}/${F}`,`./tmp/source/${r}/${F}`)}),console.log(),ne(`\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${ae.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
+ `).succeed(),k(R)})};export{Ve as generateSeePackageZip};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winner-fed/winner-deploy",
3
- "version": "4.0.0",
3
+ "version": "4.0.6",
4
4
  "description": "Generate a publication deployed by the See platform",
5
5
  "keywords": [
6
6
  "winner",
@@ -34,37 +34,30 @@
34
34
  "dist",
35
35
  "templates"
36
36
  ],
37
+ "scripts": {
38
+ "prepublishOnly": "npm run build",
39
+ "dev": "tsup --watch",
40
+ "build": "tsup",
41
+ "typecheck": "tsc --noEmit"
42
+ },
37
43
  "dependencies": {
38
44
  "@babel/core": "^7.12.3",
39
45
  "archiver": "^3.1.1",
40
46
  "chalk": "^4.0.0",
41
- "fs-extra": "^8.1.0",
47
+ "fs-extra": "^10.1.0",
42
48
  "lodash.template": "^4.5.0",
43
49
  "ora": "^4.0.4",
44
50
  "rimraf": "^3.0.2",
45
51
  "xml": "^1.0.1"
46
52
  },
47
53
  "devDependencies": {
48
- "@antfu/ni": "^0.7.0",
49
54
  "@types/fs-extra": "^9.0.13",
50
55
  "@types/lodash.template": "^4.5.1",
51
56
  "@types/node": "^16.10.1",
52
- "bumpp": "^7.1.1",
53
- "esno": "^0.9.1",
54
- "pnpm": "^7.0.0",
55
- "tsup": "^4.14.0",
56
- "typescript": "^4.6.4"
57
+ "tsup": "^4.14.0"
57
58
  },
58
59
  "publishConfig": {
59
60
  "access": "public",
60
61
  "registry": "https://registry.npmjs.org/"
61
- },
62
- "scripts": {
63
- "dev": "nr build --watch",
64
- "start": "esno src/index.ts",
65
- "build": "tsup",
66
- "release": "bumpp --commit --push --tag && pnpm publish",
67
- "typecheck": "tsc --noEmit"
68
- },
69
- "readme": "# winner-deploy\n\n## 功能接口说明\n```javscript\n/**\n * 生成 see 平台部署包\n * @param options.system {string} 系统类型, SEE 平台的分组是以系统类型字段纬度来的, 默认为 winner-front\n * @param options.type {string} 应用类型, 外框架 - bizframe | 子系统 - subsystem, 默认为 子系统 - subsystem\n * @param options.name {string} 发布物名称\n * @param options.appType {string} 发布物类型, 默认为 应用名称 - name\n * @param options.version {string} 发布包版本\n * @param options.configName {string} 配置文件名称,不带有 .js, 默认为 config.local\n * @param options.templateFunc {function} 自定义变量配置文件, 默认为\n * function () {\n if (type === 'bizframe') {\n return `./dist/config.local.js`;\n }\n }\n * @param options.variablesFunc {function} deploy.xml模板变量, 可以动态配置, 默认为\n * function () {\n * const context = process.cwd()\n if (type === 'bizframe') {\n try {\n const {variables} = require(path.resolve(\n context,\n 'build',\n 'package',\n `./variables.js`\n ));\n\n return variables || [];\n } catch (error) {\n console.error(error);\n return [];\n }\n }\n }\n * @param options.copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']\n * @param options.description {string} 发布包说明\n * @param options.seePackageName {string} see发布物的包名,也就是 zip 包的命名,默认为 `${system}-${name}-${version}`\n * @param options.seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)\n * @param options.dockerImage docker 容器化镜像名,seePackageType 为 docker 生效\n * @param options.scriptsType 脚本类型 'python'(默认的) | 'bash'\n * @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作\n */\nexport const generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc, copyFiles, description, seePackageType, dockerImage, scriptsType}, cb) {\n...\n}\n```\n"
70
- }
62
+ }
63
+ }
@@ -36,7 +36,9 @@
36
36
  <% } %>
37
37
  {{ variables }}
38
38
  </variables>
39
+ <% if (configFileName) { %>
39
40
  <config path="./${webAppName}/{{ configFileName }}.js" encoding="UTF-8"/>
41
+ <% } %>
40
42
  <config path="./scripts/{{ name }}/install.sh" encoding="UTF-8"/>
41
43
  <config path="./scripts/{{ name }}/afterInstall.sh" encoding="UTF-8"/>
42
44
  <config path="./scripts/{{ name }}/uninstall.sh" encoding="UTF-8"/>
@@ -39,7 +39,9 @@
39
39
  {{ variables }}
40
40
 
41
41
  </variables>
42
+ <% if (configFileName) { %>
42
43
  <config path="./{{ name }}/{{ configFileName }}.js" encoding="UTF-8"/>
44
+ <% } %>
43
45
  <config reference="" encoding="utf-8" path="./k8s-deploy-res.yaml" />
44
46
  <node describe="节点私有配置信息" />
45
47
  </system>
@@ -7,9 +7,9 @@ metadata:
7
7
  name: ${svc_id}-service
8
8
  spec:
9
9
  ports:
10
- - name: "http"
11
- port: 80
12
- targetPort: 80
10
+ - name: 'http'
11
+ port: 80
12
+ targetPort: 80
13
13
  selector:
14
14
  name: ${svc_id}
15
15
  ---
@@ -29,10 +29,10 @@ spec:
29
29
  name: ${svc_id}
30
30
  spec:
31
31
  imagePullPolicy: ${image_pull_policy}
32
- #if(${image_pull_secrets_enable} == "true")
32
+ #if(${image_pull_secrets_enable} == "true")
33
33
  imagePullSecrets:
34
- - name: ${image_pull_secrets}
35
- #end
34
+ - name: ${image_pull_secrets}
35
+ #end
36
36
  restartPolicy: ${restart_policy}
37
37
  hostname: ${web_app_web_service_name}
38
38
  containers:
@@ -43,7 +43,7 @@ spec:
43
43
  value: Asia/Shanghai
44
44
  ports:
45
45
  - containerPort: 80
46
- #if(${resources_enable} == "true")
46
+ #if(${resources_enable} == "true")
47
47
  resources:
48
48
  requests:
49
49
  cpu: ${cpu_req}
@@ -51,8 +51,8 @@ spec:
51
51
  limits:
52
52
  cpu: ${cpu_limit}
53
53
  memory: ${memory_limit}
54
- #end
55
- #if(${liveness_probe_enable} == "true")
54
+ #end
55
+ #if(${liveness_probe_enable} == "true")
56
56
  livenessProbe:
57
57
  httpGet:
58
58
  scheme: HTTP
@@ -37,7 +37,9 @@
37
37
  {{ variables }}
38
38
 
39
39
  </variables>
40
+ <% if (configFileName) { %>
40
41
  <config path="./${webAppName}/{{ configFileName }}.js" encoding="UTF-8"/>
42
+ <% } %>
41
43
  <config path="./scripts/{{ name }}/install.py" encoding="UTF-8"/>
42
44
  <config path="./scripts/{{ name }}/afterInstall.py" encoding="UTF-8"/>
43
45
  <config path="./scripts/{{ name }}/uninstall.py" encoding="UTF-8"/>
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 winner-fed
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.