@winner-fed/winner-deploy 2.0.6 → 2.0.10

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
@@ -1,14 +1,17 @@
1
1
  # winner-deploy
2
2
 
3
+ ## python 版本脚本兼容性问题
4
+ python2 对应 template/1.x
5
+
3
6
  ```javscript
4
7
  /**
5
8
  * 生成 see 平台部署包
6
- * @param system {string} 系统类型, SEE 平台的分组是以系统类型字段纬度来的, 默认为 winner-front
7
- * @param type {string} 应用类型, 外框架 - bizframe | 子系统 - subsystem, 默认为 子系统 - subsystem
8
- * @param name {string} 发布物名称
9
- * @param appType {string} 发布物类型, 默认为 应用名称 - name
10
- * @param version {string} 发布包版本
11
- * @param configName {string} 配置文件名称, 默认为 config.local
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} 发布包版本(发布物的版本)
14
+ * @param configName {string} 配置文件名称,不带有 .js, 默认为 config.local
12
15
  * @param templateFunc {function} 自定义变量配置文件, 默认为
13
16
  * function () {
14
17
  if (type === 'bizframe') {
@@ -34,8 +37,10 @@
34
37
  }
35
38
  }
36
39
  }
40
+ * @param copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
41
+ * @param cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
37
42
  */
38
- exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc}) {
43
+ exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc}, cb) {
39
44
  ...
40
45
  }
41
46
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winner-fed/winner-deploy",
3
- "version": "2.0.6",
3
+ "version": "2.0.10",
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",
@@ -45,11 +45,11 @@ function genZipPackage (zipPackageName, cb) {
45
45
  * @property {options.name} 发布物名称
46
46
  * @property {options.appType} 发布物类型
47
47
  * @property {options.version} 发布包版本
48
- * @property {options.configFileName} 配置文件名称 winner - config.local pro - sysconfig
48
+ * @property {options.configName} 配置文件名称 winner - config.local pro - sysconfig
49
49
  * @param handler
50
50
  */
51
51
  exports.genSeePackage = function genSeePackage (seePackageName, options, handler) {
52
- let { system, type, name, appType, version, template, variables, configFileName } = options
52
+ let { system, type, name, appType, version, template, variables, configName: configFileName } = options
53
53
  fs.ensureDirSync(tmp)
54
54
  fs.ensureDirSync(`${tmp}/scripts`)
55
55
  fs.outputFileSync(`./${tmp}/scripts/${name}/utils.py`, genScripts('utils'))
@@ -69,6 +69,9 @@ exports.genSeePackage = function genSeePackage (seePackageName, options, handler
69
69
  // 兼容操作员中心产品
70
70
  configFileName = 'sysconfig';
71
71
  fs.outputFileSync(`./${tmp}/template/${name}/sysconfig.js`, template ? genTemplate(template, variables) : '')
72
+ } else {
73
+ // 自定义配置文件的名字
74
+ fs.outputFileSync(`./${tmp}/template/${name}/${configFileName}.js`, template ? genTemplate(template, variables) : '')
72
75
  }
73
76
 
74
77
  fs.outputFileSync(`./${tmp}/deploy.xml`, genDeployXml({
@@ -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
  /**
@@ -37,7 +37,7 @@ function genManifest (type, name) {
37
37
  * @param name {string} 发布物名称
38
38
  * @param appType {string} 发布物类型, 默认为 应用名称 - name
39
39
  * @param version {string} 发布包版本
40
- * @param configName {string} 配置文件名称, 默认为 config.local
40
+ * @param configName {string} 配置文件名称,不带有 .js, 默认为 config.local
41
41
  * @param templateFunc {function} 自定义变量配置文件, 默认为
42
42
  * function () {
43
43
  if (type === 'bizframe') {
@@ -63,35 +63,47 @@ 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 cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
66
68
  */
67
- exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc}) {
68
- if(!name || !version) {
69
+ exports.generateSeePackageZip = function generateSeePackageZip ({
70
+ system,
71
+ type,
72
+ name,
73
+ appType,
74
+ version,
75
+ configName,
76
+ templateFunc,
77
+ variablesFunc,
78
+ copyFiles
79
+ }, cb) {
80
+ if (!name || !version) {
69
81
  throw new Error('应用名称和应用版本不能缺失~')
70
82
  }
71
83
  system = system || 'winner-front'
72
84
  type = type || 'bizframe'
73
85
  appType = appType || name
74
- variablesFunc = variablesFunc || function () {
86
+ variablesFunc = variablesFunc || function() {
75
87
  if (type === 'bizframe') {
76
88
  try {
77
- const {variables} = require(path.resolve(
89
+ const { variables } = require(path.resolve(
78
90
  context,
79
91
  'build',
80
92
  'package',
81
93
  `./variables.js`
82
- ));
94
+ ))
83
95
 
84
- return variables || [];
96
+ return variables || []
85
97
  } catch (error) {
86
- console.error(error);
87
- return [];
98
+ console.error(error)
99
+ return []
88
100
  }
89
101
  }
90
102
  }
91
103
 
92
- templateFunc = templateFunc || function () {
104
+ templateFunc = templateFunc || function() {
93
105
  if (type === 'bizframe') {
94
- return `./dist/config.local.js`;
106
+ return `./dist/config.local.js`
95
107
  }
96
108
  }
97
109
 
@@ -108,35 +120,45 @@ exports.generateSeePackageZip = function generateSeePackageZip({system, type, na
108
120
  variables: (variablesFunc)()
109
121
  },
110
122
  done => {
111
- const {manifest, manifestJson} = genManifest(type, name);
123
+ const { manifest, manifestJson } = genManifest(type, name)
112
124
  // 发布物中的源码部分统一放到 source 目录下
113
125
  for (const file in manifestJson) {
114
126
  if (manifestJson.hasOwnProperty(file)) {
115
- const {path, root, dir} = manifestJson[file];
127
+ const { path, dir } = manifestJson[file]
116
128
 
117
- fs.ensureDirSync(`./tmp/source/${dir}`);
118
- fs.copyFileSync(`./dist/${path}`, `./tmp/source/${path}`);
129
+ fs.ensureDirSync(`./tmp/source/${dir}`)
130
+ fs.copyFileSync(`./dist/${path}`, `./tmp/source/${path}`)
119
131
  }
120
132
  }
121
133
 
122
134
  fs.outputJSONSync(
123
135
  `./tmp/scripts/${name}/conf/${manifest}`,
124
136
  manifestJson
125
- );
137
+ )
138
+
139
+ // 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里
140
+ if (Array.isArray(copyFiles) && copyFiles.length) {
141
+ copyFiles.forEach((file) => {
142
+ fs.copyFileSync(`./dist/${name}/${file}`, `./tmp/source/${name}/${file}`);
143
+ });
144
+ }
145
+
146
+ // 自定义执行的操作
147
+ typeof cb === 'function' && cb();
126
148
 
127
- done();
128
- console.log();
149
+ done()
150
+ console.log()
129
151
  ora(
130
152
  `发布物制作完成,您可以在 SEE 平台上传并部署应用。注意:${chalk.yellow(
131
153
  '子系统发布物的安装目录需要指定到具体的应用目录'
132
154
  )}。比如/home/hsiar/hsiar-green/html/。\n`
133
- ).succeed();
155
+ ).succeed()
134
156
  }
135
- );
157
+ )
136
158
  }
137
159
 
138
160
  /**
139
161
  * 兼容 hui-deploy
140
162
  * @type {function(*=, *, *=): void}
141
163
  */
142
- exports.genSeePackage = genSeePackage;
164
+ exports.genSeePackage = genSeePackage
@@ -12,6 +12,13 @@ import re
12
12
  import sys
13
13
  import utils
14
14
 
15
+ try:
16
+ reload(sys)
17
+ sys.setdefaultencoding("utf8")
18
+ except:
19
+ print("Failed to perform module reload, continue installation")
20
+
21
+
15
22
  name = "${name}"
16
23
  type = "${type}"
17
24