@winner-fed/winner-deploy 2.0.8 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,14 +3,15 @@
3
3
  ## python 版本脚本兼容性问题
4
4
  python2 对应 template/1.x
5
5
 
6
+ ## 功能接口说明
6
7
  ```javscript
7
8
  /**
8
9
  * 生成 see 平台部署包
9
- * @param system {string} 系统类型, SEE 平台的分组是以系统类型字段纬度来的, 默认为 winner-front
10
- * @param type {string} 应用类型, 外框架 - bizframe | 子系统 - subsystem, 默认为 子系统 - subsystem
11
- * @param name {string} 发布物名称
12
- * @param appType {string} 发布物类型, 默认为 应用名称 - name
13
- * @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} 发布包版本(发布物的版本)
14
15
  * @param configName {string} 配置文件名称,不带有 .js, 默认为 config.local
15
16
  * @param templateFunc {function} 自定义变量配置文件, 默认为
16
17
  * function () {
@@ -37,8 +38,11 @@ python2 对应 template/1.x
37
38
  }
38
39
  }
39
40
  }
41
+ * @param copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
42
+ * @param description {string} 发布包说明
43
+ * @param cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
40
44
  */
41
- exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc}) {
45
+ exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc, copyFiles, description}, cb) {
42
46
  ...
43
47
  }
44
48
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winner-fed/winner-deploy",
3
- "version": "2.0.8",
3
+ "version": "2.0.12",
4
4
  "description": "Generate a publication deployed by the See platform",
5
5
  "keywords": [
6
6
  "winner",
@@ -13,11 +13,6 @@
13
13
  "templates"
14
14
  ],
15
15
  "author": "winner-fed <cloudbroker@163.com>",
16
- "repository": {
17
- "type": "git",
18
- "url": "https://github.com/cloud-templates/winner-deploy"
19
- },
20
- "license": "MIT",
21
16
  "engines": {
22
17
  "node": ">=6.0.0"
23
18
  },
@@ -62,7 +57,6 @@
62
57
  "devDependencies": {
63
58
  "@commitlint/cli": "^11.0.0",
64
59
  "@commitlint/config-conventional": "^11.0.0",
65
- "@winner-fed/eslint-config-win": "^1.0.7",
66
60
  "babel-eslint": "^10.1.0",
67
61
  "colors": "^1.4.0",
68
62
  "commitizen": "^4.2.2",
@@ -49,7 +49,7 @@ function genZipPackage (zipPackageName, cb) {
49
49
  * @param handler
50
50
  */
51
51
  exports.genSeePackage = function genSeePackage (seePackageName, options, handler) {
52
- let { system, type, name, appType, version, template, variables, configName: configFileName } = options
52
+ let { system, type, name, appType, version, template, variables, configName: configFileName, description } = options
53
53
  fs.ensureDirSync(tmp)
54
54
  fs.ensureDirSync(`${tmp}/scripts`)
55
55
  fs.outputFileSync(`./${tmp}/scripts/${name}/utils.py`, genScripts('utils'))
@@ -81,7 +81,8 @@ exports.genSeePackage = function genSeePackage (seePackageName, options, handler
81
81
  appType,
82
82
  version,
83
83
  configFileName,
84
- variables
84
+ variables,
85
+ description
85
86
  }))
86
87
 
87
88
  if (handler) {
package/src/see.js CHANGED
@@ -5,7 +5,7 @@ const xml = require('xml')
5
5
  const babel = require('@babel/core')
6
6
  const { unEscapeForXML } = require('./utils')
7
7
 
8
- exports.genDeployXml = function genDeployXml ({ system, type, name, appType, version, configFileName = 'config.local', variables = [] }) {
8
+ exports.genDeployXml = function genDeployXml ({ system, type, name, appType, version, configFileName = 'config.local', variables = [], description }) {
9
9
  const template = fs.readFileSync(path.resolve(__dirname, `../templates/see/1.x/deploy.xml`))
10
10
 
11
11
  return tpl(template)({
@@ -24,7 +24,8 @@ exports.genDeployXml = function genDeployXml ({ system, type, name, appType, ver
24
24
  return unEscapeForXML(`${xmlVariable}`)
25
25
  })
26
26
  .join('\n ')
27
- })()
27
+ })(),
28
+ description
28
29
  })
29
30
  }
30
31
 
@@ -1,33 +1,33 @@
1
- const chalk = require('chalk');
2
- const path = require('path');
3
- const ora = require('ora');
4
- const fs = require('fs-extra');
1
+ const chalk = require('chalk')
2
+ const path = require('path')
3
+ const ora = require('ora')
4
+ const fs = require('fs-extra')
5
5
 
6
- const context = process.cwd();
6
+ const context = process.cwd()
7
7
 
8
- const {genSeePackage} = require('./genZipPackage');
8
+ const { genSeePackage } = require('./genZipPackage')
9
9
 
10
10
  function genManifest (type, name) {
11
- let manifest = '';
12
- let manifestJson = '';
11
+ let manifest = ''
12
+ let manifestJson = ''
13
13
 
14
14
  if (type === 'bizframe') {
15
15
  manifest = fs
16
16
  .readdirSync(`./dist`)
17
- .find(file => /manifest\.[0-9]+\.json/.test(file));
17
+ .find(file => /manifest\.[0-9]+\.json/.test(file))
18
18
 
19
- manifestJson = fs.readJsonSync(`./dist/${manifest}`);
19
+ manifestJson = fs.readJsonSync(`./dist/${manifest}`)
20
20
  }
21
21
 
22
22
  if (type === 'subsystem') {
23
23
  manifest = fs
24
24
  .readdirSync(`./dist/${name}`)
25
- .find(file => /manifest\.[0-9]+\.json/.test(file));
25
+ .find(file => /manifest\.[0-9]+\.json/.test(file))
26
26
 
27
- manifestJson = fs.readJsonSync(`./dist/${name}/${manifest}`);
27
+ manifestJson = fs.readJsonSync(`./dist/${name}/${manifest}`)
28
28
  }
29
29
 
30
- return {manifest, manifestJson};
30
+ return { manifest, manifestJson }
31
31
  }
32
32
 
33
33
  /**
@@ -63,35 +63,49 @@ function genManifest (type, name) {
63
63
  }
64
64
  }
65
65
  }
66
+ * @param copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
67
+ * @param description {string} 发布包说明
68
+ * @param cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
66
69
  */
67
- exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc}) {
68
- if(!name || !version) {
70
+ exports.generateSeePackageZip = function generateSeePackageZip ({
71
+ system,
72
+ type,
73
+ name,
74
+ appType,
75
+ version,
76
+ configName,
77
+ templateFunc,
78
+ variablesFunc,
79
+ copyFiles,
80
+ description
81
+ }, cb) {
82
+ if (!name || !version) {
69
83
  throw new Error('应用名称和应用版本不能缺失~')
70
84
  }
71
85
  system = system || 'winner-front'
72
86
  type = type || 'bizframe'
73
87
  appType = appType || name
74
- variablesFunc = variablesFunc || function () {
88
+ variablesFunc = variablesFunc || function() {
75
89
  if (type === 'bizframe') {
76
90
  try {
77
- const {variables} = require(path.resolve(
91
+ const { variables } = require(path.resolve(
78
92
  context,
79
93
  'build',
80
94
  'package',
81
95
  `./variables.js`
82
- ));
96
+ ))
83
97
 
84
- return variables || [];
98
+ return variables || []
85
99
  } catch (error) {
86
- console.error(error);
87
- return [];
100
+ console.error(error)
101
+ return []
88
102
  }
89
103
  }
90
104
  }
91
105
 
92
- templateFunc = templateFunc || function () {
106
+ templateFunc = templateFunc || function() {
93
107
  if (type === 'bizframe') {
94
- return `./dist/config.local.js`;
108
+ return `./dist/config.local.js`
95
109
  }
96
110
  }
97
111
 
@@ -105,38 +119,52 @@ exports.generateSeePackageZip = function generateSeePackageZip({system, type, na
105
119
  version,
106
120
  configName,
107
121
  template: (templateFunc)(),
108
- variables: (variablesFunc)()
122
+ variables: (variablesFunc)(),
123
+ description
109
124
  },
110
125
  done => {
111
- const {manifest, manifestJson} = genManifest(type, name);
126
+ const { manifest, manifestJson } = genManifest(type, name)
112
127
  // 发布物中的源码部分统一放到 source 目录下
113
128
  for (const file in manifestJson) {
114
129
  if (manifestJson.hasOwnProperty(file)) {
115
- const {path, root, dir} = manifestJson[file];
130
+ const { path, dir } = manifestJson[file]
116
131
 
117
- fs.ensureDirSync(`./tmp/source/${dir}`);
118
- fs.copyFileSync(`./dist/${path}`, `./tmp/source/${path}`);
132
+ fs.ensureDirSync(`./tmp/source/${dir}`)
133
+ fs.copyFileSync(`./dist/${path}`, `./tmp/source/${path}`)
119
134
  }
120
135
  }
121
136
 
122
137
  fs.outputJSONSync(
123
138
  `./tmp/scripts/${name}/conf/${manifest}`,
124
139
  manifestJson
125
- );
140
+ )
141
+
142
+ // 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里
143
+ if (Array.isArray(copyFiles) && copyFiles.length) {
144
+ copyFiles.forEach((file) => {
145
+ // 1. 首先先确保文件目录存在,否则创建
146
+ fs.ensureFileSync(`./tmp/source/${name}/${file}`)
147
+ // 2. 然后进行拷贝
148
+ fs.copyFileSync(`./dist/${name}/${file}`, `./tmp/source/${name}/${file}`)
149
+ });
150
+ }
151
+
152
+ // 自定义执行的操作
153
+ typeof cb === 'function' && cb()
126
154
 
127
- done();
128
- console.log();
155
+ done()
156
+ console.log()
129
157
  ora(
130
158
  `发布物制作完成,您可以在 SEE 平台上传并部署应用。注意:${chalk.yellow(
131
159
  '子系统发布物的安装目录需要指定到具体的应用目录'
132
160
  )}。比如/home/hsiar/hsiar-green/html/。\n`
133
- ).succeed();
161
+ ).succeed()
134
162
  }
135
- );
163
+ )
136
164
  }
137
165
 
138
166
  /**
139
167
  * 兼容 hui-deploy
140
168
  * @type {function(*=, *, *=): void}
141
169
  */
142
- exports.genSeePackage = genSeePackage;
170
+ exports.genSeePackage = genSeePackage
@@ -5,7 +5,7 @@
5
5
  <systemType describe="系统类型">${ system }</systemType>
6
6
  <appName describe="发布物名称">${ name }</appName>
7
7
  <appType describe="发布物类型">${ appType }</appType>
8
- <appDescribe describe="发布包说明">发布包说明...</appDescribe>
8
+ <appDescribe describe="发布包说明">${ description }</appDescribe>
9
9
  <version describe="发布包版本">${ version }</version>
10
10
  <group describe="应用分组">${ type }</group>
11
11
  <packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)"></packInEffect>