meixifrontserve 2.0.66 → 2.0.68

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.
@@ -1,177 +1,177 @@
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?filepath=${ossBuckConfig[`${this.env}`]}${time}`, {
96
- }, (error, res) => {
97
- console.log(error);
98
- if (!error) {
99
- resolve(res.body.data);
100
- }
101
-
102
- });
103
-
104
- })
105
-
106
- }
107
-
108
- // 上传至oss
109
- netToFileToOss(ossParams, fileContent, fileName) {
110
-
111
- return new Promise((resolve, reject) => {
112
- let {accessKeyId, signature, host, policy, dir} = ossParams;
113
- const key = `${dir}/${fileName}`
114
- const ossUrl = `${host}/${key}`
115
-
116
- needle.post(host, {
117
- OSSAccessKeyId: accessKeyId,
118
- signature: signature,
119
- policy: policy,
120
- key: key,
121
- url: host,
122
- success_action_status: "200",
123
- file: fileContent.toLocaleString()
124
- }, {
125
- multipart: true,
126
- }, (error, res) => {
127
- if (!error) {
128
- // 返回文件的路径
129
- resolve(ossUrl);
130
- } else {
131
- resolve(false);
132
- }
133
- });
134
- })
135
-
136
-
137
- }
138
-
139
-
140
- //
141
- netToMicoModuleAPi(ossUrl, rollupBuildTargetKey) {
142
- return new Promise((resolve, reject) => {
143
- console.log('开始调用微模块管理接口')
144
- const ver = new Date().valueOf();
145
- needle.post(`${apiConfig[`${this.env}`]}/admin/client/backlog/front/code/record`, {
146
- tag: rollupBuildTargetKey,
147
- version: ver,
148
- downloadUrl: ossUrl
149
- }, {
150
- headers: {'content-type': 'application/json'}
151
- }, (error, res) => {
152
- if (!error) {
153
- resolve(true);
154
- } else {
155
- resolve(false);
156
- }
157
- });
158
- })
159
-
160
- }
161
-
162
-
163
- checkPlatform() {
164
- switch (process.platform) {
165
- case 'darwin':
166
- return 'sudo meixirollupbuild -b'
167
- case "win32":
168
- return 'meixirollupbuild -b'
169
- default:
170
- return 'meixirollupbuild -b'
171
- }
172
- }
173
-
174
- }
175
-
176
-
177
- 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?filepath=${ossBuckConfig[`${this.env}`]}${time}`, {
96
+ }, (error, res) => {
97
+ console.log(error);
98
+ if (!error) {
99
+ resolve(res.body.data);
100
+ }
101
+
102
+ });
103
+
104
+ })
105
+
106
+ }
107
+
108
+ // 上传至oss
109
+ netToFileToOss(ossParams, fileContent, fileName) {
110
+
111
+ return new Promise((resolve, reject) => {
112
+ let {accessKeyId, signature, host, policy, dir} = ossParams;
113
+ const key = `${dir}/${fileName}`
114
+ const ossUrl = `${host}/${key}`
115
+
116
+ needle.post(host, {
117
+ OSSAccessKeyId: accessKeyId,
118
+ signature: signature,
119
+ policy: policy,
120
+ key: key,
121
+ url: host,
122
+ success_action_status: "200",
123
+ file: fileContent.toLocaleString()
124
+ }, {
125
+ multipart: true,
126
+ }, (error, res) => {
127
+ if (!error) {
128
+ // 返回文件的路径
129
+ resolve(ossUrl);
130
+ } else {
131
+ resolve(false);
132
+ }
133
+ });
134
+ })
135
+
136
+
137
+ }
138
+
139
+
140
+ //
141
+ netToMicoModuleAPi(ossUrl, rollupBuildTargetKey) {
142
+ return new Promise((resolve, reject) => {
143
+ console.log('开始调用微模块管理接口')
144
+ const ver = new Date().valueOf();
145
+ needle.post(`${apiConfig[`${this.env}`]}/admin/client/backlog/front/code/record`, {
146
+ tag: rollupBuildTargetKey,
147
+ version: ver,
148
+ downloadUrl: ossUrl
149
+ }, {
150
+ headers: {'content-type': 'application/json'}
151
+ }, (error, res) => {
152
+ if (!error) {
153
+ resolve(true);
154
+ } else {
155
+ resolve(false);
156
+ }
157
+ });
158
+ })
159
+
160
+ }
161
+
162
+
163
+ checkPlatform() {
164
+ switch (process.platform) {
165
+ case 'darwin':
166
+ return 'sudo meixirollupbuild -b'
167
+ case "win32":
168
+ return 'meixirollupbuild -b'
169
+ default:
170
+ return 'meixirollupbuild -b'
171
+ }
172
+ }
173
+
174
+ }
175
+
176
+
177
+ module.exports = RollupBuildController;
@@ -1,110 +1,110 @@
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 packageV2Json = require("../config/packageV2.json");
7
- const path = require("path");
8
- const fs = require("fs");
9
-
10
-
11
- class ServeController {
12
- // 项目名称
13
- constructor(projectName, isV2 = false) {
14
- this.verName = '';
15
- this.projectName = projectName;
16
-
17
- this.projectParams = null;
18
-
19
- this.checkProjectExist();
20
-
21
- this.v2 = isV2;
22
-
23
- }
24
-
25
-
26
- async onStart() {
27
- let fileContent = await this.createEnvFiles();
28
-
29
-
30
- if (fileContent) {
31
-
32
- this.writeEnvFile(fileContent);
33
-
34
- this.writePackageJson();
35
-
36
- return true;
37
-
38
-
39
- }
40
-
41
- return false;
42
-
43
-
44
- }
45
-
46
- // 生成对应的环境模版文件
47
- createEnvFiles() {
48
-
49
-
50
- }
51
-
52
-
53
- // 写入文件
54
- writeEnvFile() {
55
-
56
-
57
- }
58
-
59
- // 写入package.json文件
60
- writePackageJson() {
61
- const press = process.cwd();
62
- const fileUrl = path.join(press, `./package.json`);
63
- const _packageJson = this.v2 ? packageV2Json : packageJson;
64
- // 读取本地json文件 dependencies.json
65
- let flag = fs.existsSync('./dependencies.json');
66
- if (flag) {
67
- const fileContent = JSON.parse(fs.readFileSync(path.join(press, './dependencies.json')));
68
-
69
- for (let fileContentKey in fileContent) {
70
- _packageJson.dependencies[`${fileContentKey}`] = fileContent[`${fileContentKey}`];
71
- }
72
- }
73
-
74
- _packageJson.name = `newoa${this.projectName}`;
75
-
76
-
77
- fs.writeFileSync(fileUrl, JSON.stringify(_packageJson));
78
- }
79
-
80
-
81
- // 检查是否存在当前的项目
82
- checkProjectExist() {
83
-
84
- this.projectParams = projectConfig[`${this.projectName}`];
85
- if (!this.projectParams) {
86
- console.log('应用名称错误,请重新输入应用名称,程序退出!');
87
- process.exit();
88
- return false;
89
-
90
- }
91
-
92
-
93
- }
94
-
95
-
96
- // 跑服务
97
- onRunServe() {
98
-
99
-
100
- }
101
-
102
- // 获取systemUrl
103
- getSystemUrl() {
104
-
105
- }
106
-
107
-
108
- }
109
-
110
- module.exports = ServeController;
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 packageV2Json = require("../config/packageV2.json");
7
+ const path = require("path");
8
+ const fs = require("fs");
9
+
10
+
11
+ class ServeController {
12
+ // 项目名称
13
+ constructor(projectName, isV2 = false) {
14
+ this.verName = '';
15
+ this.projectName = projectName;
16
+
17
+ this.projectParams = null;
18
+
19
+ this.checkProjectExist();
20
+
21
+ this.v2 = isV2;
22
+
23
+ }
24
+
25
+
26
+ async onStart() {
27
+ let fileContent = await this.createEnvFiles();
28
+
29
+
30
+ if (fileContent) {
31
+
32
+ this.writeEnvFile(fileContent);
33
+
34
+ this.writePackageJson();
35
+
36
+ return true;
37
+
38
+
39
+ }
40
+
41
+ return false;
42
+
43
+
44
+ }
45
+
46
+ // 生成对应的环境模版文件
47
+ createEnvFiles() {
48
+
49
+
50
+ }
51
+
52
+
53
+ // 写入文件
54
+ writeEnvFile() {
55
+
56
+
57
+ }
58
+
59
+ // 写入package.json文件
60
+ writePackageJson() {
61
+ const press = process.cwd();
62
+ const fileUrl = path.join(press, `./package.json`);
63
+ const _packageJson = this.v2 ? packageV2Json : packageJson;
64
+ // 读取本地json文件 dependencies.json
65
+ let flag = fs.existsSync('./dependencies.json');
66
+ if (flag) {
67
+ const fileContent = JSON.parse(fs.readFileSync(path.join(press, './dependencies.json')));
68
+
69
+ for (let fileContentKey in fileContent) {
70
+ _packageJson.dependencies[`${fileContentKey}`] = fileContent[`${fileContentKey}`];
71
+ }
72
+ }
73
+
74
+ _packageJson.name = `newoa${this.projectName}`;
75
+
76
+
77
+ fs.writeFileSync(fileUrl, JSON.stringify(_packageJson));
78
+ }
79
+
80
+
81
+ // 检查是否存在当前的项目
82
+ checkProjectExist() {
83
+
84
+ this.projectParams = projectConfig[`${this.projectName}`];
85
+ if (!this.projectParams) {
86
+ console.log('应用名称错误,请重新输入应用名称,程序退出!');
87
+ process.exit();
88
+ return false;
89
+
90
+ }
91
+
92
+
93
+ }
94
+
95
+
96
+ // 跑服务
97
+ onRunServe() {
98
+
99
+
100
+ }
101
+
102
+ // 获取systemUrl
103
+ getSystemUrl() {
104
+
105
+ }
106
+
107
+
108
+ }
109
+
110
+ module.exports = ServeController;