@steedos/service-package-loader 2.2.10 → 2.2.11
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/index.js +35 -1
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -8,6 +8,8 @@ const path = require('path');
|
|
|
8
8
|
const Future = require('fibers/future');
|
|
9
9
|
const _ = require('lodash');
|
|
10
10
|
const globby = require("globby");
|
|
11
|
+
const express = require('express');
|
|
12
|
+
const fs = require("fs");
|
|
11
13
|
/**
|
|
12
14
|
* @typedef {import('moleculer').Context} Context Moleculer's Context
|
|
13
15
|
*/
|
|
@@ -20,7 +22,8 @@ module.exports = {
|
|
|
20
22
|
*/
|
|
21
23
|
settings: {
|
|
22
24
|
path: '', // 扫描加载原数据的路径
|
|
23
|
-
name: '' // service name
|
|
25
|
+
name: '', // service name
|
|
26
|
+
loadedPackagePublicFiles: false
|
|
24
27
|
},
|
|
25
28
|
|
|
26
29
|
/**
|
|
@@ -46,6 +49,9 @@ module.exports = {
|
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
51
|
const { path : _path } = packageInfo;
|
|
52
|
+
|
|
53
|
+
this.loadPackagePublicFiles(_path);
|
|
54
|
+
|
|
49
55
|
if(_path){
|
|
50
56
|
//此处延迟10秒加载流程文件,防止工作区初始化未完成
|
|
51
57
|
setTimeout(() => {
|
|
@@ -112,6 +118,32 @@ module.exports = {
|
|
|
112
118
|
this.logger.error(error)
|
|
113
119
|
}
|
|
114
120
|
}
|
|
121
|
+
},
|
|
122
|
+
loadPackagePublicFiles: {
|
|
123
|
+
handler(packagePath) {
|
|
124
|
+
let publicPath = path.join(packagePath, 'public');
|
|
125
|
+
if (!fs.existsSync(publicPath) ||this.settings.loadedPackagePublicFiles || !WebApp) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this.settings.loadedPackagePublicFiles = true;
|
|
130
|
+
try {
|
|
131
|
+
const router = express.Router();
|
|
132
|
+
let routerPath = "";
|
|
133
|
+
if (__meteor_runtime_config__.ROOT_URL_PATH_PREFIX) {
|
|
134
|
+
routerPath = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;
|
|
135
|
+
}
|
|
136
|
+
const cacheTime = 86400000 * 1; // one day
|
|
137
|
+
router.use(routerPath, express.static(publicPath, { maxAge: cacheTime }));
|
|
138
|
+
WebApp.rawConnectHandlers.use(router);
|
|
139
|
+
|
|
140
|
+
console.log(`loadPackagePublicFiles ===>`, publicPath)
|
|
141
|
+
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error(error)
|
|
144
|
+
this.settings.loadedPackagePublicFiles = false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
115
147
|
}
|
|
116
148
|
},
|
|
117
149
|
|
|
@@ -158,6 +190,8 @@ module.exports = {
|
|
|
158
190
|
|
|
159
191
|
await this.loadPackageMetadataServices(_path);
|
|
160
192
|
|
|
193
|
+
await this.loadPackagePublicFiles(_path);
|
|
194
|
+
|
|
161
195
|
console.timeEnd(`service ${this.name} started`)
|
|
162
196
|
// console.log(`service ${this.name} started`);
|
|
163
197
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-package-loader",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@steedos/core": "2.2.
|
|
15
|
-
"@steedos/objectql": "2.2.
|
|
14
|
+
"@steedos/core": "2.2.11",
|
|
15
|
+
"@steedos/objectql": "2.2.11",
|
|
16
16
|
"clone": "^2.1.2",
|
|
17
17
|
"globby": "^9.1.0",
|
|
18
18
|
"moleculer": "^0.14.12",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "0eaf63bc2efddbc85f98eb5091c0545f3304ae9d"
|
|
36
36
|
}
|