Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ module.exports = yeoman.Base.extend({
cb();
} else {
cb(new Error(
g.f('The generator must be run in an empty directory.'))
);
g.f('The generator must be run in an empty directory.')
));
}
});
},
Expand Down Expand Up @@ -349,7 +349,8 @@ module.exports = yeoman.Base.extend({
'support and maintain LoopBack, which is at the core of\n' +
'API Connect. When your APIs need robust management and\n' +
'security options, please check out %s',
'http://ibm.biz/tryAPIC')));
'http://ibm.biz/tryAPIC'
)));
this.log();
},
},
Expand Down
9 changes: 5 additions & 4 deletions bluemix/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ module.exports = yeoman.Base.extend({
validateLoopBackDir: function() {
var root = this.destinationRoot();
if (!(this.options.login || this.options.sso)) {
if (!fs.existsSync(path.join(root, 'package.json')) ||
!fs.existsSync(path.join(root, 'server', 'server.js'))) {
this.log(chalk.red('\n Invalid LoopBack directory\n'));
process.exit();
if (
!fs.existsSync(path.join(root, 'package.json')) ||
!fs.existsSync(path.join(root, 'server', 'server.js'))
) {
throw new Error('Invalid LoopBack directory');
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions bluemix/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ function login() {
});
if (choices.length === 1) {
this.log(chalk.cyan(
g.f('> Default organization: ') + choices[0].name));
g.f('> Default organization: ') + choices[0].name
));
this.organization = choices[0].value;
}
var prompts = [
Expand Down Expand Up @@ -136,7 +137,8 @@ function login() {
});
if (choices.length === 1) {
this.log(chalk.cyan(
g.f('> Default space: ') + choices[0].name));
g.f('> Default space: ') + choices[0].name
));
this.space = choices[0].value;
}
var prompts = [
Expand Down
3 changes: 2 additions & 1 deletion datasource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ module.exports = yeoman.Base.extend({
npmModule += '@' + pkg.version;
}
var projectPkg = JSON.parse(
fs.readFileSync(path.join(this.projectDir, 'package.json'), 'utf-8'));
fs.readFileSync(path.join(this.projectDir, 'package.json'), 'utf-8')
);
if (projectPkg.dependencies[pkg.name]) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ module.exports = yeoman.Base.extend({
helpers.reportValidationError(err, self.log);
if (!err && inst) {
self.log(g.f(
'Middleware %s is added to phase %s.', inst.name, inst.phase));
'Middleware %s is added to phase %s.', inst.name, inst.phase
));
}
return done(err);
});
Expand Down
6 changes: 4 additions & 2 deletions model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ module.exports = yeoman.Base.extend({
if (err) return done(err);
this.baseModel = model;
done();
}.bind(this));
}.bind(this)
);
},

askForParameters: function() {
Expand Down Expand Up @@ -355,7 +356,8 @@ module.exports = yeoman.Base.extend({
this.log(g.f('\nLet\'s add another %s property.',
this.displayName));
this.property();
}.bind(this));
}.bind(this)
);
}.bind(this));
}
},
Expand Down
25 changes: 17 additions & 8 deletions oracle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,25 @@ module.exports = yeoman.Base.extend({
checkConnector: function() {
try {
var m = require(
this.destinationPath('node_modules/loopback-connector-oracle'));
this.destinationPath('node_modules/loopback-connector-oracle')
);
this.log(chalk.green(g.f('Oracle connector is ready.')));
if (!this.options.connector && !this.options.driver) this.skip = true;
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND') {
// loopback-connector-oracle is not installed
this.log(chalk.red(
g.f('Module is not installed: ' + e)));
g.f('Module is not installed: ' + e)
));
this.options.connector =
e.message.indexOf('loopback-connector-oracle') !== -1;
this.options.driver =
e.message.indexOf('oracledb') !== -1;
} else {
// oracledb cannot be loaded due to dynamic lib issues
this.log(chalk.red(
g.f('Module oracledb fails to load: ' + e)));
g.f('Module oracledb fails to load: ' + e)
));
this.options.driver = true;
}
}
Expand Down Expand Up @@ -151,7 +154,8 @@ module.exports = yeoman.Base.extend({
// Delete node_modules/loopback-oracle-installer so that
// npm install loopback-connector-oracle will trigger post-install
var dir = this.destinationPath(
'node_modules/loopback-oracle-installer');
'node_modules/loopback-oracle-installer'
);
if (this.options.verbose) {
this.log('Removing directory: ' + dir);
}
Expand Down Expand Up @@ -186,7 +190,8 @@ module.exports = yeoman.Base.extend({
// so that the top-level oracledb will be used
var dir =
this.destinationPath(
'node_modules/loopback-connector-oracle/node_modules/oracledb');
'node_modules/loopback-connector-oracle/node_modules/oracledb'
);
if (this.options.verbose) {
this.log('Removing directory: ' + dir);
}
Expand All @@ -211,20 +216,24 @@ module.exports = yeoman.Base.extend({
// here as it's cached by previous require
// First check node_modules/oracledb
require(
this.destinationPath('node_modules/oracledb'));
this.destinationPath('node_modules/oracledb')
);
this.log(chalk.green(g.f('Oracle driver is ready.')));
} catch (e) {
try {
// Try the local oracledb inside loopback-connector-oracle
require(
this.destinationPath(
'node_modules/loopback-connector-oracle/node_modules/oracledb'));
'node_modules/loopback-connector-oracle/node_modules/oracledb'
)
);
this.log(chalk.green(g.f('Oracle driver is ready.')));
} catch (e) {
this.log(chalk.red(g.f('Oracle driver fails to load: ' + e)));
this.log(
chalk.red(g.f('Please try `lb oracle --driver` or ' +
'follow instructions at ' + INSTALL_URL + '.')));
'follow instructions at ' + INSTALL_URL + '.'))
);
var done = this.async();

var prompts = [
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"devDependencies": {
"bluebird": "^3.1.1",
"chai": "^3.2.0",
"eslint": "^4.19.1",
"eslint-config-loopback": "^10.0.0",
"eslint": "^5.2.0",
"eslint-config-loopback": "^11.0.0",
"mocha": "^3.2.0",
"nock": "^9.0.14",
"rimraf": "^2.6.1",
Expand Down
6 changes: 4 additions & 2 deletions remote-method/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ module.exports = yeoman.Base.extend({
verb: answers.httpVerb || answers.customHttpVerb,
});
this.log(g.f(
'\nLet\'s add another endpoint, enter an empty name when done.'));
'\nLet\'s add another endpoint, enter an empty name when done.'
));
this.askForEndpoints();
}.bind(this));
}.bind(this));
Expand Down Expand Up @@ -343,7 +344,8 @@ module.exports = yeoman.Base.extend({
description: answers.returnsDes,
});
this.log(g.f(
'\nLet\'s add another return argument. Enter empty name when done.'));
'\nLet\'s add another return argument. Enter empty name when done.'
));
this.askForReturns();
}.bind(this));
}.bind(this));
Expand Down
3 changes: 2 additions & 1 deletion soap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ module.exports = yeoman.Base.extend({
if (!err) {
self.log(
chalk.green(g.f('Models are successfully generated from ' +
'{{WSDL}}.')));
'{{WSDL}}.'))
);
}
helpers.reportValidationError(err, self.log);
done(err);
Expand Down
9 changes: 6 additions & 3 deletions swagger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ module.exports = yeoman.Base.extend({
function(done) {
// Find existing model definitions
wsModels.ModelDefinition.find(
{where: {name: {inq: self.modelNames}}}, done);
{where: {name: {inq: self.modelNames}}}, done
);
},
function(done) {
wsModels.ModelConfig.find(
{where: {name: {inq: self.modelNames}}}, done);
{where: {name: {inq: self.modelNames}}}, done
);
}],
function(err, objs) {
if (err) {
Expand Down Expand Up @@ -347,7 +349,8 @@ module.exports = yeoman.Base.extend({
if (!err) {
self.log(
chalk.green(g.f('Models are successfully generated from ' +
'{{swagger spec}}.')));
'{{swagger spec}}.'))
);
}
helpers.reportValidationError(err, self.log);
done(err);
Expand Down
6 changes: 4 additions & 2 deletions test/acl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ describe('loopback:acl generator', function() {
{
name: 'Location',
facetName: 'common',
}, done);
});
}, done
);
}
);
});

it('adds an entry to models.json', function(done) {
Expand Down
14 changes: 12 additions & 2 deletions test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ describe('loopback:app generator', function() {
gen.run(function(err) {
expect(err.message).to.eql(
'Invalid LoopBack version: invalid-version. ' +
'Available versions are 2.x, 3.x.');
'Available versions are 2.x, 3.x.'
);

// a way to get around Workspace.copyRecursive not being properly
// restored to its original method
gen.emit('end');
done();
});
});
Expand All @@ -235,7 +240,12 @@ describe('loopback:app generator', function() {
gen.run(function(err) {
expect(err.message).to.eql(
'Invalid template: invalid-template. Available templates for 3.x ' +
'are api-server, empty-server, hello-world, notes');
'are api-server, empty-server, hello-world, notes'
);

// a way to get around Workspace.copyRecursive not being properly
// restored to its original method
gen.emit('end');
done();
});
});
Expand Down
6 changes: 4 additions & 2 deletions test/bluemix.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ describe('loopback:bluemix generator', function() {
assert.equal('string', typeof config.space.name);
done();
});
});
}
);

itSkipIf(!process.env.BLUEMIX_EMAIL || !process.env.BLUEMIX_PASSWORD)(
'should login with SSO passcode', function(done) {
Expand All @@ -211,7 +212,8 @@ describe('loopback:bluemix generator', function() {
assert.equal('string', typeof config.space.name);
done();
});
});
}
);
});

function givenBluemixGenerator(args) {
Expand Down
9 changes: 6 additions & 3 deletions test/datasource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ describe('loopback:datasource generator', function() {

datasourceGen.run(function() {
var pkg = fs.readFileSync(
path.join(SANDBOX, 'package.json'), 'UTF-8');
path.join(SANDBOX, 'package.json'), 'UTF-8'
);
pkg = JSON.parse(pkg);
// eslint-disable-next-line no-unused-expressions
expect(pkg.dependencies['loopback-connector-rest']).to.exist;
Expand All @@ -91,7 +92,8 @@ describe('loopback:datasource generator', function() {

datasourceGen.run(function() {
var pkg = fs.readFileSync(
path.join(SANDBOX, 'package.json'), 'UTF-8');
path.join(SANDBOX, 'package.json'), 'UTF-8'
);
pkg = JSON.parse(pkg);
// eslint-disable-next-line no-unused-expressions
expect(pkg.dependencies.lodash).to.exist;
Expand Down Expand Up @@ -274,7 +276,8 @@ describe('loopback:datasource generator', function() {
var datasources = Object.keys(readDataSourcesJsonSync('server'));
expect(datasources).to.not.include('ds-object-storage');
var pkg = fs.readFileSync(
path.join(SANDBOX, 'test-app', 'package.json'), 'UTF-8');
path.join(SANDBOX, 'test-app', 'package.json'), 'UTF-8'
);
pkg = JSON.parse(pkg);
// eslint-disable-next-line no-unused-expressions
expect(pkg.dependencies['loopback-component-storage']).to.exist;
Expand Down
9 changes: 6 additions & 3 deletions test/export-api-def.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ describe('loopback:export-api-def generator', function() {
function(err, model) {
test.Model = model;
done(err);
});
}
);
});

before(function installDependencies(done) {
Expand Down Expand Up @@ -67,7 +68,8 @@ describe('loopback:export-api-def generator', function() {
expect(content).to.have.property('basePath');
expect(content).to.have.property('info');
expect(content.info).to.have.property(
'title', 'test-app');
'title', 'test-app'
);
expect(content).to.have.property('tags');
expect(content.consumes).to.have.members([
'application/json',
Expand Down Expand Up @@ -96,7 +98,8 @@ describe('loopback:export-api-def generator', function() {
expect(content).to.have.property('basePath');
expect(content).to.have.property('info');
expect(content.info).to.have.property(
'title', 'test-app');
'title', 'test-app'
);
expect(content).to.have.property('tags');
expect(content.consumes).to.have.members([
'application/json',
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/help-texts/loopback_app_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Options:
--skip-install # Do not install npm dependencies Default: false
--skip-next-steps # Do not print "next steps" info
--explorer # Add Loopback Explorer to the project (true by default)
--loopbackVersion # Select the LoopBack version
--template # Set up the LoopBack application template
--bluemix # Set up as a Bluemix app

Arguments:
Expand Down
9 changes: 6 additions & 3 deletions test/middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ describe('loopback:middleware generator', function() {
});

var builtinSources = Object.keys(
readMiddlewaresJsonSync('server').routes);
readMiddlewaresJsonSync('server').routes
);
modelGen.run(function() {
var newSources = Object.keys(readMiddlewaresJsonSync('server').routes);
var expectedSources = builtinSources.concat(['my-middleware-3']);
Expand All @@ -91,10 +92,12 @@ describe('loopback:middleware generator', function() {
});

var builtinSources = Object.keys(
readMiddlewaresJsonSync('server')['routes:after'] || {});
readMiddlewaresJsonSync('server')['routes:after'] || {}
);
modelGen.run(function() {
var newSources = Object.keys(
readMiddlewaresJsonSync('server')['routes:after']);
readMiddlewaresJsonSync('server')['routes:after']
);
var expectedSources = builtinSources.concat(['my-middleware-4']);
expect(newSources).to.have.members(expectedSources);
done();
Expand Down
Loading