@winner-fed/winner-deploy 4.3.9 → 4.3.11

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
@@ -91,28 +91,28 @@ generateSeePackageZip(
91
91
 
92
92
  #### 参数说明
93
93
 
94
- | 参数名 | 类型 | 默认值 | 必填 | 说明 |
95
- | ----------------- | -------------------------------------- | ------------------------------------ | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
96
- | system | string | `'winner-front'` | 否 | 系统类型,SEE 平台分组维度 |
97
- | type | `'bizframe' \| 'subsystem'` | `'bizframe'` | 否 | 应用类型:外框架或子系统 |
98
- | name | string | - | 是 | 发布物名称(子系统标识、脚本目录名等) |
99
- | version | string | - | 是 | 发布包版本 |
100
- | description | string | - | 否 | 发布包说明,写入 deploy.xml |
101
- | appType | string | `name` | 否 | 发布物类型 |
102
- | appName | string | `name` | 否 | deploy.xml 中 `appName` 标签 |
103
- | group | string | `'bizframe'` | 否 | 应用分组 |
104
- | configName | string | `'config.local'` | 否 | 配置文件名(不含 `.js`)。为空时可构建不含配置 JS 的静态包,此时 `scriptsType` 应使用 `bash`。实际写入 template 的文件名还会按项目类型自动推断:存在 `dist/config.local.js` 时用 `config.local`,存在 `dist/sysconfig.js`(或子包路径下)时用 `sysconfig` |
105
- | outputName | string | `'dist'` | 否 | 构建产物目录名(相对项目根目录) |
106
- | seePackageName | string | `` `${system}-${name}-${version}` `` | 否 | zip 包文件名(不含 `.zip`) |
107
- | seePackagePath | string | `'package'` | 否 | zip 输出目录,相对项目根目录;设为 `'/'` 时输出到当前目录 |
108
- | seePackageType | `'web' \| 'docker'` | `'web'` | 否 | 发布物类型 |
109
- | dockerImage | string | - | 否 | Docker 镜像名,`seePackageType` 为 `'docker'` 时生效 |
110
- | scriptsType | `'python' \| 'bash'` | `'python'` | 否 | 集群脚本语言 |
111
- | enableObfuscation | boolean | `false` | 否 | 为 `true` 时打包 `scripts/{name}/js/`,并在 `afterInstall` 中对已注入变量后的配置 JS 做混淆:有 `node` 用 `confuse.js`(javascript-obfuscator 强混淆),无 `node` 用 `confuse.sh`(base64 + `TextDecoder`/`new Function` 轻量包裹,UTF-8 安全,强度较弱);为 `false` 时不拷贝、不执行混淆 |
112
- | tplPath | `Record<string, string>` | `{}` | 否 | 自定义模板:`key` 为包内文件名,`value` 为本地绝对路径。`deploy.xml` 同名则覆盖生成的 deploy.xml;`sysconfig.js` / `config.local.js` 会跳过自动生成对应配置 |
113
- | copyFiles | `string[]` | - | 否 | 额外拷贝到包内 `source/{name}/` 的文件名列表,源路径为 `` `${outputName}/${name}/${file}` `` |
114
- | templateFunc | `() => string \| undefined` | 见下文 | 否 | 返回待写入 template 的配置 JS 源文件路径 |
115
- | variablesFunc | `() => FieldAttributes[] \| undefined` | 见下文 | 否 | 返回 deploy.xml 动态表单项 |
94
+ | 参数名 | 类型 | 默认值 | 必填 | 说明 |
95
+ | ----------------- | ----------------------------------------------------------------- | ------------------------------------ | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
96
+ | system | string | `'winner-front'` | 否 | 系统类型,SEE 平台分组维度 |
97
+ | type | `'bizframe' \| 'subsystem'` | `'bizframe'` | 否 | 应用类型:外框架或子系统 |
98
+ | name | string | - | 是 | 发布物名称(子系统标识、脚本目录名等) |
99
+ | version | string | - | 是 | 发布包版本 |
100
+ | description | string | - | 否 | 发布包说明,写入 deploy.xml |
101
+ | appType | string | `name` | 否 | 发布物类型 |
102
+ | appName | string | `name` | 否 | deploy.xml 中 `appName` 标签 |
103
+ | group | string | `'bizframe'` | 否 | 应用分组 |
104
+ | configName | string | `'config.local'` | 否 | 配置文件名(不含 `.js`)。为空时可构建不含配置 JS 的静态包,此时 `scriptsType` 应使用 `bash`。实际写入 template 的文件名还会按项目类型自动推断:存在 `dist/config.local.js` 时用 `config.local`,存在 `dist/sysconfig.js`(或子包路径下)时用 `sysconfig` |
105
+ | outputName | string | `'dist'` | 否 | 构建产物目录名(相对项目根目录) |
106
+ | seePackageName | string | `` `${system}-${name}-${version}` `` | 否 | zip 包文件名(不含 `.zip`) |
107
+ | seePackagePath | string | `'package'` | 否 | zip 输出目录,相对项目根目录;设为 `'/'` 时输出到当前目录 |
108
+ | seePackageType | `'web' \| 'docker'` | `'web'` | 否 | 发布物类型 |
109
+ | dockerImage | string | - | 否 | Docker 镜像名,`seePackageType` 为 `'docker'` 时生效 |
110
+ | scriptsType | `'python' \| 'bash'` | `'python'` | 否 | 集群脚本语言 |
111
+ | enableObfuscation | boolean | `false` | 否 | 为 `true` 时打包 `scripts/{name}/js/`,并在 `afterInstall` 中对已注入变量后的配置 JS 做混淆:有 `node` 用 `confuse.js`(javascript-obfuscator 强混淆),无 `node` 用 `confuse.sh`(base64 + `TextDecoder`/`new Function` 轻量包裹,UTF-8 安全,强度较弱);为 `false` 时不拷贝、不执行混淆 |
112
+ | tplPath | `Record<string, string \| { path: string; transform?: boolean }>` | `{}` | 否 | 写入 SEE 包 `template/`。字符串或 `{ path }`:原样拷贝已编辑模板(js/html 等);`{ path, transform: true }`:仅 `.js` 经 genTemplate 后再写入;`deploy.xml` 覆盖自动生成。进 template 的文件会登记为 `<config>` |
113
+ | copyFiles | `string[]` | - | 否 | 额外拷贝到包内 `source/{name}/` 的文件名列表,源路径为 `` `${outputName}/${name}/${file}` `` |
114
+ | templateFunc | `() => string \| undefined` | 见下文 | 否 | 返回待写入 template 的配置 JS 源文件路径 |
115
+ | variablesFunc | `() => FieldAttributes[] \| undefined` | 见下文 | 否 | 返回 deploy.xml 动态表单项 |
116
116
 
117
117
  #### templateFunc 默认值
118
118
 
@@ -143,15 +143,27 @@ variablesFunc: () => {
143
143
 
144
144
  #### tplPath 说明
145
145
 
146
+ 已编辑好的 SEE 模板(含 `$!{VAR}` 等占位)默认**原样拷贝**到包内 `template/`,不再强制走 Babel 转换。
147
+
146
148
  ```javascript
147
149
  tplPath: {
148
- 'deploy.xml': '/abs/path/custom-deploy.xml',
149
- 'sysconfig.js': '/abs/path/sysconfig.js'
150
- }
150
+ // 已手写好的模板:直接复制到 template/
151
+ 'config.local.js': path.resolve(__dirname, './tpl/config.local.js'),
152
+ 'index.html': path.resolve(__dirname, './tpl/index.html'),
153
+ 'logo.js': path.resolve(__dirname, './tpl/logo.js'),
154
+
155
+ // 需要从源码自动替换 variables 时再显式开启
156
+ // 'theme.js': { path: path.resolve(__dirname, './src/theme.js'), transform: true },
157
+
158
+ // 'deploy.xml': path.resolve(__dirname, './tpl/deploy.xml'),
159
+ };
151
160
  ```
152
161
 
153
- - 除 `deploy.xml` 外,其余文件复制到包内 `template/` 目录。
154
- - 提供 `sysconfig.js` 或 `config.local.js` 时,不再根据 `templateFunc` 生成同名配置。
162
+ - 字符串 / `{ path, transform: false }`:原样拷贝到 `template/`(js、html 等均可)。
163
+ - `{ path, transform: true }`:仅对 `.js` 调用 `genTemplate` 后再写入。
164
+ - `deploy.xml`:原样覆盖包内 deploy.xml。
165
+ - 进入 `template/` 的文件会写入 `deploy.xml` 的 `<config>`;其中 `.js` 在 `enableObfuscation` 时由 `afterInstall` 混淆。
166
+ - 若未通过 `tplPath` 放入任何配置文件,仍使用 `configName` + `templateFunc` 生成单个配置。
155
167
 
156
168
  #### copyFiles 说明
157
169
 
@@ -224,7 +236,7 @@ const variables = [
224
236
  see-package.zip
225
237
  ├── deploy.xml
226
238
  ├── template/
227
- │ └── config.local.js | sysconfig.js | 自定义名.js
239
+ │ └── config.local.js | sysconfig.js | 自定义多个 *.js
228
240
  ├── scripts/
229
241
  │ └── {name}/
230
242
  │ ├── install.py | install.sh
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- /** build time: Thu Jul 30 2026 11:03:48 GMT+0800 (中国标准时间), build version 4.3.9 **/
2
- var xe=Object.create;var X=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames,ee=Object.getOwnPropertySymbols,Te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable;var te=(r,t,n)=>t in r?X(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,U=(r,t)=>{for(var n in t||(t={}))ne.call(t,n)&&te(r,n,t[n]);if(ee)for(var n of ee(t))ke.call(t,n)&&te(r,n,t[n]);return r};var _e=(r,t)=>{for(var n in t)X(r,n,{get:t[n],enumerable:!0})},oe=(r,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of Oe(t))!ne.call(r,l)&&l!==n&&X(r,l,{get:()=>t[l],enumerable:!(i=be(t,l))||i.enumerable});return r};var O=(r,t,n)=>(n=r!=null?xe(Te(r)):{},oe(t||!r||!r.__esModule?X(n,"default",{value:r,enumerable:!0}):n,r)),Ae=r=>oe(X({},"__esModule",{value:!0}),r);var ve={};_e(ve,{generateSeePackageZip:()=>De});module.exports=Ae(ve);var Se=O(require("chalk"),1),$e=O(require("path"),1),T=O(require("fs-extra"),1);var ye=O(require("path"),1),b=O(require("fs-extra"),1),W=require("rimraf");var C=O(require("path"),1),K=O(require("fs-extra"),1),re=O(require("archiver"),1),q=O(require("xml"),1);var B=process.cwd(),V=function(t){let n={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},i=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/g;return t&&t.replace?t.replace(i,function(l){return n[l]}):t},D=function(t,n){let i=n||"",l=C.default.resolve(B,t,i,"sysconfig.js");return K.default.pathExistsSync(l)},L=function(t){let n=C.default.resolve(B,t,"config.local.js");return K.default.pathExistsSync(n)},I=function(t,n,i,l){let o=C.default.join(B,n);n!=="/"&&K.default.ensureDirSync(o);let e=K.default.createWriteStream(`${n==="/"?".":o}/${t}.zip`);e.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(e),s.directory(i,!1),s.finalize()},Z=function(t,n,i){let{type:l,label:o,name:e,tooltip:s="",visible:c="true",required:a="false",fixed:$="false",fold:f="false",options:m="",validate:d="",upgrade:p="false"}=t,P=t.default;if(i==="form"){let k=(0,q.default)({form:[{_attr:{name:e,tooltip:s,visible:c,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p}},n]});return V(k)}let y=l==="complexSelect"?{default:t.default}:{},g=(0,q.default)({field:[{_attr:U({type:l,label:o,name:e,tooltip:s,visible:c,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p},y)},n||P]});return V(g)},ie=function(t){let i=t.children.map(l=>{let e=l.children.map(s=>Z(s)).join("");return Z(l,e,"form")}).join("");return Z(t,i)},z=function r(t,n,i="",l=""){for(let o=0;o<t.length;o++){let e=t[o];if(e.type==="complexSelect"?(e.fullName=`${e.name}`,e.fullPath=`${e.type}`):(e.fullName=`${i===""?"":i+"."}${e.name}`,e.fullPath=`${l===""?"":l+"-"}${e.type}`),n(e))return e;if(e.children&&e.children.length>0){let s=r(e.children,n,e.fullName,e.fullPath);if(s)return s}}return null};function le(r="python"){return r==="python"?"py":"sh"}var w=O(require("fs-extra"),1),se=O(require("path"),1),E=O(require("lodash.template"),1),ce=O(require("xml"),1),ae=O(require("@babel/core"),1);var Pe=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],Q=r=>se.default.resolve(__dirname,`../templates/see/${r}`),J=r=>{let t=r.type;if(!Pe.includes(t))return"";let{label:n,name:i,tooltip:l="",visible:o="true",required:e="false",fixed:s="false",fold:c="false",options:a="",validate:$="",upgrade:f="false",expose:m="",algorithm:d="",merge:p="",isomeris:P="",old_name:y=""}=r,g=r.default;if(t==="table"){let u=r.keys||[];g=(r.columns||u).map(x=>J(x)).join(`
3
- `)}else if(t==="switchForm"||t==="division"){let u=r.children;g=u?u.map(h=>J(h)).join(`
4
- `):""}else{if(t==="complexSelect")return ie(r);t==="editor"?g=typeof g=="object"?[JSON.stringify(g)]:[g]:g=[g]}let k=t==="switchForm"?{default:r.default}:{},F=U({type:t,label:n,name:i,tooltip:l,visible:o,required:e,fixed:s,fold:c,options:a,validate:$,upgrade:f,expose:m,algorithm:d,merge:p,isomeris:P,old_name:y},k),N=Object.fromEntries(Object.entries(F).filter(([u,h])=>h!==""&&h!==null&&h!==void 0)),j=(0,ce.default)({field:[{_attr:N},...Array.isArray(g)?g:[g]]});return V(j)},fe=function({system:t,type:n,name:i,appType:l,appName:o,group:e,version:s,configFileName:c="config.local",variables:a=[],description:$,scriptsType:f="python"}){let m=w.default.readFileSync(Q(`${f}/deploy.xml`)).toString();return(0,E.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:i,appName:o,appType:l,group:e,version:s,configFileName:c,variables:a.map(d=>J(d)).join(`
5
- `),description:$})},M=function(t,n){let i=`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`;t==="beforeInstall"&&(i=`${n.scriptsType}/scripts/${t}.sh`);let l=w.default.readFileSync(Q(i)).toString();return(0,E.default)(l,{interpolate:/{{([\s\S]+?)}}/g})(n)},v=function(t,n=[]){let{code:i}=ae.default.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(o){if(o.parentPath.isProperty()){let e=o.parentPath.get("key").node,s=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,s=e.value);let c=z(n,a=>s===a.name);if(c){if(c.fullPath.includes("complexSelect")&&(c.name=c.fullName),o.isStringLiteral()){o.node.value=`$!{${c.name}}`;return}if(o.isNumericLiteral()){o.node.value=`$!{${c.name}}`;return}if(o.isBooleanLiteral()){if(o.node.type="StringLiteral",c.fullPath.includes("complexSelect")){o.node.value=`$!{${c.fullName}}`;return}o.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(o){if(o.parentPath.isProperty()){let e=z(n,s=>o.parentPath.get("key").node.name===s.name);if(e){if(e.fullPath.includes("editor")){o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS]\${${e.name}}[NO_QUOTATION_MARKS]`;return}e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let s="",c=e.keys||[],a=e.columns||c;if(e.options){s=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,o.node.type="StringLiteral",o.node.value=s;return}a&&a.length&&a.forEach(f=>{s+=`${f.name}: '$!{row.${f.name}}',`}),o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${s}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(o){if(o.parentPath.isProperty()){let e=o.parentPath.get("key").node,s=e.name;if(e){let c=z(n,a=>s===a.name);if(c){if(o.node.type="StringLiteral",c.fullPath.includes("editor")){o.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`;return}o.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:t,type:n,name:i,appName:l,appType:o,version:e,group:s,configFileName:c="config.local",variables:a=[],description:$,web_app_web_service_name:f,dockerImage:m}){let d=w.default.readFileSync(Q("docker/deploy.xml")).toString();return(0,E.default)(d,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:i,appName:l,appType:o,version:e,group:s,configFileName:c,variables:a.map(p=>J(p)).join(`
6
- `),description:$,web_app_web_service_name:f,dockerImage:m})},me=function(t){let n=w.default.readFileSync(Q("docker/k8s-deploy-res.yaml")).toString();return(0,E.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},ue=function(t){let n=w.default.readFileSync(Q("docker/Dockerfile")).toString();return(0,E.default)(n)(t)};var S="tmp",ge=function(t,n,i){let{system:l,type:o,name:e,appType:s,appName:c,group:a,version:$,template:f,variables:m=[],configName:d,outputName:p="dist",description:P,scriptsType:y,enableObfuscation:g=!1,seePackagePath:k,tplPath:F}=n;b.default.ensureDirSync(S),b.default.ensureDirSync(`${S}/scripts`),b.default.ensureDirSync(`${S}/template`);let N=!1,j=!1;if(F&&Object.keys(F).length>0)for(let[x,R]of Object.entries(F))x==="deploy.xml"?(b.default.copyFileSync(R,`./${S}/deploy.xml`),N=!0):b.default.copyFileSync(R,`./${S}/template/${x}`),(x==="sysconfig.js"||x==="config.local.js")&&(j=!0);let u=d;if(j&&F?F["sysconfig.js"]?u="sysconfig":F["config.local.js"]&&(u="config.local"):j||(L(p)?u="config.local":(D(p)||D(p,e))&&(u="sysconfig")),g&&(y==="bash"||y==="python")){let x=ye.default.resolve(__dirname,`../templates/see/${y}/scripts/js`);b.default.pathExistsSync(x)&&b.default.copySync(x,`./${S}/scripts/${e}/js`)}let h=le(y);y==="python"&&(b.default.outputFileSync(`./${S}/scripts/${e}/utils.${h}`,M("utils",{scriptsType:y})),b.default.outputFileSync(`./${S}/scripts/${e}/beforeInstall.sh`,M("beforeInstall",{scriptsType:y}))),b.default.outputFileSync(`./${S}/scripts/${e}/install.${h}`,M("install",{name:e,type:o,scriptsType:y})),b.default.outputFileSync(`./${S}/scripts/${e}/afterInstall.${h}`,M("afterInstall",{name:e,scriptsType:y,configFileName:u,enableObfuscation:g})),b.default.outputFileSync(`./${S}/scripts/${e}/uninstall.${h}`,M("uninstall",{name:e,type:o,scriptsType:y})),N||b.default.outputFileSync(`./${S}/deploy.xml`,fe({system:l,type:o,name:e,appType:s,appName:c,group:a,version:$,configFileName:u,variables:m,description:P,scriptsType:y})),j||(L(p)?b.default.outputFileSync(`./${S}/template/config.local.js`,f?v(f,m):""):D(p)||D(p,e)?b.default.outputFileSync(`./${S}/template/sysconfig.js`,f?v(f,m):""):u&&b.default.outputFileSync(`./${S}/template/${u}.js`,f?v(f,m):"")),i?i(x=>{I(t,k,S,()=>{W.rimraf.sync(S),typeof x=="function"&&x()})}):I(t,k,S,()=>{W.rimraf.sync(S)})};var G=O(require("path"),1),A=O(require("fs-extra"),1),H=require("rimraf");var _="tmp",de=function(t,n,i){let{system:l,type:o,name:e,appType:s,appName:c,version:a,group:$,template:f,variables:m,configName:d,outputName:p,description:P,seePackagePath:y,dockerImage:g=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;A.default.ensureDirSync(_),A.default.ensureDirSync("docker"),A.default.pathExistsSync(G.default.resolve(process.cwd(),"docker/Dockerfile"))||A.default.outputFileSync(G.default.resolve(process.cwd(),"docker/Dockerfile"),ue({name:e,type:o})),A.default.ensureDirSync(`${_}/scripts`),A.default.ensureDirSync(`${_}/template`),L(p)?A.default.outputFileSync(`./${_}/template/${e}/config.local.js`,f?v(f,m):""):D(p)||D(p,e)?(d="sysconfig",A.default.outputFileSync(`./${_}/template/${e}/sysconfig.js`,f?v(f,m):"")):d&&A.default.outputFileSync(`./${_}/template/${e}/${d}.js`,f?v(f,m):""),A.default.outputFileSync(`./${_}/template/k8s-deploy-res.yaml`,me({configFileName:d})),A.default.outputFileSync(`./${_}/deploy.xml`,pe({system:l,type:o,name:e,appName:c,appType:s,version:a,group:$,configFileName:d,variables:m,description:P,web_app_web_service_name:`${e}-web`,dockerImage:g})),i?i(k=>{I(t,y,_,()=>{H.rimraf.sync(_),typeof k=="function"&&k()})}):I(t,y,_,()=>{H.rimraf.sync(_)})};var Fe=process.cwd();function je(r,t,n){let i="",l,o=r==="bizframe"?`./${n}`:`./${n}/${t}`;return T.default.existsSync(o)&&(i=T.default.readdirSync(o).find(e=>/manifest\.[0-9]+\.json/.test(e)),i&&(l=T.default.readJsonSync(`${o}/${i}`))),{manifest:i,manifestJson:l}}var De=function({system:t="winner-front",type:n="bizframe",name:i,appType:l,appName:o,group:e="bizframe",version:s,configName:c="config.local",outputName:a="dist",templateFunc:$,variablesFunc:f,copyFiles:m,description:d,seePackageName:p,seePackagePath:P="package",seePackageType:y="web",dockerImage:g,scriptsType:k="python",enableObfuscation:F=!1,tplPath:N={}},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 p=="string"&&p&&(p=p.replace(/@/gi,"").replace(/\//gi,"-")),l=l||i,o=o||i,f=f||function(){try{let{variables:u}=require($e.default.resolve(Fe,"build","package","./variables.js"));return u||[]}catch(u){return console.error(u),[]}},$=$||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${i}/sysconfig.js`},y==="docker"){de(p||`${t}-${i}-${s}`,{system:t,type:n,name:i,appType:l,appName:o,group:e,version:s,configName:c,outputName:a,template:$(),variables:f(),seePackagePath:P,description:d,dockerImage:g},u=>{console.log(),console.log("docker \u5BB9\u5668\u5316\u90E8\u7F72\u7684 SEE \u53D1\u5E03\u7269\u5236\u4F5C\u5B8C\u6210\uFF0C\u60A8\u53EF\u4EE5\u5728 SEE \u5E73\u53F0\u4E0A\u4F20\u5E76\u90E8\u7F72\u5E94\u7528\u3002"),u(j)});return}ge(p||`${t}-${i}-${s}`,{system:t,type:n,name:i,group:e,appType:l,appName:o,version:s,configName:c,outputName:a,template:$(),variables:f(),seePackagePath:P,description:d,scriptsType:k,enableObfuscation:F,tplPath:N},u=>{if(k==="python"){let{manifest:h,manifestJson:x}=je(n,i,a);if(h){for(let R in x)if(x.hasOwnProperty(R)){let{path:Y,dir:he}=x[R];T.default.ensureDirSync(`./tmp/source/${he}`),T.default.copyFileSync(`./${a}/${Y}`,`./tmp/source/${Y}`)}T.default.outputJSONSync(`./tmp/scripts/${i}/conf/${h}`,x)}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(m)&&m.length&&m.forEach(h=>{T.default.ensureFileSync(`./tmp/source/${i}/${h}`),T.default.copyFileSync(`./${a}/${i}/${h}`,`./tmp/source/${i}/${h}`)}),console.log(),console.log(`\u53D1\u5E03\u7269\u5236\u4F5C\u5B8C\u6210\uFF0C\u60A8\u53EF\u4EE5\u5728 SEE \u5E73\u53F0\u4E0A\u4F20\u5E76\u90E8\u7F72\u5E94\u7528\u3002\u6CE8\u610F\uFF1A${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
- `),u(j)})};0&&(module.exports={generateSeePackageZip});
1
+ /** build time: Thu Sep 10 2026 09:45:58 GMT+0800 (中国标准时间), build version 4.3.11 **/
2
+ var ke=Object.create;var K=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames,re=Object.getOwnPropertySymbols,De=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var oe=(r,e,n)=>e in r?K(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,Q=(r,e)=>{for(var n in e||(e={}))ie.call(e,n)&&oe(r,n,e[n]);if(re)for(var n of re(e))ve.call(e,n)&&oe(r,n,e[n]);return r};var we=(r,e)=>{for(var n in e)K(r,n,{get:e[n],enumerable:!0})},se=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of je(e))!ie.call(r,s)&&s!==n&&K(r,s,{get:()=>e[s],enumerable:!(o=_e(e,s))||o.enumerable});return r};var F=(r,e,n)=>(n=r!=null?ke(De(r)):{},se(e||!r||!r.__esModule?K(n,"default",{value:r,enumerable:!0}):n,r)),Ie=r=>se(K({},"__esModule",{value:!0}),r);var Ke={};we(Ke,{generateSeePackageZip:()=>Xe});module.exports=Ie(Ke);var Te=F(require("chalk"),1),Ne=F(require("path"),1),T=F(require("fs-extra"),1);var Fe=F(require("path"),1),h=F(require("fs-extra"),1),H=require("rimraf");var z=F(require("path"),1),L=F(require("fs-extra"),1),le=F(require("archiver"),1),W=F(require("xml"),1);var G=process.cwd(),U=function(e){let n={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},o=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/g;return e&&e.replace?e.replace(o,function(s){return n[s]}):e},I=function(e,n){let o=n||"",s=z.default.resolve(G,e,o,"sysconfig.js");return L.default.pathExistsSync(s)},J=function(e){let n=z.default.resolve(G,e,"config.local.js");return L.default.pathExistsSync(n)},E=function(e,n,o,s){let i=z.default.join(G,n);n!=="/"&&L.default.ensureDirSync(i);let t=L.default.createWriteStream(`${n==="/"?".":i}/${e}.zip`);t.on("close",function(){setTimeout(function(){s&&s()})});let l=(0,le.default)("zip",{zlib:{level:9}});l.on("error",function(c){console.error(),console.error(c.stack||c),c.details&&console.error(c.details)}),l.pipe(t),l.directory(o,!1),l.finalize()},q=function(e,n,o){let{type:s,label:i,name:t,tooltip:l="",visible:c="true",required:a="false",fixed:$="false",fold:p="false",options:u="",validate:f="",upgrade:m="false"}=e,b=e.default;if(o==="form"){let N=(0,W.default)({form:[{_attr:{name:t,tooltip:l,visible:c,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m}},n]});return U(N)}let y=s==="complexSelect"?{default:e.default}:{},d=(0,W.default)({field:[{_attr:Q({type:s,label:i,name:t,tooltip:l,visible:c,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m},y)},n||b]});return U(d)},ce=function(e){let o=e.children.map(s=>{let t=s.children.map(l=>q(l)).join("");return q(s,t,"form")}).join("");return q(e,o)},B=function r(e,n,o="",s=""){for(let i=0;i<e.length;i++){let t=e[i];if(t.type==="complexSelect"?(t.fullName=`${t.name}`,t.fullPath=`${t.type}`):(t.fullName=`${o===""?"":o+"."}${t.name}`,t.fullPath=`${s===""?"":s+"-"}${t.type}`),n(t))return t;if(t.children&&t.children.length>0){let l=r(t.children,n,t.fullName,t.fullPath);if(l)return l}}return null};function ae(r="python"){return r==="python"?"py":"sh"}var M=F(require("fs-extra"),1),pe=F(require("path"),1),R=F(require("lodash.template"),1),fe=F(require("xml"),1),me=F(require("@babel/core"),1);var Ee=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],V=r=>pe.default.resolve(__dirname,`../templates/see/${r}`);function ue(r,e){return(Array.isArray(r)?r:e?[e]:[]).map(o=>/\.[A-Za-z0-9]+$/.test(o)?o:`${o}.js`)}var Z=r=>{let e=r.type;if(!Ee.includes(e))return"";let{label:n,name:o,tooltip:s="",visible:i="true",required:t="false",fixed:l="false",fold:c="false",options:a="",validate:$="",upgrade:p="false",expose:u="",algorithm:f="",merge:m="",isomeris:b="",old_name:y=""}=r,d=r.default;if(e==="table"){let g=r.keys||[];d=(r.columns||g).map(k=>Z(k)).join(`
3
+ `)}else if(e==="switchForm"||e==="division"){let g=r.children;d=g?g.map(x=>Z(x)).join(`
4
+ `):""}else{if(e==="complexSelect")return ce(r);e==="editor"?d=typeof d=="object"?[JSON.stringify(d)]:[d]:d=[d]}let N=e==="switchForm"?{default:r.default}:{},D=Q({type:e,label:n,name:o,tooltip:s,visible:i,required:t,fixed:l,fold:c,options:a,validate:$,upgrade:p,expose:u,algorithm:f,merge:m,isomeris:b,old_name:y},N),w=Object.fromEntries(Object.entries(D).filter(([g,x])=>x!==""&&x!==null&&x!==void 0)),j=(0,fe.default)({field:[{_attr:w},...Array.isArray(d)?d:[d]]});return U(j)},ye=function({system:e,type:n,name:o,appType:s,appName:i,group:t,version:l,configFileName:c="config.local",configFileNames:a,variables:$=[],description:p,scriptsType:u="python"}){let f=ue(a,c),m=M.default.readFileSync(V(`${u}/deploy.xml`)).toString();return(0,R.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:o,appName:i,appType:s,group:t,version:l,configFileName:f[0],configFileNames:f,variables:$.map(b=>Z(b)).join(`
5
+ `),description:p})},X=function(e,n){let o=`${n.scriptsType}/scripts/${e}.${n.scriptsType==="python"?"py":"sh"}`;e==="beforeInstall"&&(o=`${n.scriptsType}/scripts/${e}.sh`);let s=M.default.readFileSync(V(o)).toString();return(0,R.default)(s,{interpolate:/{{([\s\S]+?)}}/g})(n)},_=function(e,n=[]){let{code:o}=me.default.transformFileSync(e,{babelrc:!1,plugins:[function(){return{visitor:{Literal(i){if(i.parentPath.isProperty()){let t=i.parentPath.get("key").node,l=t.name;t.type==="StringLiteral"&&(t.type="Identifier",t.name=t.value,l=t.value);let c=B(n,a=>l===a.name);if(c){if(c.fullPath.includes("complexSelect")&&(c.name=c.fullName),i.isStringLiteral()){i.node.value=`$!{${c.name}}`;return}if(i.isNumericLiteral()){i.node.value=`$!{${c.name}}`;return}if(i.isBooleanLiteral()){if(i.node.type="StringLiteral",c.fullPath.includes("complexSelect")){i.node.value=`$!{${c.fullName}}`;return}i.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(i){if(i.parentPath.isProperty()){let t=B(n,l=>i.parentPath.get("key").node.name===l.name);if(t){if(t.fullPath.includes("editor")){i.node.type="StringLiteral",i.node.value=`[NO_QUOTATION_MARKS]\${${t.name}}[NO_QUOTATION_MARKS]`;return}t.fullPath.includes("complexSelect")&&(t.name=t.fullName);let l="",c=t.keys||[],a=t.columns||c;if(t.options){l=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) '$row' , #end][NO_QUOTATION_MARKS]`,i.node.type="StringLiteral",i.node.value=l;return}a&&a.length&&a.forEach(p=>{l+=`${p.name}: '$!{row.${p.name}}',`}),i.node.type="StringLiteral",i.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) {${l}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(i){if(i.parentPath.isProperty()){let t=i.parentPath.get("key").node,l=t.name;if(t){let c=B(n,a=>l===a.name);if(c){if(i.node.type="StringLiteral",c.fullPath.includes("editor")){i.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`;return}i.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return o.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},ge=function({system:e,type:n,name:o,appName:s,appType:i,version:t,group:l,configFileName:c="config.local",configFileNames:a,variables:$=[],description:p,web_app_web_service_name:u,dockerImage:f}){let m=ue(a,c),b=M.default.readFileSync(V("docker/deploy.xml")).toString();return(0,R.default)(b,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:o,appName:s,appType:i,version:t,group:l,configFileName:m[0],configFileNames:m,variables:$.map(y=>Z(y)).join(`
6
+ `),description:p,web_app_web_service_name:u,dockerImage:f})},de=function(e){let n=M.default.readFileSync(V("docker/k8s-deploy-res.yaml")).toString();return(0,R.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(e)},Se=function(e){let n=M.default.readFileSync(V("docker/Dockerfile")).toString();return(0,R.default)(n)(e)};var S="tmp";function $e(r){return typeof r=="string"?{src:r,transform:!1}:{src:r.path,transform:!!r.transform}}function he(r){return/\.js$/i.test(r)}function xe(r){return r.replace(/\.js$/i,"")}var be=function(e,n,o){let{system:s,type:i,name:t,appType:l,appName:c,group:a,version:$,template:p,variables:u=[],configName:f,outputName:m="dist",description:b,scriptsType:y,enableObfuscation:d=!1,seePackagePath:N,tplPath:D}=n;h.default.ensureDirSync(S),h.default.ensureDirSync(`${S}/scripts`),h.default.ensureDirSync(`${S}/template`);let w=!1,j=[];if(D&&Object.keys(D).length>0)for(let[O,C]of Object.entries(D)){if(O==="deploy.xml"){let{src:Pe}=$e(C);h.default.copyFileSync(Pe,`./${S}/deploy.xml`),w=!0;continue}let{src:te,transform:Ae}=$e(C),ne=`./${S}/template/${O}`;Ae&&he(O)?h.default.outputFileSync(ne,_(te,u)):h.default.copyFileSync(te,ne),j.push(O)}let g=[];j.length>0?g=j:J(m)?(g=["config.local.js"],h.default.outputFileSync(`./${S}/template/config.local.js`,p?_(p,u):"")):I(m)||I(m,t)?(g=["sysconfig.js"],h.default.outputFileSync(`./${S}/template/sysconfig.js`,p?_(p,u):"")):f&&(g=[`${f}.js`],h.default.outputFileSync(`./${S}/template/${f}.js`,p?_(p,u):""));let x=g.filter(he).map(xe),k=x[0]||(g[0]?xe(g[0]):void 0);if(d&&(y==="bash"||y==="python")){let O=Fe.default.resolve(__dirname,`../templates/see/${y}/scripts/js`);h.default.pathExistsSync(O)&&h.default.copySync(O,`./${S}/scripts/${t}/js`)}let v=ae(y);y==="python"&&(h.default.outputFileSync(`./${S}/scripts/${t}/utils.${v}`,X("utils",{scriptsType:y})),h.default.outputFileSync(`./${S}/scripts/${t}/beforeInstall.sh`,X("beforeInstall",{scriptsType:y}))),h.default.outputFileSync(`./${S}/scripts/${t}/install.${v}`,X("install",{name:t,type:i,scriptsType:y})),h.default.outputFileSync(`./${S}/scripts/${t}/afterInstall.${v}`,X("afterInstall",{name:t,scriptsType:y,configFileName:k,configFileNames:x,enableObfuscation:d})),h.default.outputFileSync(`./${S}/scripts/${t}/uninstall.${v}`,X("uninstall",{name:t,type:i,scriptsType:y})),w||h.default.outputFileSync(`./${S}/deploy.xml`,ye({system:s,type:i,name:t,appType:l,appName:c,group:a,version:$,configFileName:k,configFileNames:g,variables:u,description:b,scriptsType:y})),o?o(O=>{E(e,N,S,()=>{H.rimraf.sync(S),typeof O=="function"&&O()})}):E(e,N,S,()=>{H.rimraf.sync(S)})};var Y=F(require("path"),1),P=F(require("fs-extra"),1),ee=require("rimraf");var A="tmp",Oe=function(e,n,o){let{system:s,type:i,name:t,appType:l,appName:c,version:a,group:$,template:p,variables:u,configName:f,outputName:m,description:b,seePackagePath:y,dockerImage:d=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(Y.default.resolve(process.cwd(),"docker/Dockerfile"))||P.default.outputFileSync(Y.default.resolve(process.cwd(),"docker/Dockerfile"),Se({name:t,type:i})),P.default.ensureDirSync(`${A}/scripts`),P.default.ensureDirSync(`${A}/template`),J(m)?P.default.outputFileSync(`./${A}/template/${t}/config.local.js`,p?_(p,u):""):I(m)||I(m,t)?(f="sysconfig",P.default.outputFileSync(`./${A}/template/${t}/sysconfig.js`,p?_(p,u):"")):f&&P.default.outputFileSync(`./${A}/template/${t}/${f}.js`,p?_(p,u):""),P.default.outputFileSync(`./${A}/template/k8s-deploy-res.yaml`,de({configFileName:f})),P.default.outputFileSync(`./${A}/deploy.xml`,ge({system:s,type:i,name:t,appName:c,appType:l,version:a,group:$,configFileName:f,configFileNames:f?[f]:[],variables:u,description:b,web_app_web_service_name:`${t}-web`,dockerImage:d})),o?o(N=>{E(e,y,A,()=>{ee.rimraf.sync(A),typeof N=="function"&&N()})}):E(e,y,A,()=>{ee.rimraf.sync(A)})};var Me=process.cwd();function Re(r,e,n){let o="",s,i=r==="bizframe"?`./${n}`:`./${n}/${e}`;return T.default.existsSync(i)&&(o=T.default.readdirSync(i).find(t=>/manifest\.[0-9]+\.json/.test(t)),o&&(s=T.default.readJsonSync(`${i}/${o}`))),{manifest:o,manifestJson:s}}var Xe=function({system:e="winner-front",type:n="bizframe",name:o,appType:s,appName:i,group:t="bizframe",version:l,configName:c="config.local",outputName:a="dist",templateFunc:$,variablesFunc:p,copyFiles:u,description:f,seePackageName:m,seePackagePath:b="package",seePackageType:y="web",dockerImage:d,scriptsType:N="python",enableObfuscation:D=!1,tplPath:w={}},j){if(!o||!l)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(o=o.replace(/@/gi,"").replace(/\//gi,"-"),typeof m=="string"&&m&&(m=m.replace(/@/gi,"").replace(/\//gi,"-")),s=s||o,i=i||o,p=p||function(){try{let{variables:g}=require(Ne.default.resolve(Me,"build","package","./variables.js"));return g||[]}catch(g){return console.error(g),[]}},$=$||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${o}/sysconfig.js`},y==="docker"){Oe(m||`${e}-${o}-${l}`,{system:e,type:n,name:o,appType:s,appName:i,group:t,version:l,configName:c,outputName:a,template:$(),variables:p(),seePackagePath:b,description:f,dockerImage:d},g=>{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"),g(j)});return}be(m||`${e}-${o}-${l}`,{system:e,type:n,name:o,group:t,appType:s,appName:i,version:l,configName:c,outputName:a,template:$(),variables:p(),seePackagePath:b,description:f,scriptsType:N,enableObfuscation:D,tplPath:w},g=>{if(N==="python"){let{manifest:x,manifestJson:k}=Re(n,o,a);if(x){for(let v in k)if(k.hasOwnProperty(v)){let{path:O,dir:C}=k[v];T.default.ensureDirSync(`./tmp/source/${C}`),T.default.copyFileSync(`./${a}/${O}`,`./tmp/source/${O}`)}T.default.outputJSONSync(`./tmp/scripts/${o}/conf/${x}`,k)}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(u)&&u.length&&u.forEach(x=>{T.default.ensureFileSync(`./tmp/source/${o}/${x}`),T.default.copyFileSync(`./${a}/${o}/${x}`,`./tmp/source/${o}/${x}`)}),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${Te.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
+ `),g(j)})};0&&(module.exports={generateSeePackageZip});
package/dist/index.d.cts CHANGED
@@ -48,6 +48,10 @@ interface FieldAttributes {
48
48
  /** switchForm 和 division 类型控件的子元素数组 */
49
49
  children?: FieldAttributes[];
50
50
  }
51
+ type TplPathValue = string | {
52
+ path: string;
53
+ transform?: boolean;
54
+ };
51
55
  interface DeployOptions {
52
56
  /**
53
57
  * 系统类型, SEE 平台的分组是以系统类型字段纬度来的
@@ -141,10 +145,14 @@ interface DeployOptions {
141
145
  */
142
146
  enableObfuscation?: boolean;
143
147
  /**
144
- * 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
145
- * @default null
148
+ * 模板文件路径。key 为包内 template/ 下的文件名,value 为本地绝对路径或 `{ path, transform }`。
149
+ * - 字符串 / `{ path, transform: false }`:已编辑好的模板原样拷贝到 template/(支持 js、html 等)
150
+ * - `{ path, transform: true }`:仅对 `.js` 走 genTemplate 变量替换后再写入
151
+ * - `deploy.xml`:覆盖自动生成的 deploy.xml
152
+ * 拷贝进 template/ 的文件会登记到 deploy.xml 的 `<config>`;未提供 tplPath 配置文件时仍走 configName + templateFunc。
153
+ * @default {}
146
154
  */
147
- tplPath?: Record<string, string>;
155
+ tplPath?: Record<string, TplPathValue>;
148
156
  }
149
157
 
150
158
  /**
@@ -191,7 +199,7 @@ interface DeployOptions {
191
199
  * @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
192
200
  * @param scriptsType 脚本类型 'python' | 'bash'
193
201
  * @param enableObfuscation 是否在安装后对配置 .js 做混淆,默认 false
194
- * @param tplPath 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
202
+ * @param tplPath 模板文件。默认原样拷贝到 template/(支持已编辑好的 js/html 等);`.js` 可设 `{ path, transform: true }` 走 genTemplate;`deploy.xml` 可覆盖
195
203
  * @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
196
204
  */
197
205
  declare const generateSeePackageZip: ({ system, type, name, appType, appName, group, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackagePath, seePackageType, dockerImage, scriptsType, enableObfuscation, tplPath }: DeployOptions, cb: () => void) => void;
package/dist/index.d.ts CHANGED
@@ -48,6 +48,10 @@ interface FieldAttributes {
48
48
  /** switchForm 和 division 类型控件的子元素数组 */
49
49
  children?: FieldAttributes[];
50
50
  }
51
+ type TplPathValue = string | {
52
+ path: string;
53
+ transform?: boolean;
54
+ };
51
55
  interface DeployOptions {
52
56
  /**
53
57
  * 系统类型, SEE 平台的分组是以系统类型字段纬度来的
@@ -141,10 +145,14 @@ interface DeployOptions {
141
145
  */
142
146
  enableObfuscation?: boolean;
143
147
  /**
144
- * 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
145
- * @default null
148
+ * 模板文件路径。key 为包内 template/ 下的文件名,value 为本地绝对路径或 `{ path, transform }`。
149
+ * - 字符串 / `{ path, transform: false }`:已编辑好的模板原样拷贝到 template/(支持 js、html 等)
150
+ * - `{ path, transform: true }`:仅对 `.js` 走 genTemplate 变量替换后再写入
151
+ * - `deploy.xml`:覆盖自动生成的 deploy.xml
152
+ * 拷贝进 template/ 的文件会登记到 deploy.xml 的 `<config>`;未提供 tplPath 配置文件时仍走 configName + templateFunc。
153
+ * @default {}
146
154
  */
147
- tplPath?: Record<string, string>;
155
+ tplPath?: Record<string, TplPathValue>;
148
156
  }
149
157
 
150
158
  /**
@@ -191,7 +199,7 @@ interface DeployOptions {
191
199
  * @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
192
200
  * @param scriptsType 脚本类型 'python' | 'bash'
193
201
  * @param enableObfuscation 是否在安装后对配置 .js 做混淆,默认 false
194
- * @param tplPath 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
202
+ * @param tplPath 模板文件。默认原样拷贝到 template/(支持已编辑好的 js/html 等);`.js` 可设 `{ path, transform: true }` 走 genTemplate;`deploy.xml` 可覆盖
195
203
  * @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
196
204
  */
197
205
  declare const generateSeePackageZip: ({ system, type, name, appType, appName, group, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackagePath, seePackageType, dockerImage, scriptsType, enableObfuscation, tplPath }: DeployOptions, cb: () => void) => void;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- /** build time: Thu Jul 30 2026 11:03:48 GMT+0800 (中国标准时间), build version 4.3.9 **/
2
- var fe=Object.defineProperty;var q=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var B=(i,t,n)=>t in i?fe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,K=(i,t)=>{for(var n in t||(t={}))pe.call(t,n)&&B(i,n,t[n]);if(q)for(var n of q(t))me.call(t,n)&&B(i,n,t[n]);return i};var W=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(t,n)=>(typeof require!="undefined"?require:t)[n]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});import he from"chalk";import xe from"path";import k from"fs-extra";import $e from"path";import b from"fs-extra";import{rimraf as re}from"rimraf";import z from"path";import L from"fs-extra";import ue from"archiver";import G from"xml";var J=process.cwd(),Q=function(t){let n={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},r=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/g;return t&&t.replace?t.replace(r,function(c){return n[c]}):t},j=function(t,n){let r=n||"",c=z.resolve(J,t,r,"sysconfig.js");return L.pathExistsSync(c)},E=function(t){let n=z.resolve(J,t,"config.local.js");return L.pathExistsSync(n)},N=function(t,n,r,c){let o=z.join(J,n);n!=="/"&&L.ensureDirSync(o);let e=L.createWriteStream(`${n==="/"?".":o}/${t}.zip`);e.on("close",function(){setTimeout(function(){c&&c()})});let l=ue("zip",{zlib:{level:9}});l.on("error",function(s){console.error(),console.error(s.stack||s),s.details&&console.error(s.details)}),l.pipe(e),l.directory(r,!1),l.finalize()},C=function(t,n,r){let{type:c,label:o,name:e,tooltip:l="",visible:s="true",required:a="false",fixed:$="false",fold:f="false",options:m="",validate:d="",upgrade:p="false"}=t,A=t.default;if(r==="form"){let O=G({form:[{_attr:{name:e,tooltip:l,visible:s,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p}},n]});return Q(O)}let y=c==="complexSelect"?{default:t.default}:{},g=G({field:[{_attr:K({type:c,label:o,name:e,tooltip:l,visible:s,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p},y)},n||A]});return Q(g)},H=function(t){let r=t.children.map(c=>{let e=c.children.map(l=>C(l)).join("");return C(c,e,"form")}).join("");return C(t,r)},U=function i(t,n,r="",c=""){for(let o=0;o<t.length;o++){let e=t[o];if(e.type==="complexSelect"?(e.fullName=`${e.name}`,e.fullPath=`${e.type}`):(e.fullName=`${r===""?"":r+"."}${e.name}`,e.fullPath=`${c===""?"":c+"-"}${e.type}`),n(e))return e;if(e.children&&e.children.length>0){let l=i(e.children,n,e.fullName,e.fullPath);if(l)return l}}return null};function Y(i="python"){return i==="python"?"py":"sh"}import M from"fs-extra";import ye from"path";import R from"lodash.template";import ge from"xml";import de from"@babel/core";var Se=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],X=i=>ye.resolve(__dirname,`../templates/see/${i}`),V=i=>{let t=i.type;if(!Se.includes(t))return"";let{label:n,name:r,tooltip:c="",visible:o="true",required:e="false",fixed:l="false",fold:s="false",options:a="",validate:$="",upgrade:f="false",expose:m="",algorithm:d="",merge:p="",isomeris:A="",old_name:y=""}=i,g=i.default;if(t==="table"){let u=i.keys||[];g=(i.columns||u).map(x=>V(x)).join(`
3
- `)}else if(t==="switchForm"||t==="division"){let u=i.children;g=u?u.map(h=>V(h)).join(`
4
- `):""}else{if(t==="complexSelect")return H(i);t==="editor"?g=typeof g=="object"?[JSON.stringify(g)]:[g]:g=[g]}let O=t==="switchForm"?{default:i.default}:{},P=K({type:t,label:n,name:r,tooltip:c,visible:o,required:e,fixed:l,fold:s,options:a,validate:$,upgrade:f,expose:m,algorithm:d,merge:p,isomeris:A,old_name:y},O),v=Object.fromEntries(Object.entries(P).filter(([u,h])=>h!==""&&h!==null&&h!==void 0)),F=ge({field:[{_attr:v},...Array.isArray(g)?g:[g]]});return Q(F)},ee=function({system:t,type:n,name:r,appType:c,appName:o,group:e,version:l,configFileName:s="config.local",variables:a=[],description:$,scriptsType:f="python"}){let m=M.readFileSync(X(`${f}/deploy.xml`)).toString();return R(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:r,appName:o,appType:c,group:e,version:l,configFileName:s,variables:a.map(d=>V(d)).join(`
5
- `),description:$})},I=function(t,n){let r=`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`;t==="beforeInstall"&&(r=`${n.scriptsType}/scripts/${t}.sh`);let c=M.readFileSync(X(r)).toString();return R(c,{interpolate:/{{([\s\S]+?)}}/g})(n)},D=function(t,n=[]){let{code:r}=de.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(o){if(o.parentPath.isProperty()){let e=o.parentPath.get("key").node,l=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,l=e.value);let s=U(n,a=>l===a.name);if(s){if(s.fullPath.includes("complexSelect")&&(s.name=s.fullName),o.isStringLiteral()){o.node.value=`$!{${s.name}}`;return}if(o.isNumericLiteral()){o.node.value=`$!{${s.name}}`;return}if(o.isBooleanLiteral()){if(o.node.type="StringLiteral",s.fullPath.includes("complexSelect")){o.node.value=`$!{${s.fullName}}`;return}o.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(o){if(o.parentPath.isProperty()){let e=U(n,l=>o.parentPath.get("key").node.name===l.name);if(e){if(e.fullPath.includes("editor")){o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS]\${${e.name}}[NO_QUOTATION_MARKS]`;return}e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let l="",s=e.keys||[],a=e.columns||s;if(e.options){l=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,o.node.type="StringLiteral",o.node.value=l;return}a&&a.length&&a.forEach(f=>{l+=`${f.name}: '$!{row.${f.name}}',`}),o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${l}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(o){if(o.parentPath.isProperty()){let e=o.parentPath.get("key").node,l=e.name;if(e){let s=U(n,a=>l===a.name);if(s){if(o.node.type="StringLiteral",s.fullPath.includes("editor")){o.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}o.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return r.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},te=function({system:t,type:n,name:r,appName:c,appType:o,version:e,group:l,configFileName:s="config.local",variables:a=[],description:$,web_app_web_service_name:f,dockerImage:m}){let d=M.readFileSync(X("docker/deploy.xml")).toString();return R(d,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:r,appName:c,appType:o,version:e,group:l,configFileName:s,variables:a.map(p=>V(p)).join(`
6
- `),description:$,web_app_web_service_name:f,dockerImage:m})},ne=function(t){let n=M.readFileSync(X("docker/k8s-deploy-res.yaml")).toString();return R(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},oe=function(t){let n=M.readFileSync(X("docker/Dockerfile")).toString();return R(n)(t)};var S="tmp",ie=function(t,n,r){let{system:c,type:o,name:e,appType:l,appName:s,group:a,version:$,template:f,variables:m=[],configName:d,outputName:p="dist",description:A,scriptsType:y,enableObfuscation:g=!1,seePackagePath:O,tplPath:P}=n;b.ensureDirSync(S),b.ensureDirSync(`${S}/scripts`),b.ensureDirSync(`${S}/template`);let v=!1,F=!1;if(P&&Object.keys(P).length>0)for(let[x,w]of Object.entries(P))x==="deploy.xml"?(b.copyFileSync(w,`./${S}/deploy.xml`),v=!0):b.copyFileSync(w,`./${S}/template/${x}`),(x==="sysconfig.js"||x==="config.local.js")&&(F=!0);let u=d;if(F&&P?P["sysconfig.js"]?u="sysconfig":P["config.local.js"]&&(u="config.local"):F||(E(p)?u="config.local":(j(p)||j(p,e))&&(u="sysconfig")),g&&(y==="bash"||y==="python")){let x=$e.resolve(__dirname,`../templates/see/${y}/scripts/js`);b.pathExistsSync(x)&&b.copySync(x,`./${S}/scripts/${e}/js`)}let h=Y(y);y==="python"&&(b.outputFileSync(`./${S}/scripts/${e}/utils.${h}`,I("utils",{scriptsType:y})),b.outputFileSync(`./${S}/scripts/${e}/beforeInstall.sh`,I("beforeInstall",{scriptsType:y}))),b.outputFileSync(`./${S}/scripts/${e}/install.${h}`,I("install",{name:e,type:o,scriptsType:y})),b.outputFileSync(`./${S}/scripts/${e}/afterInstall.${h}`,I("afterInstall",{name:e,scriptsType:y,configFileName:u,enableObfuscation:g})),b.outputFileSync(`./${S}/scripts/${e}/uninstall.${h}`,I("uninstall",{name:e,type:o,scriptsType:y})),v||b.outputFileSync(`./${S}/deploy.xml`,ee({system:c,type:o,name:e,appType:l,appName:s,group:a,version:$,configFileName:u,variables:m,description:A,scriptsType:y})),F||(E(p)?b.outputFileSync(`./${S}/template/config.local.js`,f?D(f,m):""):j(p)||j(p,e)?b.outputFileSync(`./${S}/template/sysconfig.js`,f?D(f,m):""):u&&b.outputFileSync(`./${S}/template/${u}.js`,f?D(f,m):"")),r?r(x=>{N(t,O,S,()=>{re.sync(S),typeof x=="function"&&x()})}):N(t,O,S,()=>{re.sync(S)})};import le from"path";import _ from"fs-extra";import{rimraf as se}from"rimraf";var T="tmp",ce=function(t,n,r){let{system:c,type:o,name:e,appType:l,appName:s,version:a,group:$,template:f,variables:m,configName:d,outputName:p,description:A,seePackagePath:y,dockerImage:g=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;_.ensureDirSync(T),_.ensureDirSync("docker"),_.pathExistsSync(le.resolve(process.cwd(),"docker/Dockerfile"))||_.outputFileSync(le.resolve(process.cwd(),"docker/Dockerfile"),oe({name:e,type:o})),_.ensureDirSync(`${T}/scripts`),_.ensureDirSync(`${T}/template`),E(p)?_.outputFileSync(`./${T}/template/${e}/config.local.js`,f?D(f,m):""):j(p)||j(p,e)?(d="sysconfig",_.outputFileSync(`./${T}/template/${e}/sysconfig.js`,f?D(f,m):"")):d&&_.outputFileSync(`./${T}/template/${e}/${d}.js`,f?D(f,m):""),_.outputFileSync(`./${T}/template/k8s-deploy-res.yaml`,ne({configFileName:d})),_.outputFileSync(`./${T}/deploy.xml`,te({system:c,type:o,name:e,appName:s,appType:l,version:a,group:$,configFileName:d,variables:m,description:A,web_app_web_service_name:`${e}-web`,dockerImage:g})),r?r(O=>{N(t,y,T,()=>{se.sync(T),typeof O=="function"&&O()})}):N(t,y,T,()=>{se.sync(T)})};var be=process.cwd();function Oe(i,t,n){let r="",c,o=i==="bizframe"?`./${n}`:`./${n}/${t}`;return k.existsSync(o)&&(r=k.readdirSync(o).find(e=>/manifest\.[0-9]+\.json/.test(e)),r&&(c=k.readJsonSync(`${o}/${r}`))),{manifest:r,manifestJson:c}}var tt=function({system:t="winner-front",type:n="bizframe",name:r,appType:c,appName:o,group:e="bizframe",version:l,configName:s="config.local",outputName:a="dist",templateFunc:$,variablesFunc:f,copyFiles:m,description:d,seePackageName:p,seePackagePath:A="package",seePackageType:y="web",dockerImage:g,scriptsType:O="python",enableObfuscation:P=!1,tplPath:v={}},F){if(!r||!l)throw new Error("\u5E94\u7528\u540D\u79F0\u548C\u5E94\u7528\u7248\u672C\u4E0D\u80FD\u7F3A\u5931~");if(r=r.replace(/@/gi,"").replace(/\//gi,"-"),typeof p=="string"&&p&&(p=p.replace(/@/gi,"").replace(/\//gi,"-")),c=c||r,o=o||r,f=f||function(){try{let{variables:u}=W(xe.resolve(be,"build","package","./variables.js"));return u||[]}catch(u){return console.error(u),[]}},$=$||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${r}/sysconfig.js`},y==="docker"){ce(p||`${t}-${r}-${l}`,{system:t,type:n,name:r,appType:c,appName:o,group:e,version:l,configName:s,outputName:a,template:$(),variables:f(),seePackagePath:A,description:d,dockerImage:g},u=>{console.log(),console.log("docker \u5BB9\u5668\u5316\u90E8\u7F72\u7684 SEE \u53D1\u5E03\u7269\u5236\u4F5C\u5B8C\u6210\uFF0C\u60A8\u53EF\u4EE5\u5728 SEE \u5E73\u53F0\u4E0A\u4F20\u5E76\u90E8\u7F72\u5E94\u7528\u3002"),u(F)});return}ie(p||`${t}-${r}-${l}`,{system:t,type:n,name:r,group:e,appType:c,appName:o,version:l,configName:s,outputName:a,template:$(),variables:f(),seePackagePath:A,description:d,scriptsType:O,enableObfuscation:P,tplPath:v},u=>{if(O==="python"){let{manifest:h,manifestJson:x}=Oe(n,r,a);if(h){for(let w in x)if(x.hasOwnProperty(w)){let{path:Z,dir:ae}=x[w];k.ensureDirSync(`./tmp/source/${ae}`),k.copyFileSync(`./${a}/${Z}`,`./tmp/source/${Z}`)}k.outputJSONSync(`./tmp/scripts/${r}/conf/${h}`,x)}else k.ensureDirSync("./tmp/source"),k.copySync(`./${a}`,"./tmp/source")}else k.ensureDirSync("./tmp/source"),k.copySync(`./${a}`,"./tmp/source");Array.isArray(m)&&m.length&&m.forEach(h=>{k.ensureFileSync(`./tmp/source/${r}/${h}`),k.copyFileSync(`./${a}/${r}/${h}`,`./tmp/source/${r}/${h}`)}),console.log(),console.log(`\u53D1\u5E03\u7269\u5236\u4F5C\u5B8C\u6210\uFF0C\u60A8\u53EF\u4EE5\u5728 SEE \u5E73\u53F0\u4E0A\u4F20\u5E76\u90E8\u7F72\u5E94\u7528\u3002\u6CE8\u610F\uFF1A${he.yellow("\u5B50\u7CFB\u7EDF\u53D1\u5E03\u7269\u7684\u5B89\u88C5\u76EE\u5F55\u9700\u8981\u6307\u5B9A\u5230\u5177\u4F53\u7684\u5E94\u7528\u76EE\u5F55")}\u3002\u6BD4\u5982/home/hsiar/hsiar-green/html/\u3002
7
- `),u(F)})};export{tt as generateSeePackageZip};
1
+ /** build time: Thu Sep 10 2026 09:45:58 GMT+0800 (中国标准时间), build version 4.3.11 **/
2
+ var $e=Object.defineProperty;var G=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable;var H=(o,t,n)=>t in o?$e(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,L=(o,t)=>{for(var n in t||(t={}))he.call(t,n)&&H(o,n,t[n]);if(G)for(var n of G(t))xe.call(t,n)&&H(o,n,t[n]);return o};var Y=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(t,n)=>(typeof require!="undefined"?require:t)[n]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});import Pe from"chalk";import ke from"path";import N from"fs-extra";import Ae from"path";import h from"fs-extra";import{rimraf as ce}from"rimraf";import B from"path";import V from"fs-extra";import Fe from"archiver";import ee from"xml";var Z=process.cwd(),C=function(t){let n={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},i=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/g;return t&&t.replace?t.replace(i,function(c){return n[c]}):t},w=function(t,n){let i=n||"",c=B.resolve(Z,t,i,"sysconfig.js");return V.pathExistsSync(c)},Q=function(t){let n=B.resolve(Z,t,"config.local.js");return V.pathExistsSync(n)},I=function(t,n,i,c){let r=B.join(Z,n);n!=="/"&&V.ensureDirSync(r);let e=V.createWriteStream(`${n==="/"?".":r}/${t}.zip`);e.on("close",function(){setTimeout(function(){c&&c()})});let s=Fe("zip",{zlib:{level:9}});s.on("error",function(l){console.error(),console.error(l.stack||l),l.details&&console.error(l.details)}),s.pipe(e),s.directory(i,!1),s.finalize()},J=function(t,n,i){let{type:c,label:r,name:e,tooltip:s="",visible:l="true",required:a="false",fixed:$="false",fold:p="false",options:u="",validate:f="",upgrade:m="false"}=t,F=t.default;if(i==="form"){let O=ee({form:[{_attr:{name:e,tooltip:s,visible:l,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m}},n]});return C(O)}let y=c==="complexSelect"?{default:t.default}:{},d=ee({field:[{_attr:L({type:c,label:r,name:e,tooltip:s,visible:l,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m},y)},n||F]});return C(d)},te=function(t){let i=t.children.map(c=>{let e=c.children.map(s=>J(s)).join("");return J(c,e,"form")}).join("");return J(t,i)},U=function o(t,n,i="",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=`${i===""?"":i+"."}${e.name}`,e.fullPath=`${c===""?"":c+"-"}${e.type}`),n(e))return e;if(e.children&&e.children.length>0){let s=o(e.children,n,e.fullName,e.fullPath);if(s)return s}}return null};function ne(o="python"){return o==="python"?"py":"sh"}import M from"fs-extra";import be from"path";import R from"lodash.template";import Oe from"xml";import Te from"@babel/core";var Ne=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],X=o=>be.resolve(__dirname,`../templates/see/${o}`);function re(o,t){return(Array.isArray(o)?o:t?[t]:[]).map(i=>/\.[A-Za-z0-9]+$/.test(i)?i:`${i}.js`)}var z=o=>{let t=o.type;if(!Ne.includes(t))return"";let{label:n,name:i,tooltip:c="",visible:r="true",required:e="false",fixed:s="false",fold:l="false",options:a="",validate:$="",upgrade:p="false",expose:u="",algorithm:f="",merge:m="",isomeris:F="",old_name:y=""}=o,d=o.default;if(t==="table"){let g=o.keys||[];d=(o.columns||g).map(P=>z(P)).join(`
3
+ `)}else if(t==="switchForm"||t==="division"){let g=o.children;d=g?g.map(x=>z(x)).join(`
4
+ `):""}else{if(t==="complexSelect")return te(o);t==="editor"?d=typeof d=="object"?[JSON.stringify(d)]:[d]:d=[d]}let O=t==="switchForm"?{default:o.default}:{},j=L({type:t,label:n,name:i,tooltip:c,visible:r,required:e,fixed:s,fold:l,options:a,validate:$,upgrade:p,expose:u,algorithm:f,merge:m,isomeris:F,old_name:y},O),v=Object.fromEntries(Object.entries(j).filter(([g,x])=>x!==""&&x!==null&&x!==void 0)),_=Oe({field:[{_attr:v},...Array.isArray(d)?d:[d]]});return C(_)},oe=function({system:t,type:n,name:i,appType:c,appName:r,group:e,version:s,configFileName:l="config.local",configFileNames:a,variables:$=[],description:p,scriptsType:u="python"}){let f=re(a,l),m=M.readFileSync(X(`${u}/deploy.xml`)).toString();return R(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:i,appName:r,appType:c,group:e,version:s,configFileName:f[0],configFileNames:f,variables:$.map(F=>z(F)).join(`
5
+ `),description:p})},E=function(t,n){let i=`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`;t==="beforeInstall"&&(i=`${n.scriptsType}/scripts/${t}.sh`);let c=M.readFileSync(X(i)).toString();return R(c,{interpolate:/{{([\s\S]+?)}}/g})(n)},k=function(t,n=[]){let{code:i}=Te.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=U(n,a=>s===a.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=U(n,s=>r.parentPath.get("key").node.name===s.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 s="",l=e.keys||[],a=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}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 $${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=U(n,a=>s===a.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 i.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},ie=function({system:t,type:n,name:i,appName:c,appType:r,version:e,group:s,configFileName:l="config.local",configFileNames:a,variables:$=[],description:p,web_app_web_service_name:u,dockerImage:f}){let m=re(a,l),F=M.readFileSync(X("docker/deploy.xml")).toString();return R(F,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:i,appName:c,appType:r,version:e,group:s,configFileName:m[0],configFileNames:m,variables:$.map(y=>z(y)).join(`
6
+ `),description:p,web_app_web_service_name:u,dockerImage:f})},se=function(t){let n=M.readFileSync(X("docker/k8s-deploy-res.yaml")).toString();return R(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},le=function(t){let n=M.readFileSync(X("docker/Dockerfile")).toString();return R(n)(t)};var S="tmp";function ae(o){return typeof o=="string"?{src:o,transform:!1}:{src:o.path,transform:!!o.transform}}function pe(o){return/\.js$/i.test(o)}function fe(o){return o.replace(/\.js$/i,"")}var me=function(t,n,i){let{system:c,type:r,name:e,appType:s,appName:l,group:a,version:$,template:p,variables:u=[],configName:f,outputName:m="dist",description:F,scriptsType:y,enableObfuscation:d=!1,seePackagePath:O,tplPath:j}=n;h.ensureDirSync(S),h.ensureDirSync(`${S}/scripts`),h.ensureDirSync(`${S}/template`);let v=!1,_=[];if(j&&Object.keys(j).length>0)for(let[b,K]of Object.entries(j)){if(b==="deploy.xml"){let{src:Se}=ae(K);h.copyFileSync(Se,`./${S}/deploy.xml`),v=!0;continue}let{src:q,transform:de}=ae(K),W=`./${S}/template/${b}`;de&&pe(b)?h.outputFileSync(W,k(q,u)):h.copyFileSync(q,W),_.push(b)}let g=[];_.length>0?g=_:Q(m)?(g=["config.local.js"],h.outputFileSync(`./${S}/template/config.local.js`,p?k(p,u):"")):w(m)||w(m,e)?(g=["sysconfig.js"],h.outputFileSync(`./${S}/template/sysconfig.js`,p?k(p,u):"")):f&&(g=[`${f}.js`],h.outputFileSync(`./${S}/template/${f}.js`,p?k(p,u):""));let x=g.filter(pe).map(fe),P=x[0]||(g[0]?fe(g[0]):void 0);if(d&&(y==="bash"||y==="python")){let b=Ae.resolve(__dirname,`../templates/see/${y}/scripts/js`);h.pathExistsSync(b)&&h.copySync(b,`./${S}/scripts/${e}/js`)}let D=ne(y);y==="python"&&(h.outputFileSync(`./${S}/scripts/${e}/utils.${D}`,E("utils",{scriptsType:y})),h.outputFileSync(`./${S}/scripts/${e}/beforeInstall.sh`,E("beforeInstall",{scriptsType:y}))),h.outputFileSync(`./${S}/scripts/${e}/install.${D}`,E("install",{name:e,type:r,scriptsType:y})),h.outputFileSync(`./${S}/scripts/${e}/afterInstall.${D}`,E("afterInstall",{name:e,scriptsType:y,configFileName:P,configFileNames:x,enableObfuscation:d})),h.outputFileSync(`./${S}/scripts/${e}/uninstall.${D}`,E("uninstall",{name:e,type:r,scriptsType:y})),v||h.outputFileSync(`./${S}/deploy.xml`,oe({system:c,type:r,name:e,appType:s,appName:l,group:a,version:$,configFileName:P,configFileNames:g,variables:u,description:F,scriptsType:y})),i?i(b=>{I(t,O,S,()=>{ce.sync(S),typeof b=="function"&&b()})}):I(t,O,S,()=>{ce.sync(S)})};import ue from"path";import A from"fs-extra";import{rimraf as ye}from"rimraf";var T="tmp",ge=function(t,n,i){let{system:c,type:r,name:e,appType:s,appName:l,version:a,group:$,template:p,variables:u,configName:f,outputName:m,description:F,seePackagePath:y,dockerImage:d=a.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;A.ensureDirSync(T),A.ensureDirSync("docker"),A.pathExistsSync(ue.resolve(process.cwd(),"docker/Dockerfile"))||A.outputFileSync(ue.resolve(process.cwd(),"docker/Dockerfile"),le({name:e,type:r})),A.ensureDirSync(`${T}/scripts`),A.ensureDirSync(`${T}/template`),Q(m)?A.outputFileSync(`./${T}/template/${e}/config.local.js`,p?k(p,u):""):w(m)||w(m,e)?(f="sysconfig",A.outputFileSync(`./${T}/template/${e}/sysconfig.js`,p?k(p,u):"")):f&&A.outputFileSync(`./${T}/template/${e}/${f}.js`,p?k(p,u):""),A.outputFileSync(`./${T}/template/k8s-deploy-res.yaml`,se({configFileName:f})),A.outputFileSync(`./${T}/deploy.xml`,ie({system:c,type:r,name:e,appName:l,appType:s,version:a,group:$,configFileName:f,configFileNames:f?[f]:[],variables:u,description:F,web_app_web_service_name:`${e}-web`,dockerImage:d})),i?i(O=>{I(t,y,T,()=>{ye.sync(T),typeof O=="function"&&O()})}):I(t,y,T,()=>{ye.sync(T)})};var _e=process.cwd();function je(o,t,n){let i="",c,r=o==="bizframe"?`./${n}`:`./${n}/${t}`;return N.existsSync(r)&&(i=N.readdirSync(r).find(e=>/manifest\.[0-9]+\.json/.test(e)),i&&(c=N.readJsonSync(`${r}/${i}`))),{manifest:i,manifestJson:c}}var at=function({system:t="winner-front",type:n="bizframe",name:i,appType:c,appName:r,group:e="bizframe",version:s,configName:l="config.local",outputName:a="dist",templateFunc:$,variablesFunc:p,copyFiles:u,description:f,seePackageName:m,seePackagePath:F="package",seePackageType:y="web",dockerImage:d,scriptsType:O="python",enableObfuscation:j=!1,tplPath:v={}},_){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 m=="string"&&m&&(m=m.replace(/@/gi,"").replace(/\//gi,"-")),c=c||i,r=r||i,p=p||function(){try{let{variables:g}=Y(ke.resolve(_e,"build","package","./variables.js"));return g||[]}catch(g){return console.error(g),[]}},$=$||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${i}/sysconfig.js`},y==="docker"){ge(m||`${t}-${i}-${s}`,{system:t,type:n,name:i,appType:c,appName:r,group:e,version:s,configName:l,outputName:a,template:$(),variables:p(),seePackagePath:F,description:f,dockerImage:d},g=>{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"),g(_)});return}me(m||`${t}-${i}-${s}`,{system:t,type:n,name:i,group:e,appType:c,appName:r,version:s,configName:l,outputName:a,template:$(),variables:p(),seePackagePath:F,description:f,scriptsType:O,enableObfuscation:j,tplPath:v},g=>{if(O==="python"){let{manifest:x,manifestJson:P}=je(n,i,a);if(x){for(let D in P)if(P.hasOwnProperty(D)){let{path:b,dir:K}=P[D];N.ensureDirSync(`./tmp/source/${K}`),N.copyFileSync(`./${a}/${b}`,`./tmp/source/${b}`)}N.outputJSONSync(`./tmp/scripts/${i}/conf/${x}`,P)}else N.ensureDirSync("./tmp/source"),N.copySync(`./${a}`,"./tmp/source")}else N.ensureDirSync("./tmp/source"),N.copySync(`./${a}`,"./tmp/source");Array.isArray(u)&&u.length&&u.forEach(x=>{N.ensureFileSync(`./tmp/source/${i}/${x}`),N.copyFileSync(`./${a}/${i}/${x}`,`./tmp/source/${i}/${x}`)}),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${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
+ `),g(_)})};export{at as generateSeePackageZip};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winner-fed/winner-deploy",
3
- "version": "4.3.9",
3
+ "version": "4.3.11",
4
4
  "description": "Generate a publication deployed by the See platform",
5
5
  "keywords": [
6
6
  "winner",
@@ -36,9 +36,9 @@
36
36
  <% } %>
37
37
  {{ variables }}
38
38
  </variables>
39
- <% if (configFileName) { %>
40
- <config path="./${webAppName}/{{ configFileName }}.js" encoding="UTF-8"/>
41
- <% } %>
39
+ <% configFileNames.forEach(function (cf) { %>
40
+ <config path="./${webAppName}/<% print(cf) %>" encoding="UTF-8"/>
41
+ <% }) %>
42
42
  <config path="./scripts/{{ name }}/install.sh" encoding="UTF-8"/>
43
43
  <config path="./scripts/{{ name }}/afterInstall.sh" encoding="UTF-8"/>
44
44
  <config path="./scripts/{{ name }}/uninstall.sh" encoding="UTF-8"/>
@@ -28,22 +28,29 @@ fi
28
28
  echo -e "${CHECK_ICON} 成功: 应用目录 '${webAppName}' 已找到且不为空。"
29
29
  echo -e "${CHECK_ICON} 安装验证通过。"
30
30
 
31
- <% if (enableObfuscation) { %>
31
+ <% if (enableObfuscation && configFileNames && configFileNames.length) { %>
32
32
  # 混淆配置文件:优先 node(javascript-obfuscator),无 node 时回退 bash 轻量混淆
33
33
  echo -e "${CHECK_ICON} 开始混淆配置文件..."
34
34
  pkg_root=`pwd`
35
35
  cd "$(dirname "$0")"
36
+ use_node=0
36
37
  if command -v node >/dev/null 2>&1; then
38
+ use_node=1
37
39
  echo -e "${INFO_ICON} 检测到 node,使用 confuse.js 强混淆"
38
- node ./js/confuse.js "${webAppName}" "{{configFileName}}" "$pkg_root"
39
40
  else
40
41
  echo -e "${WARNING_ICON} 未检测到 node,使用 confuse.sh 轻量混淆(强度较弱)"
41
- bash ./js/confuse.sh "${webAppName}" "{{configFileName}}" "$pkg_root"
42
+ fi
43
+ <% configFileNames.forEach(function (cf) { %>
44
+ if [ "$use_node" -eq 1 ]; then
45
+ node ./js/confuse.js "${webAppName}" "<% print(cf) %>" "$pkg_root"
46
+ else
47
+ bash ./js/confuse.sh "${webAppName}" "<% print(cf) %>" "$pkg_root"
42
48
  fi
43
49
  if [ $? -ne 0 ]; then
44
- echo -e "${ERROR_ICON} 错误: 混淆配置文件失败。" >&2
50
+ echo -e "${ERROR_ICON} 错误: 混淆配置文件失败 (<% print(cf) %>).js。" >&2
45
51
  exit 1
46
52
  fi
53
+ <% }) %>
47
54
 
48
55
  echo -e "${CHECK_ICON} 成功: 混淆配置文件完成。"
49
56
  <% } %>
@@ -39,9 +39,9 @@
39
39
  {{ variables }}
40
40
 
41
41
  </variables>
42
- <% if (configFileName) { %>
43
- <config path="./{{ name }}/{{ configFileName }}.js" encoding="UTF-8"/>
44
- <% } %>
42
+ <% configFileNames.forEach(function (cf) { %>
43
+ <config path="./{{ name }}/<% print(cf) %>" encoding="UTF-8"/>
44
+ <% }) %>
45
45
  <config reference="" encoding="utf-8" path="./k8s-deploy-res.yaml" />
46
46
  <node describe="节点私有配置信息" />
47
47
  </system>
@@ -37,9 +37,9 @@
37
37
  {{ variables }}
38
38
 
39
39
  </variables>
40
- <% if (configFileName) { %>
41
- <config path="./${webAppName}/{{ configFileName }}.js" encoding="UTF-8"/>
42
- <% } %>
40
+ <% configFileNames.forEach(function (cf) { %>
41
+ <config path="./${webAppName}/<% print(cf) %>" encoding="UTF-8"/>
42
+ <% }) %>
43
43
  <config path="./scripts/{{ name }}/install.py" encoding="UTF-8"/>
44
44
  <config path="./scripts/{{ name }}/afterInstall.py" encoding="UTF-8"/>
45
45
  <config path="./scripts/{{ name }}/uninstall.py" encoding="UTF-8"/>
@@ -32,12 +32,12 @@ if len(os.listdir(webAppName)) == 0:
32
32
 
33
33
  chmodPkg()
34
34
 
35
- <% if (enableObfuscation) { %>
35
+ <% if (enableObfuscation && configFileNames && configFileNames.length) { %>
36
36
  import subprocess
37
37
  script_dir = os.path.dirname(os.path.abspath(__file__))
38
38
  confuse_js = os.path.normpath(os.path.join(script_dir, 'js', 'confuse.js'))
39
39
  confuse_sh = os.path.normpath(os.path.join(script_dir, 'js', 'confuse.sh'))
40
- config_name = '{{configFileName}}'
40
+ config_names = [<% configFileNames.forEach(function (cf, i) { %>'<% print(cf) %>'<% if (i < configFileNames.length - 1) { %>, <% } %><% }) %>]
41
41
 
42
42
  def which(cmd):
43
43
  for p in os.environ.get('PATH', '').split(os.pathsep):
@@ -46,12 +46,13 @@ def which(cmd):
46
46
  return f
47
47
  return None
48
48
 
49
- if which('node'):
50
- cmd = ['node', confuse_js, webAppName, config_name, pkg_root]
51
- else:
52
- cmd = ['bash', confuse_sh, webAppName, config_name, pkg_root]
53
- ret = subprocess.call(cmd)
54
- if ret != 0:
55
- sys.stderr.write("错误: 混淆配置文件失败。\n")
56
- sys.exit(ret)
49
+ for config_name in config_names:
50
+ if which('node'):
51
+ cmd = ['node', confuse_js, webAppName, config_name, pkg_root]
52
+ else:
53
+ cmd = ['bash', confuse_sh, webAppName, config_name, pkg_root]
54
+ ret = subprocess.call(cmd)
55
+ if ret != 0:
56
+ sys.stderr.write("错误: 混淆配置文件失败 (%s.js)。\n" % config_name)
57
+ sys.exit(ret)
57
58
  <% } %>