@winner-fed/winner-deploy 4.3.10 → 4.3.12

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>` | `{}` | 否 | 多模板入口。`deploy.xml` 覆盖自动生成;`*.js` 经变量解析写入 `template/` 并登记为多条 `<config>`;其他文件原样进 `template/`。未提供任何 `*.js` 时仍走 `configName` + `templateFunc` 单文件逻辑 |
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,18 +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', // 覆盖自动生成的 deploy.xml
149
- 'config.local.js': '/abs/path/config.local.js', // 变量解析 + 登记 <config>
150
- 'logo.js': '/abs/path/logo.js' // 同上,可多个 .js
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'),
151
159
  };
152
160
  ```
153
161
 
154
- - `*.js`:经 `genTemplate` 做 SEE 变量替换后写入 `template/`,并在 `deploy.xml` 中各生成一条 `<config>`;`enableObfuscation` 时 `afterInstall` 会逐个混淆。
162
+ - 字符串 / `{ path, transform: false }`:原样拷贝到 `template/`(js、html 等均可)。
163
+ - `{ path, transform: true }`:仅对 `.js` 调用 `genTemplate` 后再写入。
155
164
  - `deploy.xml`:原样覆盖包内 deploy.xml。
156
- - 其他 key:原样拷贝到 `template/`。
157
- - 若 `tplPath` 中没有任何 `*.js`,仍使用 `configName` + `templateFunc` 生成单个配置文件。
165
+ - 进入 `template/` 的文件会写入 `deploy.xml` 的 `<config>`;其中 `.js` 在 `enableObfuscation` 时由 `afterInstall` 混淆。
166
+ - 若未通过 `tplPath` 放入任何配置文件,仍使用 `configName` + `templateFunc` 生成单个配置。
158
167
 
159
168
  #### copyFiles 说明
160
169
 
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- /** build time: Mon Sep 07 2026 09:05:55 GMT+0800 (中国标准时间), build version 4.3.10 **/
2
- var xe=Object.create;var K=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames,ee=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable;var te=(r,e,n)=>e in r?K(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,U=(r,e)=>{for(var n in e||(e={}))ne.call(e,n)&&te(r,n,e[n]);if(ee)for(var n of ee(e))Ae.call(e,n)&&te(r,n,e[n]);return r};var Te=(r,e)=>{for(var n in e)K(r,n,{get:e[n],enumerable:!0})},re=(r,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Oe(e))!ne.call(r,l)&&l!==n&&K(r,l,{get:()=>e[l],enumerable:!(i=be(e,l))||i.enumerable});return r};var b=(r,e,n)=>(n=r!=null?xe(Fe(r)):{},re(e||!r||!r.__esModule?K(n,"default",{value:r,enumerable:!0}):n,r)),ke=r=>re(K({},"__esModule",{value:!0}),r);var Ie={};Te(Ie,{generateSeePackageZip:()=>je});module.exports=ke(Ie);var Se=b(require("chalk"),1),$e=b(require("path"),1),A=b(require("fs-extra"),1);var ye=b(require("path"),1),h=b(require("fs-extra"),1),G=require("rimraf");var V=b(require("path"),1),L=b(require("fs-extra"),1),oe=b(require("archiver"),1),q=b(require("xml"),1);var B=process.cwd(),C=function(e){let n={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},i=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/g;return e&&e.replace?e.replace(i,function(l){return n[l]}):e},w=function(e,n){let i=n||"",l=V.default.resolve(B,e,i,"sysconfig.js");return L.default.pathExistsSync(l)},J=function(e){let n=V.default.resolve(B,e,"config.local.js");return L.default.pathExistsSync(n)},E=function(e,n,i,l){let o=V.default.join(B,n);n!=="/"&&L.default.ensureDirSync(o);let t=L.default.createWriteStream(`${n==="/"?".":o}/${e}.zip`);t.on("close",function(){setTimeout(function(){l&&l()})});let s=(0,oe.default)("zip",{zlib:{level:9}});s.on("error",function(c){console.error(),console.error(c.stack||c),c.details&&console.error(c.details)}),s.pipe(t),s.directory(i,!1),s.finalize()},Z=function(e,n,i){let{type:l,label:o,name:t,tooltip:s="",visible:c="true",required:a="false",fixed:$="false",fold:p="false",options:u="",validate:f="",upgrade:m="false"}=e,O=e.default;if(i==="form"){let T=(0,q.default)({form:[{_attr:{name:t,tooltip:s,visible:c,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m}},n]});return C(T)}let y=l==="complexSelect"?{default:e.default}:{},d=(0,q.default)({field:[{_attr:U({type:l,label:o,name:t,tooltip:s,visible:c,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m},y)},n||O]});return C(d)},ie=function(e){let i=e.children.map(l=>{let t=l.children.map(s=>Z(s)).join("");return Z(l,t,"form")}).join("");return Z(e,i)},z=function r(e,n,i="",l=""){for(let o=0;o<e.length;o++){let t=e[o];if(t.type==="complexSelect"?(t.fullName=`${t.name}`,t.fullPath=`${t.type}`):(t.fullName=`${i===""?"":i+"."}${t.name}`,t.fullPath=`${l===""?"":l+"-"}${t.type}`),n(t))return t;if(t.children&&t.children.length>0){let s=r(t.children,n,t.fullName,t.fullPath);if(s)return s}}return null};function le(r="python"){return r==="python"?"py":"sh"}var M=b(require("fs-extra"),1),se=b(require("path"),1),R=b(require("lodash.template"),1),ce=b(require("xml"),1),ae=b(require("@babel/core"),1);var _e=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],Q=r=>se.default.resolve(__dirname,`../templates/see/${r}`),W=r=>{let e=r.type;if(!_e.includes(e))return"";let{label:n,name:i,tooltip:l="",visible:o="true",required:t="false",fixed:s="false",fold:c="false",options:a="",validate:$="",upgrade:p="false",expose:u="",algorithm:f="",merge:m="",isomeris:O="",old_name:y=""}=r,d=r.default;if(e==="table"){let g=r.keys||[];d=(r.columns||g).map(P=>W(P)).join(`
3
- `)}else if(e==="switchForm"||e==="division"){let g=r.children;d=g?g.map(x=>W(x)).join(`
4
- `):""}else{if(e==="complexSelect")return ie(r);e==="editor"?d=typeof d=="object"?[JSON.stringify(d)]:[d]:d=[d]}let T=e==="switchForm"?{default:r.default}:{},D=U({type:e,label:n,name:i,tooltip:l,visible:o,required:t,fixed:s,fold:c,options:a,validate:$,upgrade:p,expose:u,algorithm:f,merge:m,isomeris:O,old_name:y},T),j=Object.fromEntries(Object.entries(D).filter(([g,x])=>x!==""&&x!==null&&x!==void 0)),v=(0,ce.default)({field:[{_attr:j},...Array.isArray(d)?d:[d]]});return C(v)},pe=function({system:e,type:n,name:i,appType:l,appName:o,group:t,version:s,configFileName:c="config.local",configFileNames:a,variables:$=[],description:p,scriptsType:u="python"}){let f=Array.isArray(a)?a:c?[c]:[],m=M.default.readFileSync(Q(`${u}/deploy.xml`)).toString();return(0,R.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:o,appType:l,group:t,version:s,configFileName:f[0],configFileNames:f,variables:$.map(O=>W(O)).join(`
5
- `),description:p})},X=function(e,n){let i=`${n.scriptsType}/scripts/${e}.${n.scriptsType==="python"?"py":"sh"}`;e==="beforeInstall"&&(i=`${n.scriptsType}/scripts/${e}.sh`);let l=M.default.readFileSync(Q(i)).toString();return(0,R.default)(l,{interpolate:/{{([\s\S]+?)}}/g})(n)},N=function(e,n=[]){let{code:i}=ae.default.transformFileSync(e,{babelrc:!1,plugins:[function(){return{visitor:{Literal(o){if(o.parentPath.isProperty()){let t=o.parentPath.get("key").node,s=t.name;t.type==="StringLiteral"&&(t.type="Identifier",t.name=t.value,s=t.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 t=z(n,s=>o.parentPath.get("key").node.name===s.name);if(t){if(t.fullPath.includes("editor")){o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS]\${${t.name}}[NO_QUOTATION_MARKS]`;return}t.fullPath.includes("complexSelect")&&(t.name=t.fullName);let s="",c=t.keys||[],a=t.columns||c;if(t.options){s=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) '$row' , #end][NO_QUOTATION_MARKS]`,o.node.type="StringLiteral",o.node.value=s;return}a&&a.length&&a.forEach(p=>{s+=`${p.name}: '$!{row.${p.name}}',`}),o.node.type="StringLiteral",o.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) {${s}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(o){if(o.parentPath.isProperty()){let t=o.parentPath.get("key").node,s=t.name;if(t){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")},fe=function({system:e,type:n,name:i,appName:l,appType:o,version:t,group:s,configFileName:c="config.local",configFileNames:a,variables:$=[],description:p,web_app_web_service_name:u,dockerImage:f}){let m=Array.isArray(a)?a:c?[c]:[],O=M.default.readFileSync(Q("docker/deploy.xml")).toString();return(0,R.default)(O,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:l,appType:o,version:t,group:s,configFileName:m[0],configFileNames:m,variables:$.map(y=>W(y)).join(`
6
- `),description:p,web_app_web_service_name:u,dockerImage:f})},me=function(e){let n=M.default.readFileSync(Q("docker/k8s-deploy-res.yaml")).toString();return(0,R.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(e)},ue=function(e){let n=M.default.readFileSync(Q("docker/Dockerfile")).toString();return(0,R.default)(n)(e)};var S="tmp";function Pe(r){return r.endsWith(".js")}function Ne(r){return r.replace(/\.js$/i,"")}var ge=function(e,n,i){let{system:l,type:o,name:t,appType:s,appName:c,group:a,version:$,template:p,variables:u=[],configName:f,outputName:m="dist",description:O,scriptsType:y,enableObfuscation:d=!1,seePackagePath:T,tplPath:D}=n;h.default.ensureDirSync(S),h.default.ensureDirSync(`${S}/scripts`),h.default.ensureDirSync(`${S}/template`);let j=!1,v=[];if(D&&Object.keys(D).length>0)for(let[F,I]of Object.entries(D)){if(F==="deploy.xml"){h.default.copyFileSync(I,`./${S}/deploy.xml`),j=!0;continue}if(Pe(F)){h.default.outputFileSync(`./${S}/template/${F}`,N(I,u)),v.push(Ne(F));continue}h.default.copyFileSync(I,`./${S}/template/${F}`)}let g=[];v.length>0?g=v:J(m)?(g=["config.local"],h.default.outputFileSync(`./${S}/template/config.local.js`,p?N(p,u):"")):w(m)||w(m,t)?(g=["sysconfig"],h.default.outputFileSync(`./${S}/template/sysconfig.js`,p?N(p,u):"")):f&&(g=[f],h.default.outputFileSync(`./${S}/template/${f}.js`,p?N(p,u):""));let x=g[0];if(d&&(y==="bash"||y==="python")){let F=ye.default.resolve(__dirname,`../templates/see/${y}/scripts/js`);h.default.pathExistsSync(F)&&h.default.copySync(F,`./${S}/scripts/${t}/js`)}let P=le(y);y==="python"&&(h.default.outputFileSync(`./${S}/scripts/${t}/utils.${P}`,X("utils",{scriptsType:y})),h.default.outputFileSync(`./${S}/scripts/${t}/beforeInstall.sh`,X("beforeInstall",{scriptsType:y}))),h.default.outputFileSync(`./${S}/scripts/${t}/install.${P}`,X("install",{name:t,type:o,scriptsType:y})),h.default.outputFileSync(`./${S}/scripts/${t}/afterInstall.${P}`,X("afterInstall",{name:t,scriptsType:y,configFileName:x,configFileNames:g,enableObfuscation:d})),h.default.outputFileSync(`./${S}/scripts/${t}/uninstall.${P}`,X("uninstall",{name:t,type:o,scriptsType:y})),j||h.default.outputFileSync(`./${S}/deploy.xml`,pe({system:l,type:o,name:t,appType:s,appName:c,group:a,version:$,configFileName:x,configFileNames:g,variables:u,description:O,scriptsType:y})),i?i(F=>{E(e,T,S,()=>{G.rimraf.sync(S),typeof F=="function"&&F()})}):E(e,T,S,()=>{G.rimraf.sync(S)})};var H=b(require("path"),1),_=b(require("fs-extra"),1),Y=require("rimraf");var k="tmp",de=function(e,n,i){let{system:l,type:o,name:t,appType:s,appName:c,version:a,group:$,template:p,variables:u,configName:f,outputName:m,description:O,seePackagePath:y,dockerImage:d=a.indexOf("-")>0?`isee1.0-docker-dev-local/${t}`:`isee1.0-docker-release-local/${t}`}=n;_.default.ensureDirSync(k),_.default.ensureDirSync("docker"),_.default.pathExistsSync(H.default.resolve(process.cwd(),"docker/Dockerfile"))||_.default.outputFileSync(H.default.resolve(process.cwd(),"docker/Dockerfile"),ue({name:t,type:o})),_.default.ensureDirSync(`${k}/scripts`),_.default.ensureDirSync(`${k}/template`),J(m)?_.default.outputFileSync(`./${k}/template/${t}/config.local.js`,p?N(p,u):""):w(m)||w(m,t)?(f="sysconfig",_.default.outputFileSync(`./${k}/template/${t}/sysconfig.js`,p?N(p,u):"")):f&&_.default.outputFileSync(`./${k}/template/${t}/${f}.js`,p?N(p,u):""),_.default.outputFileSync(`./${k}/template/k8s-deploy-res.yaml`,me({configFileName:f})),_.default.outputFileSync(`./${k}/deploy.xml`,fe({system:l,type:o,name:t,appName:c,appType:s,version:a,group:$,configFileName:f,configFileNames:f?[f]:[],variables:u,description:O,web_app_web_service_name:`${t}-web`,dockerImage:d})),i?i(T=>{E(e,y,k,()=>{Y.rimraf.sync(k),typeof T=="function"&&T()})}):E(e,y,k,()=>{Y.rimraf.sync(k)})};var ve=process.cwd();function De(r,e,n){let i="",l,o=r==="bizframe"?`./${n}`:`./${n}/${e}`;return A.default.existsSync(o)&&(i=A.default.readdirSync(o).find(t=>/manifest\.[0-9]+\.json/.test(t)),i&&(l=A.default.readJsonSync(`${o}/${i}`))),{manifest:i,manifestJson:l}}var je=function({system:e="winner-front",type:n="bizframe",name:i,appType:l,appName:o,group:t="bizframe",version:s,configName:c="config.local",outputName:a="dist",templateFunc:$,variablesFunc:p,copyFiles:u,description:f,seePackageName:m,seePackagePath:O="package",seePackageType:y="web",dockerImage:d,scriptsType:T="python",enableObfuscation:D=!1,tplPath:j={}},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,"-")),l=l||i,o=o||i,p=p||function(){try{let{variables:g}=require($e.default.resolve(ve,"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"){de(m||`${e}-${i}-${s}`,{system:e,type:n,name:i,appType:l,appName:o,group:t,version:s,configName:c,outputName:a,template:$(),variables:p(),seePackagePath:O,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(v)});return}ge(m||`${e}-${i}-${s}`,{system:e,type:n,name:i,group:t,appType:l,appName:o,version:s,configName:c,outputName:a,template:$(),variables:p(),seePackagePath:O,description:f,scriptsType:T,enableObfuscation:D,tplPath:j},g=>{if(T==="python"){let{manifest:x,manifestJson:P}=De(n,i,a);if(x){for(let F in P)if(P.hasOwnProperty(F)){let{path:I,dir:he}=P[F];A.default.ensureDirSync(`./tmp/source/${he}`),A.default.copyFileSync(`./${a}/${I}`,`./tmp/source/${I}`)}A.default.outputJSONSync(`./tmp/scripts/${i}/conf/${x}`,P)}else A.default.ensureDirSync("./tmp/source"),A.default.copySync(`./${a}`,"./tmp/source")}else A.default.ensureDirSync("./tmp/source"),A.default.copySync(`./${a}`,"./tmp/source");Array.isArray(u)&&u.length&&u.forEach(x=>{A.default.ensureFileSync(`./tmp/source/${i}/${x}`),A.default.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${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
- `),g(v)})};0&&(module.exports={generateSeePackageZip});
1
+ /** build time: Thu Oct 08 2026 14:02:29 GMT+0800 (中国标准时间), build version 4.3.12 **/
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:d="false",fold:p="false",options:f="",validate:m="",upgrade:u="false"}=e,b=e.default;if(o==="form"){let N=(0,W.default)({form:[{_attr:{name:t,tooltip:l,visible:c,required:a,fixed:d,fold:p,options:f,validate:m,upgrade:u}},n]});return U(N)}let y=s==="complexSelect"?{default:e.default}:{},S=(0,W.default)({field:[{_attr:Q({type:s,label:i,name:t,tooltip:l,visible:c,required:a,fixed:d,fold:p,options:f,validate:m,upgrade:u},y)},n||b]});return U(S)},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:d="",upgrade:p="false",expose:f="",algorithm:m="",merge:u="",isomeris:b="",old_name:y=""}=r,S=r.default;if(e==="table"){let g=r.keys||[];S=(r.columns||g).map(k=>Z(k)).join(`
3
+ `)}else if(e==="switchForm"||e==="division"){let g=r.children;S=g?g.map(x=>Z(x)).join(`
4
+ `):""}else{if(e==="complexSelect")return ce(r);e==="editor"?S=typeof S=="object"?[JSON.stringify(S)]:[S]:S=[S]}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:d,upgrade:p,expose:f,algorithm:m,merge:u,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(S)?S:[S]]});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:d=[],description:p,scriptsType:f="python"}){let m=ue(a,c),u=M.default.readFileSync(V(`${f}/deploy.xml`)).toString();return(0,R.default)(u,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:o,appName:i,appType:s,group:t,version:l,configFileName:m[0],configFileNames:m,variables:d.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){let a=c.fullPath.includes("complexSelect")?c.fullName:c.name;if(i.isStringLiteral()){i.node.value=`$!{${a}}`;return}if(i.isNumericLiteral()){i.node.value=`$!{${a}}`;return}if(i.isBooleanLiteral()){if(i.node.type="StringLiteral",c.fullPath.includes("complexSelect")){i.node.value=`$!{${a}}`;return}i.node.value=`[NO_QUOTATION_MARKS]\${${a}}[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}let l=t.fullPath.includes("complexSelect")?t.fullName:t.name,c="",a=t.keys||[],d=t.columns||a;if(t.options){c=`[NO_QUOTATION_MARKS][#foreach($row in $${l}) '$row' , #end][NO_QUOTATION_MARKS]`,i.node.type="StringLiteral",i.node.value=c;return}d&&d.length&&d.forEach(f=>{c+=`${f.name}: '$!{row.${f.name}}',`}),i.node.type="StringLiteral",i.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${l}) {${c}}, #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:d=[],description:p,web_app_web_service_name:f,dockerImage:m}){let u=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:u[0],configFileNames:u,variables:d.map(y=>Z(y)).join(`
6
+ `),description:p,web_app_web_service_name:f,dockerImage:m})},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 $="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:d,template:p,variables:f=[],configName:m,outputName:u="dist",description:b,scriptsType:y,enableObfuscation:S=!1,seePackagePath:N,tplPath:D}=n;h.default.ensureDirSync($),h.default.ensureDirSync(`${$}/scripts`),h.default.ensureDirSync(`${$}/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,`./${$}/deploy.xml`),w=!0;continue}let{src:te,transform:Ae}=$e(C),ne=`./${$}/template/${O}`;Ae&&he(O)?h.default.outputFileSync(ne,_(te,f)):h.default.copyFileSync(te,ne),j.push(O)}let g=[];j.length>0?g=j:J(u)?(g=["config.local.js"],h.default.outputFileSync(`./${$}/template/config.local.js`,p?_(p,f):"")):I(u)||I(u,t)?(g=["sysconfig.js"],h.default.outputFileSync(`./${$}/template/sysconfig.js`,p?_(p,f):"")):m&&(g=[`${m}.js`],h.default.outputFileSync(`./${$}/template/${m}.js`,p?_(p,f):""));let x=g.filter(he).map(xe),k=x[0]||(g[0]?xe(g[0]):void 0);if(S&&(y==="bash"||y==="python")){let O=Fe.default.resolve(__dirname,`../templates/see/${y}/scripts/js`);h.default.pathExistsSync(O)&&h.default.copySync(O,`./${$}/scripts/${t}/js`)}let v=ae(y);y==="python"&&(h.default.outputFileSync(`./${$}/scripts/${t}/utils.${v}`,X("utils",{scriptsType:y})),h.default.outputFileSync(`./${$}/scripts/${t}/beforeInstall.sh`,X("beforeInstall",{scriptsType:y}))),h.default.outputFileSync(`./${$}/scripts/${t}/install.${v}`,X("install",{name:t,type:i,scriptsType:y})),h.default.outputFileSync(`./${$}/scripts/${t}/afterInstall.${v}`,X("afterInstall",{name:t,scriptsType:y,configFileName:k,configFileNames:x,enableObfuscation:S})),h.default.outputFileSync(`./${$}/scripts/${t}/uninstall.${v}`,X("uninstall",{name:t,type:i,scriptsType:y})),w||h.default.outputFileSync(`./${$}/deploy.xml`,ye({system:s,type:i,name:t,appType:l,appName:c,group:a,version:d,configFileName:k,configFileNames:g,variables:f,description:b,scriptsType:y})),o?o(O=>{E(e,N,$,()=>{H.rimraf.sync($),typeof O=="function"&&O()})}):E(e,N,$,()=>{H.rimraf.sync($)})};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:d,template:p,variables:f,configName:m,outputName:u,description:b,seePackagePath:y,dockerImage:S=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(u)?P.default.outputFileSync(`./${A}/template/${t}/config.local.js`,p?_(p,f):""):I(u)||I(u,t)?(m="sysconfig",P.default.outputFileSync(`./${A}/template/${t}/sysconfig.js`,p?_(p,f):"")):m&&P.default.outputFileSync(`./${A}/template/${t}/${m}.js`,p?_(p,f):""),P.default.outputFileSync(`./${A}/template/k8s-deploy-res.yaml`,de({configFileName:m})),P.default.outputFileSync(`./${A}/deploy.xml`,ge({system:s,type:i,name:t,appName:c,appType:l,version:a,group:d,configFileName:m,configFileNames:m?[m]:[],variables:f,description:b,web_app_web_service_name:`${t}-web`,dockerImage:S})),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:d,variablesFunc:p,copyFiles:f,description:m,seePackageName:u,seePackagePath:b="package",seePackageType:y="web",dockerImage:S,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 u=="string"&&u&&(u=u.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),[]}},d=d||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${o}/sysconfig.js`},y==="docker"){Oe(u||`${e}-${o}-${l}`,{system:e,type:n,name:o,appType:s,appName:i,group:t,version:l,configName:c,outputName:a,template:d(),variables:p(),seePackagePath:b,description:m,dockerImage:S},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(u||`${e}-${o}-${l}`,{system:e,type:n,name:o,group:t,appType:s,appName:i,version:l,configName:c,outputName:a,template:d(),variables:p(),seePackagePath:b,description:m,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(f)&&f.length&&f.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,14 +145,14 @@ interface DeployOptions {
141
145
  */
142
146
  enableObfuscation?: boolean;
143
147
  /**
144
- * 模板文件路径。key 为包内文件名,value 为本地绝对路径。
145
- * - `deploy.xml`:覆盖自动生成的 deploy.xml(原样拷贝)
146
- * - `*.js`:经 genTemplate 做 SEE 变量替换后写入 template/,并登记为 deploy.xml 的 `<config>`(可多个)
147
- * - 其他:原样拷贝到 template/
148
- * 若未提供任何 `*.js`,仍走 configName + templateFunc 的单文件逻辑。
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。
149
153
  * @default {}
150
154
  */
151
- tplPath?: Record<string, string>;
155
+ tplPath?: Record<string, TplPathValue>;
152
156
  }
153
157
 
154
158
  /**
@@ -195,7 +199,7 @@ interface DeployOptions {
195
199
  * @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
196
200
  * @param scriptsType 脚本类型 'python' | 'bash'
197
201
  * @param enableObfuscation 是否在安装后对配置 .js 做混淆,默认 false
198
- * @param tplPath 模板文件路径。deploy.xml 可覆盖生成结果;*.js 会做变量解析并登记为多条 SEE config;其他文件原样进 template/
202
+ * @param tplPath 模板文件。默认原样拷贝到 template/(支持已编辑好的 js/html 等);`.js` 可设 `{ path, transform: true }` 走 genTemplate;`deploy.xml` 可覆盖
199
203
  * @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
200
204
  */
201
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,14 +145,14 @@ interface DeployOptions {
141
145
  */
142
146
  enableObfuscation?: boolean;
143
147
  /**
144
- * 模板文件路径。key 为包内文件名,value 为本地绝对路径。
145
- * - `deploy.xml`:覆盖自动生成的 deploy.xml(原样拷贝)
146
- * - `*.js`:经 genTemplate 做 SEE 变量替换后写入 template/,并登记为 deploy.xml 的 `<config>`(可多个)
147
- * - 其他:原样拷贝到 template/
148
- * 若未提供任何 `*.js`,仍走 configName + templateFunc 的单文件逻辑。
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。
149
153
  * @default {}
150
154
  */
151
- tplPath?: Record<string, string>;
155
+ tplPath?: Record<string, TplPathValue>;
152
156
  }
153
157
 
154
158
  /**
@@ -195,7 +199,7 @@ interface DeployOptions {
195
199
  * @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
196
200
  * @param scriptsType 脚本类型 'python' | 'bash'
197
201
  * @param enableObfuscation 是否在安装后对配置 .js 做混淆,默认 false
198
- * @param tplPath 模板文件路径。deploy.xml 可覆盖生成结果;*.js 会做变量解析并登记为多条 SEE config;其他文件原样进 template/
202
+ * @param tplPath 模板文件。默认原样拷贝到 template/(支持已编辑好的 js/html 等);`.js` 可设 `{ path, transform: true }` 走 genTemplate;`deploy.xml` 可覆盖
199
203
  * @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
200
204
  */
201
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: Mon Sep 07 2026 09:05:55 GMT+0800 (中国标准时间), build version 4.3.10 **/
2
- var pe=Object.defineProperty;var Z=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var q=(i,t,n)=>t in i?pe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,K=(i,t)=>{for(var n in t||(t={}))fe.call(t,n)&&q(i,n,t[n]);if(Z)for(var n of Z(t))me.call(t,n)&&q(i,n,t[n]);return i};var B=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(t,n)=>(typeof require!="undefined"?require:t)[n]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});import be from"chalk";import Oe from"path";import T from"fs-extra";import $e from"path";import h from"fs-extra";import{rimraf as oe}from"rimraf";import z from"path";import L from"fs-extra";import ue from"archiver";import G from"xml";var W=process.cwd(),Q=function(t){let n={"&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"},o=/(&quot;)|(&apos;)|(&lt;)|(&gt;)/g;return t&&t.replace?t.replace(o,function(c){return n[c]}):t},I=function(t,n){let o=n||"",c=z.resolve(W,t,o,"sysconfig.js");return L.pathExistsSync(c)},U=function(t){let n=z.resolve(W,t,"config.local.js");return L.pathExistsSync(n)},w=function(t,n,o,c){let r=z.join(W,n);n!=="/"&&L.ensureDirSync(r);let e=L.createWriteStream(`${n==="/"?".":r}/${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(o,!1),l.finalize()},J=function(t,n,o){let{type:c,label:r,name:e,tooltip:l="",visible:s="true",required:a="false",fixed:$="false",fold:p="false",options:u="",validate:f="",upgrade:m="false"}=t,b=t.default;if(o==="form"){let F=G({form:[{_attr:{name:e,tooltip:l,visible:s,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m}},n]});return Q(F)}let y=c==="complexSelect"?{default:t.default}:{},d=G({field:[{_attr:K({type:c,label:r,name:e,tooltip:l,visible:s,required:a,fixed:$,fold:p,options:u,validate:f,upgrade:m},y)},n||b]});return Q(d)},H=function(t){let o=t.children.map(c=>{let e=c.children.map(l=>J(l)).join("");return J(c,e,"form")}).join("");return J(t,o)},C=function i(t,n,o="",c=""){for(let r=0;r<t.length;r++){let e=t[r];if(e.type==="complexSelect"?(e.fullName=`${e.name}`,e.fullPath=`${e.type}`):(e.fullName=`${o===""?"":o+"."}${e.name}`,e.fullPath=`${c===""?"":c+"-"}${e.type}`),n(e))return e;if(e.children&&e.children.length>0){let l=i(e.children,n,e.fullName,e.fullPath);if(l)return l}}return null};function 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:o,tooltip:c="",visible:r="true",required:e="false",fixed:l="false",fold:s="false",options:a="",validate:$="",upgrade:p="false",expose:u="",algorithm:f="",merge:m="",isomeris:b="",old_name:y=""}=i,d=i.default;if(t==="table"){let g=i.keys||[];d=(i.columns||g).map(k=>V(k)).join(`
3
- `)}else if(t==="switchForm"||t==="division"){let g=i.children;d=g?g.map(x=>V(x)).join(`
4
- `):""}else{if(t==="complexSelect")return H(i);t==="editor"?d=typeof d=="object"?[JSON.stringify(d)]:[d]:d=[d]}let F=t==="switchForm"?{default:i.default}:{},v=K({type:t,label:n,name:o,tooltip:c,visible:r,required:e,fixed:l,fold:s,options:a,validate:$,upgrade:p,expose:u,algorithm:f,merge:m,isomeris:b,old_name:y},F),D=Object.fromEntries(Object.entries(v).filter(([g,x])=>x!==""&&x!==null&&x!==void 0)),N=ge({field:[{_attr:D},...Array.isArray(d)?d:[d]]});return Q(N)},ee=function({system:t,type:n,name:o,appType:c,appName:r,group:e,version:l,configFileName:s="config.local",configFileNames:a,variables:$=[],description:p,scriptsType:u="python"}){let f=Array.isArray(a)?a:s?[s]:[],m=M.readFileSync(X(`${u}/deploy.xml`)).toString();return R(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:o,appName:r,appType:c,group:e,version:l,configFileName:f[0],configFileNames:f,variables:$.map(b=>V(b)).join(`
5
- `),description:p})},E=function(t,n){let o=`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`;t==="beforeInstall"&&(o=`${n.scriptsType}/scripts/${t}.sh`);let c=M.readFileSync(X(o)).toString();return R(c,{interpolate:/{{([\s\S]+?)}}/g})(n)},P=function(t,n=[]){let{code:o}=de.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(r){if(r.parentPath.isProperty()){let e=r.parentPath.get("key").node,l=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,l=e.value);let s=C(n,a=>l===a.name);if(s){if(s.fullPath.includes("complexSelect")&&(s.name=s.fullName),r.isStringLiteral()){r.node.value=`$!{${s.name}}`;return}if(r.isNumericLiteral()){r.node.value=`$!{${s.name}}`;return}if(r.isBooleanLiteral()){if(r.node.type="StringLiteral",s.fullPath.includes("complexSelect")){r.node.value=`$!{${s.fullName}}`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(r){if(r.parentPath.isProperty()){let e=C(n,l=>r.parentPath.get("key").node.name===l.name);if(e){if(e.fullPath.includes("editor")){r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS]\${${e.name}}[NO_QUOTATION_MARKS]`;return}e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let l="",s=e.keys||[],a=e.columns||s;if(e.options){l=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,r.node.type="StringLiteral",r.node.value=l;return}a&&a.length&&a.forEach(p=>{l+=`${p.name}: '$!{row.${p.name}}',`}),r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${l}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(r){if(r.parentPath.isProperty()){let e=r.parentPath.get("key").node,l=e.name;if(e){let s=C(n,a=>l===a.name);if(s){if(r.node.type="StringLiteral",s.fullPath.includes("editor")){r.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${s.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return o.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},te=function({system:t,type:n,name:o,appName:c,appType:r,version:e,group:l,configFileName:s="config.local",configFileNames:a,variables:$=[],description:p,web_app_web_service_name:u,dockerImage:f}){let m=Array.isArray(a)?a:s?[s]:[],b=M.readFileSync(X("docker/deploy.xml")).toString();return R(b,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:o,appName:c,appType:r,version:e,group:l,configFileName:m[0],configFileNames:m,variables:$.map(y=>V(y)).join(`
6
- `),description:p,web_app_web_service_name:u,dockerImage:f})},ne=function(t){let n=M.readFileSync(X("docker/k8s-deploy-res.yaml")).toString();return R(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},re=function(t){let n=M.readFileSync(X("docker/Dockerfile")).toString();return R(n)(t)};var S="tmp";function he(i){return i.endsWith(".js")}function xe(i){return i.replace(/\.js$/i,"")}var ie=function(t,n,o){let{system:c,type:r,name:e,appType:l,appName:s,group:a,version:$,template:p,variables:u=[],configName:f,outputName:m="dist",description:b,scriptsType:y,enableObfuscation:d=!1,seePackagePath:F,tplPath:v}=n;h.ensureDirSync(S),h.ensureDirSync(`${S}/scripts`),h.ensureDirSync(`${S}/template`);let D=!1,N=[];if(v&&Object.keys(v).length>0)for(let[O,j]of Object.entries(v)){if(O==="deploy.xml"){h.copyFileSync(j,`./${S}/deploy.xml`),D=!0;continue}if(he(O)){h.outputFileSync(`./${S}/template/${O}`,P(j,u)),N.push(xe(O));continue}h.copyFileSync(j,`./${S}/template/${O}`)}let g=[];N.length>0?g=N:U(m)?(g=["config.local"],h.outputFileSync(`./${S}/template/config.local.js`,p?P(p,u):"")):I(m)||I(m,e)?(g=["sysconfig"],h.outputFileSync(`./${S}/template/sysconfig.js`,p?P(p,u):"")):f&&(g=[f],h.outputFileSync(`./${S}/template/${f}.js`,p?P(p,u):""));let x=g[0];if(d&&(y==="bash"||y==="python")){let O=$e.resolve(__dirname,`../templates/see/${y}/scripts/js`);h.pathExistsSync(O)&&h.copySync(O,`./${S}/scripts/${e}/js`)}let k=Y(y);y==="python"&&(h.outputFileSync(`./${S}/scripts/${e}/utils.${k}`,E("utils",{scriptsType:y})),h.outputFileSync(`./${S}/scripts/${e}/beforeInstall.sh`,E("beforeInstall",{scriptsType:y}))),h.outputFileSync(`./${S}/scripts/${e}/install.${k}`,E("install",{name:e,type:r,scriptsType:y})),h.outputFileSync(`./${S}/scripts/${e}/afterInstall.${k}`,E("afterInstall",{name:e,scriptsType:y,configFileName:x,configFileNames:g,enableObfuscation:d})),h.outputFileSync(`./${S}/scripts/${e}/uninstall.${k}`,E("uninstall",{name:e,type:r,scriptsType:y})),D||h.outputFileSync(`./${S}/deploy.xml`,ee({system:c,type:r,name:e,appType:l,appName:s,group:a,version:$,configFileName:x,configFileNames:g,variables:u,description:b,scriptsType:y})),o?o(O=>{w(t,F,S,()=>{oe.sync(S),typeof O=="function"&&O()})}):w(t,F,S,()=>{oe.sync(S)})};import le from"path";import _ from"fs-extra";import{rimraf as se}from"rimraf";var A="tmp",ce=function(t,n,o){let{system:c,type:r,name:e,appType:l,appName:s,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/${e}`:`isee1.0-docker-release-local/${e}`}=n;_.ensureDirSync(A),_.ensureDirSync("docker"),_.pathExistsSync(le.resolve(process.cwd(),"docker/Dockerfile"))||_.outputFileSync(le.resolve(process.cwd(),"docker/Dockerfile"),re({name:e,type:r})),_.ensureDirSync(`${A}/scripts`),_.ensureDirSync(`${A}/template`),U(m)?_.outputFileSync(`./${A}/template/${e}/config.local.js`,p?P(p,u):""):I(m)||I(m,e)?(f="sysconfig",_.outputFileSync(`./${A}/template/${e}/sysconfig.js`,p?P(p,u):"")):f&&_.outputFileSync(`./${A}/template/${e}/${f}.js`,p?P(p,u):""),_.outputFileSync(`./${A}/template/k8s-deploy-res.yaml`,ne({configFileName:f})),_.outputFileSync(`./${A}/deploy.xml`,te({system:c,type:r,name:e,appName:s,appType:l,version:a,group:$,configFileName:f,configFileNames:f?[f]:[],variables:u,description:b,web_app_web_service_name:`${e}-web`,dockerImage:d})),o?o(F=>{w(t,y,A,()=>{se.sync(A),typeof F=="function"&&F()})}):w(t,y,A,()=>{se.sync(A)})};var Fe=process.cwd();function Ae(i,t,n){let o="",c,r=i==="bizframe"?`./${n}`:`./${n}/${t}`;return T.existsSync(r)&&(o=T.readdirSync(r).find(e=>/manifest\.[0-9]+\.json/.test(e)),o&&(c=T.readJsonSync(`${r}/${o}`))),{manifest:o,manifestJson:c}}var rt=function({system:t="winner-front",type:n="bizframe",name:o,appType:c,appName:r,group:e="bizframe",version:l,configName:s="config.local",outputName:a="dist",templateFunc:$,variablesFunc:p,copyFiles:u,description:f,seePackageName:m,seePackagePath:b="package",seePackageType:y="web",dockerImage:d,scriptsType:F="python",enableObfuscation:v=!1,tplPath:D={}},N){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,"-")),c=c||o,r=r||o,p=p||function(){try{let{variables:g}=B(Oe.resolve(Fe,"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"){ce(m||`${t}-${o}-${l}`,{system:t,type:n,name:o,appType:c,appName:r,group:e,version:l,configName:s,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(N)});return}ie(m||`${t}-${o}-${l}`,{system:t,type:n,name:o,group:e,appType:c,appName:r,version:l,configName:s,outputName:a,template:$(),variables:p(),seePackagePath:b,description:f,scriptsType:F,enableObfuscation:v,tplPath:D},g=>{if(F==="python"){let{manifest:x,manifestJson:k}=Ae(n,o,a);if(x){for(let O in k)if(k.hasOwnProperty(O)){let{path:j,dir:ae}=k[O];T.ensureDirSync(`./tmp/source/${ae}`),T.copyFileSync(`./${a}/${j}`,`./tmp/source/${j}`)}T.outputJSONSync(`./tmp/scripts/${o}/conf/${x}`,k)}else T.ensureDirSync("./tmp/source"),T.copySync(`./${a}`,"./tmp/source")}else T.ensureDirSync("./tmp/source"),T.copySync(`./${a}`,"./tmp/source");Array.isArray(u)&&u.length&&u.forEach(x=>{T.ensureFileSync(`./tmp/source/${o}/${x}`),T.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${be.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(N)})};export{rt as generateSeePackageZip};
1
+ /** build time: Thu Oct 08 2026 14:02:29 GMT+0800 (中国标准时间), build version 4.3.12 **/
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(l){return n[l]}):t},w=function(t,n){let i=n||"",l=B.resolve(Z,t,i,"sysconfig.js");return V.pathExistsSync(l)},Q=function(t){let n=B.resolve(Z,t,"config.local.js");return V.pathExistsSync(n)},I=function(t,n,i,l){let r=B.join(Z,n);n!=="/"&&V.ensureDirSync(r);let e=V.createWriteStream(`${n==="/"?".":r}/${t}.zip`);e.on("close",function(){setTimeout(function(){l&&l()})});let s=Fe("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()},J=function(t,n,i){let{type:l,label:r,name:e,tooltip:s="",visible:c="true",required:a="false",fixed:d="false",fold:p="false",options:f="",validate:m="",upgrade:u="false"}=t,F=t.default;if(i==="form"){let O=ee({form:[{_attr:{name:e,tooltip:s,visible:c,required:a,fixed:d,fold:p,options:f,validate:m,upgrade:u}},n]});return C(O)}let y=l==="complexSelect"?{default:t.default}:{},S=ee({field:[{_attr:L({type:l,label:r,name:e,tooltip:s,visible:c,required:a,fixed:d,fold:p,options:f,validate:m,upgrade:u},y)},n||F]});return C(S)},te=function(t){let i=t.children.map(l=>{let e=l.children.map(s=>J(s)).join("");return J(l,e,"form")}).join("");return J(t,i)},U=function o(t,n,i="",l=""){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=`${l===""?"":l+"-"}${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:l="",visible:r="true",required:e="false",fixed:s="false",fold:c="false",options:a="",validate:d="",upgrade:p="false",expose:f="",algorithm:m="",merge:u="",isomeris:F="",old_name:y=""}=o,S=o.default;if(t==="table"){let g=o.keys||[];S=(o.columns||g).map(P=>z(P)).join(`
3
+ `)}else if(t==="switchForm"||t==="division"){let g=o.children;S=g?g.map(x=>z(x)).join(`
4
+ `):""}else{if(t==="complexSelect")return te(o);t==="editor"?S=typeof S=="object"?[JSON.stringify(S)]:[S]:S=[S]}let O=t==="switchForm"?{default:o.default}:{},j=L({type:t,label:n,name:i,tooltip:l,visible:r,required:e,fixed:s,fold:c,options:a,validate:d,upgrade:p,expose:f,algorithm:m,merge:u,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(S)?S:[S]]});return C(_)},oe=function({system:t,type:n,name:i,appType:l,appName:r,group:e,version:s,configFileName:c="config.local",configFileNames:a,variables:d=[],description:p,scriptsType:f="python"}){let m=re(a,c),u=M.readFileSync(X(`${f}/deploy.xml`)).toString();return R(u,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:i,appName:r,appType:l,group:e,version:s,configFileName:m[0],configFileNames:m,variables:d.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 l=M.readFileSync(X(i)).toString();return R(l,{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 c=U(n,a=>s===a.name);if(c){let a=c.fullPath.includes("complexSelect")?c.fullName:c.name;if(r.isStringLiteral()){r.node.value=`$!{${a}}`;return}if(r.isNumericLiteral()){r.node.value=`$!{${a}}`;return}if(r.isBooleanLiteral()){if(r.node.type="StringLiteral",c.fullPath.includes("complexSelect")){r.node.value=`$!{${a}}`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${a}}[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}let s=e.fullPath.includes("complexSelect")?e.fullName:e.name,c="",a=e.keys||[],d=e.columns||a;if(e.options){c=`[NO_QUOTATION_MARKS][#foreach($row in $${s}) '$row' , #end][NO_QUOTATION_MARKS]`,r.node.type="StringLiteral",r.node.value=c;return}d&&d.length&&d.forEach(f=>{c+=`${f.name}: '$!{row.${f.name}}',`}),r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${s}) {${c}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(r){if(r.parentPath.isProperty()){let e=r.parentPath.get("key").node,s=e.name;if(e){let c=U(n,a=>s===a.name);if(c){if(r.node.type="StringLiteral",c.fullPath.includes("editor")){r.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return i.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},ie=function({system:t,type:n,name:i,appName:l,appType:r,version:e,group:s,configFileName:c="config.local",configFileNames:a,variables:d=[],description:p,web_app_web_service_name:f,dockerImage:m}){let u=re(a,c),F=M.readFileSync(X("docker/deploy.xml")).toString();return R(F,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:i,appName:l,appType:r,version:e,group:s,configFileName:u[0],configFileNames:u,variables:d.map(y=>z(y)).join(`
6
+ `),description:p,web_app_web_service_name:f,dockerImage:m})},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 $="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:l,type:r,name:e,appType:s,appName:c,group:a,version:d,template:p,variables:f=[],configName:m,outputName:u="dist",description:F,scriptsType:y,enableObfuscation:S=!1,seePackagePath:O,tplPath:j}=n;h.ensureDirSync($),h.ensureDirSync(`${$}/scripts`),h.ensureDirSync(`${$}/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,`./${$}/deploy.xml`),v=!0;continue}let{src:q,transform:de}=ae(K),W=`./${$}/template/${b}`;de&&pe(b)?h.outputFileSync(W,k(q,f)):h.copyFileSync(q,W),_.push(b)}let g=[];_.length>0?g=_:Q(u)?(g=["config.local.js"],h.outputFileSync(`./${$}/template/config.local.js`,p?k(p,f):"")):w(u)||w(u,e)?(g=["sysconfig.js"],h.outputFileSync(`./${$}/template/sysconfig.js`,p?k(p,f):"")):m&&(g=[`${m}.js`],h.outputFileSync(`./${$}/template/${m}.js`,p?k(p,f):""));let x=g.filter(pe).map(fe),P=x[0]||(g[0]?fe(g[0]):void 0);if(S&&(y==="bash"||y==="python")){let b=Ae.resolve(__dirname,`../templates/see/${y}/scripts/js`);h.pathExistsSync(b)&&h.copySync(b,`./${$}/scripts/${e}/js`)}let D=ne(y);y==="python"&&(h.outputFileSync(`./${$}/scripts/${e}/utils.${D}`,E("utils",{scriptsType:y})),h.outputFileSync(`./${$}/scripts/${e}/beforeInstall.sh`,E("beforeInstall",{scriptsType:y}))),h.outputFileSync(`./${$}/scripts/${e}/install.${D}`,E("install",{name:e,type:r,scriptsType:y})),h.outputFileSync(`./${$}/scripts/${e}/afterInstall.${D}`,E("afterInstall",{name:e,scriptsType:y,configFileName:P,configFileNames:x,enableObfuscation:S})),h.outputFileSync(`./${$}/scripts/${e}/uninstall.${D}`,E("uninstall",{name:e,type:r,scriptsType:y})),v||h.outputFileSync(`./${$}/deploy.xml`,oe({system:l,type:r,name:e,appType:s,appName:c,group:a,version:d,configFileName:P,configFileNames:g,variables:f,description:F,scriptsType:y})),i?i(b=>{I(t,O,$,()=>{ce.sync($),typeof b=="function"&&b()})}):I(t,O,$,()=>{ce.sync($)})};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:l,type:r,name:e,appType:s,appName:c,version:a,group:d,template:p,variables:f,configName:m,outputName:u,description:F,seePackagePath:y,dockerImage:S=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(u)?A.outputFileSync(`./${T}/template/${e}/config.local.js`,p?k(p,f):""):w(u)||w(u,e)?(m="sysconfig",A.outputFileSync(`./${T}/template/${e}/sysconfig.js`,p?k(p,f):"")):m&&A.outputFileSync(`./${T}/template/${e}/${m}.js`,p?k(p,f):""),A.outputFileSync(`./${T}/template/k8s-deploy-res.yaml`,se({configFileName:m})),A.outputFileSync(`./${T}/deploy.xml`,ie({system:l,type:r,name:e,appName:c,appType:s,version:a,group:d,configFileName:m,configFileNames:m?[m]:[],variables:f,description:F,web_app_web_service_name:`${e}-web`,dockerImage:S})),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="",l,r=o==="bizframe"?`./${n}`:`./${n}/${t}`;return N.existsSync(r)&&(i=N.readdirSync(r).find(e=>/manifest\.[0-9]+\.json/.test(e)),i&&(l=N.readJsonSync(`${r}/${i}`))),{manifest:i,manifestJson:l}}var at=function({system:t="winner-front",type:n="bizframe",name:i,appType:l,appName:r,group:e="bizframe",version:s,configName:c="config.local",outputName:a="dist",templateFunc:d,variablesFunc:p,copyFiles:f,description:m,seePackageName:u,seePackagePath:F="package",seePackageType:y="web",dockerImage:S,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 u=="string"&&u&&(u=u.replace(/@/gi,"").replace(/\//gi,"-")),l=l||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),[]}},d=d||function(){return n==="bizframe"?`./${a}/config.local.js`:`./${a}/${i}/sysconfig.js`},y==="docker"){ge(u||`${t}-${i}-${s}`,{system:t,type:n,name:i,appType:l,appName:r,group:e,version:s,configName:c,outputName:a,template:d(),variables:p(),seePackagePath:F,description:m,dockerImage:S},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(u||`${t}-${i}-${s}`,{system:t,type:n,name:i,group:e,appType:l,appName:r,version:s,configName:c,outputName:a,template:d(),variables:p(),seePackagePath:F,description:m,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(f)&&f.length&&f.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,12 +1,13 @@
1
1
  {
2
2
  "name": "@winner-fed/winner-deploy",
3
- "version": "4.3.10",
3
+ "version": "4.3.12",
4
4
  "description": "Generate a publication deployed by the See platform",
5
5
  "keywords": [
6
6
  "winner",
7
7
  "see",
8
8
  "deploy"
9
9
  ],
10
+ "packageManager": "pnpm@10.0.0",
10
11
  "main": "dist/index.js",
11
12
  "module": "dist/index.js",
12
13
  "types": "dist/index.d.ts",
@@ -52,6 +53,7 @@
52
53
  "scripts": {
53
54
  "dev": "tsup --watch",
54
55
  "build": "tsup",
55
- "typecheck": "tsc --noEmit"
56
+ "typecheck": "tsc --noEmit",
57
+ "verify": "npm run typecheck && npm run build && node scripts/verify.mjs"
56
58
  }
57
59
  }
@@ -37,7 +37,7 @@
37
37
  {{ variables }}
38
38
  </variables>
39
39
  <% configFileNames.forEach(function (cf) { %>
40
- <config path="./${webAppName}/<% print(cf) %>.js" encoding="UTF-8"/>
40
+ <config path="./${webAppName}/<% print(cf) %>" encoding="UTF-8"/>
41
41
  <% }) %>
42
42
  <config path="./scripts/{{ name }}/install.sh" encoding="UTF-8"/>
43
43
  <config path="./scripts/{{ name }}/afterInstall.sh" encoding="UTF-8"/>
@@ -40,7 +40,7 @@
40
40
 
41
41
  </variables>
42
42
  <% configFileNames.forEach(function (cf) { %>
43
- <config path="./{{ name }}/<% print(cf) %>.js" encoding="UTF-8"/>
43
+ <config path="./{{ name }}/<% print(cf) %>" encoding="UTF-8"/>
44
44
  <% }) %>
45
45
  <config reference="" encoding="utf-8" path="./k8s-deploy-res.yaml" />
46
46
  <node describe="节点私有配置信息" />
@@ -38,7 +38,7 @@
38
38
 
39
39
  </variables>
40
40
  <% configFileNames.forEach(function (cf) { %>
41
- <config path="./${webAppName}/<% print(cf) %>.js" encoding="UTF-8"/>
41
+ <config path="./${webAppName}/<% print(cf) %>" encoding="UTF-8"/>
42
42
  <% }) %>
43
43
  <config path="./scripts/{{ name }}/install.py" encoding="UTF-8"/>
44
44
  <config path="./scripts/{{ name }}/afterInstall.py" encoding="UTF-8"/>