Use eslint with loopback config
Drop jshint and jscs in favour of eslint.
This commit is contained in:
parent
058e0e2f56
commit
902005ed8e
|
@ -1,3 +1,2 @@
|
||||||
node_modules/
|
|
||||||
coverage/
|
coverage/
|
||||||
test/sandbox/
|
test/sandbox/
|
25
.jscsrc
25
.jscsrc
|
@ -1,25 +0,0 @@
|
||||||
{
|
|
||||||
"preset": "google",
|
|
||||||
"requireCurlyBraces": [
|
|
||||||
"do",
|
|
||||||
"try",
|
|
||||||
"catch"
|
|
||||||
],
|
|
||||||
"disallowMultipleVarDecl": "exceptUndefined",
|
|
||||||
"disallowSpacesInsideObjectBrackets": null,
|
|
||||||
"requireSpaceAfterLineComment": true,
|
|
||||||
"maximumLineLength": {
|
|
||||||
"value": 80,
|
|
||||||
"allowRegex": true
|
|
||||||
},
|
|
||||||
"validateJSDoc": {
|
|
||||||
"checkParamNames": false,
|
|
||||||
"checkRedundantParams": false,
|
|
||||||
"requireParamTypes": true
|
|
||||||
},
|
|
||||||
"excludeFiles": [
|
|
||||||
"node_modules/**",
|
|
||||||
"coverage/**",
|
|
||||||
"test/sandbox/**"
|
|
||||||
]
|
|
||||||
}
|
|
21
.jshintrc
21
.jshintrc
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"node": true,
|
|
||||||
"browser": true,
|
|
||||||
"eqnull" : true,
|
|
||||||
"indent": 2,
|
|
||||||
"undef": true,
|
|
||||||
"unused": true,
|
|
||||||
"quotmark": "single",
|
|
||||||
"newcap": true,
|
|
||||||
"nonew": true,
|
|
||||||
"sub": true,
|
|
||||||
"unused": "vars",
|
|
||||||
"globals": {
|
|
||||||
"describe": false,
|
|
||||||
"it": false,
|
|
||||||
"before": false,
|
|
||||||
"beforeEach": false,
|
|
||||||
"after": false,
|
|
||||||
"afterEach": false
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -103,8 +103,8 @@ module.exports = function compile(options) {
|
||||||
components: componentInstructions,
|
components: componentInstructions,
|
||||||
mixins: mixinInstructions,
|
mixins: mixinInstructions,
|
||||||
files: {
|
files: {
|
||||||
boot: bootScripts
|
boot: bootScripts,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.appId)
|
if (options.appId)
|
||||||
|
@ -215,7 +215,7 @@ function buildAllModelInstructions(rootDir, modelsConfig, sources,
|
||||||
name: name,
|
name: name,
|
||||||
config: config,
|
config: config,
|
||||||
definition: definition.definition,
|
definition: definition.definition,
|
||||||
sourceFile: definition.sourceFile
|
sourceFile: definition.sourceFile,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -415,7 +415,6 @@ function tryResolveAppPath(rootDir, relativePath, resolveOptions) {
|
||||||
try {
|
try {
|
||||||
// NOTE(bajtos) We need to create a proper String object here,
|
// NOTE(bajtos) We need to create a proper String object here,
|
||||||
// otherwise we can't attach additional properties to it
|
// otherwise we can't attach additional properties to it
|
||||||
/*jshint -W053 */
|
|
||||||
var filePath = new String(require.resolve(absPath));
|
var filePath = new String(require.resolve(absPath));
|
||||||
filePath.unresolvedPath = absPath;
|
filePath.unresolvedPath = absPath;
|
||||||
return filePath;
|
return filePath;
|
||||||
|
@ -457,7 +456,7 @@ function loadModelDefinition(rootDir, jsonFile, allFiles) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
definition: definition,
|
definition: definition,
|
||||||
sourceFile: sourceFile
|
sourceFile: sourceFile,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,7 +494,7 @@ function buildMiddlewareInstructions(rootDir, config) {
|
||||||
|
|
||||||
var item = {
|
var item = {
|
||||||
sourceFile: resolved.sourceFile,
|
sourceFile: resolved.sourceFile,
|
||||||
config: middlewareConfig
|
config: middlewareConfig,
|
||||||
};
|
};
|
||||||
if (resolved.fragment) {
|
if (resolved.fragment) {
|
||||||
item.fragment = resolved.fragment;
|
item.fragment = resolved.fragment;
|
||||||
|
@ -517,13 +516,13 @@ function buildMiddlewareInstructions(rootDir, config) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
phases: flattenedPhaseNames,
|
phases: flattenedPhaseNames,
|
||||||
middleware: middlewareList
|
middleware: middlewareList,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveMiddlewarePath(rootDir, middleware, config) {
|
function resolveMiddlewarePath(rootDir, middleware, config) {
|
||||||
var resolved = {
|
var resolved = {
|
||||||
optional: !!config.optional
|
optional: !!config.optional,
|
||||||
};
|
};
|
||||||
|
|
||||||
var segments = middleware.split('#');
|
var segments = middleware.split('#');
|
||||||
|
@ -532,7 +531,7 @@ function resolveMiddlewarePath(rootDir, middleware, config) {
|
||||||
var middlewarePath = pathName;
|
var middlewarePath = pathName;
|
||||||
var opts = {
|
var opts = {
|
||||||
strict: true,
|
strict: true,
|
||||||
optional: !!config.optional
|
optional: !!config.optional,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fragment) {
|
if (fragment) {
|
||||||
|
@ -552,7 +551,7 @@ function resolveMiddlewarePath(rootDir, middleware, config) {
|
||||||
// node_modules/strong-express-metrics
|
// node_modules/strong-express-metrics
|
||||||
// instead of
|
// instead of
|
||||||
// node_modules/strong-express-metrics/index.js
|
// node_modules/strong-express-metrics/index.js
|
||||||
fullResolve: false
|
fullResolve: false,
|
||||||
});
|
});
|
||||||
var sourceFile = resolveAppScriptPath(rootDir, middlewarePath, resolveOpts);
|
var sourceFile = resolveAppScriptPath(rootDir, middlewarePath, resolveOpts);
|
||||||
|
|
||||||
|
@ -581,14 +580,13 @@ function resolveMiddlewarePath(rootDir, middleware, config) {
|
||||||
// pathName + '/' + fragment
|
// pathName + '/' + fragment
|
||||||
];
|
];
|
||||||
|
|
||||||
var err;
|
var err = undefined; // see https://github.com/eslint/eslint/issues/5744
|
||||||
for (var ix in candidates) {
|
for (var ix in candidates) {
|
||||||
try {
|
try {
|
||||||
resolved.sourceFile = resolveAppScriptPath(rootDir, candidates[ix], opts);
|
resolved.sourceFile = resolveAppScriptPath(rootDir, candidates[ix], opts);
|
||||||
delete resolved.fragment;
|
delete resolved.fragment;
|
||||||
return resolved;
|
return resolved;
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
// Report the error for the first candidate when no candidate matches
|
// Report the error for the first candidate when no candidate matches
|
||||||
if (!err) err = e;
|
if (!err) err = e;
|
||||||
}
|
}
|
||||||
|
@ -615,7 +613,7 @@ function buildComponentInstructions(rootDir, componentConfig) {
|
||||||
.map(function(name) {
|
.map(function(name) {
|
||||||
return {
|
return {
|
||||||
sourceFile: resolveAppScriptPath(rootDir, name, { strict: true }),
|
sourceFile: resolveAppScriptPath(rootDir, name, { strict: true }),
|
||||||
config: componentConfig[name]
|
config: componentConfig[name],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -635,7 +633,7 @@ function resolveRelativePaths(relativePaths, appRootDir) {
|
||||||
function getExcludedExtensions() {
|
function getExcludedExtensions() {
|
||||||
return {
|
return {
|
||||||
'.json': '.json',
|
'.json': '.json',
|
||||||
'.node': 'node'
|
'.node': 'node',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +791,9 @@ function normalizeMixinName(str, options) {
|
||||||
case 'classify':
|
case 'classify':
|
||||||
str = String(str).replace(/([A-Z]+)/g, ' $1').trim();
|
str = String(str).replace(/([A-Z]+)/g, ' $1').trim();
|
||||||
str = String(str).replace(/[\W_]/g, ' ').toLowerCase();
|
str = String(str).replace(/[\W_]/g, ' ').toLowerCase();
|
||||||
str = str.replace(/(?:^|\s|-)\S/g, function(c) { return c.toUpperCase(); });
|
str = str.replace(/(?:^|\s|-)\S/g, function(c) {
|
||||||
|
return c.toUpperCase();
|
||||||
|
});
|
||||||
str = str.replace(/\s+/g, '');
|
str = str.replace(/\s+/g, '');
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ ConfigLoader.loadDataSources = function(rootDir, env) {
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
ConfigLoader.loadModels = function(rootDir, env) {
|
ConfigLoader.loadModels = function(rootDir, env) {
|
||||||
/*jshint unused:false */
|
|
||||||
return loadNamed(rootDir, env, 'model-config', mergeModelConfig);
|
return loadNamed(rootDir, env, 'model-config', mergeModelConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,7 +97,7 @@ function findConfigFiles(appRootDir, env, name) {
|
||||||
var candidates = [
|
var candidates = [
|
||||||
master,
|
master,
|
||||||
ifExistsWithAnyExt(name + '.local'),
|
ifExistsWithAnyExt(name + '.local'),
|
||||||
ifExistsWithAnyExt(name + '.' + env)
|
ifExistsWithAnyExt(name + '.' + env),
|
||||||
];
|
];
|
||||||
|
|
||||||
return candidates.filter(function(c) { return c !== undefined; });
|
return candidates.filter(function(c) { return c !== undefined; });
|
||||||
|
@ -124,7 +123,7 @@ function loadConfigFiles(files) {
|
||||||
var config = require(f);
|
var config = require(f);
|
||||||
Object.defineProperty(config, '_filename', {
|
Object.defineProperty(config, '_filename', {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
value: f
|
value: f,
|
||||||
});
|
});
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
@ -166,7 +165,7 @@ function mergeAppConfig(target, config, fileName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mergeMiddlewareConfig(target, config, fileName) {
|
function mergeMiddlewareConfig(target, config, fileName) {
|
||||||
var err;
|
var err = undefined; // see https://github.com/eslint/eslint/issues/5744
|
||||||
for (var phase in config) {
|
for (var phase in config) {
|
||||||
if (phase in target) {
|
if (phase in target) {
|
||||||
err = mergePhaseConfig(target[phase], config[phase], phase);
|
err = mergePhaseConfig(target[phase], config[phase], phase);
|
||||||
|
@ -203,7 +202,7 @@ function mergeNamedItems(arr1, arr2, key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mergePhaseConfig(target, config, phase) {
|
function mergePhaseConfig(target, config, phase) {
|
||||||
var err;
|
var err = undefined; // see https://github.com/eslint/eslint/issues/5744
|
||||||
for (var mw in config) {
|
for (var mw in config) {
|
||||||
if (mw in target) {
|
if (mw in target) {
|
||||||
var targetMiddleware = target[mw];
|
var targetMiddleware = target[mw];
|
||||||
|
|
|
@ -128,7 +128,7 @@ function setPort(app, instructions) {
|
||||||
instructions.config.port,
|
instructions.config.port,
|
||||||
process.env.npm_package_config_port,
|
process.env.npm_package_config_port,
|
||||||
app.get('port'),
|
app.get('port'),
|
||||||
3000
|
3000,
|
||||||
], function(p) {
|
], function(p) {
|
||||||
return p != null;
|
return p != null;
|
||||||
});
|
});
|
||||||
|
@ -277,7 +277,7 @@ function runScripts(app, list, callback) {
|
||||||
debug('Exported function detected %s', filepath);
|
debug('Exported function detected %s', filepath);
|
||||||
functions.push({
|
functions.push({
|
||||||
path: filepath,
|
path: filepath,
|
||||||
func: exports
|
func: exports,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"browser": "browser.js",
|
"browser": "browser.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"pretest": "jscs . && jshint .",
|
"test": "mocha",
|
||||||
"test": "mocha"
|
"posttest": "npm run lint",
|
||||||
|
"lint": "eslint ."
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -32,9 +33,9 @@
|
||||||
"chai": "^1.10.0",
|
"chai": "^1.10.0",
|
||||||
"coffee-script": "^1.8.0",
|
"coffee-script": "^1.8.0",
|
||||||
"coffeeify": "^0.7.0",
|
"coffeeify": "^0.7.0",
|
||||||
|
"eslint": "^2.5.3",
|
||||||
|
"eslint-config-loopback": "^1.0.0",
|
||||||
"fs-extra": "^0.12.0",
|
"fs-extra": "^0.12.0",
|
||||||
"jscs": "^1.7.3",
|
|
||||||
"jshint": "^2.5.6",
|
|
||||||
"loopback": "^2.16.3",
|
"loopback": "^2.16.3",
|
||||||
"mocha": "^1.19.0",
|
"mocha": "^1.19.0",
|
||||||
"supertest": "^0.14.0"
|
"supertest": "^0.14.0"
|
||||||
|
|
|
@ -22,14 +22,14 @@ describe('browser support for multiple apps', function() {
|
||||||
{
|
{
|
||||||
appDir: app1Dir,
|
appDir: app1Dir,
|
||||||
appFile: './app.js',
|
appFile: './app.js',
|
||||||
moduleName: 'browser-app'
|
moduleName: 'browser-app',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
appDir: app2Dir,
|
appDir: app2Dir,
|
||||||
appFile: './app.js',
|
appFile: './app.js',
|
||||||
moduleName: 'browser-app2',
|
moduleName: 'browser-app2',
|
||||||
appId: 'browserApp2'
|
appId: 'browserApp2',
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
browserifyTestApps(apps, function(err, bundlePath) {
|
browserifyTestApps(apps, function(err, bundlePath) {
|
||||||
|
@ -55,7 +55,7 @@ describe('browser support for multiple apps', function() {
|
||||||
|
|
||||||
function browserifyTestApps(apps, next) {
|
function browserifyTestApps(apps, next) {
|
||||||
var b = browserify({
|
var b = browserify({
|
||||||
debug: true
|
debug: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var i in apps) {
|
for (var i in apps) {
|
||||||
|
@ -71,7 +71,7 @@ function browserifyTestApps(apps, next) {
|
||||||
if (appId) {
|
if (appId) {
|
||||||
opts = {
|
opts = {
|
||||||
appId: appId,
|
appId: appId,
|
||||||
appRootDir: appDir
|
appRootDir: appDir,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
boot.compileToBrowserify(opts, b);
|
boot.compileToBrowserify(opts, b);
|
||||||
|
|
|
@ -13,7 +13,7 @@ var compileStrategies = {
|
||||||
'default': function(appDir) {
|
'default': function(appDir) {
|
||||||
var b = browserify({
|
var b = browserify({
|
||||||
basedir: appDir,
|
basedir: appDir,
|
||||||
debug: true
|
debug: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
b.require('./app.js', { expose: 'browser-app' });
|
b.require('./app.js', { expose: 'browser-app' });
|
||||||
|
@ -24,7 +24,7 @@ var compileStrategies = {
|
||||||
var b = browserify({
|
var b = browserify({
|
||||||
basedir: appDir,
|
basedir: appDir,
|
||||||
extensions: ['.coffee'],
|
extensions: ['.coffee'],
|
||||||
debug: true
|
debug: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
b.transform('coffeeify');
|
b.transform('coffeeify');
|
||||||
|
@ -64,7 +64,7 @@ describe('browser support', function() {
|
||||||
it('loads mixins', function(done) {
|
it('loads mixins', function(done) {
|
||||||
var appDir = path.resolve(__dirname, './fixtures/browser-app');
|
var appDir = path.resolve(__dirname, './fixtures/browser-app');
|
||||||
var options = {
|
var options = {
|
||||||
appRootDir: appDir
|
appRootDir: appDir,
|
||||||
};
|
};
|
||||||
|
|
||||||
browserifyTestApp(options, function(err, bundlePath) {
|
browserifyTestApp(options, function(err, bundlePath) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -37,22 +37,22 @@ describe('executor', function() {
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
restApiRoot: '/rest-api',
|
restApiRoot: '/rest-api',
|
||||||
foo: { bar: 'bat' },
|
foo: { bar: 'bat' },
|
||||||
baz: true
|
baz: true,
|
||||||
},
|
},
|
||||||
models: [
|
models: [
|
||||||
{
|
{
|
||||||
name: 'User',
|
name: 'User',
|
||||||
config: {
|
config: {
|
||||||
dataSource: 'the-db'
|
dataSource: 'the-db',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
dataSources: {
|
dataSources: {
|
||||||
'the-db': {
|
'the-db': {
|
||||||
connector: 'memory',
|
connector: 'memory',
|
||||||
defaultForType: 'db'
|
defaultForType: 'db',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when booting', function() {
|
describe('when booting', function() {
|
||||||
|
@ -109,9 +109,9 @@ describe('executor', function() {
|
||||||
name: 'Customer',
|
name: 'Customer',
|
||||||
base: 'User',
|
base: 'User',
|
||||||
},
|
},
|
||||||
sourceFile: path.resolve(appdir.PATH, 'models', 'Customer.js')
|
sourceFile: path.resolve(appdir.PATH, 'models', 'Customer.js'),
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
expect(app.models.Customer).to.exist();
|
expect(app.models.Customer).to.exist();
|
||||||
|
@ -127,9 +127,9 @@ describe('executor', function() {
|
||||||
name: 'Vehicle',
|
name: 'Vehicle',
|
||||||
config: undefined,
|
config: undefined,
|
||||||
definition: {
|
definition: {
|
||||||
name: 'Vehicle'
|
name: 'Vehicle',
|
||||||
},
|
},
|
||||||
sourceFile: undefined
|
sourceFile: undefined,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Car',
|
name: 'Car',
|
||||||
|
@ -138,9 +138,9 @@ describe('executor', function() {
|
||||||
name: 'Car',
|
name: 'Car',
|
||||||
base: 'Vehicle',
|
base: 'Vehicle',
|
||||||
},
|
},
|
||||||
sourceFile: undefined
|
sourceFile: undefined,
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
expect(Object.keys(app.models)).to.eql(['Car']);
|
expect(Object.keys(app.models)).to.eql(['Car']);
|
||||||
|
@ -166,15 +166,15 @@ describe('executor', function() {
|
||||||
name: 'Customer',
|
name: 'Customer',
|
||||||
config: { dataSource: 'db' },
|
config: { dataSource: 'db' },
|
||||||
definition: { name: 'Customer' },
|
definition: { name: 'Customer' },
|
||||||
sourceFile: path.resolve(appdir.PATH, 'models', 'Customer.js')
|
sourceFile: path.resolve(appdir.PATH, 'models', 'Customer.js'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'UniqueName',
|
name: 'UniqueName',
|
||||||
config: { dataSource: 'db' },
|
config: { dataSource: 'db' },
|
||||||
definition: { name: 'UniqueName' },
|
definition: { name: 'UniqueName' },
|
||||||
sourceFile: undefined
|
sourceFile: undefined,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
expect(app.models.Customer._modelsWhenAttached).to.include('UniqueName');
|
expect(app.models.Customer._modelsWhenAttached).to.include('UniqueName');
|
||||||
|
@ -188,9 +188,9 @@ describe('executor', function() {
|
||||||
name: 'LocalCustomer',
|
name: 'LocalCustomer',
|
||||||
config: { dataSource: 'db' },
|
config: { dataSource: 'db' },
|
||||||
definition: { name: 'LocalCustomer' },
|
definition: { name: 'LocalCustomer' },
|
||||||
sourceFile: undefined
|
sourceFile: undefined,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
expect(Object.keys(loopback.registry.modelBuilder.models), 'global models')
|
expect(Object.keys(loopback.registry.modelBuilder.models), 'global models')
|
||||||
|
@ -236,7 +236,7 @@ describe('executor', function() {
|
||||||
require.resolve('loopback/common/models/user.json')
|
require.resolve('loopback/common/models/user.json')
|
||||||
),
|
),
|
||||||
config: { dataSource: 'db' },
|
config: { dataSource: 'db' },
|
||||||
sourceFile: require.resolve('loopback/common/models/user.js')
|
sourceFile: require.resolve('loopback/common/models/user.js'),
|
||||||
};
|
};
|
||||||
builtinModel.definition.redefined = true;
|
builtinModel.definition.redefined = true;
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ describe('executor', function() {
|
||||||
'barLoaded',
|
'barLoaded',
|
||||||
'barSyncLoaded',
|
'barSyncLoaded',
|
||||||
'fooLoaded',
|
'fooLoaded',
|
||||||
'barStarted'
|
'barStarted',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// bar finished happens in the next tick
|
// bar finished happens in the next tick
|
||||||
|
@ -272,7 +272,7 @@ describe('executor', function() {
|
||||||
'fooLoaded',
|
'fooLoaded',
|
||||||
'barStarted',
|
'barStarted',
|
||||||
'barFinished',
|
'barFinished',
|
||||||
'barSyncExecuted'
|
'barSyncExecuted',
|
||||||
]);
|
]);
|
||||||
done();
|
done();
|
||||||
}, 10);
|
}, 10);
|
||||||
|
@ -288,7 +288,7 @@ describe('executor', function() {
|
||||||
'fooLoaded',
|
'fooLoaded',
|
||||||
'barStarted',
|
'barStarted',
|
||||||
'barFinished',
|
'barFinished',
|
||||||
'barSyncExecuted'
|
'barSyncExecuted',
|
||||||
]);
|
]);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -306,11 +306,11 @@ describe('executor', function() {
|
||||||
'function(Model, options) {}');
|
'function(Model, options) {}');
|
||||||
|
|
||||||
appdir.writeConfigFileSync('custom-mixins/time-stamps.json', {
|
appdir.writeConfigFileSync('custom-mixins/time-stamps.json', {
|
||||||
name: 'Timestamping'
|
name: 'Timestamping',
|
||||||
});
|
});
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
appRootDir: appdir.PATH
|
appRootDir: appdir.PATH,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -357,8 +357,8 @@ describe('executor', function() {
|
||||||
boot.execute(app, someInstructions({
|
boot.execute(app, someInstructions({
|
||||||
config: {
|
config: {
|
||||||
port: undefined,
|
port: undefined,
|
||||||
host: undefined
|
host: undefined,
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,6 +388,7 @@ describe('executor', function() {
|
||||||
|
|
||||||
it('should prioritize host sources', function() {
|
it('should prioritize host sources', function() {
|
||||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
/*eslint-disable camelcase*/
|
||||||
process.env.npm_config_host = randomHost();
|
process.env.npm_config_host = randomHost();
|
||||||
process.env.OPENSHIFT_SLS_IP = randomHost();
|
process.env.OPENSHIFT_SLS_IP = randomHost();
|
||||||
process.env.OPENSHIFT_NODEJS_IP = randomHost();
|
process.env.OPENSHIFT_NODEJS_IP = randomHost();
|
||||||
|
@ -397,9 +398,11 @@ describe('executor', function() {
|
||||||
|
|
||||||
bootWithDefaults();
|
bootWithDefaults();
|
||||||
assert.equal(app.get('host'), process.env.npm_config_host);
|
assert.equal(app.get('host'), process.env.npm_config_host);
|
||||||
|
/*eslint-enable camelcase*/
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should prioritize port sources', function() {
|
it('should prioritize port sources', function() {
|
||||||
|
/*eslint-disable camelcase*/
|
||||||
process.env.npm_config_port = randomPort();
|
process.env.npm_config_port = randomPort();
|
||||||
process.env.OPENSHIFT_SLS_PORT = randomPort();
|
process.env.OPENSHIFT_SLS_PORT = randomPort();
|
||||||
process.env.OPENSHIFT_NODEJS_PORT = randomPort();
|
process.env.OPENSHIFT_NODEJS_PORT = randomPort();
|
||||||
|
@ -409,6 +412,7 @@ describe('executor', function() {
|
||||||
|
|
||||||
bootWithDefaults();
|
bootWithDefaults();
|
||||||
assert.equal(app.get('port'), process.env.npm_config_port);
|
assert.equal(app.get('port'), process.env.npm_config_port);
|
||||||
|
/*eslint-enable camelcase*/
|
||||||
});
|
});
|
||||||
|
|
||||||
function randomHost() {
|
function randomHost() {
|
||||||
|
@ -485,7 +489,7 @@ describe('executor', function() {
|
||||||
supertest(app).get('/').end(function(err, res) {
|
supertest(app).get('/').end(function(err, res) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
expect(res.body.info).to.eql({
|
expect(res.body.info).to.eql({
|
||||||
path: app.get('restApiRoot')
|
path: app.get('restApiRoot'),
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -499,7 +503,7 @@ describe('executor', function() {
|
||||||
supertest(app).get('/').end(function(err, res) {
|
supertest(app).get('/').end(function(err, res) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
expect(res.body.nested).to.eql({
|
expect(res.body.nested).to.eql({
|
||||||
info: { path: app.get('restApiRoot') }
|
info: { path: app.get('restApiRoot') },
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -509,7 +513,7 @@ describe('executor', function() {
|
||||||
var invalidDataTypes = [undefined, function() {}];
|
var invalidDataTypes = [undefined, function() {}];
|
||||||
async.each(invalidDataTypes, function(invalidDataType, cb) {
|
async.each(invalidDataTypes, function(invalidDataType, cb) {
|
||||||
var config = simpleMiddlewareConfig('routes', {
|
var config = simpleMiddlewareConfig('routes', {
|
||||||
path: invalidDataType
|
path: invalidDataType,
|
||||||
});
|
});
|
||||||
boot.execute(app, config);
|
boot.execute(app, config);
|
||||||
|
|
||||||
|
@ -525,7 +529,7 @@ describe('executor', function() {
|
||||||
|
|
||||||
it('should parse valid config variables', function(done) {
|
it('should parse valid config variables', function(done) {
|
||||||
var config = simpleMiddlewareConfig('routes', {
|
var config = simpleMiddlewareConfig('routes', {
|
||||||
props: ['a', '${vVar}', 1, true, function() {}, {x:1, y: '${y}'}]
|
props: ['a', '${vVar}', 1, true, function() {}, { x: 1, y: '${y}' }],
|
||||||
});
|
});
|
||||||
boot.execute(app, config);
|
boot.execute(app, config);
|
||||||
|
|
||||||
|
@ -552,7 +556,6 @@ describe('executor', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with component-config.json', function() {
|
describe('with component-config.json', function() {
|
||||||
|
|
||||||
it('should parse a simple config variable', function(done) {
|
it('should parse a simple config variable', function(done) {
|
||||||
boot.execute(app, simpleComponentConfig(
|
boot.execute(app, simpleComponentConfig(
|
||||||
{ path: '${restApiRoot}' }
|
{ path: '${restApiRoot}' }
|
||||||
|
@ -600,7 +603,7 @@ describe('executor', function() {
|
||||||
supertest(app).get('/component').end(function(err, res) {
|
supertest(app).get('/component').end(function(err, res) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
expect(res.body.info).to.eql({
|
expect(res.body.info).to.eql({
|
||||||
path: app.get('restApiRoot')
|
path: app.get('restApiRoot'),
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -614,12 +617,11 @@ describe('executor', function() {
|
||||||
supertest(app).get('/component').end(function(err, res) {
|
supertest(app).get('/component').end(function(err, res) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
expect(res.body.nested).to.eql({
|
expect(res.body.nested).to.eql({
|
||||||
info: { path: app.get('restApiRoot') }
|
info: { path: app.get('restApiRoot') },
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls function exported by boot/init.js', function() {
|
it('calls function exported by boot/init.js', function() {
|
||||||
|
@ -642,33 +644,33 @@ describe('executor', function() {
|
||||||
sourceFile: pushNamePath,
|
sourceFile: pushNamePath,
|
||||||
config: {
|
config: {
|
||||||
phase: 'initial',
|
phase: 'initial',
|
||||||
params: 'initial'
|
params: 'initial',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sourceFile: pushNamePath,
|
sourceFile: pushNamePath,
|
||||||
config: {
|
config: {
|
||||||
phase: 'custom',
|
phase: 'custom',
|
||||||
params: 'custom'
|
params: 'custom',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sourceFile: pushNamePath,
|
sourceFile: pushNamePath,
|
||||||
config: {
|
config: {
|
||||||
phase: 'routes',
|
phase: 'routes',
|
||||||
params: 'routes'
|
params: 'routes',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sourceFile: pushNamePath,
|
sourceFile: pushNamePath,
|
||||||
config: {
|
config: {
|
||||||
phase: 'routes',
|
phase: 'routes',
|
||||||
enabled: false,
|
enabled: false,
|
||||||
params: 'disabled'
|
params: 'disabled',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
supertest(app)
|
supertest(app)
|
||||||
|
@ -682,7 +684,6 @@ describe('executor', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('configures middleware using shortform', function(done) {
|
it('configures middleware using shortform', function(done) {
|
||||||
|
|
||||||
boot.execute(app, someInstructions({
|
boot.execute(app, someInstructions({
|
||||||
middleware: {
|
middleware: {
|
||||||
middleware: [
|
middleware: [
|
||||||
|
@ -691,11 +692,11 @@ describe('executor', function() {
|
||||||
fragment: 'static',
|
fragment: 'static',
|
||||||
config: {
|
config: {
|
||||||
phase: 'files',
|
phase: 'files',
|
||||||
params: path.join(__dirname, './fixtures/simple-app/client/')
|
params: path.join(__dirname, './fixtures/simple-app/client/'),
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
supertest(app)
|
supertest(app)
|
||||||
|
@ -725,8 +726,8 @@ describe('executor', function() {
|
||||||
it('configures components', function() {
|
it('configures components', function() {
|
||||||
appdir.writeConfigFileSync('component-config.json', {
|
appdir.writeConfigFileSync('component-config.json', {
|
||||||
'./components/test-component': {
|
'./components/test-component': {
|
||||||
option: 'value'
|
option: 'value',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
appdir.writeFileSync('components/test-component/index.js',
|
appdir.writeFileSync('components/test-component/index.js',
|
||||||
|
@ -743,7 +744,7 @@ describe('executor', function() {
|
||||||
|
|
||||||
it('disables component when configuration is not set', function() {
|
it('disables component when configuration is not set', function() {
|
||||||
appdir.writeConfigFileSync('component-config.json', {
|
appdir.writeConfigFileSync('component-config.json', {
|
||||||
'./components/test-component': false
|
'./components/test-component': false,
|
||||||
});
|
});
|
||||||
|
|
||||||
appdir.writeFileSync('components/test-component/index.js',
|
appdir.writeFileSync('components/test-component/index.js',
|
||||||
|
@ -758,10 +759,10 @@ describe('executor', function() {
|
||||||
|
|
||||||
it('disable component if overrided by production configuration', function() {
|
it('disable component if overrided by production configuration', function() {
|
||||||
appdir.writeConfigFileSync('component-config.json', {
|
appdir.writeConfigFileSync('component-config.json', {
|
||||||
'./components/test-component': {}
|
'./components/test-component': {},
|
||||||
});
|
});
|
||||||
appdir.writeConfigFileSync('component-config.production.json', {
|
appdir.writeConfigFileSync('component-config.production.json', {
|
||||||
'./components/test-component': null
|
'./components/test-component': null,
|
||||||
});
|
});
|
||||||
|
|
||||||
appdir.writeFileSync('components/test-component/index.js',
|
appdir.writeFileSync('components/test-component/index.js',
|
||||||
|
@ -785,11 +786,11 @@ describe('executor', function() {
|
||||||
sourceFile: passportPath,
|
sourceFile: passportPath,
|
||||||
fragment: 'initialize',
|
fragment: 'initialize',
|
||||||
config: {
|
config: {
|
||||||
phase: 'auth:before'
|
phase: 'auth:before',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
supertest(app)
|
supertest(app)
|
||||||
|
@ -808,7 +809,6 @@ describe('executor', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function simpleMiddlewareConfig(phase, paths, params) {
|
function simpleMiddlewareConfig(phase, paths, params) {
|
||||||
|
@ -819,7 +819,7 @@ function simpleMiddlewareConfig(phase, paths, params) {
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
phase: phase,
|
phase: phase,
|
||||||
params: params
|
params: params,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (paths) config.paths = paths;
|
if (paths) config.paths = paths;
|
||||||
|
@ -831,9 +831,9 @@ function simpleMiddlewareConfig(phase, paths, params) {
|
||||||
{
|
{
|
||||||
sourceFile: path.join(__dirname, './fixtures/simple-middleware.js'),
|
sourceFile: path.join(__dirname, './fixtures/simple-middleware.js'),
|
||||||
config: config,
|
config: config,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,9 +842,9 @@ function simpleComponentConfig(config) {
|
||||||
components: [
|
components: [
|
||||||
{
|
{
|
||||||
sourceFile: path.join(__dirname, './fixtures/simple-component.js'),
|
sourceFile: path.join(__dirname, './fixtures/simple-component.js'),
|
||||||
config: config
|
config: config,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,8 +873,8 @@ function someInstructions(values) {
|
||||||
middleware: values.middleware || { phases: [], middleware: [] },
|
middleware: values.middleware || { phases: [], middleware: [] },
|
||||||
components: values.components || [],
|
components: values.components || [],
|
||||||
files: {
|
files: {
|
||||||
boot: []
|
boot: [],
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (values.env)
|
if (values.env)
|
||||||
|
@ -898,6 +898,6 @@ function envAppInstructions() {
|
||||||
fs.copySync(ENV_APP, appdir.PATH);
|
fs.copySync(ENV_APP, appdir.PATH);
|
||||||
return boot.compile({
|
return boot.compile({
|
||||||
appRootDir: appdir.PATH,
|
appRootDir: appdir.PATH,
|
||||||
env: 'test'
|
env: 'test',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,5 @@ var app = module.exports = loopback();
|
||||||
|
|
||||||
boot(app, {
|
boot(app, {
|
||||||
appId: 'browserApp2',
|
appId: 'browserApp2',
|
||||||
appRootDir: __dirname
|
appRootDir: __dirname,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
module.exports = function(Model, options) {
|
module.exports = function(Model, options) {
|
||||||
|
|
||||||
Model.timeStampsMixin = true;
|
Model.timeStampsMixin = true;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ var framework = {
|
||||||
res.setHeader('passport', 'initialized');
|
res.setHeader('passport', 'initialized');
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var Passport = function() {
|
var Passport = function() {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
module.exports = function(loopbackApp, params) {
|
module.exports = function(loopbackApp, params) {
|
||||||
|
|
||||||
loopbackApp.use('/component', function(req, res, next) {
|
loopbackApp.use('/component', function(req, res, next) {
|
||||||
res.send(params);
|
res.send(params);
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,8 +27,8 @@ appdir.createConfigFilesSync = function(appConfig, dataSources, models) {
|
||||||
dataSources = extend({
|
dataSources = extend({
|
||||||
db: {
|
db: {
|
||||||
connector: 'memory',
|
connector: 'memory',
|
||||||
defaultForType: 'db'
|
defaultForType: 'db',
|
||||||
}
|
},
|
||||||
}, dataSources);
|
}, dataSources);
|
||||||
appdir.writeConfigFileSync ('datasources.json', dataSources);
|
appdir.writeConfigFileSync ('datasources.json', dataSources);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ function createContext() {
|
||||||
|
|
||||||
localStorage: {
|
localStorage: {
|
||||||
// used by `debug` module
|
// used by `debug` module
|
||||||
debug: process.env.DEBUG
|
debug: process.env.DEBUG,
|
||||||
},
|
},
|
||||||
|
|
||||||
// used by DataSource.prototype.ready
|
// used by DataSource.prototype.ready
|
||||||
|
@ -39,9 +39,9 @@ function createContext() {
|
||||||
_logs: {
|
_logs: {
|
||||||
log: [],
|
log: [],
|
||||||
warn: [],
|
warn: [],
|
||||||
error: []
|
error: [],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// `window` is used by loopback to detect browser runtime
|
// `window` is used by loopback to detect browser runtime
|
||||||
|
@ -52,9 +52,10 @@ function createContext() {
|
||||||
exports.createContext = createContext;
|
exports.createContext = createContext;
|
||||||
|
|
||||||
function printContextLogs(context) {
|
function printContextLogs(context) {
|
||||||
for (var k in context.console._logs) {
|
var k, ix; // see https://github.com/eslint/eslint/issues/5744
|
||||||
|
for (k in context.console._logs) {
|
||||||
var items = context.console._logs[k];
|
var items = context.console._logs[k];
|
||||||
for (var ix in items) {
|
for (ix in items) {
|
||||||
console[k].apply(console, items[ix]);
|
console[k].apply(console, items[ix]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue