@winner-fed/winner-deploy 4.0.6 → 4.1.0
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 +2 -1
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +8 -2
- package/dist/index.js +7 -7
- package/package.json +1 -1
- package/templates/see/bash/deploy.xml +1 -1
- package/templates/see/docker/deploy.xml +1 -1
- package/templates/see/python/deploy.xml +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @param options.name {string} 发布物名称
|
|
11
11
|
* @param options.appType {string} 发布物类型, 默认为 应用名称 - name
|
|
12
12
|
* @param options.version {string} 发布包版本
|
|
13
|
+
* @param options.group {string} 应用分组,默认为 bizframe
|
|
13
14
|
* @param options.configName {string} 配置文件名称,不带有 .js, 默认为 config.local
|
|
14
15
|
* @param options.outputName {string} 输出的目录名称,默认为 dist
|
|
15
16
|
* @param options.templateFunc {function} 自定义变量配置文件, 默认为
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
* @param options.scriptsType 脚本类型 'python'(默认的) | 'bash'
|
|
46
47
|
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
|
|
47
48
|
*/
|
|
48
|
-
export const generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageType, dockerImage, scriptsType}, cb) {
|
|
49
|
+
export const generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, group, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageType, dockerImage, scriptsType}, cb) {
|
|
49
50
|
...
|
|
50
51
|
}
|
|
51
52
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}else if(t==="switchForm"||t==="division")
|
|
3
|
-
`);else{if(t==="complexSelect")return
|
|
4
|
-
`))(),description:
|
|
5
|
-
`))(),description:
|
|
6
|
-
`))(),description:
|
|
7
|
-
`).succeed(),
|
|
1
|
+
var ue=Object.create;var E=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var de=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var W=i=>E(i,"__esModule",{value:!0});var $e=(i,t)=>{W(i);for(var o in t)E(i,o,{get:t[o],enumerable:!0})},he=(i,t,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ge(t))!Se.call(i,n)&&n!=="default"&&E(i,n,{get:()=>t[n],enumerable:!(o=ye(t,n))||o.enumerable});return i},g=i=>he(W(E(i!=null?ue(de(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);$e(exports,{generateSeePackageZip:()=>Oe});var pe=g(require("chalk")),fe=g(require("path")),J=g(require("ora")),h=g(require("fs-extra"));var d=g(require("fs-extra")),U=g(require("rimraf"));var R=g(require("path")),j=g(require("fs-extra")),Z=g(require("archiver")),K=g(require("xml")),H=process.cwd(),Y=function(t){let o={"&":"&",""":'"',"'":"'","<":"<",">":">"};return t&&t.replace?t.replace(/(&)|(")|(')|(<)|(>)/g,function(n){return o[n]}):t},_=function(t,o){let n=o||"",a=R.default.resolve(H,t,n,"sysconfig.js");return j.default.pathExistsSync(a)},M=function(t){let o=R.default.resolve(H,t,"config.local.js");return j.default.pathExistsSync(o)},D=function(t,o,n){let a="package";j.default.ensureDirSync(a);let r=j.default.createWriteStream(`${a}/${t}.zip`);r.on("close",function(){setTimeout(function(){n&&n()})});let e=(0,Z.default)("zip",{zlib:{level:9}});e.on("error",function(s){console.error(),console.error(s.stack||s),s.details&&console.error(s.details)}),e.pipe(r),e.directory(o,!1),e.finalize()},Q=function(t,o,n){let{type:a,label:r,name:e,tooltip:s="",visible:l="true",required:p="false",fixed:c="false",fold:f="false",options:m=""}=t,u=t.default;if(n==="form"){let v=(0,K.default)({form:[{_attr:{name:e,tooltip:s,visible:l,required:p,fixed:c,fold:f,options:m}},o]});return exports.unEscapeForXML(v)}let x=(0,K.default)({field:[{_attr:{type:a,label:r,name:e,tooltip:s,visible:l,required:p,fixed:c,fold:f,options:m}},u||o]});return exports.unEscapeForXML(x)},G=function(t){let n=t.children.map(a=>{let e=a.children.map(s=>Q(s)).join("");return Q(a,e,"form")}).join("");return Q(t,n)},X=function i(t,o,n="",a=""){for(let r=0;r<t.length;r++){let e=t[r];if(e.fullName=`${n===""?"":n+"."}${e.name}`,e.fullPath=`${a===""?"":a+"-"}${e.type}`,o(e))return e;if(e.children&&e.children.length>0){let s=i(e.children,o,e.fullName,e.fullPath);if(s)return s}}return null};var b=g(require("fs-extra")),ee=g(require("path")),O=g(require("lodash.template")),te=g(require("xml")),ne=g(require("@babel/core"));var xe=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division"],T=i=>ee.default.resolve(__dirname,`../templates/see/${i}`),N=i=>{let t=i.type;if(!xe.includes(t))return"";let{label:o,name:n,tooltip:a="",visible:r="true",required:e="false",fixed:s="false",fold:l="false",options:p=""}=i,c=i.default;if(t==="table"){let m=i.keys||[];c=(i.columns||m).map(x=>N(x)).join(`
|
|
2
|
+
`)}else if(t==="switchForm"||t==="division")c=i.children.map(u=>N(u)).join(`
|
|
3
|
+
`);else{if(t==="complexSelect")return G(i);t==="editor"?c=[JSON.stringify(c)]:c=[c]}let f=(0,te.default)({field:[{_attr:{type:t,label:o,name:n,tooltip:a,visible:r,required:e,fixed:s,fold:l,options:p}},c].concat(c)});return Y(`${f}`)},re=function({system:t,type:o,name:n,appType:a,group:r,version:e,configFileName:s="config.local",variables:l=[],description:p}){let c=b.default.readFileSync(T("python/deploy.xml")).toString();return(0,O.default)(c,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:n,appType:a,group:r,version:e,configFileName:s,variables:(()=>l.map(f=>N(f)).join(`
|
|
4
|
+
`))(),description:p})},w=function(t,o){let n=b.default.readFileSync(T(`python/scripts/${t}.py`)).toString();return(0,O.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(o)},P=function(t,o=[]){let{code:n}=ne.default.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(r){if(r.parentPath.isProperty()){let e=r.parentPath.get("key").node,s=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,s=e.value);let l=X(o,p=>s===p.name);if(l){if(l.fullPath.includes("complexSelect")&&(l.name=l.fullName),r.isStringLiteral()){r.node.value=`$!{${l.name}}`;return}if(r.isNumericLiteral()){r.node.value=`$!{${l.name}}`;return}if(r.isBooleanLiteral()){if(r.node.type="StringLiteral",l.fullPath.includes("complexSelect")){r.node.value=`$!{${l.fullName}}`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(r){if(r.parentPath.isProperty()){let e=X(o,s=>r.parentPath.get("key").node.name===s.name);if(e){e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let s="",l=e.keys||[],p=e.columns||l;if(e.options){s=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,r.node.type="StringLiteral",r.node.value=s;return}p&&p.length&&p.forEach(f=>{s+=`${f.name}: '$!{row.${f.name}}',`}),r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${s}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(r){if(r.parentPath.isProperty()){let e=r.parentPath.get("key").node,s=e.name;if(e){let l=X(o,p=>s===p.name);if(l){if(r.node.type="StringLiteral",l.fullPath.includes("editor")){r.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return n.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},oe=function({system:t,type:o,name:n,appType:a,version:r,group:e,configFileName:s="config.local",variables:l=[],description:p,web_app_web_service_name:c,dockerImage:f}){let m=b.default.readFileSync(T("docker/deploy.xml")).toString();return(0,O.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:n,appType:a,version:r,group:e,configFileName:s,variables:(()=>l.map(u=>N(u)).join(`
|
|
5
|
+
`))(),description:p,web_app_web_service_name:c,dockerImage:f})},ie=function(t){let o=b.default.readFileSync(T("docker/k8s-deploy-res.yaml")).toString();return(0,O.default)(o,{interpolate:/{{([\s\S]+?)}}/g})(t)},le=function(t){let o=b.default.readFileSync(T("docker/Dockerfile")).toString();return(0,O.default)(o)(t)},se=function({system:t,type:o,name:n,appType:a,version:r,group:e,configFileName:s="config.local",variables:l=[],description:p}){let c=b.default.readFileSync(T("bash/deploy.xml")).toString();return(0,O.default)(c,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:n,appType:a,version:r,group:e,configFileName:s,variables:(()=>l.map(f=>N(f)).join(`
|
|
6
|
+
`))(),description:p})},L=function(t,o){let n=b.default.readFileSync(T(`bash/scripts/${t}.sh`)).toString();return(0,O.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(o)};var y="tmp",ce=function(t,o,n){let{system:a,type:r,name:e,appType:s,group:l,version:p,template:c,variables:f,configName:m,outputName:u,description:x,scriptsType:v}=o;d.default.ensureDirSync(y),d.default.ensureDirSync(`${y}/scripts`),d.default.ensureDirSync(`${y}/template`),M(u)?d.default.outputFileSync(`./${y}/template/config.local.js`,c?P(c,f):""):_(u)||_(u,e)?(m="sysconfig",d.default.outputFileSync(`./${y}/template/sysconfig.js`,c?P(c,f):"")):m&&d.default.outputFileSync(`./${y}/template/${m}.js`,c?P(c,f):""),v==="python"?(d.default.outputFileSync(`./${y}/scripts/${e}/utils.py`,w("utils")),d.default.outputFileSync(`./${y}/scripts/${e}/install.py`,w("install",{name:e,type:r})),d.default.outputFileSync(`./${y}/scripts/${e}/afterInstall.py`,w("afterInstall",{name:e})),d.default.outputFileSync(`./${y}/scripts/${e}/uninstall.py`,w("uninstall",{name:e,type:r})),d.default.outputFileSync(`./${y}/deploy.xml`,re({system:a,type:r,name:e,appType:s,group:l,version:p,configFileName:m,variables:f,description:x}))):(d.default.outputFileSync(`./${y}/scripts/${e}/install.sh`,L("install",{name:e,type:r})),d.default.outputFileSync(`./${y}/scripts/${e}/afterInstall.sh`,L("afterInstall",{name:e})),d.default.outputFileSync(`./${y}/scripts/${e}/uninstall.sh`,L("uninstall",{name:e,type:r})),d.default.outputFileSync(`./${y}/deploy.xml`,se({system:a,type:r,name:e,appType:s,version:p,group:l,configFileName:m,variables:f,description:x}))),n?n(k=>{D(t,y,()=>{U.default.sync(y),typeof k=="function"&&k()})}):D(t,y,()=>{U.default.sync(y)})};var V=g(require("path")),S=g(require("fs-extra")),z=g(require("rimraf"));var $="tmp",ae=function(t,o,n){let{system:a,type:r,name:e,appType:s,version:l,group:p,template:c,variables:f,configName:m,outputName:u,description:x,dockerImage:v=l.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(V.default.resolve(process.cwd(),"docker/Dockerfile"))||S.default.outputFileSync(V.default.resolve(process.cwd(),"docker/Dockerfile"),le({name:e,type:r})),S.default.ensureDirSync(`${$}/scripts`),S.default.ensureDirSync(`${$}/template`),M(u)?S.default.outputFileSync(`./${$}/template/${e}/config.local.js`,c?P(c,f):""):_(u)||_(u,e)?(m="sysconfig",S.default.outputFileSync(`./${$}/template/${e}/sysconfig.js`,c?P(c,f):"")):m&&S.default.outputFileSync(`./${$}/template/${e}/${m}.js`,c?P(c,f):""),S.default.outputFileSync(`./${$}/template/k8s-deploy-res.yaml`,ie({configFileName:m})),S.default.outputFileSync(`./${$}/deploy.xml`,oe({system:a,type:r,name:e,appType:s,version:l,group:p,configFileName:m,variables:f,description:x,web_app_web_service_name:`${e}-web`,dockerImage:v})),n?n(k=>{D(t,$,()=>{z.default.sync($),typeof k=="function"&&k()})}):D(t,$,()=>{z.default.sync($)})};var ke=process.cwd();function be(i,t,o){let n="",a;if(i==="bizframe"){n=h.default.readdirSync(`./${o}`).find(r=>/manifest\.[0-9]+\.json/.test(r));try{a=h.default.readJsonSync(`./${o}/${n}`)}catch(r){process.exit(0)}}return i==="subsystem"&&(n=h.default.readdirSync(`./${o}/${t}`).find(r=>/manifest\.[0-9]+\.json/.test(r)),a=h.default.readJsonSync(`./${o}/${t}/${n}`)),{manifest:n,manifestJson:a}}var Oe=function({system:t="winner-front",type:o="bizframe",name:n,appType:a,group:r="bizframe",version:e,configName:s="config.local",outputName:l="dist",templateFunc:p,variablesFunc:c,copyFiles:f,description:m,seePackageName:u,seePackageType:x="web",dockerImage:v,scriptsType:k="python"},B){if(!n||!e)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(n=n.replace(/@/gi,"").replace(/\//gi,"-"),typeof u=="string"&&u&&(u=u.replace(/@/gi,"").replace(/\//gi,"-")),a=a||n,c=c||function(){try{let{variables:F}=require(fe.default.resolve(ke,"build","package","./variables.js"));return F||[]}catch(F){return console.error(F),[]}},p=p||function(){return o==="bizframe"?`./${l}/config.local.js`:`./${l}/${n}/sysconfig.js`},x==="docker"){ae(u||`${t}-${n}-${e}`,{system:t,type:o,name:n,appType:a,group:r,version:e,configName:s,outputName:l,template:p(),variables:c(),description:m,dockerImage:v},F=>{console.log(),(0,J.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(),F(B)});return}ce(u||`${t}-${n}-${e}`,{system:t,type:o,name:n,group:r,appType:a,version:e,configName:s,outputName:l,template:p(),variables:c(),description:m,scriptsType:k},F=>{if(k==="python"){let{manifest:A,manifestJson:I}=be(o,n,l);for(let C in I)if(I.hasOwnProperty(C)){let{path:q,dir:me}=I[C];h.default.ensureDirSync(`./tmp/source/${me}`),h.default.copyFileSync(`./${l}/${q}`,`./tmp/source/${q}`)}h.default.outputJSONSync(`./tmp/scripts/${n}/conf/${A}`,I)}else h.default.ensureDirSync("./tmp/source"),h.default.copySync(`./${l}`,"./tmp/source");Array.isArray(f)&&f.length&&f.forEach(A=>{h.default.ensureFileSync(`./tmp/source/${n}/${A}`),h.default.copyFileSync(`./${l}/${n}/${A}`,`./tmp/source/${n}/${A}`)}),console.log(),(0,J.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${pe.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(),F(B)})};0&&(module.exports={generateSeePackageZip});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type variablesType = 'input' | 'select' | 'switch' | 'smallfile' | 'table' | 'mselect' | 'switchForm' | 'complexSelect' | 'division';
|
|
1
|
+
declare type variablesType = 'input' | 'select' | 'editor' | 'switch' | 'smallfile' | 'table' | 'mselect' | 'switchForm' | 'complexSelect' | 'division';
|
|
2
2
|
interface variables {
|
|
3
3
|
type: variablesType;
|
|
4
4
|
label: string;
|
|
@@ -41,6 +41,11 @@ interface deployOptions {
|
|
|
41
41
|
* @default name
|
|
42
42
|
*/
|
|
43
43
|
appType?: string;
|
|
44
|
+
/**
|
|
45
|
+
* 应用分组, 默认为 bizframe
|
|
46
|
+
* @default 'bizframe'
|
|
47
|
+
*/
|
|
48
|
+
group?: string;
|
|
44
49
|
/**
|
|
45
50
|
* 配置文件名称,不带有 .js。当强制为空时,可以理解成,是构建静态资源的 see 包,不包含 index.html,config.local.js 文件等,此时 scriptsType 只能使用 bash
|
|
46
51
|
* @default config.local
|
|
@@ -89,6 +94,7 @@ interface deployOptions {
|
|
|
89
94
|
* @param type {string} 应用类型, 外框架 - bizframe | 子系统 - subsystem, 默认为 主系统 - bizframe
|
|
90
95
|
* @param name {string} 发布物名称。当包含 scope 时,如字符 @、/ 。会做自动的转换。如@winner-fed/winner-deploy 转换为 winner-fed-winner-deploy
|
|
91
96
|
* @param appType {string} 发布物类型, 默认为 应用名称 - name
|
|
97
|
+
* @param group {string} 应用分组, 默认为 bizframe
|
|
92
98
|
* @param version {string} 发布包版本
|
|
93
99
|
* @param configName {string} 配置文件名称,不带有 .js, 默认为 config.local
|
|
94
100
|
* @param outputName {string} 输出的目录名称,默认为 dist
|
|
@@ -125,6 +131,6 @@ interface deployOptions {
|
|
|
125
131
|
* @param scriptsType 脚本类型 'python' | 'bash'
|
|
126
132
|
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
|
|
127
133
|
*/
|
|
128
|
-
declare const generateSeePackageZip: ({ system, type, name, appType, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackageType, dockerImage, scriptsType }: deployOptions, cb: () => void) => void;
|
|
134
|
+
declare const generateSeePackageZip: ({ system, type, name, appType, group, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackageType, dockerImage, scriptsType }: deployOptions, cb: () => void) => void;
|
|
129
135
|
|
|
130
136
|
export { deployOptions, generateSeePackageZip, variables, variablesType };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}else if(
|
|
3
|
-
`);else{if(
|
|
4
|
-
`))(),description:
|
|
5
|
-
`))(),description:
|
|
6
|
-
`))(),description:
|
|
7
|
-
`).succeed(),
|
|
1
|
+
var Q=(c=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(c,{get:(t,o)=>(typeof require!="undefined"?require:t)[o]}):c)(function(c){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+c+'" is not supported')});import pe from"chalk";import fe from"path";import re from"ora";import $ from"fs-extra";import g from"fs-extra";import Y from"rimraf";import U from"path";import w from"fs-extra";import ie from"archiver";import V from"xml";var z=process.cwd(),J=function(t){let o={"&":"&",""":'"',"'":"'","<":"<",">":">"};return t&&t.replace?t.replace(/(&)|(")|(')|(<)|(>)/g,function(r){return o[r]}):t},T=function(t,o){let r=o||"",a=U.resolve(z,t,r,"sysconfig.js");return w.pathExistsSync(a)},I=function(t){let o=U.resolve(z,t,"config.local.js");return w.pathExistsSync(o)},_=function(t,o,r){let a="package";w.ensureDirSync(a);let n=w.createWriteStream(`${a}/${t}.zip`);n.on("close",function(){setTimeout(function(){r&&r()})});let e=ie("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()},X=function(t,o,r){let{type:a,label:n,name:e,tooltip:l="",visible:i="true",required:p="false",fixed:s="false",fold:f="false",options:m=""}=t,u=t.default;if(r==="form"){let b=V({form:[{_attr:{name:e,tooltip:l,visible:i,required:p,fixed:s,fold:f,options:m}},o]});return exports.unEscapeForXML(b)}let h=V({field:[{_attr:{type:a,label:n,name:e,tooltip:l,visible:i,required:p,fixed:s,fold:f,options:m}},u||o]});return exports.unEscapeForXML(h)},B=function(t){let r=t.children.map(a=>{let e=a.children.map(l=>X(l)).join("");return X(a,e,"form")}).join("");return X(t,r)},E=function c(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=c(e.children,o,e.fullName,e.fullPath);if(l)return l}}return null};import P from"fs-extra";import le from"path";import v from"lodash.template";import se from"xml";import ce from"@babel/core";var ae=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division"],F=c=>le.resolve(__dirname,`../templates/see/${c}`),A=c=>{let t=c.type;if(!ae.includes(t))return"";let{label:o,name:r,tooltip:a="",visible:n="true",required:e="false",fixed:l="false",fold:i="false",options:p=""}=c,s=c.default;if(t==="table"){let m=c.keys||[];s=(c.columns||m).map(h=>A(h)).join(`
|
|
2
|
+
`)}else if(t==="switchForm"||t==="division")s=c.children.map(u=>A(u)).join(`
|
|
3
|
+
`);else{if(t==="complexSelect")return B(c);t==="editor"?s=[JSON.stringify(s)]:s=[s]}let f=se({field:[{_attr:{type:t,label:o,name:r,tooltip:a,visible:n,required:e,fixed:l,fold:i,options:p}},s].concat(s)});return J(`${f}`)},C=function({system:t,type:o,name:r,appType:a,group:n,version:e,configFileName:l="config.local",variables:i=[],description:p}){let s=P.readFileSync(F("python/deploy.xml")).toString();return v(s,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:r,appType:a,group:n,version:e,configFileName:l,variables:(()=>i.map(f=>A(f)).join(`
|
|
4
|
+
`))(),description:p})},j=function(t,o){let r=P.readFileSync(F(`python/scripts/${t}.py`)).toString();return v(r,{interpolate:/{{([\s\S]+?)}}/g})(o)},k=function(t,o=[]){let{code:r}=ce.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 i=E(o,p=>l===p.name);if(i){if(i.fullPath.includes("complexSelect")&&(i.name=i.fullName),n.isStringLiteral()){n.node.value=`$!{${i.name}}`;return}if(n.isNumericLiteral()){n.node.value=`$!{${i.name}}`;return}if(n.isBooleanLiteral()){if(n.node.type="StringLiteral",i.fullPath.includes("complexSelect")){n.node.value=`$!{${i.fullName}}`;return}n.node.value=`[NO_QUOTATION_MARKS]\${${i.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(n){if(n.parentPath.isProperty()){let e=E(o,l=>n.parentPath.get("key").node.name===l.name);if(e){e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let l="",i=e.keys||[],p=e.columns||i;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}p&&p.length&&p.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 i=E(o,p=>l===p.name);if(i){if(n.node.type="StringLiteral",i.fullPath.includes("editor")){n.node.value=`[NO_QUOTATION_MARKS]\${${i.name}}[NO_QUOTATION_MARKS]`;return}n.node.value=`[NO_QUOTATION_MARKS]\${${i.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return r.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},q=function({system:t,type:o,name:r,appType:a,version:n,group:e,configFileName:l="config.local",variables:i=[],description:p,web_app_web_service_name:s,dockerImage:f}){let m=P.readFileSync(F("docker/deploy.xml")).toString();return v(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:r,appType:a,version:n,group:e,configFileName:l,variables:(()=>i.map(u=>A(u)).join(`
|
|
5
|
+
`))(),description:p,web_app_web_service_name:s,dockerImage:f})},W=function(t){let o=P.readFileSync(F("docker/k8s-deploy-res.yaml")).toString();return v(o,{interpolate:/{{([\s\S]+?)}}/g})(t)},Z=function(t){let o=P.readFileSync(F("docker/Dockerfile")).toString();return v(o)(t)},H=function({system:t,type:o,name:r,appType:a,version:n,group:e,configFileName:l="config.local",variables:i=[],description:p}){let s=P.readFileSync(F("bash/deploy.xml")).toString();return v(s,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:o,name:r,appType:a,version:n,group:e,configFileName:l,variables:(()=>i.map(f=>A(f)).join(`
|
|
6
|
+
`))(),description:p})},M=function(t,o){let r=P.readFileSync(F(`bash/scripts/${t}.sh`)).toString();return v(r,{interpolate:/{{([\s\S]+?)}}/g})(o)};var y="tmp",G=function(t,o,r){let{system:a,type:n,name:e,appType:l,group:i,version:p,template:s,variables:f,configName:m,outputName:u,description:h,scriptsType:b}=o;g.ensureDirSync(y),g.ensureDirSync(`${y}/scripts`),g.ensureDirSync(`${y}/template`),I(u)?g.outputFileSync(`./${y}/template/config.local.js`,s?k(s,f):""):T(u)||T(u,e)?(m="sysconfig",g.outputFileSync(`./${y}/template/sysconfig.js`,s?k(s,f):"")):m&&g.outputFileSync(`./${y}/template/${m}.js`,s?k(s,f):""),b==="python"?(g.outputFileSync(`./${y}/scripts/${e}/utils.py`,j("utils")),g.outputFileSync(`./${y}/scripts/${e}/install.py`,j("install",{name:e,type:n})),g.outputFileSync(`./${y}/scripts/${e}/afterInstall.py`,j("afterInstall",{name:e})),g.outputFileSync(`./${y}/scripts/${e}/uninstall.py`,j("uninstall",{name:e,type:n})),g.outputFileSync(`./${y}/deploy.xml`,C({system:a,type:n,name:e,appType:l,group:i,version:p,configFileName:m,variables:f,description:h}))):(g.outputFileSync(`./${y}/scripts/${e}/install.sh`,M("install",{name:e,type:n})),g.outputFileSync(`./${y}/scripts/${e}/afterInstall.sh`,M("afterInstall",{name:e})),g.outputFileSync(`./${y}/scripts/${e}/uninstall.sh`,M("uninstall",{name:e,type:n})),g.outputFileSync(`./${y}/deploy.xml`,H({system:a,type:n,name:e,appType:l,version:p,group:i,configFileName:m,variables:f,description:h}))),r?r(x=>{_(t,y,()=>{Y.sync(y),typeof x=="function"&&x()})}):_(t,y,()=>{Y.sync(y)})};import ee from"path";import S from"fs-extra";import te from"rimraf";var d="tmp",ne=function(t,o,r){let{system:a,type:n,name:e,appType:l,version:i,group:p,template:s,variables:f,configName:m,outputName:u,description:h,dockerImage:b=i.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=o;S.ensureDirSync(d),S.ensureDirSync("docker"),S.pathExistsSync(ee.resolve(process.cwd(),"docker/Dockerfile"))||S.outputFileSync(ee.resolve(process.cwd(),"docker/Dockerfile"),Z({name:e,type:n})),S.ensureDirSync(`${d}/scripts`),S.ensureDirSync(`${d}/template`),I(u)?S.outputFileSync(`./${d}/template/${e}/config.local.js`,s?k(s,f):""):T(u)||T(u,e)?(m="sysconfig",S.outputFileSync(`./${d}/template/${e}/sysconfig.js`,s?k(s,f):"")):m&&S.outputFileSync(`./${d}/template/${e}/${m}.js`,s?k(s,f):""),S.outputFileSync(`./${d}/template/k8s-deploy-res.yaml`,W({configFileName:m})),S.outputFileSync(`./${d}/deploy.xml`,q({system:a,type:n,name:e,appType:l,version:i,group:p,configFileName:m,variables:f,description:h,web_app_web_service_name:`${e}-web`,dockerImage:b})),r?r(x=>{_(t,d,()=>{te.sync(d),typeof x=="function"&&x()})}):_(t,d,()=>{te.sync(d)})};var me=process.cwd();function ue(c,t,o){let r="",a;if(c==="bizframe"){r=$.readdirSync(`./${o}`).find(n=>/manifest\.[0-9]+\.json/.test(n));try{a=$.readJsonSync(`./${o}/${r}`)}catch(n){process.exit(0)}}return c==="subsystem"&&(r=$.readdirSync(`./${o}/${t}`).find(n=>/manifest\.[0-9]+\.json/.test(n)),a=$.readJsonSync(`./${o}/${t}/${r}`)),{manifest:r,manifestJson:a}}var ze=function({system:t="winner-front",type:o="bizframe",name:r,appType:a,group:n="bizframe",version:e,configName:l="config.local",outputName:i="dist",templateFunc:p,variablesFunc:s,copyFiles:f,description:m,seePackageName:u,seePackageType:h="web",dockerImage:b,scriptsType:x="python"},L){if(!r||!e)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(r=r.replace(/@/gi,"").replace(/\//gi,"-"),typeof u=="string"&&u&&(u=u.replace(/@/gi,"").replace(/\//gi,"-")),a=a||r,s=s||function(){try{let{variables:O}=Q(fe.resolve(me,"build","package","./variables.js"));return O||[]}catch(O){return console.error(O),[]}},p=p||function(){return o==="bizframe"?`./${i}/config.local.js`:`./${i}/${r}/sysconfig.js`},h==="docker"){ne(u||`${t}-${r}-${e}`,{system:t,type:o,name:r,appType:a,group:n,version:e,configName:l,outputName:i,template:p(),variables:s(),description:m,dockerImage:b},O=>{console.log(),re("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(),O(L)});return}G(u||`${t}-${r}-${e}`,{system:t,type:o,name:r,group:n,appType:a,version:e,configName:l,outputName:i,template:p(),variables:s(),description:m,scriptsType:x},O=>{if(x==="python"){let{manifest:D,manifestJson:N}=ue(o,r,i);for(let R in N)if(N.hasOwnProperty(R)){let{path:K,dir:oe}=N[R];$.ensureDirSync(`./tmp/source/${oe}`),$.copyFileSync(`./${i}/${K}`,`./tmp/source/${K}`)}$.outputJSONSync(`./tmp/scripts/${r}/conf/${D}`,N)}else $.ensureDirSync("./tmp/source"),$.copySync(`./${i}`,"./tmp/source");Array.isArray(f)&&f.length&&f.forEach(D=>{$.ensureFileSync(`./tmp/source/${r}/${D}`),$.copyFileSync(`./${i}/${r}/${D}`,`./tmp/source/${r}/${D}`)}),console.log(),re(`\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${pe.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(),O(L)})};export{ze as generateSeePackageZip};
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<appType describe="发布物类型">{{ appType }}</appType>
|
|
8
8
|
<appDescribe describe="发布包说明">{{ description }}</appDescribe>
|
|
9
9
|
<version describe="发布包版本">{{ version }}</version>
|
|
10
|
-
<group describe="
|
|
10
|
+
<group describe="应用分组,默认为 bizframe">{{ group }}</group>
|
|
11
11
|
<packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)" />
|
|
12
12
|
</basic>
|
|
13
13
|
<globalConfig describe="系统全局配置" />
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<appName describe="应用名称">{{ name }}</appName>
|
|
8
8
|
<appDescribe describe="应用说明">{{ description }}</appDescribe>
|
|
9
9
|
<version describe="应用版本">{{ version }}</version>
|
|
10
|
-
<group describe="
|
|
10
|
+
<group describe="应用分组,默认为 bizframe">{{ group }}</group>
|
|
11
11
|
<packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)" />
|
|
12
12
|
</basic>
|
|
13
13
|
<globalConfig describe="系统全局配置" />
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<appType describe="发布物类型">{{ appType }}</appType>
|
|
8
8
|
<appDescribe describe="发布包说明">{{ description }}</appDescribe>
|
|
9
9
|
<version describe="发布包版本">{{ version }}</version>
|
|
10
|
-
<group describe="
|
|
10
|
+
<group describe="应用分组,默认为 bizframe">{{ group }}</group>
|
|
11
11
|
<packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)" />
|
|
12
12
|
</basic>
|
|
13
13
|
<globalConfig describe="系统全局配置" />
|