@midwayjs/bootstrap 3.11.11 → 3.12.0-beta.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/dist/bootstrap.js +9 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/manager/cp.js +2 -2
- package/dist/manager/thread.js +2 -2
- package/dist/util.d.ts +0 -1
- package/dist/util.js +1 -10
- package/package.json +5 -5
- package/LICENSE +0 -21
package/dist/bootstrap.js
CHANGED
|
@@ -5,7 +5,6 @@ const core_1 = require("@midwayjs/core");
|
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const logger_1 = require("@midwayjs/logger");
|
|
7
7
|
const async_hooks_context_manager_1 = require("@midwayjs/async-hooks-context-manager");
|
|
8
|
-
const util_1 = require("./util");
|
|
9
8
|
const event_bus_1 = require("@midwayjs/event-bus");
|
|
10
9
|
const sticky_1 = require("./sticky");
|
|
11
10
|
class BootstrapStarter {
|
|
@@ -32,6 +31,14 @@ class BootstrapStarter {
|
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
}
|
|
34
|
+
if (!this.globalOptions.fileLoadMode) {
|
|
35
|
+
const pkgJSON = await (0, core_1.loadModule)((0, path_1.join)(this.appDir, 'package.json'), {
|
|
36
|
+
safeLoad: true,
|
|
37
|
+
enableCache: false,
|
|
38
|
+
});
|
|
39
|
+
this.globalOptions.fileLoadMode =
|
|
40
|
+
(pkgJSON === null || pkgJSON === void 0 ? void 0 : pkgJSON.type) === 'module' ? 'esm' : 'commonjs';
|
|
41
|
+
}
|
|
35
42
|
this.applicationContext = await (0, core_1.initializeGlobalApplicationContext)({
|
|
36
43
|
asyncContextManager: (0, async_hooks_context_manager_1.createContextManager)(),
|
|
37
44
|
...this.globalOptions,
|
|
@@ -64,7 +71,7 @@ class BootstrapStarter {
|
|
|
64
71
|
if (this.globalOptions.baseDir) {
|
|
65
72
|
return this.globalOptions.baseDir;
|
|
66
73
|
}
|
|
67
|
-
if ((0,
|
|
74
|
+
if ((0, core_1.isTypeScriptEnvironment)()) {
|
|
68
75
|
return (0, path_1.join)(this.appDir, 'src');
|
|
69
76
|
}
|
|
70
77
|
else {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,10 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.setupStickyMaster = exports.AbstractForkManager = exports.ClusterManager = exports.BootstrapStarter = exports.Bootstrap =
|
|
17
|
+
exports.setupStickyMaster = exports.AbstractForkManager = exports.ClusterManager = exports.BootstrapStarter = exports.Bootstrap = void 0;
|
|
18
18
|
__exportStar(require("./interface"), exports);
|
|
19
|
-
var util_1 = require("./util");
|
|
20
|
-
Object.defineProperty(exports, "isTypeScriptEnvironment", { enumerable: true, get: function () { return util_1.isTypeScriptEnvironment; } });
|
|
21
19
|
var bootstrap_1 = require("./bootstrap");
|
|
22
20
|
Object.defineProperty(exports, "Bootstrap", { enumerable: true, get: function () { return bootstrap_1.Bootstrap; } });
|
|
23
21
|
Object.defineProperty(exports, "BootstrapStarter", { enumerable: true, get: function () { return bootstrap_1.BootstrapStarter; } });
|
package/dist/manager/cp.js
CHANGED
|
@@ -5,7 +5,7 @@ const event_bus_1 = require("@midwayjs/event-bus");
|
|
|
5
5
|
const base_1 = require("./base");
|
|
6
6
|
const cluster = require('cluster');
|
|
7
7
|
const util_1 = require("util");
|
|
8
|
-
const
|
|
8
|
+
const core_1 = require("@midwayjs/core");
|
|
9
9
|
const debug = (0, util_1.debuglog)('midway:bootstrap');
|
|
10
10
|
class ClusterManager extends base_1.AbstractForkManager {
|
|
11
11
|
constructor(options = {}) {
|
|
@@ -13,7 +13,7 @@ class ClusterManager extends base_1.AbstractForkManager {
|
|
|
13
13
|
this.options = options;
|
|
14
14
|
options.args = options.args || [];
|
|
15
15
|
options.execArgv = options.execArgv || [];
|
|
16
|
-
if ((0,
|
|
16
|
+
if ((0, core_1.isTypeScriptEnvironment)()) {
|
|
17
17
|
options.execArgv.push(...['--require', 'ts-node/register']);
|
|
18
18
|
}
|
|
19
19
|
}
|
package/dist/manager/thread.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.ThreadManager = void 0;
|
|
|
4
4
|
const base_1 = require("./base");
|
|
5
5
|
const worker_threads_1 = require("worker_threads");
|
|
6
6
|
const event_bus_1 = require("@midwayjs/event-bus");
|
|
7
|
-
const
|
|
7
|
+
const core_1 = require("@midwayjs/core");
|
|
8
8
|
class ThreadManager extends base_1.AbstractForkManager {
|
|
9
9
|
constructor(options = {}) {
|
|
10
10
|
super(options);
|
|
@@ -19,7 +19,7 @@ class ThreadManager extends base_1.AbstractForkManager {
|
|
|
19
19
|
require(${JSON.stringify(this.options.exec)});
|
|
20
20
|
`;
|
|
21
21
|
// 当前是 ts 环境
|
|
22
|
-
if ((0,
|
|
22
|
+
if ((0, core_1.isTypeScriptEnvironment)()) {
|
|
23
23
|
content = `
|
|
24
24
|
require("ts-node/register/transpile-only");
|
|
25
25
|
${content}
|
package/dist/util.d.ts
CHANGED
package/dist/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.sleep = exports.logDate = void 0;
|
|
4
4
|
function logDate() {
|
|
5
5
|
const d = new Date();
|
|
6
6
|
let date = d.getDate();
|
|
@@ -51,13 +51,4 @@ async function sleep(timeout) {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
exports.sleep = sleep;
|
|
54
|
-
function isTypeScriptEnvironment() {
|
|
55
|
-
const TS_MODE_PROCESS_FLAG = process.env.MIDWAY_TS_MODE;
|
|
56
|
-
if ('false' === TS_MODE_PROCESS_FLAG) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
// eslint-disable-next-line node/no-deprecated-api
|
|
60
|
-
return TS_MODE_PROCESS_FLAG === 'true' || !!require.extensions['.ts'];
|
|
61
|
-
}
|
|
62
|
-
exports.isTypeScriptEnvironment = isTypeScriptEnvironment;
|
|
63
54
|
//# sourceMappingURL=util.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/bootstrap",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0-beta.1",
|
|
4
4
|
"description": "midwayjs bootstrap",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@midwayjs/async-hooks-context-manager": "^3.11.
|
|
24
|
+
"@midwayjs/async-hooks-context-manager": "^3.11.15",
|
|
25
25
|
"@midwayjs/event-bus": "1.7.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@midwayjs/core": "^3.11.
|
|
28
|
+
"@midwayjs/core": "^3.11.15",
|
|
29
29
|
"@midwayjs/logger": "^2.15.0",
|
|
30
30
|
"request": "2.88.2",
|
|
31
|
-
"socket.io-client": "4.
|
|
31
|
+
"socket.io-client": "4.7.1"
|
|
32
32
|
},
|
|
33
33
|
"author": "Harry Chen <czy88840616@gmail.com>",
|
|
34
34
|
"repository": {
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=12.11.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a603d2348d6141f8f723901498f03a162a037708"
|
|
42
42
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 - Now midwayjs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|