meixifrontserve 0.6.99 → 0.7.12
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 +91 -91
- package/config/package.json +1 -1
- package/config/projectConfig.js +203 -203
- package/config/urlConfig.js +41 -41
- package/package.json +1 -1
- package/scripts/envByBetaController.js +19 -19
- package/scripts/envByBuildController.js +93 -93
- package/scripts/envByPreController.js +21 -21
- package/scripts/envByProdController.js +20 -20
- package/scripts/envByTest2Controller.js +21 -21
- package/scripts/rollupBuildController.js +178 -178
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
// rollupBuild打包
|
|
2
|
-
// umd.js
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const child_process = require("child_process");
|
|
6
|
-
const needle = require("needle");
|
|
7
|
-
const {error} = require("shelljs");
|
|
8
|
-
const {apiConfig, ossBuckConfig} = require("./apiConfig");
|
|
9
|
-
|
|
10
|
-
class RollupBuildController {
|
|
11
|
-
constructor(env) {
|
|
12
|
-
|
|
13
|
-
this.rollupBuildTarget = null;
|
|
14
|
-
this.commandStr = null;
|
|
15
|
-
this.env = env;
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
beforeRunServe() {
|
|
21
|
-
let flag = true;
|
|
22
|
-
|
|
23
|
-
// 获取配置的文件信息
|
|
24
|
-
const press = process.cwd();
|
|
25
|
-
let configPath = path.join(press, './rollupBuildTarget.json');
|
|
26
|
-
|
|
27
|
-
// 判断是否存在文件
|
|
28
|
-
flag = fs.existsSync('./rollupBuildTarget.json');
|
|
29
|
-
if (flag) {
|
|
30
|
-
this.rollupBuildTarget = JSON.parse(fs.readFileSync(configPath).toString());
|
|
31
|
-
let str = ''
|
|
32
|
-
for (let rollupBuildTargetKey in this.rollupBuildTarget) {
|
|
33
|
-
let paramsStr = `${this.rollupBuildTarget[`${rollupBuildTargetKey}`][`source`]}-lib/${rollupBuildTargetKey}.umd.js`
|
|
34
|
-
if (!str) {
|
|
35
|
-
str += `${this.checkPlatform()} / --pathTarget ${paramsStr}`
|
|
36
|
-
} else {
|
|
37
|
-
str += `-${paramsStr}`
|
|
38
|
-
}
|
|
39
|
-
this.commandStr = str;
|
|
40
|
-
console.log(str);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return flag;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
runServe() {
|
|
49
|
-
if (this.beforeRunServe()) {
|
|
50
|
-
child_process.exec(`${this.commandStr}`, async (error, stdout, statusbar) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
console.log(error);
|
|
54
|
-
|
|
55
|
-
if (!error) {
|
|
56
|
-
console.log('开始准备上传文件');
|
|
57
|
-
const press = process.cwd();
|
|
58
|
-
for (let rollupBuildTargetKey in this.rollupBuildTarget) {
|
|
59
|
-
let configPath = path.join(press, `./lib/${rollupBuildTargetKey}.umd.js`);
|
|
60
|
-
let fileContent = fs.readFileSync(configPath);
|
|
61
|
-
try {
|
|
62
|
-
let ossParams = await this.netApiToAuth();
|
|
63
|
-
let ossUrl = await this.netToFileToOss(ossParams, fileContent, rollupBuildTargetKey);
|
|
64
|
-
|
|
65
|
-
if (ossUrl) {
|
|
66
|
-
// 调用微模块管理接口
|
|
67
|
-
await this.netToMicoModuleAPi(ossUrl, rollupBuildTargetKey)
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
} catch (error) {
|
|
71
|
-
console.log(error);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
//
|
|
77
|
-
console.log('微模块打包失败!')
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
} else {
|
|
82
|
-
console.log('当前无微模块打包');
|
|
83
|
-
process.exit();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// 获取oss上传的key
|
|
90
|
-
netApiToAuth() {
|
|
91
|
-
const date = new Date();
|
|
92
|
-
let time = `${date.getFullYear()}${date.getMonth() + 1}${date.getDate()}`
|
|
93
|
-
return new Promise((resolve, reject) => {
|
|
94
|
-
console.log(`${apiConfig[`${this.env}`]}/files/osssource/common/oss/policy`)
|
|
95
|
-
needle.post(`${apiConfig[`${this.env}`]}/files/osssource/common/oss/policy`, {
|
|
96
|
-
filepath: `${ossBuckConfig[`${this.env}`]}${time}`
|
|
97
|
-
}, (error, res) => {
|
|
98
|
-
console.log(error);
|
|
99
|
-
if (!error) {
|
|
100
|
-
resolve(res.body.data);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// 上传至oss
|
|
110
|
-
netToFileToOss(ossParams, fileContent, fileName) {
|
|
111
|
-
|
|
112
|
-
return new Promise((resolve, reject) => {
|
|
113
|
-
let {accessKeyId, signature, host, policy, dir} = ossParams;
|
|
114
|
-
const key = `${dir}/${fileName}`
|
|
115
|
-
const ossUrl = `${host}/${key}`
|
|
116
|
-
|
|
117
|
-
needle.post(host, {
|
|
118
|
-
OSSAccessKeyId: accessKeyId,
|
|
119
|
-
signature: signature,
|
|
120
|
-
policy: policy,
|
|
121
|
-
key: key,
|
|
122
|
-
url: host,
|
|
123
|
-
success_action_status: "200",
|
|
124
|
-
file: fileContent.toLocaleString()
|
|
125
|
-
}, {
|
|
126
|
-
multipart: true,
|
|
127
|
-
}, (error, res) => {
|
|
128
|
-
if (!error) {
|
|
129
|
-
// 返回文件的路径
|
|
130
|
-
resolve(ossUrl);
|
|
131
|
-
} else {
|
|
132
|
-
resolve(false);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
//
|
|
142
|
-
netToMicoModuleAPi(ossUrl, rollupBuildTargetKey) {
|
|
143
|
-
return new Promise((resolve, reject) => {
|
|
144
|
-
console.log('开始调用微模块管理接口')
|
|
145
|
-
const ver = new Date().valueOf();
|
|
146
|
-
needle.post(`${apiConfig[`${this.env}`]}/admin/client/backlog/front/code/record`, {
|
|
147
|
-
tag: rollupBuildTargetKey,
|
|
148
|
-
version: ver,
|
|
149
|
-
downloadUrl: ossUrl
|
|
150
|
-
}, {
|
|
151
|
-
headers: {'content-type': 'application/json'}
|
|
152
|
-
}, (error, res) => {
|
|
153
|
-
if (!error) {
|
|
154
|
-
resolve(true);
|
|
155
|
-
} else {
|
|
156
|
-
resolve(false);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
checkPlatform() {
|
|
165
|
-
switch (process.platform) {
|
|
166
|
-
case 'darwin':
|
|
167
|
-
return 'sudo meixirollupbuild -b'
|
|
168
|
-
case "win32":
|
|
169
|
-
return 'meixirollupbuild -b'
|
|
170
|
-
default:
|
|
171
|
-
return 'meixirollupbuild -b'
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
module.exports = RollupBuildController;
|
|
1
|
+
// rollupBuild打包
|
|
2
|
+
// umd.js
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const child_process = require("child_process");
|
|
6
|
+
const needle = require("needle");
|
|
7
|
+
const {error} = require("shelljs");
|
|
8
|
+
const {apiConfig, ossBuckConfig} = require("./apiConfig");
|
|
9
|
+
|
|
10
|
+
class RollupBuildController {
|
|
11
|
+
constructor(env) {
|
|
12
|
+
|
|
13
|
+
this.rollupBuildTarget = null;
|
|
14
|
+
this.commandStr = null;
|
|
15
|
+
this.env = env;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
beforeRunServe() {
|
|
21
|
+
let flag = true;
|
|
22
|
+
|
|
23
|
+
// 获取配置的文件信息
|
|
24
|
+
const press = process.cwd();
|
|
25
|
+
let configPath = path.join(press, './rollupBuildTarget.json');
|
|
26
|
+
|
|
27
|
+
// 判断是否存在文件
|
|
28
|
+
flag = fs.existsSync('./rollupBuildTarget.json');
|
|
29
|
+
if (flag) {
|
|
30
|
+
this.rollupBuildTarget = JSON.parse(fs.readFileSync(configPath).toString());
|
|
31
|
+
let str = ''
|
|
32
|
+
for (let rollupBuildTargetKey in this.rollupBuildTarget) {
|
|
33
|
+
let paramsStr = `${this.rollupBuildTarget[`${rollupBuildTargetKey}`][`source`]}-lib/${rollupBuildTargetKey}.umd.js`
|
|
34
|
+
if (!str) {
|
|
35
|
+
str += `${this.checkPlatform()} / --pathTarget ${paramsStr}`
|
|
36
|
+
} else {
|
|
37
|
+
str += `-${paramsStr}`
|
|
38
|
+
}
|
|
39
|
+
this.commandStr = str;
|
|
40
|
+
console.log(str);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
return flag;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
runServe() {
|
|
49
|
+
if (this.beforeRunServe()) {
|
|
50
|
+
child_process.exec(`${this.commandStr}`, async (error, stdout, statusbar) => {
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
console.log(error);
|
|
54
|
+
|
|
55
|
+
if (!error) {
|
|
56
|
+
console.log('开始准备上传文件');
|
|
57
|
+
const press = process.cwd();
|
|
58
|
+
for (let rollupBuildTargetKey in this.rollupBuildTarget) {
|
|
59
|
+
let configPath = path.join(press, `./lib/${rollupBuildTargetKey}.umd.js`);
|
|
60
|
+
let fileContent = fs.readFileSync(configPath);
|
|
61
|
+
try {
|
|
62
|
+
let ossParams = await this.netApiToAuth();
|
|
63
|
+
let ossUrl = await this.netToFileToOss(ossParams, fileContent, rollupBuildTargetKey);
|
|
64
|
+
|
|
65
|
+
if (ossUrl) {
|
|
66
|
+
// 调用微模块管理接口
|
|
67
|
+
await this.netToMicoModuleAPi(ossUrl, rollupBuildTargetKey)
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.log(error);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
//
|
|
77
|
+
console.log('微模块打包失败!')
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
} else {
|
|
82
|
+
console.log('当前无微模块打包');
|
|
83
|
+
process.exit();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
// 获取oss上传的key
|
|
90
|
+
netApiToAuth() {
|
|
91
|
+
const date = new Date();
|
|
92
|
+
let time = `${date.getFullYear()}${date.getMonth() + 1}${date.getDate()}`
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
console.log(`${apiConfig[`${this.env}`]}/files/osssource/common/oss/policy`)
|
|
95
|
+
needle.post(`${apiConfig[`${this.env}`]}/files/osssource/common/oss/policy`, {
|
|
96
|
+
filepath: `${ossBuckConfig[`${this.env}`]}${time}`
|
|
97
|
+
}, (error, res) => {
|
|
98
|
+
console.log(error);
|
|
99
|
+
if (!error) {
|
|
100
|
+
resolve(res.body.data);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 上传至oss
|
|
110
|
+
netToFileToOss(ossParams, fileContent, fileName) {
|
|
111
|
+
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
let {accessKeyId, signature, host, policy, dir} = ossParams;
|
|
114
|
+
const key = `${dir}/${fileName}`
|
|
115
|
+
const ossUrl = `${host}/${key}`
|
|
116
|
+
|
|
117
|
+
needle.post(host, {
|
|
118
|
+
OSSAccessKeyId: accessKeyId,
|
|
119
|
+
signature: signature,
|
|
120
|
+
policy: policy,
|
|
121
|
+
key: key,
|
|
122
|
+
url: host,
|
|
123
|
+
success_action_status: "200",
|
|
124
|
+
file: fileContent.toLocaleString()
|
|
125
|
+
}, {
|
|
126
|
+
multipart: true,
|
|
127
|
+
}, (error, res) => {
|
|
128
|
+
if (!error) {
|
|
129
|
+
// 返回文件的路径
|
|
130
|
+
resolve(ossUrl);
|
|
131
|
+
} else {
|
|
132
|
+
resolve(false);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
//
|
|
142
|
+
netToMicoModuleAPi(ossUrl, rollupBuildTargetKey) {
|
|
143
|
+
return new Promise((resolve, reject) => {
|
|
144
|
+
console.log('开始调用微模块管理接口')
|
|
145
|
+
const ver = new Date().valueOf();
|
|
146
|
+
needle.post(`${apiConfig[`${this.env}`]}/admin/client/backlog/front/code/record`, {
|
|
147
|
+
tag: rollupBuildTargetKey,
|
|
148
|
+
version: ver,
|
|
149
|
+
downloadUrl: ossUrl
|
|
150
|
+
}, {
|
|
151
|
+
headers: {'content-type': 'application/json'}
|
|
152
|
+
}, (error, res) => {
|
|
153
|
+
if (!error) {
|
|
154
|
+
resolve(true);
|
|
155
|
+
} else {
|
|
156
|
+
resolve(false);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
checkPlatform() {
|
|
165
|
+
switch (process.platform) {
|
|
166
|
+
case 'darwin':
|
|
167
|
+
return 'sudo meixirollupbuild -b'
|
|
168
|
+
case "win32":
|
|
169
|
+
return 'meixirollupbuild -b'
|
|
170
|
+
default:
|
|
171
|
+
return 'meixirollupbuild -b'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
module.exports = RollupBuildController;
|