@winner-fed/winner-deploy 4.3.1 → 4.3.3
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 +309 -46
- package/TYPE.md +249 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +154 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -1,52 +1,315 @@
|
|
|
1
|
-
# winner-deploy
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
# @winner-fed/winner-deploy
|
|
2
|
+
|
|
3
|
+
> 用于生成 SEE 平台部署包的工具库
|
|
4
|
+
|
|
5
|
+
## 简介
|
|
6
|
+
|
|
7
|
+
`@winner-fed/winner-deploy` 是一个专门为 SEE 平台设计的部署包生成工具。它可以将前端项目打包成符合 SEE 平台规范的部署包,支持多种应用类型和部署模式。
|
|
8
|
+
|
|
9
|
+
## 特性
|
|
10
|
+
|
|
11
|
+
- 🚀 支持外框架(bizframe)和子系统(subsystem)两种应用类型
|
|
12
|
+
- 📦 自动生成 SEE 平台所需的 manifest.json 和 deploy.xml 配置文件
|
|
13
|
+
- 🐳 支持 Docker 容器化部署
|
|
14
|
+
- 🔧 灵活的模板变量配置系统
|
|
15
|
+
- 📝 支持 Python 和 Bash 两种脚本类型
|
|
16
|
+
- 🎯 可自定义文件拷贝和配置生成逻辑
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @winner-fed/winner-deploy
|
|
22
|
+
# 或
|
|
23
|
+
yarn add @winner-fed/winner-deploy
|
|
24
|
+
# 或
|
|
25
|
+
pnpm add @winner-fed/winner-deploy
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 快速开始
|
|
29
|
+
|
|
30
|
+
### 基础用法
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import { generateSeePackageZip } from '@winner-fed/winner-deploy';
|
|
34
|
+
|
|
35
|
+
// 最简单的使用方式
|
|
36
|
+
generateSeePackageZip({
|
|
37
|
+
name: 'my-app',
|
|
38
|
+
version: '1.0.0',
|
|
39
|
+
description: '我的应用'
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 完整配置示例
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
import { generateSeePackageZip } from '@winner-fed/winner-deploy';
|
|
47
|
+
|
|
48
|
+
generateSeePackageZip(
|
|
49
|
+
{
|
|
50
|
+
system: 'winner-front',
|
|
51
|
+
type: 'subsystem',
|
|
52
|
+
name: 'my-app',
|
|
53
|
+
appType: 'my-app',
|
|
54
|
+
version: '1.0.0',
|
|
55
|
+
group: 'bizframe',
|
|
56
|
+
configName: 'config.local',
|
|
57
|
+
outputName: 'dist',
|
|
58
|
+
description: '我的应用部署包',
|
|
59
|
+
seePackageType: 'web',
|
|
60
|
+
scriptsType: 'python',
|
|
61
|
+
copyFiles: ['version.js', 'logo.png'],
|
|
62
|
+
templateFunc: () => {
|
|
63
|
+
return './dist/config.local.js';
|
|
64
|
+
},
|
|
65
|
+
variablesFunc: () => {
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
type: 'input',
|
|
69
|
+
label: '应用标题',
|
|
70
|
+
name: 'APP_TITLE',
|
|
71
|
+
default: '默认标题'
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
(err, result) => {
|
|
77
|
+
if (err) {
|
|
78
|
+
console.error('生成失败:', err);
|
|
79
|
+
} else {
|
|
80
|
+
console.log('生成成功:', result);
|
|
20
81
|
}
|
|
21
82
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## API 文档
|
|
87
|
+
|
|
88
|
+
### generateSeePackageZip(options, callback)
|
|
89
|
+
|
|
90
|
+
生成 SEE 平台部署包的主要函数。
|
|
91
|
+
|
|
92
|
+
#### 参数说明
|
|
93
|
+
|
|
94
|
+
| 参数名 | 类型 | 默认值 | 必填 | 说明 |
|
|
95
|
+
| -------------- | ------------- | ------------------------------ | ---- | -------------------------------------------------------- |
|
|
96
|
+
| system | string | 'winner-front' | 否 | 系统类型,SEE 平台的分组维度 |
|
|
97
|
+
| type | string | 'subsystem' | 否 | 应用类型:'bizframe'(外框架)或 'subsystem'(子系统) |
|
|
98
|
+
| name | string | - | 是 | 发布物名称 |
|
|
99
|
+
| appType | string | name 的值 | 否 | 发布物类型 |
|
|
100
|
+
| version | string | - | 是 | 发布包版本 |
|
|
101
|
+
| group | string | 'bizframe' | 否 | 应用分组 |
|
|
102
|
+
| configName | string | 'config.local' | 否 | 配置文件名称(不含 .js 后缀) |
|
|
103
|
+
| outputName | string | 'dist' | 否 | 输出目录名称 |
|
|
104
|
+
| description | string | - | 否 | 发布包说明 |
|
|
105
|
+
| seePackageName | string | `${system}-${name}-${version}` | 否 | SEE 发布物的包名(zip 文件名) |
|
|
106
|
+
| seePackageType | string | 'web' | 否 | SEE 平台发布物包类型:'web' 或 'docker' |
|
|
107
|
+
| dockerImage | string | - | 否 | Docker 容器化镜像名(seePackageType 为 'docker' 时生效) |
|
|
108
|
+
| scriptsType | string | 'python' | 否 | 脚本类型:'python' 或 'bash' |
|
|
109
|
+
| copyFiles | Array<string> | [] | 否 | 需要直接拷贝到 SEE 包的文件列表 |
|
|
110
|
+
| templateFunc | function | - | 否 | 自定义变量配置文件生成函数 |
|
|
111
|
+
| variablesFunc | function | - | 否 | deploy.xml 模板变量配置函数 |
|
|
112
|
+
|
|
113
|
+
#### templateFunc 函数
|
|
114
|
+
|
|
115
|
+
用于自定义变量配置文件的生成逻辑。
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
templateFunc: function() {
|
|
119
|
+
if (type === 'bizframe') {
|
|
120
|
+
return `./dist/config.local.js`;
|
|
121
|
+
}
|
|
122
|
+
// 返回配置文件路径
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### variablesFunc 函数
|
|
127
|
+
|
|
128
|
+
用于配置 deploy.xml 模板变量,支持动态配置。
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
variablesFunc: function() {
|
|
132
|
+
const context = process.cwd();
|
|
133
|
+
if (type === 'bizframe') {
|
|
134
|
+
try {
|
|
135
|
+
const { variables } = require(path.resolve(
|
|
136
|
+
context,
|
|
137
|
+
'build',
|
|
138
|
+
'package',
|
|
139
|
+
'./variables.js'
|
|
140
|
+
));
|
|
141
|
+
return variables || [];
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error(error);
|
|
144
|
+
return [];
|
|
39
145
|
}
|
|
40
146
|
}
|
|
41
|
-
|
|
42
|
-
* @param options.description {string} 发布包说明
|
|
43
|
-
* @param options.seePackageName {string} see发布物的包名,也就是 zip 包的命名,默认为 `${system}-${name}-${version}`
|
|
44
|
-
* @param options.seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
|
|
45
|
-
* @param options.dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
|
|
46
|
-
* @param options.scriptsType 脚本类型 'python'(默认的) | 'bash'
|
|
47
|
-
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
|
|
48
|
-
*/
|
|
49
|
-
export const generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, group, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageType, dockerImage, scriptsType}, cb) {
|
|
50
|
-
...
|
|
147
|
+
return [];
|
|
51
148
|
}
|
|
52
149
|
```
|
|
150
|
+
|
|
151
|
+
#### copyFiles 配置
|
|
152
|
+
|
|
153
|
+
指定需要直接拷贝到 SEE 包中但不包含在 manifest.json 配置中的文件。
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
copyFiles: [
|
|
157
|
+
'version.js', // 项目根目录下的 version.js
|
|
158
|
+
'assets/logo.png', // assets 目录下的 logo.png
|
|
159
|
+
'config/env.json' // config 目录下的 env.json
|
|
160
|
+
];
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### callback 回调函数
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
function callback(error, result) {
|
|
167
|
+
if (error) {
|
|
168
|
+
// 处理错误
|
|
169
|
+
console.error('生成失败:', error);
|
|
170
|
+
} else {
|
|
171
|
+
// 处理成功结果
|
|
172
|
+
console.log('生成成功:', result);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## 模板变量配置
|
|
178
|
+
|
|
179
|
+
SEE 平台支持多种类型的模板变量控件,用于在部署时动态配置应用参数。详细的模板变量配置说明请参考 [TYPE.md](./TYPE.md)。
|
|
180
|
+
|
|
181
|
+
### 支持的控件类型
|
|
182
|
+
|
|
183
|
+
- **input**: 普通文本输入框
|
|
184
|
+
- **select**: 单选下拉框
|
|
185
|
+
- **switch**: 开关组件
|
|
186
|
+
- **smallfile**: 文件上传控件(小于 2M)
|
|
187
|
+
- **switchForm**: 开关表单
|
|
188
|
+
- **complexSelect**: 复杂单选框
|
|
189
|
+
- **table**: 表格控件
|
|
190
|
+
- **division**: 分栏折叠控件
|
|
191
|
+
- **password**: 密码输入框(数据加密存储)
|
|
192
|
+
- **hidden**: 隐藏输入框(不显示给用户)
|
|
193
|
+
|
|
194
|
+
### 示例配置
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
const variables = [
|
|
198
|
+
{
|
|
199
|
+
type: 'input',
|
|
200
|
+
label: '应用标题',
|
|
201
|
+
tooltip: '设置应用的显示标题',
|
|
202
|
+
name: 'APP_TITLE',
|
|
203
|
+
default: '默认应用标题'
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
type: 'select',
|
|
207
|
+
label: '环境选择',
|
|
208
|
+
options: 'dev:开发环境;test:测试环境;prod:生产环境',
|
|
209
|
+
tooltip: '选择部署环境',
|
|
210
|
+
name: 'ENVIRONMENT',
|
|
211
|
+
default: 'dev'
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
type: 'switch',
|
|
215
|
+
label: '启用调试',
|
|
216
|
+
tooltip: '是否启用调试模式',
|
|
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'
|
|
234
|
+
}
|
|
235
|
+
];
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 项目结构
|
|
239
|
+
|
|
240
|
+
生成的 SEE 部署包包含以下文件:
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
see-package.zip
|
|
244
|
+
├── manifest.json # 应用清单文件
|
|
245
|
+
├── deploy.xml # 部署配置文件
|
|
246
|
+
├── install.py/.sh # 安装脚本
|
|
247
|
+
├── uninstall.py/.sh # 卸载脚本
|
|
248
|
+
├── start.py/.sh # 启动脚本
|
|
249
|
+
├── stop.py/.sh # 停止脚本
|
|
250
|
+
├── config.local.js # 配置文件(如果存在)
|
|
251
|
+
└── dist/ # 应用文件目录
|
|
252
|
+
└── ...
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## 使用场景
|
|
256
|
+
|
|
257
|
+
### 1. 外框架应用(bizframe)
|
|
258
|
+
|
|
259
|
+
适用于作为主框架的运行的子应用。
|
|
260
|
+
|
|
261
|
+
```javascript
|
|
262
|
+
generateSeePackageZip({
|
|
263
|
+
type: 'bizframe',
|
|
264
|
+
name: 'main-frame',
|
|
265
|
+
version: '1.0.0',
|
|
266
|
+
description: '主框架应用'
|
|
267
|
+
});
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### 2. 子系统应用(subsystem)
|
|
271
|
+
|
|
272
|
+
适用于业务子系统,通常作为微前端模块。
|
|
273
|
+
|
|
274
|
+
```javascript
|
|
275
|
+
generateSeePackageZip({
|
|
276
|
+
type: 'subsystem',
|
|
277
|
+
name: 'user-management',
|
|
278
|
+
version: '1.0.0',
|
|
279
|
+
description: '用户管理子系统'
|
|
280
|
+
});
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### 3. Docker 容器化部署
|
|
284
|
+
|
|
285
|
+
支持生成容器化部署的 SEE 包。
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
generateSeePackageZip({
|
|
289
|
+
name: 'my-app',
|
|
290
|
+
version: '1.0.0',
|
|
291
|
+
seePackageType: 'docker',
|
|
292
|
+
dockerImage: 'my-app:1.0.0',
|
|
293
|
+
description: '容器化应用'
|
|
294
|
+
});
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## 注意事项
|
|
298
|
+
|
|
299
|
+
1. **文件路径**: `copyFiles` 中的文件路径是相对于项目根目录的
|
|
300
|
+
2. **配置文件**: 配置文件名不需要包含 `.js` 后缀
|
|
301
|
+
3. **版本号**: 建议使用语义化版本号格式
|
|
302
|
+
4. **Docker 镜像**: 使用 Docker 部署时需要确保镜像已构建并推送到镜像仓库
|
|
303
|
+
5. **脚本类型**: Python 脚本需要目标环境支持 Python 运行时
|
|
304
|
+
|
|
305
|
+
## 更新日志
|
|
306
|
+
|
|
307
|
+
详细的更新日志请查看 [CHANGELOG.md](./CHANGELOG.md)。
|
|
308
|
+
|
|
309
|
+
## 许可证
|
|
310
|
+
|
|
311
|
+
MIT License
|
|
312
|
+
|
|
313
|
+
## 贡献
|
|
314
|
+
|
|
315
|
+
欢迎提交 Issue 和 Pull Request 来改进这个项目。
|
package/TYPE.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# 模板变量说明
|
|
2
|
+
|
|
3
|
+
## 模板变量配置说明
|
|
4
|
+
|
|
5
|
+
目前,模板变量控件支持以下类型
|
|
6
|
+
|
|
7
|
+
- input - 普通文本输入框。
|
|
8
|
+
- select - 单选下拉框。
|
|
9
|
+
- switch - 开关组件。
|
|
10
|
+
- smallfile - 文件上传控件,仅支持小于 2M 的文件,文件内容以 base64 转码后的字符串存储。
|
|
11
|
+
- switchForm - 开关表单,通过控件 switch 控制下面表单的显示
|
|
12
|
+
- complexSelect - 复杂单选框,通过控件 select 控制下面显示哪个表单
|
|
13
|
+
- table - 表格控件,table 类型的模板配置目前只支持 Array<Object> 类型配置项,比如 APPS。
|
|
14
|
+
- division - 分栏折叠控件,division 分栏组件将界面上众多的组件分栏并给出每一栏目的标头。该控件仅用于界面展示控制由于其不具有 name 属性故其子元素取值方式保持原有不变,举例 division 包含子控件 b 其取值变量为 b)。分区组件,用于界面控制,作为分栏使用,对参数使用没意义。
|
|
15
|
+
- password - 密码输入框,密码框输入值将被加密保存,数据加密处理。
|
|
16
|
+
- hidden - 隐藏输入框,默认值输入框,不显示给用户,用于存储系统级别的配置参数。
|
|
17
|
+
|
|
18
|
+
### input(输入框)
|
|
19
|
+
|
|
20
|
+
配置如下所示
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
variables: [
|
|
24
|
+
{
|
|
25
|
+
type: 'input', // 控件类型,这里是 input 控件
|
|
26
|
+
label: 'input', // 左侧的 label 标签
|
|
27
|
+
tooltip: ' Input 输入框 测试 ', // 控件下面的提示框
|
|
28
|
+
name: 'INPUT', // 变量绑定,跟 sysconfig.js 或者 config.local.js 文件下的 window.LOCAL_CONFIG 属性字段的 key 相对应
|
|
29
|
+
default: '输入框的默认值' // input 的默认值
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### select(单选框)
|
|
35
|
+
|
|
36
|
+
配置如下所示
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
variables: [
|
|
40
|
+
{
|
|
41
|
+
type: 'select', // 控件类型 这里是 单选框
|
|
42
|
+
label: 'select', // 左侧的 label 标签
|
|
43
|
+
options: 'A:A;B:B;C:C', // 单选框选项, 值:标签 为一组,标签和值用 ":" 分开,每一组选项用 ";" 分开
|
|
44
|
+
tooltip: 'select 单选框 测试', // 控件下面的提示框
|
|
45
|
+
name: 'SELECT', // 变量绑定,跟 sysconfig.js 或者 config.local.js 文件下的 window.LOCAL_CONFIG 属性字段的 key 相对应
|
|
46
|
+
default: 'A' // 默认值,这里默认选项值为 A
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### switch(开关)
|
|
52
|
+
|
|
53
|
+
配置如下所示
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
variables: [
|
|
57
|
+
{
|
|
58
|
+
type: 'switch', // 控件类型 这里是开关
|
|
59
|
+
label: 'switch', // 左侧的 label 标签
|
|
60
|
+
tooltip: 'switch 开关 测试', // 控件下面的提示框
|
|
61
|
+
name: 'SWITCH', // 变量绑定,跟 sysconfig.js 或者 config.local.js 文件下的 window.LOCAL_CONFIG 属性字段的 key 相对应
|
|
62
|
+
options: 'true:是;false:否', // 开关选项选项, 值:标签为一组,标签和值用 ":" 分开,只有两者,true和 false
|
|
63
|
+
default: 'true' // 默认值
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### switchForm(开关表单)
|
|
69
|
+
|
|
70
|
+
配置如下所示
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
variables: [
|
|
74
|
+
{
|
|
75
|
+
type: 'switchForm', // 控件类型
|
|
76
|
+
label: 'switchForm', // 左侧的 label 标签
|
|
77
|
+
tooltip: 'switchForm 开关表单 测试', // 控件下面的提示框
|
|
78
|
+
name: 'SWITCH_FORM', // 变量绑定,跟 sysconfig.js 或者 config.local.js 文件下的 window.LOCAL_CONFIG 属性字段的 key 相对应
|
|
79
|
+
children: [
|
|
80
|
+
//!!! 开关表单下面的表单元素
|
|
81
|
+
{
|
|
82
|
+
type: 'mselect',
|
|
83
|
+
label: 'switchForm mselect',
|
|
84
|
+
options: 'A:A;B:B;C:C;D:D',
|
|
85
|
+
tooltip: 'switchForm mselect 开关表单 多选框 测试',
|
|
86
|
+
name: 'SWITCH_FORM_MSELECT',
|
|
87
|
+
default: 'A,B'
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### complexSelect
|
|
95
|
+
|
|
96
|
+
配置如下所示
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
variables: [
|
|
100
|
+
{
|
|
101
|
+
type: 'complexSelect',
|
|
102
|
+
label: 'complexSelect',
|
|
103
|
+
tooltip: '复杂选择器 测试 注意,一次只能一个表单填写的值有效,当保存一个表单填写的值后其他的值会 “制空”',
|
|
104
|
+
options: 'A:第一个表单;B:第二个表单', // 单选框选项
|
|
105
|
+
name: 'ComplexSelect',
|
|
106
|
+
children: [
|
|
107
|
+
{
|
|
108
|
+
type: 'form',
|
|
109
|
+
name: 'A', // 下拉框对应选项的值,如果单选框选择的值为 A,则会显示这表单
|
|
110
|
+
children: [
|
|
111
|
+
// ...
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: 'form',
|
|
116
|
+
name: 'B', // 下拉框对应选项的值,如果单选框选择的值为 B,则会显示这表单
|
|
117
|
+
children: [
|
|
118
|
+
// ...
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
];
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### table
|
|
127
|
+
|
|
128
|
+
配置如下所示
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
variables: [
|
|
132
|
+
{
|
|
133
|
+
type: 'table', // 控件类型
|
|
134
|
+
label: 'table', // 左侧 标签名
|
|
135
|
+
tooltip: 'table 表格 测试 使用 frameLayout - app', // 下面控件的提示语
|
|
136
|
+
name: 'TABLES',
|
|
137
|
+
columns: [
|
|
138
|
+
{
|
|
139
|
+
type: 'input', // 类型
|
|
140
|
+
label: '应用名称', // 标签名
|
|
141
|
+
name: 'name', // 模板变量绑定名
|
|
142
|
+
default: 'foo' // 默认值
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
type: 'input',
|
|
146
|
+
label: '应用入口',
|
|
147
|
+
name: 'entry',
|
|
148
|
+
default: '//192.168.194.101:8010/omc/index.html'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: 'input',
|
|
152
|
+
label: '挂载容器',
|
|
153
|
+
name: 'container',
|
|
154
|
+
default: '#subapp-container'
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'input',
|
|
158
|
+
label: '激活条件',
|
|
159
|
+
name: 'activeWhen',
|
|
160
|
+
default: ''
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
type: 'input',
|
|
164
|
+
label: '路由前缀',
|
|
165
|
+
name: 'urlPrefix',
|
|
166
|
+
default: '/foo/#'
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
];
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### division
|
|
174
|
+
|
|
175
|
+
配置如下所示
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
variables: [
|
|
179
|
+
{
|
|
180
|
+
type: 'division',
|
|
181
|
+
label: '中银证券分享页配置参数',
|
|
182
|
+
name: 'bocichiaShareSetting',
|
|
183
|
+
fold: false,
|
|
184
|
+
children: [
|
|
185
|
+
{
|
|
186
|
+
type: 'input',
|
|
187
|
+
label: '用户中心',
|
|
188
|
+
name: 'API_BIND',
|
|
189
|
+
default: 'https://zygjdev.winner123.cn/g/hsxone.uic/v'
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
type: 'input',
|
|
193
|
+
label: '用户中心(boc)',
|
|
194
|
+
name: 'API_BIND_BOC',
|
|
195
|
+
default: 'https://zygjdev.winner123.cn/g/hsxone.uic.boc/v'
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
type: 'input',
|
|
199
|
+
label: '权益中心',
|
|
200
|
+
name: 'API_HOME',
|
|
201
|
+
default: 'https://zygjdev.winner123.cn/g/hsxone.ric.member/v'
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
type: 'input',
|
|
205
|
+
label: '是否启用调试工具',
|
|
206
|
+
name: 'IS_OPEN_VCONSOLE',
|
|
207
|
+
default: 'false'
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
];
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### password(密码输入框)
|
|
215
|
+
|
|
216
|
+
配置如下所示
|
|
217
|
+
|
|
218
|
+
```js
|
|
219
|
+
variables: [
|
|
220
|
+
{
|
|
221
|
+
type: 'password', // 控件类型,这里是密码输入框
|
|
222
|
+
label: '数据库密码', // 左侧的 label 标签
|
|
223
|
+
tooltip: '数据库连接密码', // 控件下面的提示框
|
|
224
|
+
name: 'DB_PASSWORD', // 变量绑定,跟 sysconfig.js 或者 config.local.js 文件下的 window.LOCAL_CONFIG 属性字段的 key 相对应
|
|
225
|
+
required: true, // 是否必填
|
|
226
|
+
default: '' // 默认值
|
|
227
|
+
}
|
|
228
|
+
];
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### hidden(隐藏输入框)
|
|
232
|
+
|
|
233
|
+
配置如下所示
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
variables: [
|
|
237
|
+
{
|
|
238
|
+
type: 'hidden', // 控件类型,这里是隐藏输入框
|
|
239
|
+
label: '应用版本号', // 左侧的 label 标签(虽然隐藏,但仍需要设置)
|
|
240
|
+
tooltip: '应用内部版本号,用于系统识别', // 控件下面的提示框
|
|
241
|
+
name: 'APP_VERSION', // 变量绑定,跟 sysconfig.js 或者 config.local.js 文件下的 window.LOCAL_CONFIG 属性字段的 key 相对应
|
|
242
|
+
default: '1.0.0' // 默认值
|
|
243
|
+
}
|
|
244
|
+
];
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## more
|
|
248
|
+
|
|
249
|
+
更多内容可参考 see 平台的 [Deploy 帮助手册](http://rdcdocs.hundsun.com/pages/viewpage.action?pageId=39243038)
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** build time:
|
|
2
|
-
var $e=Object.create;var R=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames,Y=Object.getOwnPropertySymbols,be=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable;var ee=(o,e,n)=>e in o?R(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,K=(o,e)=>{for(var n in e||(e={}))te.call(e,n)&&ee(o,n,e[n]);if(Y)for(var n of Y(e))Oe.call(e,n)&&ee(o,n,e[n]);return o};var ke=(o,e)=>{for(var n in e)R(o,n,{get:e[n],enumerable:!0})},ne=(o,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xe(e))!te.call(o,s)&&s!==n&&R(o,s,{get:()=>e[s],enumerable:!(i=he(e,s))||i.enumerable});return o};var S=(o,e,n)=>(n=o!=null?$e(be(o)):{},ne(e||!o||!o.__esModule?R(n,"default",{value:o,enumerable:!0}):n,o)),Te=o=>ne(R({},"__esModule",{value:!0}),o);var Fe={};ke(Fe,{generateSeePackageZip:()=>Ae});module.exports=Te(Fe);var ge=S(require("chalk"),1),de=S(require("path"),1),O=S(require("fs-extra"),1);var $=S(require("fs-extra"),1),Z=require("rimraf");var Q=S(require("path"),1),M=S(require("fs-extra"),1),re=S(require("archiver"),1),J=S(require("xml"),1);var q=process.cwd(),L=function(e){let n={""":'"',"'":"'","<":"<",">":">"},i=/(")|(')|(<)|(>)/g;return e&&e.replace?e.replace(i,function(s){return n[s]}):e},j=function(e,n){let i=n||"",s=Q.default.resolve(q,e,i,"sysconfig.js");return M.default.pathExistsSync(s)},U=function(e){let n=Q.default.resolve(q,e,"config.local.js");return M.default.pathExistsSync(n)},D=function(e,n,i,s){let r=Q.default.join(q,n);n!=="/"&&M.default.ensureDirSync(r);let t=M.default.createWriteStream(`${n==="/"?".":r}/${e}.zip`);t.on("close",function(){setTimeout(function(){s&&s()})});let l=(0,re.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(i,!1),l.finalize()},C=function(e,n,i){let{type:s,label:r,name:t,tooltip:l="",visible:c="true",required:p="false",fixed:y="false",fold:f="false",options:a="",validate:m="",upgrade:u="false"}=e,k=e.default;if(i==="form"){let T=(0,J.default)({form:[{_attr:{name:t,tooltip:l,visible:c,required:p,fixed:y,fold:f,options:a,validate:m,upgrade:u}},n]});return L(T)}let g=s==="complexSelect"?{default:e.default}:{},P=(0,J.default)({field:[{_attr:K({type:s,label:r,name:t,tooltip:l,visible:c,required:p,fixed:y,fold:f,options:a,validate:m,upgrade:u},g)},n||k]});return L(P)},oe=function(e){let i=e.children.map(s=>{let t=s.children.map(l=>C(l)).join("");return C(s,t,"form")}).join("");return C(e,i)},V=function o(e,n,i="",s=""){for(let r=0;r<e.length;r++){let t=e[r];if(t.type==="complexSelect"?(t.fullName=`${t.name}`,t.fullPath=`${t.type}`):(t.fullName=`${i===""?"":i+"."}${t.name}`,t.fullPath=`${s===""?"":s+"-"}${t.type}`),n(t))return t;if(t.children&&t.children.length>0){let l=o(t.children,n,t.fullName,t.fullPath);if(l)return l}}return null};function ie(o="python"){return o==="python"?"py":"sh"}var N=S(require("fs-extra"),1),se=S(require("path"),1),w=S(require("lodash.template"),1),le=S(require("xml"),1),ce=S(require("@babel/core"),1);var Pe=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division"],E=o=>se.default.resolve(__dirname,`../templates/see/${o}`),z=o=>{let e=o.type;if(!Pe.includes(e))return"";let{label:n,name:i,tooltip:s="",visible:r="true",required:t="false",fixed:l="false",fold:c="false",options:p="",validate:y="",upgrade:f="false"}=o,a=o.default;if(e==="table"){let k=o.keys||[];a=(o.columns||k).map(P=>z(P)).join(`
|
|
1
|
+
/** build time: Fri Jul 04 2025 16:33:17 GMT+0800 (China Standard Time), build version 4.3.3 **/
|
|
2
|
+
var $e=Object.create;var R=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames,Y=Object.getOwnPropertySymbols,be=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable;var ee=(o,e,n)=>e in o?R(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,K=(o,e)=>{for(var n in e||(e={}))te.call(e,n)&&ee(o,n,e[n]);if(Y)for(var n of Y(e))Oe.call(e,n)&&ee(o,n,e[n]);return o};var ke=(o,e)=>{for(var n in e)R(o,n,{get:e[n],enumerable:!0})},ne=(o,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xe(e))!te.call(o,s)&&s!==n&&R(o,s,{get:()=>e[s],enumerable:!(i=he(e,s))||i.enumerable});return o};var S=(o,e,n)=>(n=o!=null?$e(be(o)):{},ne(e||!o||!o.__esModule?R(n,"default",{value:o,enumerable:!0}):n,o)),Te=o=>ne(R({},"__esModule",{value:!0}),o);var Fe={};ke(Fe,{generateSeePackageZip:()=>Ae});module.exports=Te(Fe);var ge=S(require("chalk"),1),de=S(require("path"),1),O=S(require("fs-extra"),1);var $=S(require("fs-extra"),1),Z=require("rimraf");var Q=S(require("path"),1),M=S(require("fs-extra"),1),re=S(require("archiver"),1),J=S(require("xml"),1);var q=process.cwd(),L=function(e){let n={""":'"',"'":"'","<":"<",">":">"},i=/(")|(')|(<)|(>)/g;return e&&e.replace?e.replace(i,function(s){return n[s]}):e},j=function(e,n){let i=n||"",s=Q.default.resolve(q,e,i,"sysconfig.js");return M.default.pathExistsSync(s)},U=function(e){let n=Q.default.resolve(q,e,"config.local.js");return M.default.pathExistsSync(n)},D=function(e,n,i,s){let r=Q.default.join(q,n);n!=="/"&&M.default.ensureDirSync(r);let t=M.default.createWriteStream(`${n==="/"?".":r}/${e}.zip`);t.on("close",function(){setTimeout(function(){s&&s()})});let l=(0,re.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(i,!1),l.finalize()},C=function(e,n,i){let{type:s,label:r,name:t,tooltip:l="",visible:c="true",required:p="false",fixed:y="false",fold:f="false",options:a="",validate:m="",upgrade:u="false"}=e,k=e.default;if(i==="form"){let T=(0,J.default)({form:[{_attr:{name:t,tooltip:l,visible:c,required:p,fixed:y,fold:f,options:a,validate:m,upgrade:u}},n]});return L(T)}let g=s==="complexSelect"?{default:e.default}:{},P=(0,J.default)({field:[{_attr:K({type:s,label:r,name:t,tooltip:l,visible:c,required:p,fixed:y,fold:f,options:a,validate:m,upgrade:u},g)},n||k]});return L(P)},oe=function(e){let i=e.children.map(s=>{let t=s.children.map(l=>C(l)).join("");return C(s,t,"form")}).join("");return C(e,i)},V=function o(e,n,i="",s=""){for(let r=0;r<e.length;r++){let t=e[r];if(t.type==="complexSelect"?(t.fullName=`${t.name}`,t.fullPath=`${t.type}`):(t.fullName=`${i===""?"":i+"."}${t.name}`,t.fullPath=`${s===""?"":s+"-"}${t.type}`),n(t))return t;if(t.children&&t.children.length>0){let l=o(t.children,n,t.fullName,t.fullPath);if(l)return l}}return null};function ie(o="python"){return o==="python"?"py":"sh"}var N=S(require("fs-extra"),1),se=S(require("path"),1),w=S(require("lodash.template"),1),le=S(require("xml"),1),ce=S(require("@babel/core"),1);var Pe=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],E=o=>se.default.resolve(__dirname,`../templates/see/${o}`),z=o=>{let e=o.type;if(!Pe.includes(e))return"";let{label:n,name:i,tooltip:s="",visible:r="true",required:t="false",fixed:l="false",fold:c="false",options:p="",validate:y="",upgrade:f="false"}=o,a=o.default;if(e==="table"){let k=o.keys||[];a=(o.columns||k).map(P=>z(P)).join(`
|
|
3
3
|
`)}else if(e==="switchForm"||e==="division")a=o.children.map(g=>z(g)).join(`
|
|
4
|
-
`);else{if(e==="complexSelect")return oe(o);e==="editor"?a=typeof a=="object"?[JSON.stringify(a)]:[a]:a=[a]}let m=e==="switchForm"?{default:o.default}:{},u=(0,le.default)({field:[{_attr:K({type:e,label:n,name:i,tooltip:s,visible:r,required:t,fixed:l,fold:c,options:p,validate:y,upgrade:f},m)},...Array.isArray(a)?a:[a]]});return L(u)},ae=function({system:e,type:n,name:i,appType:s,appName:r,group:t,version:l,configFileName:c="config.local",variables:p=[],description:y,scriptsType:f="python"}){let a=N.default.readFileSync(E(`${f}/deploy.xml`)).toString();return(0,w.default)(a,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:r,appType:s,group:t,version:l,configFileName:c,variables:
|
|
5
|
-
`)
|
|
6
|
-
`)
|
|
4
|
+
`);else{if(e==="complexSelect")return oe(o);e==="editor"?a=typeof a=="object"?[JSON.stringify(a)]:[a]:a=[a]}let m=e==="switchForm"?{default:o.default}:{},u=(0,le.default)({field:[{_attr:K({type:e,label:n,name:i,tooltip:s,visible:r,required:t,fixed:l,fold:c,options:p,validate:y,upgrade:f},m)},...Array.isArray(a)?a:[a]]});return L(u)},ae=function({system:e,type:n,name:i,appType:s,appName:r,group:t,version:l,configFileName:c="config.local",variables:p=[],description:y,scriptsType:f="python"}){let a=N.default.readFileSync(E(`${f}/deploy.xml`)).toString();return(0,w.default)(a,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:r,appType:s,group:t,version:l,configFileName:c,variables:p.map(m=>z(m)).join(`
|
|
5
|
+
`),description:y})},X=function(e,n){let i=N.default.readFileSync(E(`${n.scriptsType}/scripts/${e}.${n.scriptsType==="python"?"py":"sh"}`)).toString();return(0,w.default)(i,{interpolate:/{{([\s\S]+?)}}/g})(n)},_=function(e,n=[]){let{code:i}=ce.default.transformFileSync(e,{babelrc:!1,plugins:[function(){return{visitor:{Literal(r){if(r.parentPath.isProperty()){let t=r.parentPath.get("key").node,l=t.name;t.type==="StringLiteral"&&(t.type="Identifier",t.name=t.value,l=t.value);let c=V(n,p=>l===p.name);if(c){if(c.fullPath.includes("complexSelect")&&(c.name=c.fullName),r.isStringLiteral()){r.node.value=`$!{${c.name}}`;return}if(r.isNumericLiteral()){r.node.value=`$!{${c.name}}`;return}if(r.isBooleanLiteral()){if(r.node.type="StringLiteral",c.fullPath.includes("complexSelect")){r.node.value=`$!{${c.fullName}}`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${c.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(r){if(r.parentPath.isProperty()){let t=V(n,l=>r.parentPath.get("key").node.name===l.name);if(t){if(t.fullPath.includes("editor")){r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS]\${${t.name}}[NO_QUOTATION_MARKS]`;return}t.fullPath.includes("complexSelect")&&(t.name=t.fullName);let l="",c=t.keys||[],p=t.columns||c;if(t.options){l=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) '$row' , #end][NO_QUOTATION_MARKS]`,r.node.type="StringLiteral",r.node.value=l;return}p&&p.length&&p.forEach(f=>{l+=`${f.name}: '$!{row.${f.name}}',`}),r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${t.name}) {${l}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(r){if(r.parentPath.isProperty()){let t=r.parentPath.get("key").node,l=t.name;if(t){let c=V(n,p=>l===p.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")},pe=function({system:e,type:n,name:i,appName:s,appType:r,version:t,group:l,configFileName:c="config.local",variables:p=[],description:y,web_app_web_service_name:f,dockerImage:a}){let m=N.default.readFileSync(E("docker/deploy.xml")).toString();return(0,w.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:e,type:n,name:i,appName:s,appType:r,version:t,group:l,configFileName:c,variables:p.map(u=>z(u)).join(`
|
|
6
|
+
`),description:y,web_app_web_service_name:f,dockerImage:a})},fe=function(e){let n=N.default.readFileSync(E("docker/k8s-deploy-res.yaml")).toString();return(0,w.default)(n,{interpolate:/{{([\s\S]+?)}}/g})(e)},me=function(e){let n=N.default.readFileSync(E("docker/Dockerfile")).toString();return(0,w.default)(n)(e)};var d="tmp",ue=function(e,n,i){let{system:s,type:r,name:t,appType:l,appName:c,group:p,version:y,template:f,variables:a=[],configName:m,outputName:u="dist",description:k,scriptsType:g,seePackagePath:P,tplPath:T}=n;$.default.ensureDirSync(d),$.default.ensureDirSync(`${d}/scripts`),$.default.ensureDirSync(`${d}/template`);let F=ie(g);g==="python"&&$.default.outputFileSync(`./${d}/scripts/${t}/utils.${F}`,X("utils",{scriptsType:g})),$.default.outputFileSync(`./${d}/scripts/${t}/install.${F}`,X("install",{name:t,type:r,scriptsType:g})),$.default.outputFileSync(`./${d}/scripts/${t}/afterInstall.${F}`,X("afterInstall",{name:t,scriptsType:g})),$.default.outputFileSync(`./${d}/scripts/${t}/uninstall.${F}`,X("uninstall",{name:t,type:r,scriptsType:g}));let I=!1,v=!1;if(T&&Object.keys(T).length>0)for(let[h,A]of Object.entries(T))h==="deploy.xml"?($.default.copyFileSync(A,`./${d}/deploy.xml`),I=!0):$.default.copyFileSync(A,`./${d}/template/${h}`),(h==="sysconfig.js"||h==="config.local.js")&&(v=!0);I||$.default.outputFileSync(`./${d}/deploy.xml`,ae({system:s,type:r,name:t,appType:l,appName:c,group:p,version:y,configFileName:m,variables:a,description:k,scriptsType:g})),v||(U(u)?$.default.outputFileSync(`./${d}/template/config.local.js`,f?_(f,a):""):j(u)||j(u,t)?(m="sysconfig",$.default.outputFileSync(`./${d}/template/sysconfig.js`,f?_(f,a):"")):m&&$.default.outputFileSync(`./${d}/template/${m}.js`,f?_(f,a):"")),i?i(h=>{D(e,P,d,()=>{Z.rimraf.sync(d),typeof h=="function"&&h()})}):D(e,P,d,()=>{Z.rimraf.sync(d)})};var B=S(require("path"),1),b=S(require("fs-extra"),1),W=require("rimraf");var x="tmp",ye=function(e,n,i){let{system:s,type:r,name:t,appType:l,appName:c,version:p,group:y,template:f,variables:a,configName:m,outputName:u,description:k,seePackagePath:g,dockerImage:P=p.indexOf("-")>0?`isee1.0-docker-dev-local/${t}`:`isee1.0-docker-release-local/${t}`}=n;b.default.ensureDirSync(x),b.default.ensureDirSync("docker"),b.default.pathExistsSync(B.default.resolve(process.cwd(),"docker/Dockerfile"))||b.default.outputFileSync(B.default.resolve(process.cwd(),"docker/Dockerfile"),me({name:t,type:r})),b.default.ensureDirSync(`${x}/scripts`),b.default.ensureDirSync(`${x}/template`),U(u)?b.default.outputFileSync(`./${x}/template/${t}/config.local.js`,f?_(f,a):""):j(u)||j(u,t)?(m="sysconfig",b.default.outputFileSync(`./${x}/template/${t}/sysconfig.js`,f?_(f,a):"")):m&&b.default.outputFileSync(`./${x}/template/${t}/${m}.js`,f?_(f,a):""),b.default.outputFileSync(`./${x}/template/k8s-deploy-res.yaml`,fe({configFileName:m})),b.default.outputFileSync(`./${x}/deploy.xml`,pe({system:s,type:r,name:t,appName:c,appType:l,version:p,group:y,configFileName:m,variables:a,description:k,web_app_web_service_name:`${t}-web`,dockerImage:P})),i?i(T=>{D(e,g,x,()=>{W.rimraf.sync(x),typeof T=="function"&&T()})}):D(e,g,x,()=>{W.rimraf.sync(x)})};var ve=process.cwd();function _e(o,e,n){let i="",s;if(o==="bizframe"){i=O.default.readdirSync(`./${n}`).find(r=>/manifest\.[0-9]+\.json/.test(r));try{s=O.default.readJsonSync(`./${n}/${i}`)}catch(r){console.error(`${n} \u76EE\u5F55\u4E0B\u7684 manifest.xxx.json \u89E3\u6790\u5931\u8D25\uFF01\u8BF7\u786E\u8BA4\u6B64\u6587\u4EF6\u662F\u5426\u5B58\u5728\u3002\u6216\u53EF\u4EE5\u5C06 scriptsType \u8BBE\u7F6E\u4E3A bash \u8BD5\u8BD5\u770B\u3002`),process.exit(0)}}return o==="subsystem"&&(i=O.default.readdirSync(`./${n}/${e}`).find(r=>/manifest\.[0-9]+\.json/.test(r)),s=O.default.readJsonSync(`./${n}/${e}/${i}`)),{manifest:i,manifestJson:s}}var Ae=function({system:e="winner-front",type:n="bizframe",name:i,appType:s,appName:r,group:t="bizframe",version:l,configName:c="config.local",outputName:p="dist",templateFunc:y,variablesFunc:f,copyFiles:a,description:m,seePackageName:u,seePackagePath:k="package",seePackageType:g="web",dockerImage:P,scriptsType:T="python",tplPath:F={}},I){if(!i||!l)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,"-")),s=s||i,r=r||i,f=f||function(){try{let{variables:v}=require(de.default.resolve(ve,"build","package","./variables.js"));return v||[]}catch(v){return console.error(v),[]}},y=y||function(){return n==="bizframe"?`./${p}/config.local.js`:`./${p}/${i}/sysconfig.js`},g==="docker"){ye(u||`${e}-${i}-${l}`,{system:e,type:n,name:i,appType:s,appName:r,group:t,version:l,configName:c,outputName:p,template:y(),variables:f(),seePackagePath:k,description:m,dockerImage:P},v=>{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"),v(I)});return}ue(u||`${e}-${i}-${l}`,{system:e,type:n,name:i,group:t,appType:s,appName:r,version:l,configName:c,outputName:p,template:y(),variables:f(),seePackagePath:k,description:m,scriptsType:T,tplPath:F},v=>{if(T==="python"){let{manifest:h,manifestJson:A}=_e(n,i,p);for(let G in A)if(A.hasOwnProperty(G)){let{path:H,dir:Se}=A[G];O.default.ensureDirSync(`./tmp/source/${Se}`),O.default.copyFileSync(`./${p}/${H}`,`./tmp/source/${H}`)}O.default.outputJSONSync(`./tmp/scripts/${i}/conf/${h}`,A)}else O.default.ensureDirSync("./tmp/source"),O.default.copySync(`./${p}`,"./tmp/source");Array.isArray(a)&&a.length&&a.forEach(h=>{O.default.ensureFileSync(`./tmp/source/${i}/${h}`),O.default.copyFileSync(`./${p}/${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${ge.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
7
|
`),v(I)})};0&&(module.exports={generateSeePackageZip});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
type variablesType = 'input' | 'select' | 'editor' | 'switch' | 'smallfile' | 'table' | 'mselect' | 'switchForm' | 'complexSelect' | 'division' | 'password' | 'hidden';
|
|
2
|
+
interface variables {
|
|
3
|
+
type: variablesType;
|
|
4
|
+
label: string;
|
|
5
|
+
name: string;
|
|
6
|
+
options: string;
|
|
7
|
+
required: boolean;
|
|
8
|
+
fold: boolean;
|
|
9
|
+
children: Array<variables>;
|
|
10
|
+
tooltip: string;
|
|
11
|
+
default: string;
|
|
12
|
+
}
|
|
13
|
+
interface deployOptions {
|
|
14
|
+
/**
|
|
15
|
+
* 系统类型, SEE 平台的分组是以系统类型字段纬度来的
|
|
16
|
+
* @default winner-front
|
|
17
|
+
*/
|
|
18
|
+
system: string;
|
|
19
|
+
/**
|
|
20
|
+
* 应用类型, 外框架 - bizframe | 子系统 - subsystem
|
|
21
|
+
* @default bizframe
|
|
22
|
+
*/
|
|
23
|
+
type: 'bizframe' | 'subsystem';
|
|
24
|
+
/**
|
|
25
|
+
* 发布物名称。当包含 scope 时,如字符 @、/ 。会做自动的转换。如@winner-fed/winner-deploy 转换为 winner-fed-winner-deploy
|
|
26
|
+
* @default package.json -> name
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
/**
|
|
30
|
+
* 发布包版本
|
|
31
|
+
* @default package.json -> version
|
|
32
|
+
*/
|
|
33
|
+
version: string;
|
|
34
|
+
/**
|
|
35
|
+
* 发布包的描述说明
|
|
36
|
+
* @default package.json -> description
|
|
37
|
+
*/
|
|
38
|
+
description: string;
|
|
39
|
+
/**
|
|
40
|
+
* 发布物类型, 默认为 应用名称
|
|
41
|
+
* @default name
|
|
42
|
+
*/
|
|
43
|
+
appType?: string;
|
|
44
|
+
/**
|
|
45
|
+
* 发布物名称, 默认为 应用名称
|
|
46
|
+
* @default name
|
|
47
|
+
*/
|
|
48
|
+
appName?: string;
|
|
49
|
+
/**
|
|
50
|
+
* 应用分组, 默认为 bizframe
|
|
51
|
+
* @default 'bizframe'
|
|
52
|
+
*/
|
|
53
|
+
group?: string;
|
|
54
|
+
/**
|
|
55
|
+
* 配置文件名称,不带有 .js。当强制为空时,可以理解成,是构建静态资源的 see 包,不包含 index.html,config.local.js 文件等,此时 scriptsType 只能使用 bash
|
|
56
|
+
* @default config.local
|
|
57
|
+
*/
|
|
58
|
+
configName?: string;
|
|
59
|
+
/**
|
|
60
|
+
* 输出的目录名称
|
|
61
|
+
* @default dist
|
|
62
|
+
*/
|
|
63
|
+
outputName?: string;
|
|
64
|
+
/**
|
|
65
|
+
* 自定义变量配置文件
|
|
66
|
+
*/
|
|
67
|
+
templateFunc?: () => string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* deploy.xml模板变量, 可以动态配置
|
|
70
|
+
*/
|
|
71
|
+
variablesFunc?: () => Array<variables> | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
|
|
74
|
+
*/
|
|
75
|
+
copyFiles?: string[];
|
|
76
|
+
/**
|
|
77
|
+
* see发布物的包名,也就是 zip 包的命名
|
|
78
|
+
* @default `${system}-${name}-${version}`
|
|
79
|
+
*/
|
|
80
|
+
seePackageName?: string;
|
|
81
|
+
/**
|
|
82
|
+
* see发布物的存放路径,默认项目根目录下的 package
|
|
83
|
+
* @default `package`
|
|
84
|
+
*/
|
|
85
|
+
seePackagePath?: string;
|
|
86
|
+
/**
|
|
87
|
+
* see平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
|
|
88
|
+
* @default web
|
|
89
|
+
*/
|
|
90
|
+
seePackageType?: 'web' | 'docker';
|
|
91
|
+
/**
|
|
92
|
+
* docker 容器化镜像名,seePackageType 为 docker 时生效
|
|
93
|
+
*/
|
|
94
|
+
dockerImage?: string;
|
|
95
|
+
/**
|
|
96
|
+
* 脚本类型
|
|
97
|
+
* @default python
|
|
98
|
+
*/
|
|
99
|
+
scriptsType?: 'python' | 'bash';
|
|
100
|
+
/**
|
|
101
|
+
* 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
|
|
102
|
+
* @default null
|
|
103
|
+
*/
|
|
104
|
+
tplPath?: Record<string, string>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 生成 see 平台部署包
|
|
108
|
+
* @param system {string} 系统类型, SEE 平台的分组是以系统类型字段纬度来的, 默认为 winner-front
|
|
109
|
+
* @param type {string} 应用类型, 外框架 - bizframe | 子系统 - subsystem, 默认为 主系统 - bizframe
|
|
110
|
+
* @param name {string} 发布物名称。当包含 scope 时,如字符 @、/ 。会做自动的转换。如@winner-fed/winner-deploy 转换为 winner-fed-winner-deploy
|
|
111
|
+
* @param appType {string} 发布物类型, 默认为 应用名称 - name
|
|
112
|
+
* @param appName {string} 发布物名称, 默认为 应用名称 - name
|
|
113
|
+
* @param group {string} 应用分组, 默认为 bizframe
|
|
114
|
+
* @param version {string} 发布包版本
|
|
115
|
+
* @param configName {string} 配置文件名称,不带有 .js, 默认为 config.local
|
|
116
|
+
* @param outputName {string} 输出的目录名称,默认为 dist
|
|
117
|
+
* @param templateFunc {function} 自定义变量配置文件, 默认为
|
|
118
|
+
* function () {
|
|
119
|
+
if (type === 'bizframe') {
|
|
120
|
+
return `./dist/config.local.js`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
* @param variablesFunc {function} deploy.xml模板变量, 可以动态配置, 默认为
|
|
124
|
+
* function () {
|
|
125
|
+
* const context = process.cwd()
|
|
126
|
+
if (type === 'bizframe') {
|
|
127
|
+
try {
|
|
128
|
+
const {variables} = require(path.resolve(
|
|
129
|
+
context,
|
|
130
|
+
'build',
|
|
131
|
+
'package',
|
|
132
|
+
`./variables.js`
|
|
133
|
+
));
|
|
134
|
+
|
|
135
|
+
return variables || [];
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error(error);
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
* @param copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
|
|
143
|
+
* @param description {string} 发布包说明
|
|
144
|
+
* @param seePackageName {string} see发布物的包名,也就是 zip 包的命名,默认为 `${system}-${name}-${version}`
|
|
145
|
+
* @param seePackagePath {string} see发布物的存放路径,默认项目根目录下的 package,如果想在根目录下生成see发布物,值可设置为 '/'
|
|
146
|
+
* @param seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
|
|
147
|
+
* @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
|
|
148
|
+
* @param scriptsType 脚本类型 'python' | 'bash'
|
|
149
|
+
* @param tplPath 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
|
|
150
|
+
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
|
|
151
|
+
*/
|
|
152
|
+
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;
|
|
153
|
+
|
|
154
|
+
export { type deployOptions, generateSeePackageZip, type variables, type variablesType };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type variablesType = 'input' | 'select' | 'editor' | 'switch' | 'smallfile' | 'table' | 'mselect' | 'switchForm' | 'complexSelect' | 'division' | 'password' | 'hidden';
|
|
2
2
|
interface variables {
|
|
3
3
|
type: variablesType;
|
|
4
4
|
label: string;
|
|
@@ -151,4 +151,4 @@ interface deployOptions {
|
|
|
151
151
|
*/
|
|
152
152
|
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;
|
|
153
153
|
|
|
154
|
-
export { deployOptions, generateSeePackageZip, variables, variablesType };
|
|
154
|
+
export { type deployOptions, generateSeePackageZip, type variables, type variablesType };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** build time:
|
|
2
|
-
var ae=Object.defineProperty;var q=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var Z=(i,t,n)=>t in i?ae(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,M=(i,t)=>{for(var n in t||(t={}))pe.call(t,n)&&Z(i,n,t[n]);if(q)for(var n of q(t))fe.call(t,n)&&Z(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
|
|
1
|
+
/** build time: Fri Jul 04 2025 16:33:17 GMT+0800 (China Standard Time), build version 4.3.3 **/
|
|
2
|
+
var ae=Object.defineProperty;var q=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var Z=(i,t,n)=>t in i?ae(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,M=(i,t)=>{for(var n in t||(t={}))pe.call(t,n)&&Z(i,n,t[n]);if(q)for(var n of q(t))fe.call(t,n)&&Z(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 Se from"chalk";import $e from"path";import k from"fs-extra";import $ from"fs-extra";import{rimraf as re}from"rimraf";import V from"path";import E from"fs-extra";import me from"archiver";import W from"xml";var z=process.cwd(),X=function(t){let n={""":'"',"'":"'","<":"<",">":">"},o=/(")|(')|(<)|(>)/g;return t&&t.replace?t.replace(o,function(c){return n[c]}):t},F=function(t,n){let o=n||"",c=V.resolve(z,t,o,"sysconfig.js");return E.pathExistsSync(c)},K=function(t){let n=V.resolve(z,t,"config.local.js");return E.pathExistsSync(n)},j=function(t,n,o,c){let r=V.join(z,n);n!=="/"&&E.ensureDirSync(r);let e=E.createWriteStream(`${n==="/"?".":r}/${t}.zip`);e.on("close",function(){setTimeout(function(){c&&c()})});let s=me("zip",{zlib:{level:9}});s.on("error",function(l){console.error(),console.error(l.stack||l),l.details&&console.error(l.details)}),s.pipe(e),s.directory(o,!1),s.finalize()},U=function(t,n,o){let{type:c,label:r,name:e,tooltip:s="",visible:l="true",required:p="false",fixed:y="false",fold:f="false",options:a="",validate:m="",upgrade:u="false"}=t,x=t.default;if(o==="form"){let b=W({form:[{_attr:{name:e,tooltip:s,visible:l,required:p,fixed:y,fold:f,options:a,validate:m,upgrade:u}},n]});return X(b)}let g=c==="complexSelect"?{default:t.default}:{},T=W({field:[{_attr:M({type:c,label:r,name:e,tooltip:s,visible:l,required:p,fixed:y,fold:f,options:a,validate:m,upgrade:u},g)},n||x]});return X(T)},G=function(t){let o=t.children.map(c=>{let e=c.children.map(s=>U(s)).join("");return U(c,e,"form")}).join("");return U(t,o)},L=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 s=i(e.children,n,e.fullName,e.fullPath);if(s)return s}}return null};function H(i="python"){return i==="python"?"py":"sh"}import N from"fs-extra";import ue from"path";import w from"lodash.template";import ye from"xml";import ge from"@babel/core";var de=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],I=i=>ue.resolve(__dirname,`../templates/see/${i}`),Q=i=>{let t=i.type;if(!de.includes(t))return"";let{label:n,name:o,tooltip:c="",visible:r="true",required:e="false",fixed:s="false",fold:l="false",options:p="",validate:y="",upgrade:f="false"}=i,a=i.default;if(t==="table"){let x=i.keys||[];a=(i.columns||x).map(T=>Q(T)).join(`
|
|
3
3
|
`)}else if(t==="switchForm"||t==="division")a=i.children.map(g=>Q(g)).join(`
|
|
4
|
-
`);else{if(t==="complexSelect")return G(i);t==="editor"?a=typeof a=="object"?[JSON.stringify(a)]:[a]:a=[a]}let m=t==="switchForm"?{default:i.default}:{},u=ye({field:[{_attr:M({type:t,label:n,name:o,tooltip:c,visible:r,required:e,fixed:s,fold:l,options:p,validate:y,upgrade:f},m)},...Array.isArray(a)?a:[a]]});return X(u)},Y=function({system:t,type:n,name:o,appType:c,appName:r,group:e,version:s,configFileName:l="config.local",variables:p=[],description:y,scriptsType:f="python"}){let a=N.readFileSync(I(`${f}/deploy.xml`)).toString();return w(a,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:o,appName:r,appType:c,group:e,version:s,configFileName:l,variables:
|
|
5
|
-
`)
|
|
6
|
-
`)
|
|
4
|
+
`);else{if(t==="complexSelect")return G(i);t==="editor"?a=typeof a=="object"?[JSON.stringify(a)]:[a]:a=[a]}let m=t==="switchForm"?{default:i.default}:{},u=ye({field:[{_attr:M({type:t,label:n,name:o,tooltip:c,visible:r,required:e,fixed:s,fold:l,options:p,validate:y,upgrade:f},m)},...Array.isArray(a)?a:[a]]});return X(u)},Y=function({system:t,type:n,name:o,appType:c,appName:r,group:e,version:s,configFileName:l="config.local",variables:p=[],description:y,scriptsType:f="python"}){let a=N.readFileSync(I(`${f}/deploy.xml`)).toString();return w(a,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:o,appName:r,appType:c,group:e,version:s,configFileName:l,variables:p.map(m=>Q(m)).join(`
|
|
5
|
+
`),description:y})},R=function(t,n){let o=N.readFileSync(I(`${n.scriptsType}/scripts/${t}.${n.scriptsType==="python"?"py":"sh"}`)).toString();return w(o,{interpolate:/{{([\s\S]+?)}}/g})(n)},v=function(t,n=[]){let{code:o}=ge.transformFileSync(t,{babelrc:!1,plugins:[function(){return{visitor:{Literal(r){if(r.parentPath.isProperty()){let e=r.parentPath.get("key").node,s=e.name;e.type==="StringLiteral"&&(e.type="Identifier",e.name=e.value,s=e.value);let l=L(n,p=>s===p.name);if(l){if(l.fullPath.includes("complexSelect")&&(l.name=l.fullName),r.isStringLiteral()){r.node.value=`$!{${l.name}}`;return}if(r.isNumericLiteral()){r.node.value=`$!{${l.name}}`;return}if(r.isBooleanLiteral()){if(r.node.type="StringLiteral",l.fullPath.includes("complexSelect")){r.node.value=`$!{${l.fullName}}`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`}}}},ArrayExpression(r){if(r.parentPath.isProperty()){let e=L(n,s=>r.parentPath.get("key").node.name===s.name);if(e){if(e.fullPath.includes("editor")){r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS]\${${e.name}}[NO_QUOTATION_MARKS]`;return}e.fullPath.includes("complexSelect")&&(e.name=e.fullName);let s="",l=e.keys||[],p=e.columns||l;if(e.options){s=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) '$row' , #end][NO_QUOTATION_MARKS]`,r.node.type="StringLiteral",r.node.value=s;return}p&&p.length&&p.forEach(f=>{s+=`${f.name}: '$!{row.${f.name}}',`}),r.node.type="StringLiteral",r.node.value=`[NO_QUOTATION_MARKS][#foreach($row in $${e.name}) {${s}}, #end][NO_QUOTATION_MARKS]`}}},ObjectExpression(r){if(r.parentPath.isProperty()){let e=r.parentPath.get("key").node,s=e.name;if(e){let l=L(n,p=>s===p.name);if(l){if(r.node.type="StringLiteral",l.fullPath.includes("editor")){r.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`;return}r.node.value=`[NO_QUOTATION_MARKS]\${${l.name}}[NO_QUOTATION_MARKS]`;return}}}}}}}],retainLines:!0});return o.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g,"$1")},ee=function({system:t,type:n,name:o,appName:c,appType:r,version:e,group:s,configFileName:l="config.local",variables:p=[],description:y,web_app_web_service_name:f,dockerImage:a}){let m=N.readFileSync(I("docker/deploy.xml")).toString();return w(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:o,appName:c,appType:r,version:e,group:s,configFileName:l,variables:p.map(u=>Q(u)).join(`
|
|
6
|
+
`),description:y,web_app_web_service_name:f,dockerImage:a})},te=function(t){let n=N.readFileSync(I("docker/k8s-deploy-res.yaml")).toString();return w(n,{interpolate:/{{([\s\S]+?)}}/g})(t)},ne=function(t){let n=N.readFileSync(I("docker/Dockerfile")).toString();return w(n)(t)};var d="tmp",oe=function(t,n,o){let{system:c,type:r,name:e,appType:s,appName:l,group:p,version:y,template:f,variables:a=[],configName:m,outputName:u="dist",description:x,scriptsType:g,seePackagePath:T,tplPath:b}=n;$.ensureDirSync(d),$.ensureDirSync(`${d}/scripts`),$.ensureDirSync(`${d}/template`);let A=H(g);g==="python"&&$.outputFileSync(`./${d}/scripts/${e}/utils.${A}`,R("utils",{scriptsType:g})),$.outputFileSync(`./${d}/scripts/${e}/install.${A}`,R("install",{name:e,type:r,scriptsType:g})),$.outputFileSync(`./${d}/scripts/${e}/afterInstall.${A}`,R("afterInstall",{name:e,scriptsType:g})),$.outputFileSync(`./${d}/scripts/${e}/uninstall.${A}`,R("uninstall",{name:e,type:r,scriptsType:g}));let D=!1,P=!1;if(b&&Object.keys(b).length>0)for(let[S,_]of Object.entries(b))S==="deploy.xml"?($.copyFileSync(_,`./${d}/deploy.xml`),D=!0):$.copyFileSync(_,`./${d}/template/${S}`),(S==="sysconfig.js"||S==="config.local.js")&&(P=!0);D||$.outputFileSync(`./${d}/deploy.xml`,Y({system:c,type:r,name:e,appType:s,appName:l,group:p,version:y,configFileName:m,variables:a,description:x,scriptsType:g})),P||(K(u)?$.outputFileSync(`./${d}/template/config.local.js`,f?v(f,a):""):F(u)||F(u,e)?(m="sysconfig",$.outputFileSync(`./${d}/template/sysconfig.js`,f?v(f,a):"")):m&&$.outputFileSync(`./${d}/template/${m}.js`,f?v(f,a):"")),o?o(S=>{j(t,T,d,()=>{re.sync(d),typeof S=="function"&&S()})}):j(t,T,d,()=>{re.sync(d)})};import ie from"path";import O from"fs-extra";import{rimraf as se}from"rimraf";var h="tmp",le=function(t,n,o){let{system:c,type:r,name:e,appType:s,appName:l,version:p,group:y,template:f,variables:a,configName:m,outputName:u,description:x,seePackagePath:g,dockerImage:T=p.indexOf("-")>0?`isee1.0-docker-dev-local/${e}`:`isee1.0-docker-release-local/${e}`}=n;O.ensureDirSync(h),O.ensureDirSync("docker"),O.pathExistsSync(ie.resolve(process.cwd(),"docker/Dockerfile"))||O.outputFileSync(ie.resolve(process.cwd(),"docker/Dockerfile"),ne({name:e,type:r})),O.ensureDirSync(`${h}/scripts`),O.ensureDirSync(`${h}/template`),K(u)?O.outputFileSync(`./${h}/template/${e}/config.local.js`,f?v(f,a):""):F(u)||F(u,e)?(m="sysconfig",O.outputFileSync(`./${h}/template/${e}/sysconfig.js`,f?v(f,a):"")):m&&O.outputFileSync(`./${h}/template/${e}/${m}.js`,f?v(f,a):""),O.outputFileSync(`./${h}/template/k8s-deploy-res.yaml`,te({configFileName:m})),O.outputFileSync(`./${h}/deploy.xml`,ee({system:c,type:r,name:e,appName:l,appType:s,version:p,group:y,configFileName:m,variables:a,description:x,web_app_web_service_name:`${e}-web`,dockerImage:T})),o?o(b=>{j(t,g,h,()=>{se.sync(h),typeof b=="function"&&b()})}):j(t,g,h,()=>{se.sync(h)})};var he=process.cwd();function xe(i,t,n){let o="",c;if(i==="bizframe"){o=k.readdirSync(`./${n}`).find(r=>/manifest\.[0-9]+\.json/.test(r));try{c=k.readJsonSync(`./${n}/${o}`)}catch(r){console.error(`${n} \u76EE\u5F55\u4E0B\u7684 manifest.xxx.json \u89E3\u6790\u5931\u8D25\uFF01\u8BF7\u786E\u8BA4\u6B64\u6587\u4EF6\u662F\u5426\u5B58\u5728\u3002\u6216\u53EF\u4EE5\u5C06 scriptsType \u8BBE\u7F6E\u4E3A bash \u8BD5\u8BD5\u770B\u3002`),process.exit(0)}}return i==="subsystem"&&(o=k.readdirSync(`./${n}/${t}`).find(r=>/manifest\.[0-9]+\.json/.test(r)),c=k.readJsonSync(`./${n}/${t}/${o}`)),{manifest:o,manifestJson:c}}var He=function({system:t="winner-front",type:n="bizframe",name:o,appType:c,appName:r,group:e="bizframe",version:s,configName:l="config.local",outputName:p="dist",templateFunc:y,variablesFunc:f,copyFiles:a,description:m,seePackageName:u,seePackagePath:x="package",seePackageType:g="web",dockerImage:T,scriptsType:b="python",tplPath:A={}},D){if(!o||!s)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,"-")),c=c||o,r=r||o,f=f||function(){try{let{variables:P}=B($e.resolve(he,"build","package","./variables.js"));return P||[]}catch(P){return console.error(P),[]}},y=y||function(){return n==="bizframe"?`./${p}/config.local.js`:`./${p}/${o}/sysconfig.js`},g==="docker"){le(u||`${t}-${o}-${s}`,{system:t,type:n,name:o,appType:c,appName:r,group:e,version:s,configName:l,outputName:p,template:y(),variables:f(),seePackagePath:x,description:m,dockerImage:T},P=>{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"),P(D)});return}oe(u||`${t}-${o}-${s}`,{system:t,type:n,name:o,group:e,appType:c,appName:r,version:s,configName:l,outputName:p,template:y(),variables:f(),seePackagePath:x,description:m,scriptsType:b,tplPath:A},P=>{if(b==="python"){let{manifest:S,manifestJson:_}=xe(n,o,p);for(let C in _)if(_.hasOwnProperty(C)){let{path:J,dir:ce}=_[C];k.ensureDirSync(`./tmp/source/${ce}`),k.copyFileSync(`./${p}/${J}`,`./tmp/source/${J}`)}k.outputJSONSync(`./tmp/scripts/${o}/conf/${S}`,_)}else k.ensureDirSync("./tmp/source"),k.copySync(`./${p}`,"./tmp/source");Array.isArray(a)&&a.length&&a.forEach(S=>{k.ensureFileSync(`./tmp/source/${o}/${S}`),k.copyFileSync(`./${p}/${o}/${S}`,`./tmp/source/${o}/${S}`)}),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.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
7
|
`),P(D)})};export{He as generateSeePackageZip};
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winner-fed/winner-deploy",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.3",
|
|
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
|
+
"packageManager": "pnpm@10.0.0",
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"module": "dist/index.js",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
|
-
"
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
17
|
"import": "./dist/index.js",
|
|
18
|
-
"
|
|
18
|
+
"require": "./dist/index.cjs"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"typesVersions": {
|
|
@@ -32,22 +32,23 @@
|
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"files": [
|
|
34
34
|
"dist",
|
|
35
|
-
"templates"
|
|
35
|
+
"templates",
|
|
36
|
+
"TYPE.md"
|
|
36
37
|
],
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@babel/core": "
|
|
39
|
-
"archiver": "
|
|
40
|
-
"chalk": "
|
|
39
|
+
"@babel/core": "catalog:",
|
|
40
|
+
"archiver": "catalog:",
|
|
41
|
+
"chalk": "catalog:",
|
|
41
42
|
"fs-extra": "10.1.0",
|
|
42
|
-
"lodash.template": "
|
|
43
|
-
"rimraf": "
|
|
44
|
-
"xml": "
|
|
43
|
+
"lodash.template": "catalog:",
|
|
44
|
+
"rimraf": "catalog:",
|
|
45
|
+
"xml": "catalog:"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@types/fs-extra": "
|
|
48
|
-
"@types/lodash.template": "
|
|
48
|
+
"@types/fs-extra": "catalog:",
|
|
49
|
+
"@types/lodash.template": "catalog:",
|
|
49
50
|
"@types/node": "^16.10.1",
|
|
50
|
-
"tsup": "
|
|
51
|
+
"tsup": "catalog:"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
53
54
|
"dev": "tsup --watch",
|