meixifrontserve 0.4.1 → 0.4.3
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 +4 -2
- package/bin/index.js +22 -7
- package/config/urlConfig.js +6 -1
- package/package.json +1 -1
- package/scripts/envByDevServerController.js +13 -0
- package/scripts/envByServerController.js +36 -7
- package/scripts/envByTestServerController.js +15 -0
- package/scripts/serveController.js +3 -2
package/README.md
CHANGED
|
@@ -23,9 +23,11 @@ npm install meixifrontserve@latest -g
|
|
|
23
23
|
|
|
24
24
|
# 运行项目
|
|
25
25
|
# 这个例子是启动项目
|
|
26
|
-
# -
|
|
26
|
+
# -serveByDev 是指运行的项目模式为开发
|
|
27
|
+
# -serveByTest 是指运行的项目模式为测试环境
|
|
27
28
|
# --name 是指运行的是产品中心,具体其它的模块见下面的介绍
|
|
28
|
-
meixifrontserve -
|
|
29
|
+
meixifrontserve -serveByDev / --name production
|
|
30
|
+
|
|
29
31
|
|
|
30
32
|
# beta 是指打包项目的环境是测试环境
|
|
31
33
|
meixifrontserve -beta / --name production
|
package/bin/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
const {program} = require('commander');
|
|
3
|
-
const
|
|
3
|
+
const EnvByTestServerController = require('../scripts/envByTestServerController')
|
|
4
|
+
const EnvByDevServerController = require('../scripts/envByDevServerController')
|
|
4
5
|
const EnvByBetaController = require('../scripts/envByBetaController');
|
|
5
6
|
const EnvByPreController = require('../scripts/envByPreController');
|
|
6
7
|
const EnvByProdController = require('../scripts/envByProdController')
|
|
@@ -9,9 +10,11 @@ const RollupBuildController = require('../scripts/rollupBuildController');
|
|
|
9
10
|
const checkUpdate = require('../scripts/checkUpdate');
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
//
|
|
13
|
-
program.option('--name <char>').option('-
|
|
14
|
-
//
|
|
13
|
+
// 开发正常环境
|
|
14
|
+
program.option('--name <char>').option('-serveByDev');
|
|
15
|
+
// 开发测试环境
|
|
16
|
+
program.option('--name <char>').option('-serveByTest');
|
|
17
|
+
// 测试打包
|
|
15
18
|
program.option('--name <char>').option('-beta')
|
|
16
19
|
// 预上线
|
|
17
20
|
program.option('--name <char>').option('-pre')
|
|
@@ -26,13 +29,25 @@ program.parse();
|
|
|
26
29
|
const run = async () => {
|
|
27
30
|
|
|
28
31
|
const programOps = program.opts();
|
|
29
|
-
const {name,env} = programOps
|
|
32
|
+
const {name, env} = programOps
|
|
30
33
|
// 如果是开发
|
|
31
|
-
if (programOps.
|
|
34
|
+
if (programOps.ServeByDev) {
|
|
32
35
|
// 检查更新
|
|
33
36
|
let flag = await checkUpdate();
|
|
34
37
|
if (flag) {
|
|
35
|
-
|
|
38
|
+
try {
|
|
39
|
+
let envByServerController = new EnvByDevServerController(name);
|
|
40
|
+
await envByServerController.onStart();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.log(error)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
} else if (programOps.ServeByTest) {
|
|
47
|
+
// 检查更新
|
|
48
|
+
let flag = await checkUpdate();
|
|
49
|
+
if (flag) {
|
|
50
|
+
let envByServerController = new EnvByTestServerController(name);
|
|
36
51
|
await envByServerController.onStart();
|
|
37
52
|
}
|
|
38
53
|
|
package/config/urlConfig.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
const urlConfig = {
|
|
2
2
|
// 开发环境需要具体的ip地址与端口号
|
|
3
|
-
|
|
3
|
+
serveByDev: {
|
|
4
4
|
urlPrefixes: [],
|
|
5
5
|
authUrl: 'auth.wubangtu.xyz/login',
|
|
6
6
|
wsUrl: 'ws://gateway.wubangtu.xyz:9999/ws/websocket/mxapp'
|
|
7
7
|
},
|
|
8
|
+
serveByTest: {
|
|
9
|
+
urlPrefixes: [],
|
|
10
|
+
authUrl: 'testauth.wubangtu.xyz/login',
|
|
11
|
+
wsUrl: 'ws://gateway.wubangtu.xyz:9999/ws/websocket/mxapp'
|
|
12
|
+
},
|
|
8
13
|
beta: {
|
|
9
14
|
urlPrefixes: ['wubangtu', 'xyz'],
|
|
10
15
|
authUrl: 'auth.wubangtu.xyz/login',
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
const envByServerController = require('./envByServerController')
|
|
3
|
+
|
|
4
|
+
class EnvByDevServerController extends envByServerController {
|
|
5
|
+
constructor(projectName) {
|
|
6
|
+
super(projectName);
|
|
7
|
+
this.proxy = "http://meixi.wubangtu.xyz/api";
|
|
8
|
+
this.configProps='serveByDev'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
module.exports = EnvByDevServerController;
|
|
@@ -16,15 +16,19 @@ class EnvByServerController extends ServerController {
|
|
|
16
16
|
constructor(projectName) {
|
|
17
17
|
super(projectName);
|
|
18
18
|
this.port = 8888;
|
|
19
|
-
this.verName =
|
|
19
|
+
this.verName = "Dev";
|
|
20
|
+
this.configProps = null;
|
|
21
|
+
this.proxy = null;
|
|
22
|
+
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
async onStart() {
|
|
23
|
-
|
|
24
|
-
if (
|
|
26
|
+
let flag = await super.onStart()
|
|
27
|
+
if (flag) {
|
|
25
28
|
|
|
26
29
|
this.writeVueConfigJs()
|
|
27
30
|
|
|
31
|
+
|
|
28
32
|
this.onRunServe();
|
|
29
33
|
}
|
|
30
34
|
|
|
@@ -33,12 +37,12 @@ class EnvByServerController extends ServerController {
|
|
|
33
37
|
|
|
34
38
|
|
|
35
39
|
createEnvFiles = async () => {
|
|
36
|
-
let _urlConfig = urlConfig.
|
|
40
|
+
let _urlConfig = urlConfig[`${this.configProps}`];
|
|
37
41
|
let flag = await this.getServerPort();
|
|
38
42
|
if (flag) {
|
|
39
43
|
let envFileParams = {
|
|
40
44
|
envName: 'development',
|
|
41
|
-
proxy:
|
|
45
|
+
proxy: this.proxy,
|
|
42
46
|
systemId: this.projectParams.systemId,
|
|
43
47
|
systemName: this.projectParams.systemName,
|
|
44
48
|
apiUrl: '/proxy',
|
|
@@ -47,13 +51,16 @@ class EnvByServerController extends ServerController {
|
|
|
47
51
|
authUrl: _urlConfig.authUrl,
|
|
48
52
|
wsUrl: _urlConfig.wsUrl,
|
|
49
53
|
}
|
|
50
|
-
return
|
|
54
|
+
return false
|
|
55
|
+
// return getEnvFileTemplate(envFileParams);
|
|
51
56
|
} else {
|
|
52
57
|
setTimeout(() => {
|
|
53
58
|
this.onStart();
|
|
54
59
|
}, 500)
|
|
55
60
|
return false;
|
|
56
61
|
}
|
|
62
|
+
|
|
63
|
+
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
|
|
@@ -120,9 +127,13 @@ class EnvByServerController extends ServerController {
|
|
|
120
127
|
let ipAddress;
|
|
121
128
|
Object.keys(interfaces).forEach((interfaceName) => {
|
|
122
129
|
interfaces[interfaceName].forEach((interfaceInfo) => {
|
|
130
|
+
console.log(interfaceName);
|
|
123
131
|
if (interfaceInfo.family === 'IPv4' && !interfaceInfo.internal) {
|
|
124
132
|
ipAddress = interfaceInfo.address;
|
|
125
133
|
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
126
137
|
});
|
|
127
138
|
});
|
|
128
139
|
return ipAddress;
|
|
@@ -142,8 +153,8 @@ class EnvByServerController extends ServerController {
|
|
|
142
153
|
exec('npm install --legacy-peer-deps', async (error, stdout, stderr) => {
|
|
143
154
|
if (!error) {
|
|
144
155
|
shell.exec('npm run serve', (error, stdout, stderr) => {
|
|
145
|
-
console.log(error);
|
|
146
156
|
})
|
|
157
|
+
this.openDefaultBrowser(`http://${this.getSystemUrl()}`);
|
|
147
158
|
} else {
|
|
148
159
|
console.log(error)
|
|
149
160
|
console.error('依赖下载失败!')
|
|
@@ -156,6 +167,24 @@ class EnvByServerController extends ServerController {
|
|
|
156
167
|
}
|
|
157
168
|
|
|
158
169
|
|
|
170
|
+
|
|
171
|
+
openDefaultBrowser (url) {
|
|
172
|
+
var exec = require('child_process').exec;
|
|
173
|
+
console.log(process.platform)
|
|
174
|
+
switch (process.platform) {
|
|
175
|
+
case "darwin":
|
|
176
|
+
exec('open ' + url);
|
|
177
|
+
break;
|
|
178
|
+
case "win32":
|
|
179
|
+
exec('start ' + url);
|
|
180
|
+
break;
|
|
181
|
+
default:
|
|
182
|
+
exec('xdg-open', [url]);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
159
188
|
}
|
|
160
189
|
|
|
161
190
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
const envByServerController = require('./envByServerController')
|
|
3
|
+
|
|
4
|
+
class EnvByTestServerController extends envByServerController {
|
|
5
|
+
constructor(projectName) {
|
|
6
|
+
super(projectName);
|
|
7
|
+
this.proxy = "http://gateway.wubangtu.xyz:9999";
|
|
8
|
+
this.configProps='serveByTest'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
module.exports = EnvByTestServerController;
|
|
@@ -20,9 +20,10 @@ class ServeController {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
async onStart() {
|
|
24
24
|
let fileContent = await this.createEnvFiles();
|
|
25
25
|
|
|
26
|
+
|
|
26
27
|
if (fileContent) {
|
|
27
28
|
|
|
28
29
|
this.writeEnvFile(fileContent);
|
|
@@ -37,13 +38,13 @@ class ServeController {
|
|
|
37
38
|
return false;
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// 生成对应的环境模版文件
|
|
44
44
|
createEnvFiles() {
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
|