@winner-fed/winner-deploy 2.0.5 → 2.0.9

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,9 @@
34
37
  }
35
38
  }
36
39
  }
40
+ * @param cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
37
41
  */
38
- exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc}) {
42
+ exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc}, cb) {
39
43
  ...
40
44
  }
41
45
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winner-fed/winner-deploy",
3
- "version": "2.0.5",
3
+ "version": "2.0.9",
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,45 @@ function genManifest (type, name) {
63
63
  }
64
64
  }
65
65
  }
66
+ * @param cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
66
67
  */
67
- exports.generateSeePackageZip = function generateSeePackageZip({system, type, name, appType, version, configName, templateFunc, variablesFunc}) {
68
- if(!name || !version) {
68
+ exports.generateSeePackageZip = function generateSeePackageZip ({
69
+ system,
70
+ type,
71
+ name,
72
+ appType,
73
+ version,
74
+ configName,
75
+ templateFunc,
76
+ variablesFunc
77
+ }, cb) {
78
+ if (!name || !version) {
69
79
  throw new Error('应用名称和应用版本不能缺失~')
70
80
  }
71
81
  system = system || 'winner-front'
72
82
  type = type || 'bizframe'
73
83
  appType = appType || name
74
- variablesFunc = variablesFunc || function () {
84
+ variablesFunc = variablesFunc || function() {
75
85
  if (type === 'bizframe') {
76
86
  try {
77
- const {variables} = require(path.resolve(
87
+ const { variables } = require(path.resolve(
78
88
  context,
79
89
  'build',
80
90
  'package',
81
91
  `./variables.js`
82
- ));
92
+ ))
83
93
 
84
- return variables || [];
94
+ return variables || []
85
95
  } catch (error) {
86
- console.error(error);
87
- return [];
96
+ console.error(error)
97
+ return []
88
98
  }
89
99
  }
90
100
  }
91
101
 
92
- templateFunc = templateFunc || function () {
102
+ templateFunc = templateFunc || function() {
93
103
  if (type === 'bizframe') {
94
- return `./dist/config.local.js`;
104
+ return `./dist/config.local.js`
95
105
  }
96
106
  }
97
107
 
@@ -108,35 +118,38 @@ exports.generateSeePackageZip = function generateSeePackageZip({system, type, na
108
118
  variables: (variablesFunc)()
109
119
  },
110
120
  done => {
111
- const {manifest, manifestJson} = genManifest(type, name);
121
+ const { manifest, manifestJson } = genManifest(type, name)
112
122
  // 发布物中的源码部分统一放到 source 目录下
113
123
  for (const file in manifestJson) {
114
124
  if (manifestJson.hasOwnProperty(file)) {
115
- const {path, root, dir} = manifestJson[file];
125
+ const { path, dir } = manifestJson[file]
116
126
 
117
- fs.ensureDirSync(`./tmp/source/${dir}`);
118
- fs.copyFileSync(`./dist/${path}`, `./tmp/source/${path}`);
127
+ fs.ensureDirSync(`./tmp/source/${dir}`)
128
+ fs.copyFileSync(`./dist/${path}`, `./tmp/source/${path}`)
119
129
  }
120
130
  }
121
131
 
122
132
  fs.outputJSONSync(
123
133
  `./tmp/scripts/${name}/conf/${manifest}`,
124
134
  manifestJson
125
- );
135
+ )
136
+
137
+ // 自定义执行的操作
138
+ typeof cb === 'function' && cb();
126
139
 
127
- done();
128
- console.log();
140
+ done()
141
+ console.log()
129
142
  ora(
130
143
  `发布物制作完成,您可以在 SEE 平台上传并部署应用。注意:${chalk.yellow(
131
144
  '子系统发布物的安装目录需要指定到具体的应用目录'
132
145
  )}。比如/home/hsiar/hsiar-green/html/。\n`
133
- ).succeed();
146
+ ).succeed()
134
147
  }
135
- );
148
+ )
136
149
  }
137
150
 
138
151
  /**
139
152
  * 兼容 hui-deploy
140
153
  * @type {function(*=, *, *=): void}
141
154
  */
142
- exports.genSeePackage = genSeePackage;
155
+ exports.genSeePackage = genSeePackage
@@ -5,9 +5,9 @@
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="发布包说明">发布包说明...</appDescribe>
9
9
  <version describe="发布包版本">${ version }</version>
10
- <group describe="应用分组">>${ type }</group>
10
+ <group describe="应用分组">${ type }</group>
11
11
  <packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)"></packInEffect>
12
12
  </basic>
13
13
  <globalConfig describe="系统全局配置"></globalConfig>
@@ -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