Comparing version 4.7.1 to 4.8.0
4.8.0 / 2018-05-22 | ||
================== | ||
**features** | ||
* [[`bb24396`](http://github.com/eggjs/egg-core/commit/bb243964c98a633c6ccdfb5b0dc1f55a4d1ea301)] - feat: pick commit from 3.x (#166) (Haoliang Gao <<sakura9515@gmail.com>>) | ||
**others** | ||
* [[`72d33ae`](http://github.com/eggjs/egg-core/commit/72d33ae10cf8ff9e8e640bf3aba028da5ca7b90a)] - test: add testcase for loadExtend with function call (#167) (Haoliang Gao <<sakura9515@gmail.com>>) | ||
4.7.1 / 2018-04-25 | ||
@@ -3,0 +12,0 @@ ================== |
@@ -13,4 +13,4 @@ 'use strict'; | ||
const Router = require('./utils/router'); | ||
const Timing = require('./utils/timing'); | ||
const DEPRECATE = Symbol('EggCore#deprecate'); | ||
@@ -23,4 +23,4 @@ const CLOSESET = Symbol('EggCore#closeSet'); | ||
const INIT_READY = Symbol('EggCore#initReady'); | ||
const EGG_READY_TIMEOUT_ENV = Symbol('EggCore#eggReadyTimeoutEnv'); | ||
class EggCore extends KoaApplication { | ||
@@ -48,2 +48,4 @@ | ||
this.timing = new Timing(); | ||
// register a close set | ||
@@ -54,7 +56,6 @@ this[CLOSESET] = new Set(); | ||
// get app timeout from env or use default timeout 10 second | ||
const eggReadyTimeoutEnv = process.env.EGG_READY_TIMEOUT_ENV; | ||
this[EGG_READY_TIMEOUT_ENV] = Number.parseInt(eggReadyTimeoutEnv || 10000); | ||
this[INIT_READY](); | ||
assert(Number.isInteger(this[EGG_READY_TIMEOUT_ENV]), `process.env.EGG_READY_TIMEOUT_ENV ${eggReadyTimeoutEnv} should be able to parseInt.`); | ||
this.timing.start('Application Start'); | ||
this.ready(() => this.timing.end('Application Start')); | ||
@@ -131,4 +132,2 @@ /** | ||
}); | ||
this[INIT_READY](); | ||
} | ||
@@ -224,2 +223,6 @@ | ||
const name = utils.getCalleeFromStack(true); | ||
const timingkey = 'Before Start in ' + utils.getResolvedFilename(name, this.options.baseDir); | ||
this.timing.start(timingkey); | ||
const done = this.readyCallback(name); | ||
@@ -229,3 +232,9 @@ | ||
process.nextTick(() => { | ||
utils.callFn(scope).then(() => done(), done); | ||
utils.callFn(scope).then(() => { | ||
done(); | ||
this.timing.end(timingkey); | ||
}, err => { | ||
done(err); | ||
this.timing.end(timingkey); | ||
}); | ||
}); | ||
@@ -235,3 +244,3 @@ } | ||
/** | ||
* Close all, it will close | ||
* Close all, it wisll close | ||
* - callbacks registered by beforeClose | ||
@@ -292,2 +301,6 @@ * - emit `close` event | ||
// get app timeout from env or use default timeout 10 second | ||
const eggReadyTimeoutEnv = Number.parseInt(process.env.EGG_READY_TIMEOUT_ENV || 10000); | ||
assert(Number.isInteger(eggReadyTimeoutEnv), `process.env.EGG_READY_TIMEOUT_ENV ${process.env.EGG_READY_TIMEOUT_ENV} should be able to parseInt.`); | ||
/** | ||
@@ -306,3 +319,3 @@ * If a client starts asynchronously, you can register `readyCallback`, | ||
*/ | ||
require('ready-callback')({ timeout: this[EGG_READY_TIMEOUT_ENV] }).mixin(this); | ||
require('ready-callback')({ timeout: eggReadyTimeoutEnv }).mixin(this); | ||
@@ -312,6 +325,4 @@ this.on('ready_stat', data => { | ||
}).on('ready_timeout', id => { | ||
this.console.warn('[egg:core:ready_timeout] %s seconds later %s was still unable to finish.', this[EGG_READY_TIMEOUT_ENV] / 1000, id); | ||
this.console.warn('[egg:core:ready_timeout] %s seconds later %s was still unable to finish.', eggReadyTimeoutEnv / 1000, id); | ||
}); | ||
this.ready(() => debug('egg emit ready, application started')); | ||
} | ||
@@ -318,0 +329,0 @@ |
@@ -13,4 +13,7 @@ 'use strict'; | ||
const utils = require('../utils'); | ||
const Timing = require('../utils/timing'); | ||
const REQUIRE_COUNT = Symbol('EggLoader#requireCount'); | ||
class EggLoader { | ||
@@ -34,2 +37,4 @@ | ||
this.app = this.options.app; | ||
this.timing = this.app.timing || new Timing(); | ||
this[REQUIRE_COUNT] = 0; | ||
@@ -291,9 +296,24 @@ /** | ||
const ret = utils.loadFile(filepath); | ||
// function(arg1, args, ...) {} | ||
if (inject.length === 0) inject = [ this.app ]; | ||
return isFunction(ret) ? ret(...inject) : ret; | ||
let ret = this.requireFile(filepath); | ||
ret = isFunction(ret) ? ret(...inject) : ret; | ||
return ret; | ||
} | ||
/** | ||
* @param {String} filepath - fullpath | ||
* @return {Object} exports | ||
* @private | ||
*/ | ||
requireFile(filepath) { | ||
const timingKey = `Require(${this[REQUIRE_COUNT]++}) ${utils.getResolvedFilename(filepath, this.options.baseDir)}`; | ||
this.timing.start(timingKey); | ||
const ret = utils.loadFile(filepath); | ||
this.timing.end(timingKey); | ||
return ret; | ||
} | ||
/** | ||
* Get all loadUnit | ||
@@ -361,3 +381,7 @@ * | ||
}, opt); | ||
const timingKey = `Load "${String(property)}" to Application`; | ||
this.timing.start(timingKey); | ||
new FileLoader(opt).load(); | ||
this.timing.end(timingKey); | ||
} | ||
@@ -378,3 +402,7 @@ | ||
}, opt); | ||
const timingKey = `Load "${String(property)}" to Context`; | ||
this.timing.start(timingKey); | ||
new ContextLoader(opt).load(); | ||
this.timing.end(timingKey); | ||
} | ||
@@ -381,0 +409,0 @@ |
@@ -8,2 +8,3 @@ 'use strict'; | ||
const SET_CONFIG_META = Symbol('Loader#setConfigMeta'); | ||
@@ -22,2 +23,3 @@ | ||
loadConfig() { | ||
this.timing.start('Load Config'); | ||
this.configMeta = {}; | ||
@@ -55,2 +57,3 @@ | ||
this.config = target; | ||
this.timing.end('Load Config'); | ||
}, | ||
@@ -57,0 +60,0 @@ |
@@ -9,2 +9,3 @@ 'use strict'; | ||
module.exports = { | ||
@@ -18,2 +19,3 @@ | ||
loadController(opt) { | ||
this.timing.start('Load Controller'); | ||
opt = Object.assign({ | ||
@@ -51,2 +53,3 @@ caseStyle: 'lower', | ||
this.options.logger.info('[egg:loader] Controller loaded: %s', controllerBase); | ||
this.timing.end('Load Controller'); | ||
}, | ||
@@ -53,0 +56,0 @@ |
@@ -5,2 +5,3 @@ 'use strict'; | ||
module.exports = { | ||
@@ -25,4 +26,6 @@ | ||
loadCustomApp() { | ||
this.timing.start('Load app.js'); | ||
this.getLoadUnits() | ||
.forEach(unit => this.loadFile(this.resolveModule(path.join(unit.path, 'app')))); | ||
this.timing.end('Load app.js'); | ||
}, | ||
@@ -34,6 +37,8 @@ | ||
loadCustomAgent() { | ||
this.timing.start('Load agent.js'); | ||
this.getLoadUnits() | ||
.forEach(unit => this.loadFile(this.resolveModule(path.join(unit.path, 'agent')))); | ||
this.timing.end('Load agent.js'); | ||
}, | ||
}; |
@@ -92,2 +92,3 @@ 'use strict'; | ||
loadExtend(name, proto) { | ||
this.timing.start(`Load extend/${name}.js`); | ||
// All extend files | ||
@@ -113,3 +114,3 @@ const filepaths = this.getExtendFilePaths(name); | ||
const ext = this.loadFile(filepath); | ||
const ext = this.requireFile(filepath); | ||
@@ -150,3 +151,4 @@ const properties = Object.getOwnPropertyNames(ext) | ||
} | ||
this.timing.end(`Load extend/${name}.js`); | ||
}, | ||
}; |
@@ -11,2 +11,3 @@ 'use strict'; | ||
module.exports = { | ||
@@ -34,2 +35,3 @@ | ||
loadMiddleware(opt) { | ||
this.timing.start('Load Middleware'); | ||
const app = this.app; | ||
@@ -90,2 +92,3 @@ | ||
this.options.logger.info('[egg:loader] Loaded middleware from %j', middlewarePaths); | ||
this.timing.end('Load Middleware'); | ||
}, | ||
@@ -92,0 +95,0 @@ |
@@ -9,2 +9,3 @@ 'use strict'; | ||
module.exports = { | ||
@@ -59,2 +60,4 @@ | ||
loadPlugin() { | ||
this.timing.start('Load Plugin'); | ||
// loader plugins from application | ||
@@ -140,2 +143,4 @@ const appPlugins = this.readPluginConfigs(path.join(this.options.baseDir, 'config/plugin.default')); | ||
this.plugins = enablePlugins; | ||
this.timing.end('Load Plugin'); | ||
}, | ||
@@ -142,0 +147,0 @@ |
@@ -5,2 +5,3 @@ 'use strict'; | ||
module.exports = { | ||
@@ -15,5 +16,7 @@ | ||
loadRouter() { | ||
this.timing.start('Load Router'); | ||
// 加载 router.js | ||
this.loadFile(this.resolveModule(path.join(this.options.baseDir, 'app/router'))); | ||
this.timing.end('Load Router'); | ||
}, | ||
}; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
module.exports = { | ||
@@ -15,2 +16,3 @@ | ||
loadService(opt) { | ||
this.timing.start('Load Service'); | ||
// 载入到 app.serviceClasses | ||
@@ -25,4 +27,5 @@ opt = Object.assign({ | ||
this.loadToContext(servicePaths, 'service', opt); | ||
this.timing.end('Load Service'); | ||
}, | ||
}; |
@@ -76,2 +76,7 @@ 'use strict'; | ||
}, | ||
getResolvedFilename(filepath, baseDir) { | ||
const reg = /\\|\//g; | ||
return filepath.replace(baseDir + path.sep, '').replace(reg, '/'); | ||
}, | ||
}; | ||
@@ -78,0 +83,0 @@ |
{ | ||
"name": "egg-core", | ||
"version": "4.7.1", | ||
"version": "4.8.0", | ||
"description": "A core Pluggable framework based on koa", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"ci": { | ||
"version": "8, 9" | ||
"version": "8, 10" | ||
}, | ||
@@ -39,5 +39,6 @@ "devDependencies": { | ||
"coffee": "^4.1.0", | ||
"egg-bin": "^4.3.7", | ||
"egg-bin": "^4.7.0", | ||
"egg-ci": "^1.8.0", | ||
"eslint": "^4.18.2", | ||
"egg-utils": "^2.4.0", | ||
"eslint": "^4.19.1", | ||
"eslint-config-egg": "^7.0.0", | ||
@@ -56,3 +57,3 @@ "js-yaml": "^3.11.0", | ||
"depd": "^1.1.2", | ||
"egg-logger": "^1.6.1", | ||
"egg-logger": "^1.6.2", | ||
"egg-path-matching": "^1.0.1", | ||
@@ -59,0 +60,0 @@ "extend2": "^1.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101832
22
2443
14
20
Updatedegg-logger@^1.6.2