Skip to content

Commit b9d30d5

Browse files
committed
Replace npm with yarn
Closes #156
1 parent 75338b7 commit b9d30d5

File tree

4 files changed

+4867
-23
lines changed

4 files changed

+4867
-23
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ language: node_js
22
node_js:
33
- "4.6"
44
- "6.9"
5-
- "7.0"
5+
- "7.2"
66
services:
77
- mongodb
88
cache:
99
directories:
1010
- node_modules
1111
git:
1212
depth: 3
13-
before_script:
14-
- npm prune
1513
after_script:
16-
- npm run report-coverage
14+
- yarn report-coverage

README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Heavily inspired from [Egghead.io - How to Write an Open Source JavaScript Libra
2525
| Authentication via JsonWebToken | Supports authentication using [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken). |
2626
| Code Linting | JavaScript code linting is done using [ESLint](http://eslint.org) - a pluggable linter tool for identifying and reporting on patterns in JavaScript. Uses ESLint with [eslint-config-airbnb](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb), which tries to follow the Airbnb JavaScript style guide. |
2727
| Auto server restart | Restart the server using [nodemon](https://github.com/remy/nodemon) in real-time anytime an edit is made, with babel compilation and eslint. |
28-
| ES6 Code Coverage via [istanbul](https://www.npmjs.com/package/istanbul) | Supports code coverage of ES6 code using istanbul and mocha. Code coverage reports are saved in `coverage/` directory post `npm test` execution. Open `coverage/lcov-report/index.html` to view coverage report. `npm test` also displays code coverage summary on console. Code coverage can also be enforced overall and per file as well, configured via .istanbul.yml |
28+
| ES6 Code Coverage via [istanbul](https://www.npmjs.com/package/istanbul) | Supports code coverage of ES6 code using istanbul and mocha. Code coverage reports are saved in `coverage/` directory post `yarn test` execution. Open `coverage/lcov-report/index.html` to view coverage report. `yarn test` also displays code coverage summary on console. Code coverage can also be enforced overall and per file as well, configured via .istanbul.yml |
2929
| Debugging via [debug](https://www.npmjs.com/package/debug) | Instead of inserting and deleting console.log you can replace it with the debug function and just leave it there. You can then selectively debug portions of your code by setting DEBUG env variable. If DEBUG env variable is not set, nothing is displayed to the console. |
3030
| Promisified Code via [bluebird](https://github.com/petkaantonov/bluebird) | We love promise, don't we ? All our code is promisified and even so our tests via [supertest-as-promised](https://www.npmjs.com/package/supertest-as-promised). |
3131
| API parameter validation via [express-validation](https://www.npmjs.com/package/express-validation) | Validate body, params, query, headers and cookies of a request (via middleware) and return a response with errors; if any of the configured validation rules fail. You won't anymore need to make your route handler dirty with such validations. |
@@ -44,41 +44,46 @@ git clone [email protected]:KunalKapadia/express-mongoose-es6-rest-api.git
4444
cd express-mongoose-es6-rest-api
4545
```
4646

47+
Install yarn:
48+
```js
49+
npm install -g yarn
50+
```
51+
4752
Install dependencies:
4853
```sh
49-
npm install
54+
yarn
5055
```
5156

5257
Start server:
5358
```sh
5459
# Start server
55-
npm start
60+
yarn start
5661

5762
# Selectively set DEBUG env var to get logs
58-
DEBUG=express-mongoose-es6-rest-api:* npm start
63+
DEBUG=express-mongoose-es6-rest-api:* yarn start
5964
```
6065
Refer [debug](https://www.npmjs.com/package/debug) to know how to selectively turn on logs.
6166

6267

6368
Tests:
6469
```sh
6570
# Run tests written in ES6 along with code coverage
66-
npm test
71+
yarn test
6772

6873
# Run tests on file change
69-
npm run test:watch
74+
yarn test:watch
7075

7176
# Run tests enforcing code coverage (configured via .istanbul.yml)
72-
npm run test:check-coverage
77+
yarn test:check-coverage
7378
```
7479

7580
Lint:
7681
```sh
7782
# Lint code with ESLint
78-
npm run lint
83+
yarn lint
7984

8085
# Run lint on any file change
81-
npm run lint:watch
86+
yarn lint:watch
8287
```
8388

8489
Other gulp tasks:
@@ -94,13 +99,13 @@ gulp
9499

95100
```sh
96101
# compile to ES5
97-
1. npm run build
102+
1. yarn build
98103

99104
# upload dist/ to your server
100105
2. scp -rp dist/ user@dest:/path
101106

102107
# install production dependencies only
103-
3. npm i --production
108+
3. yarn --production
104109

105110
# Use any process manager to start your services
106111
4. pm2 start dist/index.js
@@ -122,10 +127,10 @@ Logs stacktrace of error to console along with other details. You should ideally
122127
![Error logging](https://cloud.githubusercontent.com/assets/4172932/12563361/fb9ef108-c3cf-11e5-9a58-3c5c4936ae3e.JPG)
123128

124129
## Code Coverage
125-
Get code coverage summary on executing `npm test`
130+
Get code coverage summary on executing `yarn test`
126131
![Code Coverage Text Summary](https://cloud.githubusercontent.com/assets/4172932/12827832/a0531e70-cba7-11e5-9b7c-9e7f833d8f9f.JPG)
127132

128-
`npm test` also generates HTML code coverage report in `coverage/` directory. Open `lcov-report/index.html` to view it.
133+
`yarn test` also generates HTML code coverage report in `coverage/` directory. Open `lcov-report/index.html` to view it.
129134
![Code coverage HTML report](https://cloud.githubusercontent.com/assets/4172932/12625331/571a48fe-c559-11e5-8aa0-f9aacfb8c1cb.jpg)
130135

131136
## A Boilerplate-only Option

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66
"main": "index.js",
77
"private": false,
88
"engines": {
9-
"node": ">=4.6.x",
10-
"npm": ">=2.15.x"
9+
"node": ">=4.6.0",
10+
"npm": ">=2.15.9",
11+
"yarn": ">=0.17.9"
1112
},
1213
"scripts": {
1314
"start": "gulp serve",
1415
"build": "gulp",
1516
"lint": "esw *.js server config --color",
16-
"lint:watch": "npm run lint -- --watch",
17+
"lint:watch": "yarn lint -- --watch",
1718
"test": "NODE_ENV=test babel-node node_modules/.bin/isparta cover _mocha -- --ui bdd --reporter spec --colors --compilers js:babel-core/register ./server/**/*.test.js",
18-
"test:watch": "npm run test -- --watch",
19-
"test:check-coverage": "npm run test && istanbul check-coverage",
19+
"test:watch": "yarn test -- --watch",
20+
"test:check-coverage": "yarn test && istanbul check-coverage",
2021
"report-coverage": "coveralls < ./coverage/lcov.info"
2122
},
2223
"repository": {
@@ -89,7 +90,7 @@
8990
"license": "MIT",
9091
"config": {
9192
"ghooks": {
92-
"pre-commit": "npm run lint && npm test"
93+
"pre-commit": "yarn lint && yarn test"
9394
},
9495
"commitizen": {
9596
"path": "./node_modules/cz-conventional-changelog"

0 commit comments

Comments
 (0)