commit
2675771ec1
3
index.js
3
index.js
|
@ -200,7 +200,8 @@ exports.PluginBase = PluginBase;
|
|||
|
||||
exports.execute = function(app, instructions, done) {
|
||||
var bootstrapper = new Bootstrapper(
|
||||
{phases: ['starting', 'start', 'started']});
|
||||
{phases: ['starting', 'start', 'started']}
|
||||
);
|
||||
var context = {
|
||||
app: app,
|
||||
instructions: instructions,
|
||||
|
|
|
@ -104,7 +104,8 @@ function bundleInstructions(context, bundler) {
|
|||
if (hasMiddleware) {
|
||||
g.warn(
|
||||
'Discarding {{middleware}} instructions,' +
|
||||
' {{loopback}} client does not support {{middleware}}.');
|
||||
' {{loopback}} client does not support {{middleware}}.'
|
||||
);
|
||||
}
|
||||
delete instructions.middleware;
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ function assertLoopBackVersion(app) {
|
|||
'The `app` is powered by an incompatible loopback version %s. ' +
|
||||
'Supported versions: %s',
|
||||
loopback.version || '(unknown)',
|
||||
RANGE);
|
||||
RANGE
|
||||
);
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,8 +102,7 @@ Middleware.prototype.buildInstructions = function(context, rootDir, config) {
|
|||
if (!resolved.sourceFile) {
|
||||
return g.log('Middleware "%s" not found: %s',
|
||||
middleware,
|
||||
resolved.optional
|
||||
);
|
||||
resolved.optional);
|
||||
}
|
||||
|
||||
var middlewareConfig = cloneDeep(config);
|
||||
|
@ -111,7 +110,8 @@ Middleware.prototype.buildInstructions = function(context, rootDir, config) {
|
|||
|
||||
if (middlewareConfig.params) {
|
||||
middlewareConfig.params = resolveMiddlewareParams(
|
||||
rootDir, middlewareConfig.params);
|
||||
rootDir, middlewareConfig.params
|
||||
);
|
||||
}
|
||||
|
||||
var item = {
|
||||
|
|
|
@ -37,7 +37,8 @@ Mixin.prototype.buildInstructions = function(context, rootDir, config) {
|
|||
var scriptExtensions = this.options.scriptExtensions || require.extensions;
|
||||
|
||||
var mixinInstructions = buildAllMixinInstructions(
|
||||
rootDir, this.options, mixinSources, scriptExtensions, modelInstructions);
|
||||
rootDir, this.options, mixinSources, scriptExtensions, modelInstructions
|
||||
);
|
||||
|
||||
return mixinInstructions;
|
||||
};
|
||||
|
@ -72,12 +73,14 @@ function buildAllMixinInstructions(appRootDir, options, mixinSources,
|
|||
|
||||
// Filter-in only mixins, that are used in models
|
||||
instructionsFromMixinSources = filterMixinInstructionsUsingWhitelist(
|
||||
instructionsFromMixinSources, modelMixins);
|
||||
instructionsFromMixinSources, modelMixins
|
||||
);
|
||||
|
||||
var mixins = _.assign(
|
||||
instructionsFromMixins,
|
||||
instructionsFromMixinDirs,
|
||||
instructionsFromMixinSources);
|
||||
instructionsFromMixinSources
|
||||
);
|
||||
|
||||
return _.values(mixins);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ Model.prototype.buildInstructions = function(context, rootDir, modelsConfig) {
|
|||
['./models'];
|
||||
var modelInstructions = buildAllModelInstructions(
|
||||
rootDir, modelsConfig, modelSources, this.options.modelDefinitions,
|
||||
this.options.scriptExtensions);
|
||||
this.options.scriptExtensions
|
||||
);
|
||||
return modelInstructions;
|
||||
};
|
||||
|
||||
|
@ -152,7 +153,8 @@ function verifyModelDefinitions(rootDir, modelDefinitions, scriptExtensions) {
|
|||
definition.sourceFile = fixFileExtension(
|
||||
fullPath,
|
||||
tryReadDir(path.dirname(fullPath)),
|
||||
scriptExtensions);
|
||||
scriptExtensions
|
||||
);
|
||||
|
||||
if (!definition.sourceFile) {
|
||||
debug('Model source code not found: %s - %s', definition.sourceFile);
|
||||
|
@ -246,7 +248,8 @@ function assertIsValidModelConfig(config) {
|
|||
if (unsupported) {
|
||||
throw new Error(g.f(
|
||||
'The data in {{model-config.json}} ' +
|
||||
'is in the unsupported {{1.x}} format.'));
|
||||
'is in the unsupported {{1.x}} format.'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +257,8 @@ function assertIsValidModelConfig(config) {
|
|||
// Regular expression to match built-in loopback models
|
||||
var LOOPBACK_MODEL_REGEXP = new RegExp(
|
||||
['', 'node_modules', 'loopback', '[^\\/\\\\]+', 'models', '[^\\/\\\\]+\\.js$']
|
||||
.join('\\' + path.sep));
|
||||
.join('\\' + path.sep)
|
||||
);
|
||||
|
||||
function isBuiltinLoopBackModel(app, data) {
|
||||
// 1. Built-in models are exposed on the loopback object
|
||||
|
|
10
package.json
10
package.json
|
@ -34,8 +34,8 @@
|
|||
"debug": "^2.2.0",
|
||||
"lodash": "^4.13.1",
|
||||
"semver": "^5.1.0",
|
||||
"strong-globalize": "^3.1.0",
|
||||
"toposort": "^1.0.0"
|
||||
"strong-globalize": "^4.1.1",
|
||||
"toposort": "^2.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^4.2.3",
|
||||
|
@ -43,11 +43,11 @@
|
|||
"coffeescript": "^2.3.1",
|
||||
"coffeeify": "^2.0.1",
|
||||
"dirty-chai": "^1.2.2",
|
||||
"eslint": "^3.19.0",
|
||||
"eslint-config-loopback": "^8.0.0",
|
||||
"eslint": "^5.2.0",
|
||||
"eslint-config-loopback": "^11.0.0",
|
||||
"fs-extra": "^3.0.1",
|
||||
"loopback": "^3.0.0",
|
||||
"mocha": "^3.3.0",
|
||||
"mocha": "^5.2.0",
|
||||
"supertest": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -407,8 +407,7 @@ describe('executor', function() {
|
|||
boot.execute(app, context.instructions, done);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('for mixins', function() {
|
||||
var options;
|
||||
|
@ -598,8 +597,7 @@ describe('executor', function() {
|
|||
|
||||
it('should parse a simple config variable', function(done) {
|
||||
boot.execute(app, simpleMiddlewareConfig('routes',
|
||||
{path: '${restApiRoot}'}
|
||||
), function(err) {
|
||||
{path: '${restApiRoot}'}), function(err) {
|
||||
if (err) return done(err);
|
||||
|
||||
supertest(app).get('/').end(function(err, res) {
|
||||
|
@ -613,8 +611,7 @@ describe('executor', function() {
|
|||
it('should parse simple config variable from env var', function(done) {
|
||||
process.env.restApiRoot = '/url-from-env-var';
|
||||
boot.execute(app, simpleMiddlewareConfig('routes',
|
||||
{path: '${restApiRoot}'}
|
||||
), function(err) {
|
||||
{path: '${restApiRoot}'}), function(err) {
|
||||
if (err) return done(err);
|
||||
|
||||
supertest(app).get('/url-from-env-var').end(function(err, res) {
|
||||
|
@ -646,8 +643,7 @@ describe('executor', function() {
|
|||
|
||||
it('should parse multiple config variables', function(done) {
|
||||
boot.execute(app, simpleMiddlewareConfig('routes',
|
||||
{path: '${restApiRoot}', env: '${env}'}
|
||||
), function(err) {
|
||||
{path: '${restApiRoot}', env: '${env}'}), function(err) {
|
||||
if (err) return done(err);
|
||||
|
||||
supertest(app).get('/').end(function(err, res) {
|
||||
|
@ -661,8 +657,7 @@ describe('executor', function() {
|
|||
|
||||
it('should parse config variables in an array', function(done) {
|
||||
boot.execute(app, simpleMiddlewareConfig('routes',
|
||||
{paths: ['${restApiRoot}']}
|
||||
), function(err) {
|
||||
{paths: ['${restApiRoot}']}), function(err) {
|
||||
if (err) return done(err);
|
||||
|
||||
supertest(app).get('/').end(function(err, res) {
|
||||
|
@ -677,8 +672,7 @@ describe('executor', function() {
|
|||
|
||||
it('should parse config variables in an object', function(done) {
|
||||
boot.execute(app, simpleMiddlewareConfig('routes',
|
||||
{info: {path: '${restApiRoot}'}}
|
||||
), function(err) {
|
||||
{info: {path: '${restApiRoot}'}}), function(err) {
|
||||
if (err) return done(err);
|
||||
|
||||
supertest(app).get('/').end(function(err, res) {
|
||||
|
@ -693,8 +687,7 @@ describe('executor', function() {
|
|||
|
||||
it('should parse config variables in a nested object', function(done) {
|
||||
boot.execute(app, simpleMiddlewareConfig('routes',
|
||||
{nested: {info: {path: '${restApiRoot}'}}}
|
||||
), function(err) {
|
||||
{nested: {info: {path: '${restApiRoot}'}}}), function(err) {
|
||||
if (err) return done(err);
|
||||
|
||||
supertest(app).get('/').end(function(err, res) {
|
||||
|
@ -709,8 +702,7 @@ describe('executor', function() {
|
|||
|
||||
it('should parse config variables with null values', function(done) {
|
||||
boot.execute(app, simpleMiddlewareConfig('routes',
|
||||
{nested: {info: {path: '${restApiRoot}', some: null}}}
|
||||
), function(err) {
|
||||
{nested: {info: {path: '${restApiRoot}', some: null}}}), function(err) {
|
||||
if (err) return done(err);
|
||||
|
||||
supertest(app).get('/').end(function(err, res) {
|
||||
|
@ -769,7 +761,8 @@ describe('executor', function() {
|
|||
'routes',
|
||||
// IMPORTANT we need more than one item to trigger the original issue
|
||||
[/^\/foobar/, /^\/another/],
|
||||
{});
|
||||
{}
|
||||
);
|
||||
boot.execute(app, config, function(err) {
|
||||
if (err) return done(err);
|
||||
|
||||
|
@ -1036,7 +1029,8 @@ describe('executor', function() {
|
|||
if (err) return done(err);
|
||||
|
||||
expect(Object.keys(require.cache)).to.include(
|
||||
appdir.resolve('components/test-component/index.js'));
|
||||
appdir.resolve('components/test-component/index.js')
|
||||
);
|
||||
|
||||
expect(app.componentOptions).to.eql({option: 'value'});
|
||||
done();
|
||||
|
@ -1056,7 +1050,8 @@ describe('executor', function() {
|
|||
if (err) return done(err);
|
||||
|
||||
expect(Object.keys(require.cache)).to.not.include(
|
||||
appdir.resolve('components/test-component/index.js'));
|
||||
appdir.resolve('components/test-component/index.js')
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -1078,7 +1073,8 @@ describe('executor', function() {
|
|||
if (err) return done(err);
|
||||
|
||||
expect(Object.keys(require.cache)).to.not.include(
|
||||
appdir.resolve('components/test-component/index.js'));
|
||||
appdir.resolve('components/test-component/index.js')
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -1219,7 +1215,8 @@ describe('executor', function() {
|
|||
boot.execute(app, someInstructions(bootInstructions), function() {
|
||||
expect(app.get('DYNAMIC_HOST')).to.equal('127.0.0.4');
|
||||
expect(app.datasources.mydb.settings.host).to.equal(
|
||||
'127.0.0.4');
|
||||
'127.0.0.4'
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue