meixifrontserve 0.0.1
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/.env +19 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/meixicli.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +0 -0
- package/bin/index.js +46 -0
- package/config/envFileTemplate.js +25 -0
- package/config/package.json +97 -0
- package/config/projectConfig.js +115 -0
- package/config/urlConfig.js +26 -0
- package/directoryList.md +22 -0
- package/index.js +0 -0
- package/package.json +20 -0
- package/scripts/envByBetaController.js +21 -0
- package/scripts/envByBuildController.js +90 -0
- package/scripts/envByPreController.js +21 -0
- package/scripts/envByProdController.js +20 -0
- package/scripts/envByServerController.js +170 -0
- package/scripts/serveController.js +88 -0
package/.env
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
NODE_ENV=development
|
|
3
|
+
VUE_APP_ENV=development
|
|
4
|
+
VUE_APP_VERSION=1.0.0
|
|
5
|
+
VUE_APP_PROXY=http://meixi.wubangtu.xyz/api
|
|
6
|
+
#自行更改
|
|
7
|
+
VUE_APP_SYSTEMID=1554748096283357186
|
|
8
|
+
VUE_APP_AUTH=mx:mx
|
|
9
|
+
#自行更改
|
|
10
|
+
VUE_APP_PRODUCTNAME=魅熙人事应用
|
|
11
|
+
VUE_APP_URL=/proxy
|
|
12
|
+
VUE_APP_UPLOAD_URL="Web/OA"
|
|
13
|
+
#开发环境地址 自行更改
|
|
14
|
+
VUE_APP_SYSTEM_URL=192.168.31.148:8888
|
|
15
|
+
#登录验证的地址,请勿修改
|
|
16
|
+
VUE_APP_AUTH_URL=auth.wubangtu.xyz/login
|
|
17
|
+
#ws的链接
|
|
18
|
+
VUE_APP_WEBSOCKET_URL="ws://gateway.wubangtu.xyz:9999/ws/websocket/mxapp"
|
|
19
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
package/.idea/vcs.xml
ADDED
package/README.md
ADDED
|
File without changes
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
const {program} = require('commander');
|
|
3
|
+
const EnvByServerController = require('../scripts/envByServerController');
|
|
4
|
+
const EnvByBetaController = require('../scripts/envByBetaController');
|
|
5
|
+
const EnvByPreController = require('../scripts/envByPreController');
|
|
6
|
+
const EnvByProdController = require('../scripts/envByProdController')
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// 开发环境
|
|
10
|
+
program.option('--name <char>').option('-serve');
|
|
11
|
+
// 测试
|
|
12
|
+
program.option('--name <char>').option('-beta')
|
|
13
|
+
// 预上线
|
|
14
|
+
program.option('--name <char>').option('-pre')
|
|
15
|
+
// 生产打包
|
|
16
|
+
program.option('--name <char>').option('-prod')
|
|
17
|
+
program.parse();
|
|
18
|
+
const run = async () => {
|
|
19
|
+
|
|
20
|
+
const programOps = program.opts();
|
|
21
|
+
const {name} = programOps
|
|
22
|
+
|
|
23
|
+
// 如果是开发
|
|
24
|
+
if (programOps.Serve) {
|
|
25
|
+
let envByServerController = new EnvByServerController(name);
|
|
26
|
+
await envByServerController.onStart();
|
|
27
|
+
|
|
28
|
+
} else if (programOps.Beta) {
|
|
29
|
+
let envByBetaController = new EnvByBetaController(name, 'beta');
|
|
30
|
+
await envByBetaController.onStart();
|
|
31
|
+
|
|
32
|
+
} else if (programOps.Pre) {
|
|
33
|
+
let envByPreController = new EnvByPreController(name, 'pre');
|
|
34
|
+
await envByPreController.onStart();
|
|
35
|
+
|
|
36
|
+
} else if (programOps.Prod) {
|
|
37
|
+
let envByProdController = new EnvByProdController(name, 'prod');
|
|
38
|
+
await envByProdController.onStart();
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
run().then();
|
|
45
|
+
|
|
46
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const getEnvFileTemplate = (params) => {
|
|
2
|
+
return `NODE_ENV=${params.envName}
|
|
3
|
+
VUE_APP_ENV=${params.envName}
|
|
4
|
+
VUE_APP_VERSION=1.0.0
|
|
5
|
+
VUE_APP_PROXY=${params.proxy}
|
|
6
|
+
VUE_APP_VER_NAME="${params.verName}"
|
|
7
|
+
#自行更改
|
|
8
|
+
VUE_APP_SYSTEMID=${params.systemId}
|
|
9
|
+
VUE_APP_AUTH=mx:mx
|
|
10
|
+
#自行更改
|
|
11
|
+
VUE_APP_PRODUCTNAME=${params.systemName}
|
|
12
|
+
VUE_APP_URL=${params.apiUrl}
|
|
13
|
+
VUE_APP_UPLOAD_URL="Web/OA"
|
|
14
|
+
#开发环境地址 自行更改
|
|
15
|
+
VUE_APP_SYSTEM_URL=${params.systemUrl}
|
|
16
|
+
#登录验证的地址,请勿修改
|
|
17
|
+
VUE_APP_AUTH_URL=${params.authUrl}
|
|
18
|
+
#ws的链接
|
|
19
|
+
VUE_APP_WEBSOCKET_URL="${params.wsUrl}"
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
module.exports = getEnvFileTemplate;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "newoaadmin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"serve": "vue-cli-service serve",
|
|
7
|
+
"lint": "vue-cli-service lint",
|
|
8
|
+
"build:beta": "vue-cli-service build --mode beta",
|
|
9
|
+
"build:pre": "vue-cli-service build --mode pre",
|
|
10
|
+
"build:prod": "vue-cli-service build --mode prod",
|
|
11
|
+
"rollupBuild": "sudo meixirollupbuild -b / --pathTarget src/pages/ordermanage/oaorder/index.js-lib/oaOrderIndex.umd.js"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
|
|
15
|
+
"@wangeditor/editor": "^5.1.14",
|
|
16
|
+
"@wangeditor/editor-for-vue": "^1.0.2",
|
|
17
|
+
"@wangeditor/plugin-md": "^1.0.0",
|
|
18
|
+
"async_hooks": "^1.0.0",
|
|
19
|
+
"axios": "^0.26.0",
|
|
20
|
+
"babel-helper-vue-jsx-merge-props": "^2.0.3",
|
|
21
|
+
"babel-plugin-transform-vue-jsx": "^3.7.0",
|
|
22
|
+
"babel-preset-env": "^1.7.0",
|
|
23
|
+
"core-js": "^3.6.5",
|
|
24
|
+
"crypto-js": "^3.1.9-1",
|
|
25
|
+
"dayjs": "^1.11.2",
|
|
26
|
+
"element-ui": "^2.15.6",
|
|
27
|
+
"js-md5": "^0.7.3",
|
|
28
|
+
"meixiappmain": "0.1.7",
|
|
29
|
+
"meixicheckgoodstable": "0.1.0",
|
|
30
|
+
"meixicheckstaff": "^0.1.8",
|
|
31
|
+
"meixidialogtablecheck": "^0.3.1",
|
|
32
|
+
"meixiexpresscheck": "0.0.5",
|
|
33
|
+
"meixigoodstablecontrol": "^0.3.46",
|
|
34
|
+
"meixihandlerecorde": "0.0.5",
|
|
35
|
+
"meixihelpmenu": "0.0.2",
|
|
36
|
+
"meixilayout": "^0.2.7",
|
|
37
|
+
"meixirequestts": "^0.2.1",
|
|
38
|
+
"meixisetting": "0.0.7",
|
|
39
|
+
"meixistepbar": "0.0.5",
|
|
40
|
+
"meixistoretag": "0.1.7",
|
|
41
|
+
"meixiverifyflowinfo": "0.0.8",
|
|
42
|
+
"path": "^0.12.7",
|
|
43
|
+
"register-service-worker": "^1.7.2",
|
|
44
|
+
"v-click-outside": "^3.2.0",
|
|
45
|
+
"vue": "^2.7.10",
|
|
46
|
+
"vue-cropper": "^0.5.8",
|
|
47
|
+
"vue-router": "3.0.2",
|
|
48
|
+
"vuedraggable": "^2.24.3",
|
|
49
|
+
"vuex": "^3.4.0",
|
|
50
|
+
"meixioacomponent": "^0.9.68"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@babel/eslint-parser": "^7.5.0",
|
|
54
|
+
"@vue/cli-plugin-babel": "~5.0.0",
|
|
55
|
+
"@vue/cli-plugin-eslint": "~5.0.0",
|
|
56
|
+
"@vue/cli-plugin-router": "~5.0.0",
|
|
57
|
+
"@vue/cli-plugin-vuex": "~4.5.13",
|
|
58
|
+
"@vue/cli-service": "~4.5.18",
|
|
59
|
+
"@vue/eslint-config-standard": "^5.1.2",
|
|
60
|
+
"@vuepress/plugin-pwa": "^1.9.7",
|
|
61
|
+
"babel-eslint": "^10.1.0",
|
|
62
|
+
"babel-plugin-component": "^1.1.1",
|
|
63
|
+
"eslint": "^8.0.0",
|
|
64
|
+
"eslint-plugin-import": "^2.20.2",
|
|
65
|
+
"eslint-plugin-node": "^11.1.0",
|
|
66
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
67
|
+
"eslint-plugin-standard": "^4.0.0",
|
|
68
|
+
"eslint-plugin-vue": "^9.0.0",
|
|
69
|
+
"less": "^3.13.1",
|
|
70
|
+
"less-loader": "^5.0.0",
|
|
71
|
+
"style-resources-loader": "^1.5.0",
|
|
72
|
+
"svg-sprite-loader": "4.1.3",
|
|
73
|
+
"unplugin-vue-define-options": "^1.0.0",
|
|
74
|
+
"vue-demi": "^0.13.1",
|
|
75
|
+
"vue-loader": "^17.0.1",
|
|
76
|
+
"vue-template-compiler": "^2.7.14"
|
|
77
|
+
},
|
|
78
|
+
"eslintConfig": {
|
|
79
|
+
"root": true,
|
|
80
|
+
"env": {
|
|
81
|
+
"node": true
|
|
82
|
+
},
|
|
83
|
+
"extends": [
|
|
84
|
+
"plugin:vue/essential",
|
|
85
|
+
"@vue/standard"
|
|
86
|
+
],
|
|
87
|
+
"parserOptions": {
|
|
88
|
+
"parser": "babel-eslint"
|
|
89
|
+
},
|
|
90
|
+
"rules": {}
|
|
91
|
+
},
|
|
92
|
+
"browserslist": [
|
|
93
|
+
"> 1%",
|
|
94
|
+
"last 2 versions",
|
|
95
|
+
"not dead"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const projectConfig = {
|
|
2
|
+
// 客户
|
|
3
|
+
customer: {
|
|
4
|
+
// 系统Id
|
|
5
|
+
systemId: '1554747286892318722',
|
|
6
|
+
// url的前缀 目前除了开发不会使用到改文件
|
|
7
|
+
urlPrefix: {
|
|
8
|
+
beta: 'mxcustomer',
|
|
9
|
+
pre: 'mxcustomer',
|
|
10
|
+
prod: 'mxcustomer'
|
|
11
|
+
},
|
|
12
|
+
systemName: '魅熙客户平台',
|
|
13
|
+
},
|
|
14
|
+
//人事
|
|
15
|
+
hr: {
|
|
16
|
+
// 系统Id
|
|
17
|
+
systemId: '1554748096283357186',
|
|
18
|
+
// url的前缀 目前除了开发不会使用到改文件
|
|
19
|
+
urlPrefix: {
|
|
20
|
+
beta: 'saashr',
|
|
21
|
+
pre: 'oahr',
|
|
22
|
+
prod: 'oahr'
|
|
23
|
+
},
|
|
24
|
+
systemName: '魅熙人事应用',
|
|
25
|
+
},
|
|
26
|
+
//产品
|
|
27
|
+
production: {
|
|
28
|
+
// 系统Id
|
|
29
|
+
systemId: '1565611783794565121',
|
|
30
|
+
// url的前缀 目前除了开发不会使用到改文件
|
|
31
|
+
urlPrefix: {
|
|
32
|
+
beta: 'devproduct',
|
|
33
|
+
pre: 'mxproduct',
|
|
34
|
+
prod: 'mxproduct'
|
|
35
|
+
},
|
|
36
|
+
systemName: '魅熙产品中心',
|
|
37
|
+
},
|
|
38
|
+
//仓库
|
|
39
|
+
store: {
|
|
40
|
+
// 系统Id
|
|
41
|
+
systemId: '1584728237220040706',
|
|
42
|
+
// url的前缀 目前除了开发不会使用到改文件
|
|
43
|
+
urlPrefix: {
|
|
44
|
+
beta: 'mxstore',
|
|
45
|
+
pre: 'store',
|
|
46
|
+
prod: 'store'
|
|
47
|
+
},
|
|
48
|
+
systemName: '魅熙仓储系统',
|
|
49
|
+
},
|
|
50
|
+
//售卖平台
|
|
51
|
+
sale: {
|
|
52
|
+
// 系统Id
|
|
53
|
+
systemId: '1573200964897751041',
|
|
54
|
+
// url的前缀 目前除了开发不会使用到改文件
|
|
55
|
+
urlPrefix: {
|
|
56
|
+
beta: 'mxsale',
|
|
57
|
+
pre: 'sale',
|
|
58
|
+
prod: 'sale'
|
|
59
|
+
},
|
|
60
|
+
systemName: '魅熙售卖平台',
|
|
61
|
+
},
|
|
62
|
+
// 订单
|
|
63
|
+
order: {
|
|
64
|
+
// 系统Id
|
|
65
|
+
systemId: '1580083890302222338',
|
|
66
|
+
// url的前缀 目前除了开发不会使用到改文件
|
|
67
|
+
urlPrefix: {
|
|
68
|
+
beta: 'mxorder',
|
|
69
|
+
pre: 'mxorder',
|
|
70
|
+
prod: 'mxorder'
|
|
71
|
+
},
|
|
72
|
+
systemName: '魅熙订单平台',
|
|
73
|
+
},
|
|
74
|
+
// 资金
|
|
75
|
+
finance: {
|
|
76
|
+
// 系统Id
|
|
77
|
+
systemId: '1588346218818850818',
|
|
78
|
+
// url的前缀 目前除了开发不会使用到改文件
|
|
79
|
+
urlPrefix: {
|
|
80
|
+
beta: 'mxfinance',
|
|
81
|
+
pre: 'finance',
|
|
82
|
+
prod: 'finance'
|
|
83
|
+
},
|
|
84
|
+
systemName: '魅熙资金平台',
|
|
85
|
+
},
|
|
86
|
+
// 活动
|
|
87
|
+
activity: {
|
|
88
|
+
// 系统Id
|
|
89
|
+
systemId: '1602541833173934081',
|
|
90
|
+
// url的前缀 目前除了开发不会使用到改文件
|
|
91
|
+
urlPrefix: {
|
|
92
|
+
beta: 'mxactivity',
|
|
93
|
+
pre: 'activity',
|
|
94
|
+
prod: 'activity'
|
|
95
|
+
},
|
|
96
|
+
systemName: '魅熙活动平台',
|
|
97
|
+
},
|
|
98
|
+
// 后台管理
|
|
99
|
+
admin: {
|
|
100
|
+
// 系统Id
|
|
101
|
+
systemId: '1554743634638614529',
|
|
102
|
+
// url的前缀 目前除了开发不会使用到改文件
|
|
103
|
+
urlPrefix: {
|
|
104
|
+
beta: 'meixi',
|
|
105
|
+
pre: 'oaadmin',
|
|
106
|
+
prod: 'oaadmin'
|
|
107
|
+
},
|
|
108
|
+
systemName: '魅熙超级运维',
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
module.exports = projectConfig;
|
|
115
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const urlConfig = {
|
|
2
|
+
// 开发环境需要具体的ip地址与端口号
|
|
3
|
+
serve: {
|
|
4
|
+
urlPrefixes: [],
|
|
5
|
+
authUrl: 'auth.wubangtu.xyz/login',
|
|
6
|
+
wsUrl: 'ws://gateway.wubangtu.xyz:9999/ws/websocket/mxapp'
|
|
7
|
+
},
|
|
8
|
+
beta: {
|
|
9
|
+
urlPrefixes: ['wubangtu', 'xyx'],
|
|
10
|
+
authUrl: 'auth.wubangtu.xyz/login',
|
|
11
|
+
wsUrl: 'ws://gateway.wubangtu.xyz:9999/ws/websocket/mxapp'
|
|
12
|
+
},
|
|
13
|
+
pre: {
|
|
14
|
+
urlPrefixes: ['pre', 'meixioa', 'com'],
|
|
15
|
+
authUrl: 'pre.auth.meixioa.com/login',
|
|
16
|
+
wsUrl: 'ws://pre.gateway.meixioa.com/ws/websocket/mxapp'
|
|
17
|
+
},
|
|
18
|
+
prod: {
|
|
19
|
+
urlPrefixes: ['meixioa', 'com'],
|
|
20
|
+
authUrl: 'auth.meixioa.com/login',
|
|
21
|
+
wsUrl: 'wss://ws.gateway.meixioa.com/ws/websocket/mxapp'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
module.exports = urlConfig
|
package/directoryList.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|-- code
|
|
2
|
+
|-- .DS_Store
|
|
3
|
+
|-- .env
|
|
4
|
+
|-- README.md
|
|
5
|
+
|-- index.js
|
|
6
|
+
|-- package-lock.json
|
|
7
|
+
|-- package.json
|
|
8
|
+
|-- .idea
|
|
9
|
+
| |-- .gitignore
|
|
10
|
+
| |-- jsLibraryMappings.xml
|
|
11
|
+
| |-- meixicli.iml
|
|
12
|
+
| |-- modules.xml
|
|
13
|
+
| |-- workspace.xml
|
|
14
|
+
|-- bin
|
|
15
|
+
| |-- index.js
|
|
16
|
+
|-- scripts
|
|
17
|
+
|-- rollup.projectConfig.js
|
|
18
|
+
|-- rollupPluginListConfig.js
|
|
19
|
+
|-- rollupBuildHooks
|
|
20
|
+
|-- rollupBuildScript.js
|
|
21
|
+
|-- rollupConfig.json
|
|
22
|
+
|-- updatePackageType.js
|
package/index.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "meixifrontserve",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"private": false,
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"meixifrontserve": "./bin/index.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "yuri_star",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"commander": "^10.0.0",
|
|
18
|
+
"shelljs": "^0.8.5"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const EnvByBuildController = require('./envByBuildController')
|
|
2
|
+
|
|
3
|
+
class EnvByBetaController extends EnvByBuildController {
|
|
4
|
+
constructor(projectName, envType) {
|
|
5
|
+
super(projectName, envType);
|
|
6
|
+
this.envName = 'beta'
|
|
7
|
+
this.envType = 'beta'
|
|
8
|
+
this.verName = 'Beta'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
getSystemUrl() {
|
|
13
|
+
this.urlConfig.urlPrefixes.splice(0, 0, this.projectParams.urlPrefix[`${this.envType}`]);
|
|
14
|
+
return this.urlConfig.urlPrefixes.toString();
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
module.exports = EnvByBetaController;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
const ServerController = require('./serveController')
|
|
3
|
+
const urlConfig = require('../config/urlConfig');
|
|
4
|
+
|
|
5
|
+
const getEnvFileTemplate = require('../config/envFileTemplate')
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const packageJson = require("../config/package.json");
|
|
9
|
+
const childProcess = require("child_process");
|
|
10
|
+
const {exec} = childProcess;
|
|
11
|
+
const shell = require('shelljs');
|
|
12
|
+
|
|
13
|
+
// 打包环境
|
|
14
|
+
class EnvByBuildController extends ServerController {
|
|
15
|
+
|
|
16
|
+
constructor(projectName, envType) {
|
|
17
|
+
super(projectName);
|
|
18
|
+
this.port = 8888;
|
|
19
|
+
this.envName = '';
|
|
20
|
+
this.envType = envType;
|
|
21
|
+
|
|
22
|
+
this.urlConfig = null;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async onStart() {
|
|
27
|
+
await super.onStart();
|
|
28
|
+
this.onRunServe();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
async createEnvFiles() {
|
|
33
|
+
this.urlConfig = urlConfig[`${this.envType}`];
|
|
34
|
+
|
|
35
|
+
let envFileParams = {
|
|
36
|
+
envName: this.envName,
|
|
37
|
+
proxy: '/proxy',
|
|
38
|
+
systemId: this.projectParams.systemId,
|
|
39
|
+
systemName: this.projectParams.systemName,
|
|
40
|
+
apiUrl: '/api/',
|
|
41
|
+
systemUrl: this.getSystemUrl(),
|
|
42
|
+
authUrl: this.urlConfig.authUrl,
|
|
43
|
+
wsUrl: this.urlConfig.wsUrl,
|
|
44
|
+
verName: this.verName,
|
|
45
|
+
}
|
|
46
|
+
return getEnvFileTemplate(envFileParams);
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
async getServerPort() {
|
|
52
|
+
|
|
53
|
+
let flag = await this.isPortAvailable(this.port);
|
|
54
|
+
|
|
55
|
+
if (!flag) {
|
|
56
|
+
this.port += 1;
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
writeEnvFile(fileContent) {
|
|
65
|
+
const press = process.cwd();
|
|
66
|
+
const fileUrl = path.join(press, `./.env.${this.envType}`);
|
|
67
|
+
fs.writeFileSync(fileUrl, fileContent);
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
onRunServe() {
|
|
73
|
+
console.log('正在下载依赖');
|
|
74
|
+
exec('npm install', async (error, stdout, stderr) => {
|
|
75
|
+
if (!error) {
|
|
76
|
+
shell.exec(`npm run build:${this.envType}`, (error, stdout, stderr) => {
|
|
77
|
+
console.log(error);
|
|
78
|
+
})
|
|
79
|
+
} else {
|
|
80
|
+
console.error('依赖下载失败!')
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
module.exports = EnvByBuildController;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const EnvByBuildController = require('./envByBuildController');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class EnvByPreController extends EnvByBuildController {
|
|
5
|
+
constructor(projectName, envType) {
|
|
6
|
+
super(projectName, envType);
|
|
7
|
+
this.envName = 'preview'
|
|
8
|
+
this.envType = 'pre'
|
|
9
|
+
this.verName = 'preview'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
getSystemUrl() {
|
|
14
|
+
this.urlConfig.urlPrefixes.splice(1, 0, this.projectParams.urlPrefix[`${this.envType}`]);
|
|
15
|
+
return this.urlConfig.urlPrefixes.toString();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
module.exports = EnvByPreController;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const EnvByBuildController = require('./envByBuildController');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class EnvByProdController extends EnvByBuildController {
|
|
5
|
+
constructor(projectName, envType) {
|
|
6
|
+
super(projectName, envType);
|
|
7
|
+
this.envName = 'production'
|
|
8
|
+
this.envType = 'prod'
|
|
9
|
+
this.verName = 'Prod'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
getSystemUrl() {
|
|
14
|
+
this.urlConfig.urlPrefixes.splice(0, 0, this.projectParams.urlPrefix[`${this.envType}`]);
|
|
15
|
+
return this.urlConfig.urlPrefixes.toString();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module.exports = EnvByProdController
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
const ServerController = require('./serveController')
|
|
3
|
+
const urlConfig = require('../config/urlConfig');
|
|
4
|
+
|
|
5
|
+
const getEnvFileTemplate = require('../config/envFileTemplate')
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const packageJson = require("../config/package.json");
|
|
9
|
+
const childProcess = require("child_process");
|
|
10
|
+
const {exec} = childProcess;
|
|
11
|
+
const shell = require('shelljs');
|
|
12
|
+
|
|
13
|
+
// 开发环境
|
|
14
|
+
class EnvByServerController extends ServerController {
|
|
15
|
+
|
|
16
|
+
constructor(projectName) {
|
|
17
|
+
super(projectName);
|
|
18
|
+
this.port = 8888;
|
|
19
|
+
this.verName = 'Dev';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async onStart() {
|
|
23
|
+
await super.onStart();
|
|
24
|
+
|
|
25
|
+
this.writeVueConfigJs()
|
|
26
|
+
|
|
27
|
+
this.onRunServe();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async createEnvFiles() {
|
|
32
|
+
let _urlConfig = urlConfig.serve;
|
|
33
|
+
let flag = await this.getServerPort();
|
|
34
|
+
if (flag) {
|
|
35
|
+
let envFileParams = {
|
|
36
|
+
envName: 'development',
|
|
37
|
+
proxy: 'http://meixi.wubangtu.xyz/api',
|
|
38
|
+
systemId: this.projectParams.systemId,
|
|
39
|
+
systemName: this.projectParams.systemName,
|
|
40
|
+
apiUrl: '/proxy',
|
|
41
|
+
verName: this.verName,
|
|
42
|
+
systemUrl: this.getSystemUrl(),
|
|
43
|
+
authUrl: _urlConfig.authUrl,
|
|
44
|
+
wsUrl: _urlConfig.wsUrl,
|
|
45
|
+
}
|
|
46
|
+
return getEnvFileTemplate(envFileParams);
|
|
47
|
+
} else {
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
this.onStart();
|
|
50
|
+
}, 500)
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
async getServerPort() {
|
|
57
|
+
|
|
58
|
+
let flag = await this.isPortAvailable(this.port);
|
|
59
|
+
|
|
60
|
+
if (!flag) {
|
|
61
|
+
this.port += 1;
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
writeEnvFile(fileContent) {
|
|
70
|
+
const press = process.cwd();
|
|
71
|
+
const fileUrl = path.join(press, `./.env`);
|
|
72
|
+
fs.writeFileSync(fileUrl, fileContent);
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
writePackageJson() {
|
|
77
|
+
const press = process.cwd();
|
|
78
|
+
const fileUrl = path.join(press, `./package.json`);
|
|
79
|
+
const _packageJson = packageJson;
|
|
80
|
+
// 读取本地json文件 dependencies.json
|
|
81
|
+
let flag = fs.existsSync('./dependencies.json');
|
|
82
|
+
if (flag) {
|
|
83
|
+
const fileContent = JSON.parse(fs.readFileSync(path.join(press, './dependencies.json')));
|
|
84
|
+
|
|
85
|
+
for (let fileContentKey in fileContent) {
|
|
86
|
+
_packageJson.dependencies[`${fileContentKey}`] = fileContent[`${fileContentKey}`];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
fs.writeFileSync(fileUrl, JSON.stringify(_packageJson));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
writeVueConfigJs() {
|
|
95
|
+
const press = process.cwd();
|
|
96
|
+
const fileUrl = path.join(press, './vue.config.js');
|
|
97
|
+
let fileContent = fs.readFileSync(fileUrl).toString();
|
|
98
|
+
const regex = /(?<=^|[^0-9])port: \d{4}(?=$|[^0-9])/;
|
|
99
|
+
fileContent = fileContent.replace(regex, (math, index, input) => {
|
|
100
|
+
return `port: ${this.port}`;
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
fs.writeFileSync(path.join(press, './vue.config.js'), fileContent);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
// 获取指定端口是否可以使用
|
|
108
|
+
isPortAvailable(port) {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const net = require('net');
|
|
111
|
+
const server = net.createServer();
|
|
112
|
+
|
|
113
|
+
server.once('error', (err) => {
|
|
114
|
+
if (err.code === 'EADDRINUSE') {
|
|
115
|
+
// 端口已经被占用
|
|
116
|
+
resolve(false);
|
|
117
|
+
} else {
|
|
118
|
+
reject(err);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
server.once('listening', () => {
|
|
123
|
+
// 端口可用
|
|
124
|
+
server.close();
|
|
125
|
+
resolve(true);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
server.listen(port);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 获取本机ip
|
|
133
|
+
getLocalAddress() {
|
|
134
|
+
const os = require('os');
|
|
135
|
+
const interfaces = os.networkInterfaces();
|
|
136
|
+
let ipAddress;
|
|
137
|
+
Object.keys(interfaces).forEach((interfaceName) => {
|
|
138
|
+
interfaces[interfaceName].forEach((interfaceInfo) => {
|
|
139
|
+
if (interfaceInfo.family === 'IPv4' && !interfaceInfo.internal) {
|
|
140
|
+
ipAddress = interfaceInfo.address;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
return ipAddress;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
onRunServe() {
|
|
149
|
+
|
|
150
|
+
exec('npm install', async (error, stdout, stderr) => {
|
|
151
|
+
if (!error) {
|
|
152
|
+
shell.exec('npm run serve', (error, stdout, stderr) => {
|
|
153
|
+
console.log(error);
|
|
154
|
+
})
|
|
155
|
+
} else {
|
|
156
|
+
console.error('依赖下载失败!')
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
getSystemUrl() {
|
|
163
|
+
return `${this.getLocalAddress()}:${this.port}`;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
module.exports = EnvByServerController;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
const projectConfig = require('../config/projectConfig');
|
|
3
|
+
const getEnvFileTemplate = require('../config/envFileTemplate');
|
|
4
|
+
|
|
5
|
+
const packageJson = require('../config/package.json');
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ServeController {
|
|
11
|
+
// 项目名称
|
|
12
|
+
constructor(projectName) {
|
|
13
|
+
this.verName = '';
|
|
14
|
+
this.projectName = projectName;
|
|
15
|
+
|
|
16
|
+
this.projectParams = null;
|
|
17
|
+
|
|
18
|
+
this.checkProjectExist();
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
async onStart() {
|
|
24
|
+
let fileContent = await this.createEnvFiles();
|
|
25
|
+
|
|
26
|
+
if (fileContent) {
|
|
27
|
+
|
|
28
|
+
this.writeEnvFile(fileContent);
|
|
29
|
+
|
|
30
|
+
this.writePackageJson();
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 生成对应的环境模版文件
|
|
39
|
+
createEnvFiles() {
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// 写入文件
|
|
46
|
+
writeEnvFile() {
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 写入package.json文件
|
|
52
|
+
writePackageJson() {
|
|
53
|
+
const press = process.cwd();
|
|
54
|
+
const fileUrl = path.join(press, `./package.json`);
|
|
55
|
+
fs.writeFileSync(fileUrl, JSON.stringify(packageJson));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// 检查是否存在当前的项目
|
|
60
|
+
checkProjectExist() {
|
|
61
|
+
|
|
62
|
+
this.projectParams = projectConfig[`${this.projectName}`];
|
|
63
|
+
if (!this.projectParams) {
|
|
64
|
+
console.log('应用名称错误,请重新输入应用名称,程序退出!');
|
|
65
|
+
process.exit();
|
|
66
|
+
return false;
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// 跑服务
|
|
75
|
+
onRunServe() {
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 获取systemUrl
|
|
81
|
+
getSystemUrl() {
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
module.exports = ServeController;
|