@midwayjs/bootstrap 3.0.2 → 3.0.6
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/package.json +8 -9
- package/dist/bootstrap.js.map +0 -1
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/bootstrap",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"description": "midwayjs bootstrap",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -17,16 +17,15 @@
|
|
|
17
17
|
],
|
|
18
18
|
"files": [
|
|
19
19
|
"dist/**/*.js",
|
|
20
|
-
"dist/**/*.d.ts"
|
|
21
|
-
"dist/**/*.js.map"
|
|
20
|
+
"dist/**/*.d.ts"
|
|
22
21
|
],
|
|
23
22
|
"license": "MIT",
|
|
24
23
|
"devDependencies": {
|
|
25
|
-
"@midwayjs/core": "^3.0.
|
|
26
|
-
"@midwayjs/decorator": "^3.0.
|
|
27
|
-
"@midwayjs/logger": "^2.
|
|
28
|
-
"@midwayjs/socketio": "^3.0.
|
|
29
|
-
"@midwayjs/web": "^3.0.
|
|
24
|
+
"@midwayjs/core": "^3.0.6",
|
|
25
|
+
"@midwayjs/decorator": "^3.0.6",
|
|
26
|
+
"@midwayjs/logger": "^2.15.0",
|
|
27
|
+
"@midwayjs/socketio": "^3.0.6",
|
|
28
|
+
"@midwayjs/web": "^3.0.6",
|
|
30
29
|
"@types/socket.io-client": "1.4.36",
|
|
31
30
|
"request": "2.88.2",
|
|
32
31
|
"socket.io-client": "4.4.1"
|
|
@@ -39,5 +38,5 @@
|
|
|
39
38
|
"engines": {
|
|
40
39
|
"node": ">=12"
|
|
41
40
|
},
|
|
42
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "afaa5b59a2be85e915233a9268c0e05965dd5c61"
|
|
43
42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AAU,GAAG,KAAK,CAAC","sourcesContent":["import {\n IMidwayBootstrapOptions,\n IMidwayContainer,\n initializeGlobalApplicationContext,\n destroyGlobalApplicationContext,\n} from '@midwayjs/core';\nimport { join } from 'path';\nimport { IMidwayLogger, MidwayBaseLogger } from '@midwayjs/logger';\n\nexport function isTypeScriptEnvironment() {\n const TS_MODE_PROCESS_FLAG: string = process.env.MIDWAY_TS_MODE;\n if ('false' === TS_MODE_PROCESS_FLAG) {\n return false;\n }\n // eslint-disable-next-line node/no-deprecated-api\n return TS_MODE_PROCESS_FLAG === 'true' || !!require.extensions['.ts'];\n}\n\nexport class BootstrapStarter {\n protected appDir: string;\n protected baseDir: string;\n protected globalOptions: Partial<IMidwayBootstrapOptions> = {};\n protected globalConfig: any;\n private applicationContext: IMidwayContainer;\n\n public configure(options: IMidwayBootstrapOptions) {\n this.globalOptions = options;\n return this;\n }\n\n public async init() {\n this.appDir = this.globalOptions.appDir || process.cwd();\n this.baseDir = this.getBaseDir();\n\n this.applicationContext = await initializeGlobalApplicationContext({\n ...this.globalOptions,\n appDir: this.appDir,\n baseDir: this.baseDir,\n });\n return this.applicationContext;\n }\n\n public async run() {}\n\n public async stop() {\n await destroyGlobalApplicationContext(this.applicationContext);\n }\n\n protected getBaseDir() {\n if (this.globalOptions.baseDir) {\n return this.globalOptions.baseDir;\n }\n if (isTypeScriptEnvironment()) {\n return join(this.appDir, 'src');\n } else {\n return join(this.appDir, 'dist');\n }\n }\n}\n\nexport class Bootstrap {\n private static starter: BootstrapStarter;\n private static logger: IMidwayLogger;\n private static configured = false;\n private static applicationContext: IMidwayContainer;\n\n /**\n * set global configuration for midway\n * @param configuration\n */\n static configure(configuration: IMidwayBootstrapOptions = {}) {\n this.configured = true;\n if (!this.logger && !configuration.logger) {\n this.logger = new MidwayBaseLogger({\n disableError: true,\n disableFile: true,\n });\n if (configuration.logger === false) {\n this.logger?.['disableConsole']();\n }\n configuration.logger = this.logger;\n } else {\n this.logger = this.logger || (configuration.logger as IMidwayLogger);\n }\n\n // 处理三方框架内部依赖 process.cwd 来查找 node_modules 等问题\n if (configuration.appDir && configuration.appDir !== process.cwd()) {\n process.chdir(configuration.appDir);\n }\n\n this.getStarter().configure(configuration);\n return this;\n }\n\n private static getStarter() {\n if (!this.starter) {\n this.starter = new BootstrapStarter();\n }\n return this.starter;\n }\n\n static async run() {\n if (!this.configured) {\n this.configure();\n }\n // https://nodejs.org/api/process.html#process_signal_events\n // https://en.wikipedia.org/wiki/Unix_signal\n // kill(2) Ctrl-C\n process.once('SIGINT', this.onSignal.bind(this, 'SIGINT'));\n // kill(3) Ctrl-\\\n process.once('SIGQUIT', this.onSignal.bind(this, 'SIGQUIT'));\n // kill(15) default\n process.once('SIGTERM', this.onSignal.bind(this, 'SIGTERM'));\n\n process.once('exit', this.onExit.bind(this));\n\n this.uncaughtExceptionHandler = this.uncaughtExceptionHandler.bind(this);\n process.on('uncaughtException', this.uncaughtExceptionHandler);\n\n this.unhandledRejectionHandler = this.unhandledRejectionHandler.bind(this);\n process.on('unhandledRejection', this.unhandledRejectionHandler);\n\n this.applicationContext = await this.getStarter().init();\n return this.getStarter()\n .run()\n .then(() => {\n this.logger.info('[midway:bootstrap] current app started');\n })\n .catch(err => {\n this.logger.error(err);\n process.exit(1);\n });\n }\n\n static async stop() {\n await this.getStarter().stop();\n process.removeListener('uncaughtException', this.uncaughtExceptionHandler);\n process.removeListener(\n 'unhandledRejection',\n this.unhandledRejectionHandler\n );\n this.reset();\n }\n\n static reset() {\n this.configured = false;\n this.starter = null;\n this.logger.close();\n }\n\n /**\n * on bootstrap receive a exit signal\n * @param signal\n */\n private static async onSignal(signal) {\n this.logger.info('[midway:bootstrap] receive signal %s, closing', signal);\n try {\n await this.stop();\n this.logger.info('[midway:bootstrap] close done, exiting with code:0');\n process.exit(0);\n } catch (err) {\n this.logger.error('[midway:bootstrap] close with error: ', err);\n process.exit(1);\n }\n }\n\n /**\n * on bootstrap process exit\n * @param code\n */\n private static onExit(code) {\n this.logger.info('[midway:bootstrap] exit with code:%s', code);\n }\n\n private static uncaughtExceptionHandler(err) {\n if (!(err instanceof Error)) {\n err = new Error(String(err));\n }\n if (err.name === 'Error') {\n err.name = 'unhandledExceptionError';\n }\n this.logger.error(err);\n }\n\n private static unhandledRejectionHandler(err) {\n if (!(err instanceof Error)) {\n const newError = new Error(String(err));\n // err maybe an object, try to copy the name, message and stack to the new error instance\n if (err) {\n if (err.name) newError.name = err.name;\n if (err.message) newError.message = err.message;\n if (err.stack) newError.stack = err.stack;\n }\n err = newError;\n }\n if (err.name === 'Error') {\n err.name = 'unhandledRejectionError';\n }\n this.logger.error(err);\n }\n\n static getApplicationContext(): IMidwayContainer {\n return this.applicationContext;\n }\n}\n"]}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAIqB;AAHnB,oHAAA,uBAAuB,OAAA;AACvB,sGAAA,SAAS,OAAA;AACT,6GAAA,gBAAgB,OAAA","sourcesContent":["export {\n isTypeScriptEnvironment,\n Bootstrap,\n BootstrapStarter,\n} from './bootstrap';\n"]}
|