@winner-fed/winner-deploy 2.0.8 → 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
@@ -6,11 +6,11 @@ python2 对应 template/1.x
6
6
  ```javscript
7
7
  /**
8
8
  * 生成 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} 发布包版本
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
14
  * @param configName {string} 配置文件名称,不带有 .js, 默认为 config.local
15
15
  * @param templateFunc {function} 自定义变量配置文件, 默认为
16
16
  * function () {
@@ -37,8 +37,9 @@ python2 对应 template/1.x
37
37
  }
38
38
  }
39
39
  }
40
+ * @param cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
40
41
  */
41
- 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) {
42
43
  ...
43
44
  }
44
45
  ```
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.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",
@@ -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,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