@steedos/service-package-loader 2.2.9 → 2.2.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/index.js +32 -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,29 @@ 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
|
+
} catch (error) {
|
|
140
|
+
console.error(error)
|
|
141
|
+
this.settings.loadedPackagePublicFiles = false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
115
144
|
}
|
|
116
145
|
},
|
|
117
146
|
|
|
@@ -158,6 +187,8 @@ module.exports = {
|
|
|
158
187
|
|
|
159
188
|
await this.loadPackageMetadataServices(_path);
|
|
160
189
|
|
|
190
|
+
await this.loadPackagePublicFiles(_path);
|
|
191
|
+
|
|
161
192
|
console.timeEnd(`service ${this.name} started`)
|
|
162
193
|
// console.log(`service ${this.name} started`);
|
|
163
194
|
},
|
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.12",
|
|
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.12",
|
|
15
|
+
"@steedos/objectql": "2.2.12",
|
|
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": "06806c509f487a82158919278c6c0b384373f8ac"
|
|
36
36
|
}
|