Upgrade deps and fix style issues

This commit is contained in:
Raymond Feng 2017-05-08 14:48:48 -07:00
parent 480380224d
commit 3bb519d5e9
46 changed files with 265 additions and 170 deletions

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var Bootstrapper = require('./lib/bootstrapper');
/**

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
// Strong globalize
var g = require('./lib/globalize');
@ -144,6 +146,10 @@ var addInstructionsToBrowserify = require('./lib/bundler');
*/
exports = module.exports = function bootLoopBackApp(app, options, callback) {
if (typeof options === 'string') {
// The 2nd arg is appRootDir
options = {appRootDir: options};
}
if (typeof options === 'function' && callback === undefined) {
callback = options;
options = {};
@ -182,7 +188,7 @@ exports.compile = function(options, done) {
exports.compileToBrowserify = function(options, bundler, done) {
return exports.compile(options, function(err, context) {
if (err) return done(err);
addInstructionsToBrowserify({ instructions: context.instructions },
addInstructionsToBrowserify({instructions: context.instructions},
bundler);
done();
});
@ -194,7 +200,7 @@ 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,

4
lib/bootstrapper.js vendored
View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var _ = require('lodash');
var assert = require('assert');
var async = require('async');
@ -57,7 +59,7 @@ function Bootstrapper(options) {
options = options || {};
if (typeof options === 'string') {
options = { appRootDir: options };
options = {appRootDir: options};
}
// For setting properties without modifying the original object

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var fs = require('fs');
var path = require('path');
var commondir = require('commondir');
@ -29,7 +31,7 @@ function addPlugins(bundler) {
var files = fs.readdirSync(dir);
files.forEach(function(f) {
bundler.require(path.join(dir, f),
{ expose: './plugins/' + path.basename(f, '.js') });
{expose: './plugins/' + path.basename(f, '.js')});
});
}
@ -86,7 +88,7 @@ function addScriptsToBundle(name, list, bundler) {
var fileid = 'loopback-boot#' + name + '#' + path.relative(root, filepath);
// Add the file to the bundle.
bundler.require(filepath, { expose: fileid });
bundler.require(filepath, {expose: fileid});
// Rewrite the context entry with the new id that will be
// used to load the file via `require(fileid)`.
@ -130,5 +132,5 @@ function bundleInstructions(context, bundler) {
fs.writeFileSync(instructionsFile, instructionsString, 'utf-8');
var moduleName = 'loopback-boot#' + instructionId;
bundler.require(instructionsFile, { expose: moduleName });
bundler.require(instructionsFile, {expose: moduleName});
}

View File

@ -7,5 +7,5 @@
var path = require('path');
var SG = require('strong-globalize');
SG.SetRootDir(path.join(__dirname, '..'), { autonomousMsgLoading: 'all' });
SG.SetRootDir(path.join(__dirname, '..'), {autonomousMsgLoading: 'all'});
module.exports = SG();

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var fs = require('fs');
var path = require('path');
var debug = require('debug')('loopback:boot:plugin');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var util = require('util');
var utils = require('./utils');
var path = require('path');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var util = require('util');
var assert = require('assert');
var semver = require('semver');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var util = require('util');
var utils = require('../utils');
var path = require('path');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var util = require('util');
var debug = require('debug')('loopback:boot:component');
var PluginBase = require('../plugin-base');
@ -31,7 +33,7 @@ Component.prototype.buildInstructions = function(context, rootDir, config) {
return !!config[name];
}).map(function(name) {
return {
sourceFile: resolveAppScriptPath(rootDir, name, { strict: true }),
sourceFile: resolveAppScriptPath(rootDir, name, {strict: true}),
config: config[name],
};
});
@ -44,7 +46,7 @@ Component.prototype.start = function(context) {
debug('Configuring component %j', data.sourceFile);
var configFn = require(data.sourceFile);
data.config = self.getUpdatedConfigObject(context, data.config,
{ useEnvVars: true });
{useEnvVars: true});
configFn(app, data.config);
});
};

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var util = require('util');
var utils = require('../utils');
var PluginBase = require('../plugin-base');
@ -27,7 +29,7 @@ DataSource.prototype.start = function(context) {
var self = this;
var lazyConnect = process.env.LB_LAZYCONNECT_DATASOURCES;
utils.forEachKeyedObject(context.instructions[this.name], function(key, obj) {
obj = self.getUpdatedConfigObject(context, obj, { useEnvVars: true });
obj = self.getUpdatedConfigObject(context, obj, {useEnvVars: true});
debug('Registering data source %s %j', key, obj);
if (lazyConnect) {
obj.lazyConnect =

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var util = require('util');
var assert = require('assert');
var path = require('path');
@ -258,7 +260,7 @@ Middleware.prototype.start = function(context) {
assert(typeof factory === 'function',
'Middleware factory must be a function');
data.config = self.getUpdatedConfigObject(context, data.config,
{ useEnvVars: true });
{useEnvVars: true});
app.middlewareFromConfig(factory, data.config);
});
};

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var util = require('util');
var fs = require('fs');
var path = require('path');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var assert = require('assert');
var util = require('util');
var PluginBase = require('../plugin-base');
@ -181,7 +183,7 @@ function findModelDefinitions(rootDir, sources, scriptExtensions) {
var registry = {};
sources.forEach(function(src) {
var srcDir = tryResolveAppPath(rootDir, src, { strict: false });
var srcDir = tryResolveAppPath(rootDir, src, {strict: false});
if (!srcDir) {
debug('Skipping unknown module source dir %j', src);
return;

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var util = require('util');
var PluginBase = require('../plugin-base');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var debug = require('debug')('loopback:boot');
var path = require('path');
var Module = require('module');
@ -85,13 +87,13 @@ function tryReadDir() {
}
function resolveRelativePaths(relativePaths, appRootDir) {
var resolveOpts = { strict: false };
var resolveOpts = {strict: false};
relativePaths.forEach(function(relativePath, k) {
var resolvedPath = tryResolveAppPath(appRootDir, relativePath, resolveOpts);
if (resolvedPath !== undefined) {
relativePaths[k] = resolvedPath;
} else {
debug ('skipping boot script %s - unknown file', relativePath);
debug('skipping boot script %s - unknown file', relativePath);
}
});
}
@ -179,7 +181,7 @@ function tryResolveAppPath(rootDir, relativePath, resolveOptions) {
* - `resolveOptions.strict = false` attempts to resolve the value
* as a relative path first before searching `node_modules`
*/
resolveOptions = resolveOptions || { strict: true };
resolveOptions = resolveOptions || {strict: true};
var isModuleRelative = false;
if (relativePath[0] === '/') {
@ -202,7 +204,7 @@ function tryResolveAppPath(rootDir, relativePath, resolveOptions) {
return fullPath;
} catch (err) {
if (!isModuleRelative) {
debug ('Skipping %s - %s', fullPath, err);
debug('Skipping %s - %s', fullPath, err);
return undefined;
}
}
@ -223,7 +225,7 @@ function tryResolveAppPath(rootDir, relativePath, resolveOptions) {
try {
// NOTE(bajtos) We need to create a proper String object here,
// otherwise we can't attach additional properties to it
/*jshint -W053 */
/* jshint -W053 */
var filePath = new String(require.resolve(absPath));
filePath.unresolvedPath = absPath;
return filePath;
@ -243,7 +245,7 @@ function tryResolveAppPath(rootDir, relativePath, resolveOptions) {
return fullPath.toString();
}
debug ('Skipping %s - module not found', fullPath);
debug('Skipping %s - module not found', fullPath);
return undefined;
}

View File

@ -27,7 +27,7 @@
},
"license": "MIT",
"dependencies": {
"async": "^1.5.2",
"async": "^2.4.0",
"bluebird": "^3.4.0",
"commondir": "^1.0.1",
"debug": "^2.2.0",
@ -42,11 +42,11 @@
"coffee-script": "^1.10.0",
"coffeeify": "^2.0.1",
"dirty-chai": "^1.2.2",
"eslint": "^2.11.1",
"eslint-config-loopback": "^1.0.0",
"fs-extra": "^0.30.0",
"eslint": "^3.19.0",
"eslint-config-loopback": "^8.0.0",
"fs-extra": "^3.0.1",
"loopback": "^3.0.0",
"mocha": "^2.5.3",
"supertest": "^1.2.0"
"mocha": "^3.3.0",
"supertest": "^3.0.0"
}
}

View File

@ -1,3 +1,5 @@
'use strict';
var path = require('path');
var loopback = require('loopback');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var boot = require('../');
var async = require('async');
var exportBrowserifyToFile = require('./helpers/browserify').exportToSandbox;
@ -74,7 +76,7 @@ function browserifyTestApps(apps, next) {
var appId = apps[i].appId;
appFile = path.join(appDir, appFile);
b.require(appFile, { expose: moduleName });
b.require(appFile, {expose: moduleName});
var opts = appDir;
if (appId) {

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var boot = require('../');
var exportBrowserifyToFile = require('./helpers/browserify').exportToSandbox;
var fs = require('fs');
@ -20,7 +22,7 @@ var compileStrategies = {
basedir: appDir,
debug: true,
});
b.require('./app.js', { expose: 'browser-app' });
b.require('./app.js', {expose: 'browser-app'});
return b;
},
@ -32,7 +34,7 @@ var compileStrategies = {
});
b.transform('coffeeify');
b.require('./app.coffee', { expose: 'browser-app' });
b.require('./app.coffee', {expose: 'browser-app'});
return b;
},
};
@ -58,7 +60,7 @@ describe('browser support', function() {
// configured in fixtures/browser-app/component-config.json
// and fixtures/browser-app/components/dummy-component.js
expect(app.dummyComponentOptions).to.eql({ option: 'value' });
expect(app.dummyComponentOptions).to.eql({option: 'value'});
done();
});
});

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var boot = require('../');
var fs = require('fs-extra');
var path = require('path');
@ -54,7 +56,7 @@ describe('compiler', function() {
port: 3000,
host: '127.0.0.1',
restApiRoot: '/rest-api',
foo: { bar: 'bat' },
foo: {bar: 'bat'},
baz: true,
},
models: {
@ -114,7 +116,7 @@ describe('compiler', function() {
describe('with custom model definitions', function(done) {
var dataSources = {
'the-db': { connector: 'memory' },
'the-db': {connector: 'memory'},
};
it('loads model without definition', function(done) {
@ -367,12 +369,12 @@ describe('compiler', function() {
it('merges datasource configs from multiple files', function(done) {
appdir.createConfigFilesSync();
appdir.writeConfigFileSync('datasources.local.json', {
db: { local: 'applied' },
db: {local: 'applied'},
});
var env = process.env.NODE_ENV || 'development';
appdir.writeConfigFileSync('datasources.' + env + '.json', {
db: { env: 'applied' },
db: {env: 'applied'},
});
boot.compile(appdir.PATH, function(err, context) {
@ -409,10 +411,10 @@ describe('compiler', function() {
});
it('merges new Object values', function(done) {
var objectValue = { key: 'value' };
var objectValue = {key: 'value'};
appdir.createConfigFilesSync();
appdir.writeConfigFileSync('datasources.local.json', {
db: { nested: objectValue },
db: {nested: objectValue},
});
boot.compile(appdir.PATH, function(err, context) {
@ -495,7 +497,7 @@ describe('compiler', function() {
var arrayValue = ['value'];
appdir.createConfigFilesSync();
appdir.writeConfigFileSync('datasources.local.json', {
db: { nested: arrayValue },
db: {nested: arrayValue},
});
boot.compile(appdir.PATH, function(err, context) {
@ -512,10 +514,10 @@ describe('compiler', function() {
it('does not cache loaded values', function(done) {
appdir.createConfigFilesSync();
appdir.writeConfigFileSync('middleware.json', {
'strong-error-handler': { params: { debug: false }},
'strong-error-handler': {params: {debug: false}},
});
appdir.writeConfigFileSync('middleware.development.json', {
'strong-error-handler': { params: { debug: true }},
'strong-error-handler': {params: {debug: true}},
});
// Here we load main config and merge it with DEV overrides
@ -546,7 +548,7 @@ describe('compiler', function() {
it('allows env specific model-config json', function(done) {
appdir.createConfigFilesSync();
appdir.writeConfigFileSync('model-config.local.json', {
foo: { dataSource: 'db' },
foo: {dataSource: 'db'},
});
boot.compile(appdir.PATH, function(err, context) {
@ -561,9 +563,9 @@ describe('compiler', function() {
it('allows env specific model-config json to be merged', function(done) {
appdir.createConfigFilesSync(null, null,
{ foo: { dataSource: 'mongo', public: false }});
{foo: {dataSource: 'mongo', public: false}});
appdir.writeConfigFileSync('model-config.local.json', {
foo: { dataSource: 'db' },
foo: {dataSource: 'db'},
});
boot.compile(appdir.PATH, function(err, context) {
@ -675,11 +677,11 @@ describe('compiler', function() {
it('merges app configs from multiple files', function(done) {
appdir.createConfigFilesSync();
appdir.writeConfigFileSync('config.local.json', { cfgLocal: 'applied' });
appdir.writeConfigFileSync('config.local.json', {cfgLocal: 'applied'});
var env = process.env.NODE_ENV || 'development';
appdir.writeConfigFileSync('config.' + env + '.json',
{ cfgEnv: 'applied' });
{cfgEnv: 'applied'});
boot.compile(appdir.PATH, function(err, context) {
if (err) return done(err);
@ -715,7 +717,7 @@ describe('compiler', function() {
});
it('supports `appConfigRootDir` option', function(done) {
appdir.createConfigFilesSync({ port: 3000 });
appdir.createConfigFilesSync({port: 3000});
var customDir = path.resolve(appdir.PATH, 'custom');
fs.mkdirsSync(customDir);
@ -759,7 +761,7 @@ describe('compiler', function() {
it('supports `modelsRootDir` option', function(done) {
appdir.createConfigFilesSync();
appdir.writeConfigFileSync('custom/model-config.json', {
foo: { dataSource: 'db' },
foo: {dataSource: 'db'},
});
boot.compile({
@ -1018,7 +1020,7 @@ describe('compiler', function() {
it('throws when models-config.json contains 1.x `properties`',
function(done) {
appdir.createConfigFilesSync({}, {}, {
foo: { properties: { name: 'string' }},
foo: {properties: {name: 'string'}},
});
expectCompileToThrow(/unsupported 1\.x format/, done);
@ -1027,7 +1029,7 @@ describe('compiler', function() {
it('throws when model-config.json contains 1.x `options.base`',
function(done) {
appdir.createConfigFilesSync({}, {}, {
Customer: { options: { base: 'User' }},
Customer: {options: {base: 'User'}},
});
expectCompileToThrow(/unsupported 1\.x format/, done);
@ -1035,9 +1037,9 @@ describe('compiler', function() {
it('loads models from `./models`', function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', { name: 'Car' });
appdir.writeConfigFileSync('models/car.json', {name: 'Car'});
appdir.writeFileSync('models/car.js', '');
boot.compile(appdir.PATH, function(err, context) {
@ -1061,9 +1063,9 @@ describe('compiler', function() {
it('loads coffeescript models from `./models`', function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', { name: 'Car' });
appdir.writeConfigFileSync('models/car.json', {name: 'Car'});
appdir.writeFileSync('models/car.coffee', '');
boot.compile(appdir.PATH, function(err, context) {
@ -1087,9 +1089,9 @@ describe('compiler', function() {
it('supports `modelSources` option', function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('custom-models/car.json', { name: 'Car' });
appdir.writeConfigFileSync('custom-models/car.json', {name: 'Car'});
appdir.writeFileSync('custom-models/car.js', '');
boot.compile({
@ -1119,9 +1121,9 @@ describe('compiler', function() {
_meta: {
sources: ['./custom-models'],
},
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('custom-models/car.json', { name: 'Car' });
appdir.writeConfigFileSync('custom-models/car.json', {name: 'Car'});
appdir.writeFileSync('custom-models/car.js', '');
boot.compile(appdir.PATH, function(err, context) {
@ -1145,7 +1147,7 @@ describe('compiler', function() {
it('supports sources relative to node_modules', function(done) {
appdir.createConfigFilesSync({}, {}, {
User: { dataSource: 'db' },
User: {dataSource: 'db'},
});
boot.compile({
@ -1173,9 +1175,9 @@ describe('compiler', function() {
it('resolves relative path in `modelSources` option', function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('custom-models/car.json', { name: 'Car' });
appdir.writeConfigFileSync('custom-models/car.json', {name: 'Car'});
var appJS = appdir.writeFileSync('custom-models/car.js', '');
boot.compile({
@ -1194,10 +1196,10 @@ describe('compiler', function() {
it('resolves module relative path in `modelSources` option',
function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('node_modules/custom-models/car.json',
{ name: 'Car' });
{name: 'Car'});
var appJS = appdir.writeFileSync(
'node_modules/custom-models/car.js', '');
@ -1220,9 +1222,9 @@ describe('compiler', function() {
_meta: {
sources: ['./custom-models'],
},
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('custom-models/car.json', { name: 'Car' });
appdir.writeConfigFileSync('custom-models/car.json', {name: 'Car'});
var appJS = appdir.writeFileSync('custom-models/car.js', '');
boot.compile(appdir.PATH, function(err, context) {
@ -1241,10 +1243,10 @@ describe('compiler', function() {
_meta: {
sources: ['custom-models'],
},
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('node_modules/custom-models/car.json',
{ name: 'Car' });
{name: 'Car'});
var appJS = appdir.writeFileSync(
'node_modules/custom-models/car.js', '');
@ -1261,9 +1263,9 @@ describe('compiler', function() {
it('handles model definitions with no code', function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', { name: 'Car' });
appdir.writeConfigFileSync('models/car.json', {name: 'Car'});
boot.compile(appdir.PATH, function(err, context) {
if (err) return done(err);
@ -1285,10 +1287,10 @@ describe('compiler', function() {
it('excludes models not listed in `model-config.json`', function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', { name: 'Car' });
appdir.writeConfigFileSync('models/bar.json', { name: 'Bar' });
appdir.writeConfigFileSync('models/car.json', {name: 'Car'});
appdir.writeConfigFileSync('models/bar.json', {name: 'Bar'});
boot.compile(appdir.PATH, function(err, context) {
if (err) return done(err);
@ -1302,7 +1304,7 @@ describe('compiler', function() {
it('includes models used as Base models', function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', {
name: 'Car',
@ -1326,7 +1328,7 @@ describe('compiler', function() {
it('excludes pre-built base models', function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', {
name: 'Car',
@ -1345,9 +1347,9 @@ describe('compiler', function() {
it('sorts models, base models first', function(done) {
appdir.createConfigFilesSync({}, {}, {
Vehicle: { dataSource: 'db' },
FlyingCar: { dataSource: 'db' },
Car: { dataSource: 'db' },
Vehicle: {dataSource: 'db'},
FlyingCar: {dataSource: 'db'},
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', {
name: 'Car',
@ -1373,8 +1375,8 @@ describe('compiler', function() {
it('detects circular Model dependencies', function(done) {
appdir.createConfigFilesSync({}, {}, {
Vehicle: { dataSource: 'db' },
Car: { dataSource: 'db' },
Vehicle: {dataSource: 'db'},
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', {
name: 'Car',
@ -1390,7 +1392,7 @@ describe('compiler', function() {
it('uses file name as default value for model name', function(done) {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', {});
@ -1407,7 +1409,7 @@ describe('compiler', function() {
it('uses `OrderItem` as default model name for file with name `order-item`',
function(done) {
appdir.createConfigFilesSync({}, {}, {
OrderItem: { dataSource: 'db' },
OrderItem: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/order-item.json', {});
@ -1424,7 +1426,7 @@ describe('compiler', function() {
it('uses `OrderItem` as default model name for file with name `order_item`',
function(done) {
appdir.createConfigFilesSync({}, {}, {
OrderItem: { dataSource: 'db' },
OrderItem: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/order_item.json', {});
@ -1441,7 +1443,7 @@ describe('compiler', function() {
it('uses `OrderItem` as default model name for file with name `order item`',
function(done) {
appdir.createConfigFilesSync({}, {}, {
OrderItem: { dataSource: 'db' },
OrderItem: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/order item.json', {});
@ -1458,9 +1460,9 @@ describe('compiler', function() {
it('overrides `default model name` by `name` in model definition',
function(done) {
appdir.createConfigFilesSync({}, {}, {
overrideCar: { dataSource: 'db' },
overrideCar: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', { name: 'overrideCar' });
appdir.writeConfigFileSync('models/car.json', {name: 'overrideCar'});
boot.compile(appdir.PATH, function(err, context) {
if (err) return done(err);
@ -1474,19 +1476,19 @@ describe('compiler', function() {
it('overwrites model with same default name', function(done) {
appdir.createConfigFilesSync({}, {}, {
'OrderItem': { dataSource: 'db' },
'OrderItem': {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/order-item.json', {
properties: {
price: { type: 'number' },
price: {type: 'number'},
},
});
appdir.writeFileSync('models/order-item.js', '');
appdir.writeConfigFileSync('models/orderItem.json', {
properties: {
quantity: { type: 'number' },
quantity: {type: 'number'},
},
});
var appJS = appdir.writeFileSync('models/orderItem.js', '');
@ -1503,7 +1505,7 @@ describe('compiler', function() {
definition: {
name: 'OrderItem',
properties: {
quantity: { type: 'number' },
quantity: {type: 'number'},
},
},
sourceFile: appJS,
@ -1514,13 +1516,13 @@ describe('compiler', function() {
it('overwrites model with same name in model definition', function(done) {
appdir.createConfigFilesSync({}, {}, {
'customOrder': { dataSource: 'db' },
'customOrder': {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/order1.json', {
name: 'customOrder',
properties: {
price: { type: 'number' },
price: {type: 'number'},
},
});
appdir.writeFileSync('models/order1.js', '');
@ -1528,7 +1530,7 @@ describe('compiler', function() {
appdir.writeConfigFileSync('models/order2.json', {
name: 'customOrder',
properties: {
quantity: { type: 'number' },
quantity: {type: 'number'},
},
});
var appJS = appdir.writeFileSync('models/order2.js', '');
@ -1545,7 +1547,7 @@ describe('compiler', function() {
definition: {
name: 'customOrder',
properties: {
quantity: { type: 'number' },
quantity: {type: 'number'},
},
},
sourceFile: appJS,
@ -1608,11 +1610,11 @@ describe('compiler', function() {
describe(' - mixinSources', function() {
beforeEach(function() {
appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' },
Car: {dataSource: 'db'},
});
appdir.writeConfigFileSync('models/car.json', {
name: 'Car',
mixins: { 'TimeStamps': {}},
mixins: {'TimeStamps': {}},
});
});
@ -1700,7 +1702,7 @@ describe('compiler', function() {
appdir.writeConfigFileSync('models/car.json', {
name: 'Car',
mixins: { 'Timestamping': {}},
mixins: {'Timestamping': {}},
});
boot.compile(appdir.PATH, function(err, context) {
@ -1775,7 +1777,7 @@ describe('compiler', function() {
describe('name normalization', function() {
var options;
beforeEach(function() {
options = { appRootDir: appdir.PATH, mixinDirs: ['./custom-mixins'] };
options = {appRootDir: appdir.PATH, mixinDirs: ['./custom-mixins']};
appdir.writeFileSync('custom-mixins/foo.js', '');
appdir.writeFileSync('custom-mixins/time-stamps.js', '');
@ -1892,7 +1894,7 @@ describe('compiler', function() {
it('overrides default mixin name, by `name` in JSON', function(done) {
appdir.writeFileSync('mixins/foo.js', '');
appdir.writeConfigFileSync('mixins/foo.json', { name: 'fooBar' });
appdir.writeConfigFileSync('mixins/foo.json', {name: 'fooBar'});
var options = {
appRootDir: appdir.PATH,
@ -2087,7 +2089,7 @@ describe('compiler', function() {
phases: ['routes'],
middleware: [{
sourceFile: path.resolve(appdir.PATH, 'my-middleware.js'),
config: { phase: 'routes' },
config: {phase: 'routes'},
}],
});
done();
@ -2481,7 +2483,7 @@ describe('compiler', function() {
});
});
it('resolves modules relative to appRootDir', function() {
it('resolves modules relative to appRootDir', function(done) {
var HANDLER_FILE = 'node_modules/handler/index.js';
appdir.writeFileSync(
HANDLER_FILE,
@ -2644,7 +2646,7 @@ describe('compiler', function() {
});
it('converts paths in top-level array items', function(done) {
givenMiddlewareEntrySync({ params: RELATIVE_PATH_PARAMS });
givenMiddlewareEntrySync({params: RELATIVE_PATH_PARAMS});
boot.compile(appdir.PATH, function(err, context) {
if (err) return done(err);
@ -2668,13 +2670,13 @@ describe('compiler', function() {
var instructions = context.instructions;
expectFirstMiddlewareParams(instructions)
.to.eql({ path: absolutePathParams[0] });
.to.eql({path: absolutePathParams[0]});
done();
});
});
it('converts path value when params is a string', function(done) {
givenMiddlewareEntrySync({ params: RELATIVE_PATH_PARAMS[0] });
givenMiddlewareEntrySync({params: RELATIVE_PATH_PARAMS[0]});
boot.compile(appdir.PATH, function(err, context) {
if (err) return done(err);
@ -2714,7 +2716,7 @@ describe('compiler', function() {
it('does not convert values not starting with `./` or `../`',
function(done) {
var PARAMS = ['$!.somerc', '$!/root', '$!hello!'];
givenMiddlewareEntrySync({ params: PARAMS });
givenMiddlewareEntrySync({params: PARAMS});
boot.compile(appdir.PATH, function(err, context) {
if (err) return done(err);
@ -2731,15 +2733,15 @@ describe('compiler', function() {
it('loads component configs from multiple files', function(done) {
appdir.createConfigFilesSync();
appdir.writeConfigFileSync('component-config.json', {
debug: { option: 'value' },
debug: {option: 'value'},
});
appdir.writeConfigFileSync('component-config.local.json', {
debug: { local: 'applied' },
debug: {local: 'applied'},
});
var env = process.env.NODE_ENV || 'development';
appdir.writeConfigFileSync('component-config.' + env + '.json', {
debug: { env: 'applied' },
debug: {env: 'applied'},
});
boot.compile(appdir.PATH, function(err, context) {

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var async = require('async');
var boot = require('../');
var path = require('path');
@ -46,7 +48,7 @@ describe('executor', function() {
port: 0,
host: '127.0.0.1',
restApiRoot: '/rest-api',
foo: { bar: 'bat' },
foo: {bar: 'bat'},
baz: true,
},
models: [
@ -70,7 +72,7 @@ describe('executor', function() {
simpleAppInstructions(function(err, context) {
if (err) return done(err);
boot.execute(app, context.instructions, function(err) {
expect(err).to.not.exist;
expect(err).to.not.exist();
expect(process.bootingFlagSet).to.be.true();
expect(app.booting).to.be.false();
done();
@ -80,7 +82,7 @@ describe('executor', function() {
it('should emit the `booted` event in the next tick', function(done) {
boot.execute(app, dummyInstructions, function(err) {
expect(err).to.not.exist;
expect(err).to.not.exist();
});
app.on('booted', function() {
// This test fails with a timeout when the `booted` event has not been
@ -119,7 +121,7 @@ describe('executor', function() {
models: [
{
name: 'Customer',
config: { dataSource: 'db' },
config: {dataSource: 'db'},
definition: {
name: 'Customer',
base: 'User',
@ -130,7 +132,7 @@ describe('executor', function() {
}), function(err, context) {
if (err) return done(err);
expect(app.models.Customer).to.exist;
expect(app.models.Customer).to.exist();
expect(app.models.Customer.settings._customized).to.be.equal('Customer');
var UserModel = app.registry.getModel('User');
expect(UserModel.settings._customized).to.equal('Base');
@ -151,7 +153,7 @@ describe('executor', function() {
},
{
name: 'Car',
config: { dataSource: 'db' },
config: {dataSource: 'db'},
definition: {
name: 'Car',
base: 'Vehicle',
@ -177,7 +179,7 @@ describe('executor', function() {
it('defines all models first before running the config phase',
function(done) {
appdir.writeFileSync('models/Customer.js', 'module.exports = ' +
function(Customer/*, Base*/) {
function(Customer/* , Base */) {
Customer.on('attached', function() {
Customer._modelsWhenAttached =
Object.keys(Customer.modelBuilder.models);
@ -188,14 +190,14 @@ describe('executor', function() {
models: [
{
name: 'Customer',
config: { dataSource: 'db' },
definition: { name: 'Customer' },
config: {dataSource: 'db'},
definition: {name: 'Customer'},
sourceFile: path.resolve(appdir.PATH, 'models', 'Customer.js'),
},
{
name: 'UniqueName',
config: { dataSource: 'db' },
definition: { name: 'UniqueName' },
config: {dataSource: 'db'},
definition: {name: 'UniqueName'},
sourceFile: undefined,
},
],
@ -208,13 +210,13 @@ describe('executor', function() {
});
it('defines models in the local app registry', function(done) {
app = loopback({ localRegistry: true });
app = loopback({localRegistry: true});
boot.execute(app, someInstructions({
models: [
{
name: 'LocalCustomer',
config: { dataSource: 'db' },
definition: { name: 'LocalCustomer' },
config: {dataSource: 'db'},
definition: {name: 'LocalCustomer'},
sourceFile: undefined,
},
],
@ -233,7 +235,7 @@ describe('executor', function() {
var file = appdir.writeFileSync('boot/badScript.js',
'require("doesnt-exist"); module.exports = {};');
boot.execute(app, someInstructions({ bootScripts: [file] }),
boot.execute(app, someInstructions({bootScripts: [file]}),
function(err) {
expect(err && err.message)
.to.match(/Cannot find module \'doesnt-exist\'/);
@ -272,12 +274,12 @@ describe('executor', function() {
definition: fs.readJsonSync(
require.resolve('loopback/common/models/user.json')
),
config: { dataSource: 'db' },
config: {dataSource: 'db'},
sourceFile: require.resolve('loopback/common/models/user.js'),
};
builtinModel.definition.redefined = true;
boot.execute(app, someInstructions({ models: [builtinModel] }),
boot.execute(app, someInstructions({models: [builtinModel]}),
function(err, context) {
if (err) return done(err);
expect(app.models.User.settings.redefined,
@ -405,7 +407,7 @@ describe('executor', function() {
}
it('should apply env passed in option object', function(done) {
boot.execute(app, someInstructions({ env: 'custom_env' }), function(err) {
boot.execute(app, someInstructions({env: 'custom_env'}), function(err) {
if (err) return done(err);
expect(app.get('env')).to.equal('custom_env');
done();
@ -427,12 +429,12 @@ describe('executor', function() {
}
async.eachSeries([
{ port: 'OPENSHIFT_SLS_PORT', host: 'OPENSHIFT_NODEJS_IP' },
{ port: 'npm_config_port', host: 'npm_config_host' },
{ port: 'npm_package_config_port', host: 'npm_package_config_host' },
{ port: 'OPENSHIFT_SLS_PORT', host: 'OPENSHIFT_SLS_IP' },
{ port: 'VCAP_APP_PORT', host: 'VCAP_APP_HOST' },
{ port: 'PORT', host: 'HOST' },
{port: 'OPENSHIFT_SLS_PORT', host: 'OPENSHIFT_NODEJS_IP'},
{port: 'npm_config_port', host: 'npm_config_host'},
{port: 'npm_package_config_port', host: 'npm_package_config_host'},
{port: 'OPENSHIFT_SLS_PORT', host: 'OPENSHIFT_SLS_IP'},
{port: 'VCAP_APP_PORT', host: 'VCAP_APP_HOST'},
{port: 'PORT', host: 'HOST'},
], function(config, cb) {
assertHonored(config.port, config.host, cb);
}, done);
@ -440,7 +442,7 @@ describe('executor', function() {
it('should prioritize host sources', function(done) {
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
/*eslint-disable camelcase*/
/* eslint-disable camelcase */
process.env.npm_config_host = randomHost();
process.env.OPENSHIFT_SLS_IP = randomHost();
process.env.OPENSHIFT_NODEJS_IP = randomHost();
@ -451,13 +453,13 @@ describe('executor', function() {
bootWithDefaults(function(err) {
if (err) return done(err);
assert.equal(app.get('host'), process.env.npm_config_host);
/*eslint-enable camelcase*/
/* eslint-enable camelcase */
done();
});
});
it('should prioritize port sources', function(done) {
/*eslint-disable camelcase*/
/* eslint-disable camelcase */
process.env.npm_config_port = randomPort();
process.env.OPENSHIFT_SLS_PORT = randomPort();
process.env.OPENSHIFT_NODEJS_PORT = randomPort();
@ -468,7 +470,7 @@ describe('executor', function() {
bootWithDefaults(function(err) {
if (err) return done(err);
assert.equal(app.get('port'), process.env.npm_config_port);
/*eslint-enable camelcase*/
/* eslint-enable camelcase */
done();
});
});
@ -482,7 +484,7 @@ describe('executor', function() {
}
it('should honor 0 for free port', function(done) {
boot.execute(app, someInstructions({ application: { port: 0 }}),
boot.execute(app, someInstructions({application: {port: 0}}),
function(err) {
if (err) return done(err);
assert.equal(app.get('port'), 0);
@ -491,7 +493,7 @@ describe('executor', function() {
});
it('should default to port 3000', function(done) {
boot.execute(app, someInstructions({ application: { port: undefined }}),
boot.execute(app, someInstructions({application: {port: undefined}}),
function(err) {
if (err) return done(err);
assert.equal(app.get('port'), 3000);
@ -502,7 +504,7 @@ describe('executor', function() {
it('should respect named pipes port values in ENV', function(done) {
var NAMED_PORT = '\\.\\pipe\\test';
process.env.PORT = NAMED_PORT;
boot.execute(app, someInstructions({ application: { port: 3000 }}),
boot.execute(app, someInstructions({application: {port: 3000}}),
function(err) {
if (err) return done(err);
assert.equal(app.get('port'), NAMED_PORT);
@ -518,7 +520,7 @@ describe('executor', function() {
it('should parse a simple config variable', function(done) {
boot.execute(app, simpleMiddlewareConfig('routes',
{ path: '${restApiRoot}' }
{path: '${restApiRoot}'}
), function(err) {
if (err) return done(err);
@ -533,7 +535,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}' }
{path: '${restApiRoot}'}
), function(err) {
if (err) return done(err);
@ -550,8 +552,8 @@ describe('executor', function() {
process.env.restApiRoot = '/url-from-env-var';
var bootInstructions;
bootInstructions = simpleMiddlewareConfig('routes',
{ path: '${restApiRoot}' });
bootInstructions.application = { restApiRoot: '/url-from-config' };
{path: '${restApiRoot}'});
bootInstructions.application = {restApiRoot: '/url-from-config'};
boot.execute(app, someInstructions(bootInstructions), function(err) {
if (err) return done(err);
@ -566,7 +568,7 @@ describe('executor', function() {
it('should parse multiple config variables', function(done) {
boot.execute(app, simpleMiddlewareConfig('routes',
{ path: '${restApiRoot}', env: '${env}' }
{path: '${restApiRoot}', env: '${env}'}
), function(err) {
if (err) return done(err);
@ -581,7 +583,7 @@ describe('executor', function() {
it('should parse config variables in an array', function(done) {
boot.execute(app, simpleMiddlewareConfig('routes',
{ paths: ['${restApiRoot}'] }
{paths: ['${restApiRoot}']}
), function(err) {
if (err) return done(err);
@ -597,7 +599,7 @@ describe('executor', function() {
it('should parse config variables in an object', function(done) {
boot.execute(app, simpleMiddlewareConfig('routes',
{ info: { path: '${restApiRoot}' }}
{info: {path: '${restApiRoot}'}}
), function(err) {
if (err) return done(err);
@ -613,14 +615,14 @@ describe('executor', function() {
it('should parse config variables in a nested object', function(done) {
boot.execute(app, simpleMiddlewareConfig('routes',
{ nested: { info: { path: '${restApiRoot}' }}}
{nested: {info: {path: '${restApiRoot}'}}}
), function(err) {
if (err) return done(err);
supertest(app).get('/').end(function(err, res) {
if (err) return done(err);
expect(res.body.nested).to.eql({
info: { path: app.get('restApiRoot') },
info: {path: app.get('restApiRoot')},
});
done();
});
@ -629,7 +631,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 }}}
{nested: {info: {path: '${restApiRoot}', some: null}}}
), function(err) {
if (err) return done(err);
@ -670,7 +672,7 @@ describe('executor', function() {
it('should parse valid config variables', function(done) {
var config = simpleMiddlewareConfig('routes', {
props: ['a', '${vVar}', 1, true, function() {
}, { x: 1, y: '${y}' }],
}, {x: 1, y: '${y}'}],
});
boot.execute(app, config, function(err) {
if (err) return done(err);
@ -708,7 +710,7 @@ describe('executor', function() {
it('should parse a simple config variable', function(done) {
boot.execute(app, simpleComponentConfig(
{ path: '${restApiRoot}' }
{path: '${restApiRoot}'}
), function(err) {
if (err) return done(err);
@ -766,7 +768,7 @@ describe('executor', function() {
it('should parse multiple config variables', function(done) {
boot.execute(app, simpleComponentConfig(
{ path: '${restApiRoot}', env: '${env}' }
{path: '${restApiRoot}', env: '${env}'}
), function(err) {
if (err) return done(err);
@ -781,7 +783,7 @@ describe('executor', function() {
it('should parse config variables in an array', function(done) {
boot.execute(app, simpleComponentConfig(
{ paths: ['${restApiRoot}'] }
{paths: ['${restApiRoot}']}
), function(err) {
if (err) return done(err);
@ -797,7 +799,7 @@ describe('executor', function() {
it('should parse config variables in an object', function(done) {
boot.execute(app, simpleComponentConfig(
{ info: { path: '${restApiRoot}' }}
{info: {path: '${restApiRoot}'}}
), function(err) {
if (err) return done(err);
@ -813,14 +815,14 @@ describe('executor', function() {
it('should parse config variables in a nested object', function(done) {
boot.execute(app, simpleComponentConfig(
{ nested: { info: { path: '${restApiRoot}' }}}
{nested: {info: {path: '${restApiRoot}'}}}
), function(err) {
if (err) return done(err);
supertest(app).get('/component').end(function(err, res) {
if (err) return done(err);
expect(res.body.nested).to.eql({
info: { path: app.get('restApiRoot') },
info: {path: app.get('restApiRoot')},
});
done();
});
@ -833,7 +835,7 @@ describe('executor', function() {
'module.exports = function(app) { app.fnCalled = true; };');
delete app.fnCalled;
boot.execute(app, someInstructions({ bootScripts: [file] }),
boot.execute(app, someInstructions({bootScripts: [file]}),
function(err) {
if (err) return done(err);
expect(app.fnCalled, 'exported fn was called').to.be.true();
@ -958,12 +960,12 @@ describe('executor', function() {
expect(Object.keys(require.cache)).to.include(
appdir.resolve('components/test-component/index.js'));
expect(app.componentOptions).to.eql({ option: 'value' });
expect(app.componentOptions).to.eql({option: 'value'});
done();
});
});
it('disables component when configuration is not set', function() {
it('disables component when configuration is not set', function(done) {
appdir.writeConfigFileSync('component-config.json', {
'./components/test-component': false,
});
@ -977,10 +979,12 @@ describe('executor', function() {
expect(Object.keys(require.cache)).to.not.include(
appdir.resolve('components/test-component/index.js'));
done();
});
});
it('disable component if overrided by production configuration', function() {
it('disables component if overrided by production configuration',
function(done) {
appdir.writeConfigFileSync('component-config.json', {
'./components/test-component': {},
});
@ -992,11 +996,12 @@ describe('executor', function() {
'module.exports = ' +
'function(app, options) { app.componentOptions = options; }');
boot(app, { appRootDir: appdir.PATH, env: 'production' }, function(err) {
boot(app, {appRootDir: appdir.PATH, env: 'production'}, function(err) {
if (err) return done(err);
expect(Object.keys(require.cache)).to.not.include(
appdir.resolve('components/test-component/index.js'));
done();
});
});
@ -1109,7 +1114,7 @@ describe('executor', function() {
port: '${DYNAMIC_PORT}',
},
};
var bootInstructions = { dataSources: datasource };
var bootInstructions = {dataSources: datasource};
process.env.DYNAMIC_PORT = '10007';
process.env.DYNAMIC_HOST = '123.321.123.132';
@ -1123,10 +1128,10 @@ describe('executor', function() {
it('should resolve dynamic config via app.get()', function(done) {
var datasource = {
mydb: { host: '${DYNAMIC_HOST}' },
mydb: {host: '${DYNAMIC_HOST}'},
};
var bootInstructions = {
application: { DYNAMIC_HOST: '127.0.0.4' },
application: {DYNAMIC_HOST: '127.0.0.4'},
dataSources: datasource,
};
boot.execute(app, someInstructions(bootInstructions), function() {
@ -1140,10 +1145,10 @@ describe('executor', function() {
it('should take ENV precedence over config.json', function(done) {
process.env.DYNAMIC_HOST = '127.0.0.2';
var datasource = {
mydb: { host: '${DYNAMIC_HOST}' },
mydb: {host: '${DYNAMIC_HOST}'},
};
var bootInstructions = {
application: { DYNAMIC_HOST: '127.0.0.3' },
application: {DYNAMIC_HOST: '127.0.0.3'},
dataSources: datasource,
};
boot.execute(app, someInstructions(bootInstructions), function() {
@ -1155,9 +1160,9 @@ describe('executor', function() {
it('empty dynamic conf should resolve as `undefined`', function(done) {
var datasource = {
mydb: { host: '${DYNAMIC_HOST}' },
mydb: {host: '${DYNAMIC_HOST}'},
};
var bootInstructions = { dataSources: datasource };
var bootInstructions = {dataSources: datasource};
boot.execute(app, someInstructions(bootInstructions), function() {
expect(app.get('DYNAMIC_HOST')).to.be.undefined();
@ -1226,8 +1231,8 @@ function someInstructions(values) {
var result = {
application: values.application || {},
models: values.models || [],
dataSources: values.dataSources || { db: { connector: 'memory' }},
middleware: values.middleware || { phases: [], middleware: [] },
dataSources: values.dataSources || {db: {connector: 'memory'}},
middleware: values.middleware || {phases: [], middleware: []},
components: values.components || [],
bootScripts: values.bootScripts || [],
};

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var loopback = require('loopback');
var boot = require('../../../');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = function(Robot) {
Robot.settings._customized = 'Robot';
Robot.base.settings._customized = 'Robot';

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var loopback = require('loopback');
var boot = require('../../../');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = function(app) {
app.set('custom-key', 'custom-value');
};

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = function(app, options) {
app.dummyComponentOptions = options;
};

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = function(Model, options) {
Model.timeStampsMixin = true;
};

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = function(Customer) {
Customer.settings._customized = 'Customer';
Customer.base.settings._customized = 'Base';

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
process.bootFlags.push('barLoadedInTest');
module.exports = function(app, callback) {
callback();

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var framework = {
initialize: function(passport) {
return function(req, res, next) {

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
process.bootFlags.push('barLoaded');
module.exports = function(app, callback) {
process.bootFlags.push('barStarted');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
process.bootFlags.push('barSyncLoaded');
module.exports = function(app) {
process.bootFlags.push('barSyncExecuted');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = function(app, cb) {
if (app.booting)
process.bootingFlagSet = true;

View File

@ -3,4 +3,6 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
process.bootFlags.push('fooLoaded');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
exports.myMiddleware = function(name) {
return function(req, res, next) {
req._names = req._names || [];

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
/**
* Exporting a middleware as a property of the main module
*/

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function(opitions) {
return new Tracker(opitions);
};

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = function(loopbackApp, params) {
loopbackApp.use('/component', function(req, res, next) {
res.send(params);

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = function(params) {
return function(req, res, next) {
res.send(params);

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var path = require('path');
var fs = require('fs-extra');
var extend = require('util')._extend;
@ -27,7 +29,7 @@ appdir.init = function(cb) {
appdir.createConfigFilesSync = function(appConfig, dataSources, models) {
appConfig = extend({
}, appConfig);
appdir.writeConfigFileSync ('config.json', appConfig);
appdir.writeConfigFileSync('config.json', appConfig);
dataSources = extend({
db: {
@ -35,11 +37,11 @@ appdir.createConfigFilesSync = function(appConfig, dataSources, models) {
defaultForType: 'db',
},
}, dataSources);
appdir.writeConfigFileSync ('datasources.json', dataSources);
appdir.writeConfigFileSync('datasources.json', dataSources);
models = extend({
}, models);
appdir.writeConfigFileSync ('model-config.json', models);
appdir.writeConfigFileSync('model-config.json', models);
};
appdir.writeConfigFileSync = function(name, json) {

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var vm = require('vm');
function createContext() {
@ -20,10 +22,10 @@ function createContext() {
setTimeout: setTimeout,
// used by `debug` module
document: { documentElement: { style: {}}},
document: {documentElement: {style: {}}},
// used by `debug` module
navigator: { userAgent: 'sandbox' },
navigator: {userAgent: 'sandbox'},
// used by crypto-browserify & friends
Int32Array: Int32Array,

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var fs = require('fs');
var sandbox = require('./sandbox');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = function(name) {
return function(req, res, next) {
req._names = req._names || [];

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var fs = require('fs-extra');
var path = require('path');

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var utils = require('../lib/utils');
var expect = require('chai').expect;
var sandbox = require('./helpers/sandbox');