Merge pull request #12 from strongloop/feature/drop-peer-dep-on-loopback
Drop peer dep on loopback; add a runtime check
This commit is contained in:
commit
a0d5dafd99
|
@ -1,6 +1,7 @@
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var loopback = require('loopback');
|
var loopback = require('loopback');
|
||||||
|
var semver = require('semver');
|
||||||
var debug = require('debug')('loopback:boot:executor');
|
var debug = require('debug')('loopback:boot:executor');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +14,8 @@ var debug = require('debug')('loopback:boot:executor');
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = function execute(app, instructions) {
|
module.exports = function execute(app, instructions) {
|
||||||
|
assertLoopBackVersion(app);
|
||||||
|
|
||||||
setHost(app, instructions);
|
setHost(app, instructions);
|
||||||
setPort(app, instructions);
|
setPort(app, instructions);
|
||||||
setApiRoot(app, instructions);
|
setApiRoot(app, instructions);
|
||||||
|
@ -27,6 +30,22 @@ module.exports = function execute(app, instructions) {
|
||||||
enableAnonymousSwagger(app, instructions);
|
enableAnonymousSwagger(app, instructions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function assertLoopBackVersion(app) {
|
||||||
|
var RANGE = '1.x || 2.x';
|
||||||
|
|
||||||
|
// app.loopback was introduced in 1.9.0
|
||||||
|
var loopback = app.loopback || {};
|
||||||
|
var version = loopback.version || '1.0.0';
|
||||||
|
|
||||||
|
if (!semver.satisfies(version, RANGE)) {
|
||||||
|
throw new Error(
|
||||||
|
'The `app` is powered by an incompatible loopback version %s. ' +
|
||||||
|
'Supported versions: %s',
|
||||||
|
loopback.version || '<1.9',
|
||||||
|
RANGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setHost(app, instructions) {
|
function setHost(app, instructions) {
|
||||||
//jshint camelcase:false
|
//jshint camelcase:false
|
||||||
var host =
|
var host =
|
||||||
|
|
10
package.json
10
package.json
|
@ -10,7 +10,7 @@
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/loobpack/loopback-boot"
|
"url": "https://github.com/strongloop/loopback-boot"
|
||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"browser": "browser.js",
|
"browser": "browser.js",
|
||||||
|
@ -23,9 +23,10 @@
|
||||||
"url": "https://github.com/strongloop/loopback-boot/blob/master/LICENSE"
|
"url": "https://github.com/strongloop/loopback-boot/blob/master/LICENSE"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"underscore": "^1.6.0",
|
"commondir": "0.0.1",
|
||||||
"debug": "^0.8.1",
|
"debug": "^0.8.1",
|
||||||
"commondir": "0.0.1"
|
"semver": "^2.3.0",
|
||||||
|
"underscore": "^1.6.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"loopback": "^1.5.0",
|
"loopback": "^1.5.0",
|
||||||
|
@ -34,8 +35,5 @@
|
||||||
"supertest": "^0.13.0",
|
"supertest": "^0.13.0",
|
||||||
"fs-extra": "^0.9.1",
|
"fs-extra": "^0.9.1",
|
||||||
"browserify": "^4.1.8"
|
"browserify": "^4.1.8"
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"loopback": "1.x || 2.x"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue