@winner-fed/winner-deploy 4.3.6 → 4.3.8
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 +174 -161
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7 -7
- package/package.json +1 -1
- package/templates/see/bash/scripts/afterInstall.sh +48 -0
- package/templates/see/bash/scripts/js/confuse.js +43 -0
- package/templates/see/bash/scripts/js/confuse.sh +58 -0
- package/templates/see/bash/scripts/js/obfuscator.js +2 -0
- package/templates/see/bash/scripts/js/readme.md +16 -0
- package/templates/see/python/scripts/afterInstall.py +34 -3
- package/templates/see/python/scripts/js/confuse.js +43 -0
- package/templates/see/python/scripts/js/confuse.sh +58 -0
- package/templates/see/python/scripts/js/obfuscator.js +2 -0
- package/templates/see/python/scripts/js/readme.md +16 -0
package/README.md
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
## 特性
|
|
10
10
|
|
|
11
11
|
- 🚀 支持外框架(bizframe)和子系统(subsystem)两种应用类型
|
|
12
|
-
- 📦 自动生成 SEE 平台所需的
|
|
13
|
-
- 🐳 支持 Docker
|
|
14
|
-
- 🔧
|
|
12
|
+
- 📦 自动生成 SEE 平台所需的 deploy.xml 与 template 配置文件
|
|
13
|
+
- 🐳 支持 Docker 容器化部署(`seePackageType: 'docker'`)
|
|
14
|
+
- 🔧 灵活的模板变量配置系统(`variablesFunc` / `tplPath`)
|
|
15
15
|
- 📝 支持 Python 和 Bash 两种脚本类型
|
|
16
|
+
- 🔒 可选的安装后配置 JS 混淆(`enableObfuscation`)
|
|
16
17
|
- 🎯 可自定义文件拷贝和配置生成逻辑
|
|
17
18
|
|
|
18
19
|
## 安装
|
|
@@ -32,12 +33,16 @@ pnpm add @winner-fed/winner-deploy
|
|
|
32
33
|
```javascript
|
|
33
34
|
import { generateSeePackageZip } from '@winner-fed/winner-deploy';
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
36
|
+
generateSeePackageZip(
|
|
37
|
+
{
|
|
38
|
+
name: 'my-app',
|
|
39
|
+
version: '1.0.0',
|
|
40
|
+
description: '我的应用'
|
|
41
|
+
},
|
|
42
|
+
() => {
|
|
43
|
+
console.log('生成完成');
|
|
44
|
+
}
|
|
45
|
+
);
|
|
41
46
|
```
|
|
42
47
|
|
|
43
48
|
### 完整配置示例
|
|
@@ -51,34 +56,29 @@ generateSeePackageZip(
|
|
|
51
56
|
type: 'subsystem',
|
|
52
57
|
name: 'my-app',
|
|
53
58
|
appType: 'my-app',
|
|
59
|
+
appName: 'my-app',
|
|
54
60
|
version: '1.0.0',
|
|
55
61
|
group: 'bizframe',
|
|
56
62
|
configName: 'config.local',
|
|
57
63
|
outputName: 'dist',
|
|
58
64
|
description: '我的应用部署包',
|
|
65
|
+
seePackagePath: 'package',
|
|
59
66
|
seePackageType: 'web',
|
|
60
67
|
scriptsType: 'python',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
variablesFunc: () =>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
];
|
|
74
|
-
}
|
|
68
|
+
enableObfuscation: false,
|
|
69
|
+
copyFiles: ['version.js'],
|
|
70
|
+
tplPath: {},
|
|
71
|
+
templateFunc: () => './dist/my-app/sysconfig.js',
|
|
72
|
+
variablesFunc: () => [
|
|
73
|
+
{
|
|
74
|
+
type: 'input',
|
|
75
|
+
label: '应用标题',
|
|
76
|
+
name: 'APP_TITLE'
|
|
77
|
+
}
|
|
78
|
+
]
|
|
75
79
|
},
|
|
76
|
-
(
|
|
77
|
-
|
|
78
|
-
console.error('生成失败:', err);
|
|
79
|
-
} else {
|
|
80
|
-
console.log('生成成功:', result);
|
|
81
|
-
}
|
|
80
|
+
() => {
|
|
81
|
+
console.log('生成成功');
|
|
82
82
|
}
|
|
83
83
|
);
|
|
84
84
|
```
|
|
@@ -87,100 +87,101 @@ generateSeePackageZip(
|
|
|
87
87
|
|
|
88
88
|
### generateSeePackageZip(options, callback)
|
|
89
89
|
|
|
90
|
-
生成 SEE
|
|
90
|
+
生成 SEE 平台部署包。`name`、`version` 缺失时会抛出错误;`name` 与 `seePackageName` 中的 `@`、`/` 会自动替换为 `-`。
|
|
91
91
|
|
|
92
92
|
#### 参数说明
|
|
93
93
|
|
|
94
|
-
| 参数名
|
|
95
|
-
|
|
|
96
|
-
| system
|
|
97
|
-
| type
|
|
98
|
-
| name
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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/`(含 `confuse.js`),并在 `afterInstall` 中对 template 配置 JS 做混淆;为 `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 动态表单项 |
|
|
116
|
+
|
|
117
|
+
#### templateFunc 默认值
|
|
118
|
+
|
|
119
|
+
未传入时按 `type` 与 `outputName` 解析:
|
|
116
120
|
|
|
117
121
|
```javascript
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
122
|
+
// type === 'bizframe'
|
|
123
|
+
() => `./${outputName}/config.local.js`
|
|
124
|
+
|
|
125
|
+
// type === 'subsystem'
|
|
126
|
+
() => `./${outputName}/${name}/sysconfig.js`
|
|
124
127
|
```
|
|
125
128
|
|
|
126
|
-
#### variablesFunc
|
|
129
|
+
#### variablesFunc 默认值
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
未传入时尝试加载项目根目录下 `build/package/variables.js` 的 `variables` 字段;加载失败则返回 `[]`(与 `type` 无关)。
|
|
129
132
|
|
|
130
133
|
```javascript
|
|
131
|
-
variablesFunc:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
'build',
|
|
138
|
-
'package',
|
|
139
|
-
'./variables.js'
|
|
140
|
-
));
|
|
141
|
-
return variables || [];
|
|
142
|
-
} catch (error) {
|
|
143
|
-
console.error(error);
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
134
|
+
variablesFunc: () => {
|
|
135
|
+
try {
|
|
136
|
+
const { variables } = require('./build/package/variables.js');
|
|
137
|
+
return variables || [];
|
|
138
|
+
} catch {
|
|
139
|
+
return [];
|
|
146
140
|
}
|
|
147
|
-
|
|
141
|
+
};
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### tplPath 说明
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
tplPath: {
|
|
148
|
+
'deploy.xml': '/abs/path/custom-deploy.xml',
|
|
149
|
+
'sysconfig.js': '/abs/path/sysconfig.js'
|
|
148
150
|
}
|
|
149
151
|
```
|
|
150
152
|
|
|
151
|
-
|
|
153
|
+
- 除 `deploy.xml` 外,其余文件复制到包内 `template/` 目录。
|
|
154
|
+
- 提供 `sysconfig.js` 或 `config.local.js` 时,不再根据 `templateFunc` 生成同名配置。
|
|
152
155
|
|
|
153
|
-
|
|
156
|
+
#### copyFiles 说明
|
|
157
|
+
|
|
158
|
+
适用于 manifest 未收录、但需要打进 SEE 包的文件:
|
|
154
159
|
|
|
155
160
|
```javascript
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
'assets/logo.png', // assets 目录下的 logo.png
|
|
159
|
-
'config/env.json' // config 目录下的 env.json
|
|
160
|
-
];
|
|
161
|
+
// 将 dist/my-app/version.js 拷贝到包内 source/my-app/version.js
|
|
162
|
+
copyFiles: ['version.js'];
|
|
161
163
|
```
|
|
162
164
|
|
|
163
|
-
#### callback
|
|
165
|
+
#### callback 回调
|
|
166
|
+
|
|
167
|
+
第二个参数为无参函数,在 zip 写入完成且临时目录清理后调用,**不传递 error / result**:
|
|
164
168
|
|
|
165
169
|
```javascript
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
console.error('生成失败:', error);
|
|
170
|
-
} else {
|
|
171
|
-
// 处理成功结果
|
|
172
|
-
console.log('生成成功:', result);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
170
|
+
generateSeePackageZip(options, () => {
|
|
171
|
+
console.log('打包结束');
|
|
172
|
+
});
|
|
175
173
|
```
|
|
176
174
|
|
|
175
|
+
打包过程中会先组装 `tmp/`,在回调阶段写入 `source/`(及 python 的 manifest 相关文件),再压缩为 zip。
|
|
176
|
+
|
|
177
177
|
## 模板变量配置
|
|
178
178
|
|
|
179
|
-
SEE
|
|
179
|
+
SEE 平台支持多种类型的模板变量控件,用于在部署时动态配置应用参数。详细说明见 [TYPE.md](./TYPE.md)。
|
|
180
180
|
|
|
181
181
|
### 支持的控件类型
|
|
182
182
|
|
|
183
183
|
- **input**: 普通文本输入框
|
|
184
|
+
- **editor**: 大文本编辑框
|
|
184
185
|
- **select**: 单选下拉框
|
|
185
186
|
- **switch**: 开关组件
|
|
186
187
|
- **smallfile**: 文件上传控件(小于 2M)
|
|
@@ -188,8 +189,8 @@ SEE 平台支持多种类型的模板变量控件,用于在部署时动态配
|
|
|
188
189
|
- **complexSelect**: 复杂单选框
|
|
189
190
|
- **table**: 表格控件
|
|
190
191
|
- **division**: 分栏折叠控件
|
|
191
|
-
- **password**:
|
|
192
|
-
- **hidden**:
|
|
192
|
+
- **password**: 密码输入框(加密存储)
|
|
193
|
+
- **hidden**: 隐藏输入框
|
|
193
194
|
|
|
194
195
|
### 示例配置
|
|
195
196
|
|
|
@@ -199,112 +200,124 @@ const variables = [
|
|
|
199
200
|
type: 'input',
|
|
200
201
|
label: '应用标题',
|
|
201
202
|
tooltip: '设置应用的显示标题',
|
|
202
|
-
name: 'APP_TITLE'
|
|
203
|
-
default: '默认应用标题'
|
|
203
|
+
name: 'APP_TITLE'
|
|
204
204
|
},
|
|
205
205
|
{
|
|
206
206
|
type: 'select',
|
|
207
207
|
label: '环境选择',
|
|
208
208
|
options: 'dev:开发环境;test:测试环境;prod:生产环境',
|
|
209
|
-
|
|
210
|
-
name: 'ENVIRONMENT',
|
|
211
|
-
default: 'dev'
|
|
209
|
+
name: 'ENVIRONMENT'
|
|
212
210
|
},
|
|
213
211
|
{
|
|
214
212
|
type: 'switch',
|
|
215
213
|
label: '启用调试',
|
|
216
|
-
|
|
217
|
-
name: 'DEBUG_MODE',
|
|
218
|
-
default: false
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
type: 'password',
|
|
222
|
-
label: '数据库密码',
|
|
223
|
-
tooltip: '数据库连接密码',
|
|
224
|
-
name: 'DB_PASSWORD',
|
|
225
|
-
required: true,
|
|
226
|
-
default: ''
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
type: 'hidden',
|
|
230
|
-
label: '应用版本号',
|
|
231
|
-
tooltip: '应用内部版本号,用于系统识别',
|
|
232
|
-
name: 'APP_VERSION',
|
|
233
|
-
default: '1.0.0'
|
|
214
|
+
name: 'DEBUG_MODE'
|
|
234
215
|
}
|
|
235
216
|
];
|
|
236
217
|
```
|
|
237
218
|
|
|
238
|
-
##
|
|
219
|
+
## 发布包结构
|
|
239
220
|
|
|
240
|
-
|
|
221
|
+
默认输出路径:`{seePackagePath}/{seePackageName}.zip`(例如 `package/winner-front-my-app-1.0.0.zip`)。
|
|
241
222
|
|
|
242
223
|
```
|
|
243
224
|
see-package.zip
|
|
244
|
-
├──
|
|
245
|
-
├──
|
|
246
|
-
|
|
247
|
-
├──
|
|
248
|
-
|
|
249
|
-
├──
|
|
250
|
-
├──
|
|
251
|
-
|
|
225
|
+
├── deploy.xml
|
|
226
|
+
├── template/
|
|
227
|
+
│ └── config.local.js | sysconfig.js | 自定义名.js
|
|
228
|
+
├── scripts/
|
|
229
|
+
│ └── {name}/
|
|
230
|
+
│ ├── install.py | install.sh
|
|
231
|
+
│ ├── afterInstall.py | afterInstall.sh
|
|
232
|
+
│ ├── uninstall.py | uninstall.sh
|
|
233
|
+
│ ├── utils.py # 仅 python
|
|
234
|
+
│ ├── beforeInstall.sh # 仅 python
|
|
235
|
+
│ ├── conf/manifest.*.json # 仅 python 且 dist 含 manifest 时
|
|
236
|
+
│ └── js/ # 仅 enableObfuscation === true
|
|
237
|
+
│ ├── confuse.js
|
|
238
|
+
│ └── javascript-obfuscator.js
|
|
239
|
+
└── source/ # 安装脚本从 tmp/source 部署到 workspace
|
|
252
240
|
└── ...
|
|
253
241
|
```
|
|
254
242
|
|
|
243
|
+
`scriptsType === 'python'` 且存在 `manifest.{timestamp}.json` 时,按 manifest 拷贝文件到 `source/`;否则将整个 `outputName` 目录拷贝到 `source/`。`scriptsType === 'bash'` 时始终拷贝整个 `outputName` 到 `source/`。
|
|
244
|
+
|
|
255
245
|
## 使用场景
|
|
256
246
|
|
|
257
247
|
### 1. 外框架应用(bizframe)
|
|
258
248
|
|
|
259
|
-
适用于作为主框架的运行的子应用。
|
|
260
|
-
|
|
261
249
|
```javascript
|
|
262
|
-
generateSeePackageZip(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
250
|
+
generateSeePackageZip(
|
|
251
|
+
{
|
|
252
|
+
type: 'bizframe',
|
|
253
|
+
name: 'main-frame',
|
|
254
|
+
version: '1.0.0',
|
|
255
|
+
description: '主框架应用'
|
|
256
|
+
},
|
|
257
|
+
() => {}
|
|
258
|
+
);
|
|
268
259
|
```
|
|
269
260
|
|
|
270
261
|
### 2. 子系统应用(subsystem)
|
|
271
262
|
|
|
272
|
-
适用于业务子系统,通常作为微前端模块。
|
|
273
|
-
|
|
274
263
|
```javascript
|
|
275
|
-
generateSeePackageZip(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
264
|
+
generateSeePackageZip(
|
|
265
|
+
{
|
|
266
|
+
type: 'subsystem',
|
|
267
|
+
name: 'user-management',
|
|
268
|
+
version: '1.0.0',
|
|
269
|
+
description: '用户管理子系统'
|
|
270
|
+
},
|
|
271
|
+
() => {}
|
|
272
|
+
);
|
|
281
273
|
```
|
|
282
274
|
|
|
283
|
-
|
|
275
|
+
子系统安装目录需指向具体前端根目录(如 `/home/hsiar/hsiar-green/html/`),详见控制台完成提示。
|
|
284
276
|
|
|
285
|
-
|
|
277
|
+
### 3. 开启配置 JS 混淆
|
|
278
|
+
|
|
279
|
+
需目标环境已安装 `node`:
|
|
286
280
|
|
|
287
281
|
```javascript
|
|
288
|
-
generateSeePackageZip(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
282
|
+
generateSeePackageZip(
|
|
283
|
+
{
|
|
284
|
+
name: 'my-app',
|
|
285
|
+
version: '1.0.0',
|
|
286
|
+
scriptsType: 'bash',
|
|
287
|
+
enableObfuscation: true,
|
|
288
|
+
description: '开启 afterInstall 混淆'
|
|
289
|
+
},
|
|
290
|
+
() => {}
|
|
291
|
+
);
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### 4. Docker 容器化部署
|
|
295
|
+
|
|
296
|
+
```javascript
|
|
297
|
+
generateSeePackageZip(
|
|
298
|
+
{
|
|
299
|
+
name: 'my-app',
|
|
300
|
+
version: '1.0.0',
|
|
301
|
+
seePackageType: 'docker',
|
|
302
|
+
dockerImage: 'my-app:1.0.0',
|
|
303
|
+
description: '容器化应用'
|
|
304
|
+
},
|
|
305
|
+
() => {}
|
|
306
|
+
);
|
|
295
307
|
```
|
|
296
308
|
|
|
297
309
|
## 注意事项
|
|
298
310
|
|
|
299
|
-
1.
|
|
300
|
-
2.
|
|
301
|
-
3.
|
|
302
|
-
4. **Docker
|
|
303
|
-
5.
|
|
311
|
+
1. **copyFiles**:源文件路径为 `` `${outputName}/${name}/文件名` ``,不是项目根目录直写路径。
|
|
312
|
+
2. **configName**:除手动指定外,会根据 `outputName` 下是否存在 `config.local.js` / `sysconfig.js` 自动选用文件名。
|
|
313
|
+
3. **name 特殊字符**:`@`、`/` 会在打包前替换为 `-`。
|
|
314
|
+
4. **Docker**:使用 Docker 部署时需确保镜像已构建并可被 SEE 环境拉取。
|
|
315
|
+
5. **混淆**:`enableObfuscation: true` 时 `afterInstall` 依赖 `node` 执行 `confuse.js`。
|
|
316
|
+
6. **Python 脚本**:目标环境需具备 Python 运行时(及 `node`,若开启混淆)。
|
|
304
317
|
|
|
305
318
|
## 更新日志
|
|
306
319
|
|
|
307
|
-
|
|
320
|
+
详见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
308
321
|
|
|
309
322
|
## 许可证
|
|
310
323
|
|
|
@@ -312,4 +325,4 @@ MIT License
|
|
|
312
325
|
|
|
313
326
|
## 贡献
|
|
314
327
|
|
|
315
|
-
欢迎提交 Issue 和 Pull Request
|
|
328
|
+
欢迎提交 Issue 和 Pull Request。
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** build time:
|
|
2
|
-
var
|
|
3
|
-
`)}else if(
|
|
4
|
-
`):""}else{if(
|
|
5
|
-
`),description
|
|
6
|
-
`),description
|
|
7
|
-
`),
|
|
1
|
+
/** build time: Thu Jul 30 2026 10:40:12 GMT+0800 (中国标准时间), build version 4.3.8 **/
|
|
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={""":'"',"'":"'","<":"<",">":">"},i=/(")|(')|(<)|(>)/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});
|
package/dist/index.d.cts
CHANGED
|
@@ -135,6 +135,11 @@ interface DeployOptions {
|
|
|
135
135
|
* @default python
|
|
136
136
|
*/
|
|
137
137
|
scriptsType?: 'python' | 'bash';
|
|
138
|
+
/**
|
|
139
|
+
* 是否在安装后对 template 中的配置 .js 做混淆;为 false 时不拷贝 scripts/js,afterInstall 不执行 node 混淆
|
|
140
|
+
* @default false
|
|
141
|
+
*/
|
|
142
|
+
enableObfuscation?: boolean;
|
|
138
143
|
/**
|
|
139
144
|
* 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
|
|
140
145
|
* @default null
|
|
@@ -185,9 +190,10 @@ interface DeployOptions {
|
|
|
185
190
|
* @param seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
|
|
186
191
|
* @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
|
|
187
192
|
* @param scriptsType 脚本类型 'python' | 'bash'
|
|
193
|
+
* @param enableObfuscation 是否在安装后对配置 .js 做混淆,默认 false
|
|
188
194
|
* @param tplPath 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
|
|
189
195
|
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
|
|
190
196
|
*/
|
|
191
|
-
declare const generateSeePackageZip: ({ system, type, name, appType, appName, group, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackagePath, seePackageType, dockerImage, scriptsType, tplPath }: DeployOptions, cb: () => void) => void;
|
|
197
|
+
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;
|
|
192
198
|
|
|
193
199
|
export { generateSeePackageZip };
|