Skip to content

Commit

Permalink
Update project dependencies (#174)
Browse files Browse the repository at this point in the history
* Update project dependencies

- Mongoose: 4.12 -> 5.1

- ESLint: 4.4 -> 4.19

- Mockgoose: dropped in favor of mongodb-memory-server

* Upgrade TravisCI Node versions

* Upgrade gulp-nsp (and consequently nsp itself)

* Disable NSP

* Add Node v6 and v7 to TravisCI

* Fix tests by waiting for mongoose/mongodb to disconnect
  • Loading branch information
pedro-victor authored and diegohaz committed May 19, 2018
1 parent 4a6c3d5 commit ebc9a01
Show file tree
Hide file tree
Showing 8 changed files with 314 additions and 513 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ cache:
directories:
- node_modules
node_js:
- v4
- v5
- v6
- v7
- v8
- v9
addons:
apt:
sources:
Expand Down
16 changes: 9 additions & 7 deletions generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
"babel-jest": "^20.0.3",
"cross-env": "^5.0.5",
"dotenv-safe": "^4.0.3",
"eslint": "^4.4.1",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-promise": "^3.0.0",
"eslint-plugin-standard": "^3.0.1",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.1.0",
"jest-cli": "^20.0.4",
"mockgoose": "^6.0.8",
"mongodb-memory-server": "^1.7.3",
"nock": "^9.0.2",
"nodemon": "^1.10.2",
"opn-cli": "^3.1.0",
Expand Down Expand Up @@ -58,9 +60,9 @@
<%_ if (generateAuthApi) { _%>
"jsonwebtoken": "^8.1.0",
<%_ } _%>
"mongoose": "^4.12.4",
"mongoose": "^5.1.0",
"mongoose-create-unique": "^0.4.4",
"mongoose-keywords": "^0.3.2",
"mongoose-keywords": "^0.4.0",
"morgan": "^1.7.0",
<%_ if (generateAuthApi) { _%>
"passport": "^0.4.0",
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import api from './api'
const app = express(apiRoot, api)
const server = http.createServer(app)

mongoose.connect(mongo.uri, { useMongoClient: true })
mongoose.connect(mongo.uri)
mongoose.Promise = Promise

setImmediate(() => {
Expand Down
9 changes: 1 addition & 8 deletions generators/app/templates/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ const config = {
}
}
},
test: {
mongo: {
uri: 'mongodb://localhost/<%= slug %>-test',
options: {
debug: false
}
}
},
test: { },
development: {
mongo: {
uri: 'mongodb://localhost/<%= slug %>-dev',
Expand Down
17 changes: 11 additions & 6 deletions generators/app/templates/test/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { EventEmitter } from 'events'
import mockgoose from 'mockgoose'
import MongodbMemoryServer from 'mongodb-memory-server'
import mongoose from '../<%= srcDir %>/services/mongoose'
import { mongo } from '../<%= srcDir %>/config'

EventEmitter.defaultMaxListeners = Infinity
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000
Expand All @@ -22,13 +21,19 @@ global.TypeError = TypeError
global.parseInt = parseInt
global.parseFloat = parseFloat

let mongoServer

beforeAll(async () => {
await mockgoose(mongoose)
mongoose.connect(mongo.uri)
mongoServer = new MongodbMemoryServer()
const mongoUri = await mongoServer.getConnectionString()
await mongoose.connect(mongoUri, (err) => {
if (err) console.error(err)
})
})

afterAll(() => {
mongoose.disconnect()
afterAll(async () => {
await mongoose.disconnect()
await mongoServer.stop()
})

afterEach(async () => {
Expand Down
10 changes: 5 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
// var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
var coveralls = require('gulp-coveralls');

Expand All @@ -17,9 +17,9 @@ gulp.task('lint', function () {
.pipe(eslint.failAfterError());
});

gulp.task('nsp', function (cb) {
nsp({package: path.resolve('package.json')}, cb);
});
// gulp.task('nsp', function (cb) {
// nsp({package: path.resolve('package.json')}, cb);
// });

gulp.task('pre-test', function () {
return gulp.src(['generators/!(templates)**/index.js'])
Expand Down Expand Up @@ -58,5 +58,5 @@ gulp.task('coveralls', ['test'], function () {
.pipe(coveralls());
});

gulp.task('prepublish', ['nsp']);
gulp.task('prepublish', [/* 'nsp' */]);
gulp.task('default', ['test', 'coveralls']);
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,13 @@
"gulp-istanbul": "^1.0.0",
"gulp-line-ending-corrector": "^1.0.1",
"gulp-mocha": "^2.0.0",
"gulp-nsp": "^2.1.0",
"gulp-plumber": "^1.0.0",
"jest-cli": "^20.0.4",
"jsonwebtoken": "^8.1.0",
"mockgoose": "^6.0.8",
"mongoose": "^4.12.4",
"mongodb-memory-server": "^1.7.3",
"mongoose": "^5.1.0",
"mongoose-create-unique": "^0.4.4",
"mongoose-keywords": "^0.3.2",
"mongoose-keywords": "^0.4.0",
"morgan": "^1.7.0",
"nock": "^9.0.2",
"nodemon": "^1.10.2",
Expand Down
Loading

0 comments on commit ebc9a01

Please sign in to comment.