meixifrontserve 0.4.0 → 0.4.2
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/bin/index.js +22 -6
- package/config/package.json +1 -1
- package/config/urlConfig.js +6 -1
- package/package.json +1 -1
- package/scripts/envByDevServerController.js +13 -0
- package/scripts/envByServerController.js +28 -6
- package/scripts/envByTestServerController.js +15 -0
- package/scripts/serveController.js +3 -2
package/bin/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
const {program} = require('commander');
|
|
3
3
|
const EnvByServerController = require('../scripts/envByServerController');
|
|
4
|
+
const EnvByTestServerController = require('../scripts/envByTestServerController')
|
|
5
|
+
const EnvByDevServerController = require('../scripts/envByDevServerController')
|
|
4
6
|
const EnvByBetaController = require('../scripts/envByBetaController');
|
|
5
7
|
const EnvByPreController = require('../scripts/envByPreController');
|
|
6
8
|
const EnvByProdController = require('../scripts/envByProdController')
|
|
@@ -9,9 +11,11 @@ const RollupBuildController = require('../scripts/rollupBuildController');
|
|
|
9
11
|
const checkUpdate = require('../scripts/checkUpdate');
|
|
10
12
|
|
|
11
13
|
|
|
12
|
-
//
|
|
13
|
-
program.option('--name <char>').option('-
|
|
14
|
-
//
|
|
14
|
+
// 开发正常环境
|
|
15
|
+
program.option('--name <char>').option('-serveByDev');
|
|
16
|
+
// 开发测试环境
|
|
17
|
+
program.option('--name <char>').option('-serveByTest');
|
|
18
|
+
// 测试打包
|
|
15
19
|
program.option('--name <char>').option('-beta')
|
|
16
20
|
// 预上线
|
|
17
21
|
program.option('--name <char>').option('-pre')
|
|
@@ -26,13 +30,25 @@ program.parse();
|
|
|
26
30
|
const run = async () => {
|
|
27
31
|
|
|
28
32
|
const programOps = program.opts();
|
|
29
|
-
const {name,env} = programOps
|
|
33
|
+
const {name, env} = programOps
|
|
30
34
|
// 如果是开发
|
|
31
|
-
if (programOps.
|
|
35
|
+
if (programOps.ServeByDev) {
|
|
32
36
|
// 检查更新
|
|
33
37
|
let flag = await checkUpdate();
|
|
34
38
|
if (flag) {
|
|
35
|
-
|
|
39
|
+
try {
|
|
40
|
+
let envByServerController = new EnvByDevServerController(name);
|
|
41
|
+
await envByServerController.onStart();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.log(error)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
} else if (programOps.ServeByTest) {
|
|
48
|
+
// 检查更新
|
|
49
|
+
let flag = await checkUpdate();
|
|
50
|
+
if (flag) {
|
|
51
|
+
let envByServerController = new EnvByTestServerController(name);
|
|
36
52
|
await envByServerController.onStart();
|
|
37
53
|
}
|
|
38
54
|
|
package/config/package.json
CHANGED
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',
|
|
@@ -142,8 +146,8 @@ class EnvByServerController extends ServerController {
|
|
|
142
146
|
exec('npm install --legacy-peer-deps', async (error, stdout, stderr) => {
|
|
143
147
|
if (!error) {
|
|
144
148
|
shell.exec('npm run serve', (error, stdout, stderr) => {
|
|
145
|
-
console.log(error);
|
|
146
149
|
})
|
|
150
|
+
this.openDefaultBrowser(`http://${this.getSystemUrl()}`);
|
|
147
151
|
} else {
|
|
148
152
|
console.log(error)
|
|
149
153
|
console.error('依赖下载失败!')
|
|
@@ -156,6 +160,24 @@ class EnvByServerController extends ServerController {
|
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
|
|
163
|
+
|
|
164
|
+
openDefaultBrowser (url) {
|
|
165
|
+
var exec = require('child_process').exec;
|
|
166
|
+
console.log(process.platform)
|
|
167
|
+
switch (process.platform) {
|
|
168
|
+
case "darwin":
|
|
169
|
+
exec('open ' + url);
|
|
170
|
+
break;
|
|
171
|
+
case "win32":
|
|
172
|
+
exec('start ' + url);
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
exec('xdg-open', [url]);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
159
181
|
}
|
|
160
182
|
|
|
161
183
|
|
|
@@ -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
|
|