@winner-fed/winner-deploy 3.0.1 → 3.0.5

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
@@ -7,11 +7,11 @@ python2 对应 template/1.x
7
7
  ```javscript
8
8
  /**
9
9
  * 生成 see 平台部署包
10
- * @param system {string} 系统类型(发布物的系统类型), SEE 平台的分组是以系统类型字段纬度来的, 默认为 winner-front
11
- * @param type {string} 应用类型(发布物的应用类型), 外框架 - bizframe | 子系统 - subsystem, 默认为 子系统 - subsystem
12
- * @param name {string} 发布物名称(发布物的应用名称)
13
- * @param appType {string} 发布物类型(发布物的应用类型), 默认为 应用名称 - name
14
- * @param version {string} 发布包版本(发布物的版本)
10
+ * @param system {string} 系统类型, SEE 平台的分组是以系统类型字段纬度来的, 默认为 winner-front
11
+ * @param type {string} 应用类型, 外框架 - bizframe | 子系统 - subsystem, 默认为 子系统 - subsystem
12
+ * @param name {string} 发布物名称
13
+ * @param appType {string} 发布物类型, 默认为 应用名称 - name
14
+ * @param version {string} 发布包版本
15
15
  * @param configName {string} 配置文件名称,不带有 .js, 默认为 config.local
16
16
  * @param templateFunc {function} 自定义变量配置文件, 默认为
17
17
  * function () {
@@ -38,12 +38,14 @@ python2 对应 template/1.x
38
38
  }
39
39
  }
40
40
  }
41
- * @param copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
41
+ * @param copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
42
42
  * @param description {string} 发布包说明
43
43
  * @param seePackageName {string} see发布物的包名,也就是 zip 包的命名,默认为 `${system}-${name}-${version}`
44
- * @param cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
44
+ * @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
45
+ * @param seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
46
+ * @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
45
47
  */
46
- exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc, copyFiles, description}, cb) {
48
+ exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc, copyFiles, description, seePackageType, dockerImage}, cb) {
47
49
  ...
48
50
  }
49
51
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winner-fed/winner-deploy",
3
- "version": "3.0.1",
3
+ "version": "3.0.5",
4
4
  "description": "Generate a publication deployed by the See platform",
5
5
  "keywords": [
6
6
  "winner",
@@ -31,13 +31,18 @@ exports.genDockerPackage = function genDockerPackage (seePackageName, options, h
31
31
  template,
32
32
  variables,
33
33
  configName: configFileName,
34
- description
34
+ description,
35
+ dockerImage = version.indexOf('-') > 0 ? `ws6.0-docker-dev-local/${name}` : `ws6.0-docker-release-local/${name}`
35
36
  } = options
36
37
  fs.ensureDirSync(tmp)
37
38
 
38
39
  // 项目根目录下 Dockerfile 文件
39
40
  fs.ensureDirSync('docker')
40
- fs.outputFileSync(path.resolve(process.cwd(), `docker/Dockerfile`), genDockerfile({ name }));
41
+
42
+ // 如果项目根目录下已经存在 Dockerfile,则不进行重新生成
43
+ if (!fs.pathExistsSync(path.resolve(process.cwd(), `docker/Dockerfile`))) {
44
+ fs.outputFileSync(path.resolve(process.cwd(), `docker/Dockerfile`), genDockerfile({ name }));
45
+ }
41
46
 
42
47
  // 缺少 scripts 目录会导致 SEE 平台上传发布物报错
43
48
  fs.ensureDirSync(`${tmp}/scripts`);
@@ -70,13 +75,14 @@ exports.genDockerPackage = function genDockerPackage (seePackageName, options, h
70
75
  variables,
71
76
  description,
72
77
  web_app_web_service_name: `${name}-web`,
73
- dockerImage: version.indexOf('-') > 0 ? `ws6.0-docker-dev-local/${name}` : `ws6.0-docker-release-local/${name}`
78
+ dockerImage
74
79
  }))
75
80
 
76
81
  if (handler) {
77
- handler(() => {
82
+ handler((cb) => {
78
83
  genZipPackage(seePackageName, tmp, () => {
79
84
  rm.sync(tmp)
85
+ typeof cb === 'function' && cb()
80
86
  })
81
87
  })
82
88
  } else {
@@ -68,9 +68,10 @@ exports.genSeePackage = function genSeePackage (seePackageName, options, handler
68
68
  }))
69
69
 
70
70
  if (handler) {
71
- handler(() => {
71
+ handler((cb) => {
72
72
  genZipPackage(seePackageName, tmp, () => {
73
73
  rm.sync(tmp)
74
+ typeof cb === 'function' && cb()
74
75
  })
75
76
  })
76
77
  } else {
@@ -67,8 +67,9 @@ function genManifest (type, name) {
67
67
  * @param copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
68
68
  * @param description {string} 发布包说明
69
69
  * @param seePackageName {string} see发布物的包名,也就是 zip 包的命名,默认为 `${system}-${name}-${version}`
70
- * @param cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
70
+ * @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
71
71
  * @param seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
72
+ * @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
72
73
  */
73
74
  exports.generateSeePackageZip = function generateSeePackageZip ({
74
75
  system,
@@ -82,7 +83,8 @@ exports.generateSeePackageZip = function generateSeePackageZip ({
82
83
  copyFiles,
83
84
  description,
84
85
  seePackageName,
85
- seePackageType = 'web'
86
+ seePackageType = 'web',
87
+ dockerImage
86
88
  }, cb) {
87
89
  if (!name || !version) {
88
90
  throw new Error('应用名称和应用版本不能缺失~')
@@ -126,18 +128,17 @@ exports.generateSeePackageZip = function generateSeePackageZip ({
126
128
  configName,
127
129
  template: (templateFunc)(),
128
130
  variables: (variablesFunc)(),
129
- description
131
+ description,
132
+ dockerImage
130
133
  },
131
134
  done => {
132
135
 
133
- // 自定义执行的操作
134
- typeof cb === 'function' && cb()
135
-
136
- done()
137
136
  console.log()
138
137
  ora(
139
138
  `docker 容器化部署的 SEE 发布物制作完成,您可以在 SEE 平台上传并部署应用。`
140
139
  ).succeed()
140
+
141
+ done(cb)
141
142
  }
142
143
  )
143
144
  return;
@@ -183,16 +184,14 @@ exports.generateSeePackageZip = function generateSeePackageZip ({
183
184
  });
184
185
  }
185
186
 
186
- // 自定义执行的操作
187
- typeof cb === 'function' && cb()
188
-
189
- done()
190
187
  console.log()
191
188
  ora(
192
189
  `发布物制作完成,您可以在 SEE 平台上传并部署应用。注意:${chalk.yellow(
193
190
  '子系统发布物的安装目录需要指定到具体的应用目录'
194
191
  )}。比如/home/hsiar/hsiar-green/html/。\n`
195
192
  ).succeed()
193
+
194
+ done(cb)
196
195
  }
197
196
  )
198
197
  }
@@ -1,8 +1,10 @@
1
1
  # Dockerfile用于生成应用镜像,非特殊情况请勿修改
2
2
  FROM package.hundsun.com/public-docker-local/freestyle/hswealth/nginx:1.18.0-alpine-see
3
3
 
4
- WORKDIR ${name}
4
+ COPY dist /usr/share/nginx/html/hui-pro
5
5
 
6
- COPY html "./"
6
+ RUN chmod +x /etc/nginx/* && \
7
+ chmod +x /usr/share/nginx/html/* &&\
8
+ chmod +x /usr/local/bin/*
7
9
 
8
- RUN chmod -R a+x "./"
10
+ WORKDIR /usr/share/nginx/html
@@ -15,7 +15,7 @@
15
15
  <system id="${ name }" type="" name="${ name }" mode="cluster" front="">
16
16
  <variables describe="集群基本参数">
17
17
  <field name="user" label="安装用户" type="input">root</field>
18
- <field name="workspace" label="前端安装目录" type="hidden">/html</field>
18
+ <field name="workspace" label="前端安装目录" type="input" tooltip="IAR上存放前端目录">/home/hsiar/hsiar-green/html</field>
19
19
 
20
20
  <!-- K8S部署配置 -->
21
21
  <field name="division_k8s" label="K8S部署配置" type="division" fold="false">
@@ -7,9 +7,9 @@ metadata:
7
7
  name: ${svc_id}-service
8
8
  spec:
9
9
  ports:
10
- - name: "http"
11
- port: 80
12
- targetPort: 80
10
+ - name: "http"
11
+ port: 80
12
+ targetPort: 80
13
13
  selector:
14
14
  name: ${svc_id}
15
15
  ---
@@ -29,10 +29,10 @@ spec:
29
29
  name: ${svc_id}
30
30
  spec:
31
31
  imagePullPolicy: ${image_pull_policy}
32
- #if(${image_pull_secrets_enable} == "true")
32
+ #if(${image_pull_secrets_enable} == "true")
33
33
  imagePullSecrets:
34
- - name: ${image_pull_secrets}
35
- #end
34
+ - name: ${image_pull_secrets}
35
+ #end
36
36
  restartPolicy: ${restart_policy}
37
37
  hostname: ${web_app_web_service_name}
38
38
  containers:
@@ -43,7 +43,7 @@ spec:
43
43
  value: Asia/Shanghai
44
44
  ports:
45
45
  - containerPort: 80
46
- #if(${resources_enable} == "true")
46
+ #if(${resources_enable} == "true")
47
47
  resources:
48
48
  requests:
49
49
  cpu: ${cpu_req}
@@ -51,13 +51,13 @@ spec:
51
51
  limits:
52
52
  cpu: ${cpu_limit}
53
53
  memory: ${memory_limit}
54
- #end
55
- #if(${liveness_probe_enable} == "true")
54
+ #end
55
+ #if(${liveness_probe_enable} == "true")
56
56
  livenessProbe:
57
57
  httpGet:
58
58
  scheme: HTTP
59
59
  port: 80
60
- path: /{{ configFileName }}.js
60
+ path: /sysconfig.js
61
61
  initialDelaySeconds: 5
62
62
  periodSeconds: 3
63
63
  timeoutSeconds: 3
@@ -67,7 +67,7 @@ spec:
67
67
  httpGet:
68
68
  scheme: HTTP
69
69
  port: 80
70
- path: /{{ configFileName }}.js
70
+ path: /sysconfig.js
71
71
  initialDelaySeconds: 5
72
72
  periodSeconds: 3
73
73
  timeoutSeconds: 3