Node Developer Boilerplate
Node / npm Boilerplate with Babel ES6 / ES7 Support, Testing, CI Integration, Code Coverage, JS Standard Style, Commit Guidelines, Git Hooks, Security Checks, Automatic Semantic Versioning, Benchmarking, Debugging, Monitoring, Source Map Generation, Auto Reload, Linting and more cool stuff ...
Project Status
Whats inside?
- Node optimized ES6 / ES7 transpilation with Babel
- ES6+ aware minifier based on the Babel toolchain babili
- Auto Reload while developing with nodemon
- Node.js Server Performance Monitoring with nodejs-dashboard
- Code Linting with ESLint
- Code Benchmark Testing with benchmark.js
- ES6+ Testing via babel-register with Mocha & Chai
- HTML Export from the Test results via mochawesome
- ES6+ Code Coverage with babel-istanbul
- Ready for Continuous Integration & Delivery with travis-ci
- Javascript Standard Coding Style ready
- Standard Releasing via Standard Version
- Use Standard Conventional Commit Messages via commitizen
- Debugging with babel-node-debug
- Source Map Generation
- Vulnerability scan via snyk
- Check for latest versions of dependencies via npm-check-updates
- Run Git Hooks before commit via ghooks
- Automatically generate a Changelog from git metadata via commit convention
- npm scripts to get quick up and running
External Services
all used services are free to use for open source projects and quick super quick registration via github authentication
- github - Modern Version Control System
- npmjs - Javascript Package Registry (optional: only if you want to publish to the npm registry)
- travis-ci - Continuous Integration & Delivery
- codecov.io - Code Coverage
- snyk.io - Fix and prevent known vulnerabilities in dependencies
- greenkeeper.io - Automated Dependency Management
In case you have to pass some secure token to Travis-CI i recommend the travis-cli tool for decryption and lots of other features. You can read more about it here. Linux / OS X Installation via sudo gem install travis
. You can also set Token on GitHub in the Repository Settings.
Quickstart (npm)
git clone https://github.com/ellerbrock/node-developer-boilerplate
cd node-developer-boilerplate
npm install
Quickstart (yarn)
git clone https://github.com/ellerbrock/node-developer-boilerplate
cd node-developer-boilerplate
yarn
Scripts
-
npm run benchmark
- run benchmark tests withbenchmark.js
-
npm run benchmark:watch
- run benchmark tests withbenchmark.js
and watch for file changes -
npm run build
- transpile and minify ES6+ code and generate Source Maps withbabel
&babili
-
npm run clean
- deletes the dist folder (Cross Platform Support viaShell.js / shx
) -
npm run debug
- run node in debug mode -
npm run git:add
- add all files to git and print the status (ignore files via.gitignore
) -
npm run git:commit
- commit conventional messages via commitizen` -
npm run git:push
- -
npm run lint
- code linting witheslint
-
npm run lint:fix
- fix problems automatically witheslint
-
npm run release
- Automatic versioning and CHANGELOG management viaStandard Version
-
npm run scan:security
- run vulnerability tests via the node security platformnsp
-
npm run scan:updates
- check for latest versions of dependencies viancu
-
npm run serve
- serve production files from the./dist
folder vianode
-
npm run setenv:dev
- deactivate npm production mode -
npm run setenv:prod
- activate npm production mode -
npm run test:export
- export tests results as html files in the./reports
folder viamochasome
-
npm run test:watch
- run tests withmocha
andchai
and watch for changes -
npm start src
- execute code with life reload vianodemon
transpiled withbabel-node
(add the folder and script name if not index.js as argument) -
npm test
- run tests withmocha
andchai
with spec as reporter -
npm test:export
- export your test results viamochawesome
as html -
npm test:watch
- run tests withmocha
andchai
with spec as reporter in watch mode
"scripts": {
"benchmark": "babel-node benchmark",
"benchmark:watch": "nodemon $2 --exec babel-node benchmark",
"pre-build": "npm run clean",
"build": "cross-env NODE_ENV=production babel -s true src -d dist",
"clean": "shx rm -rf dist",
"coverage": "cross-env NODE_ENV=test babel-istanbul cover src/*.js _mocha --report lcovonly -- -R spec",
"coverage:check": "cross-env NODE_ENV=test babel-istanbul check-coverage --statements 100 --branches 100 --functions 100 --lines 100",
"coverage:travis": "cross-env NODE_ENV=test npm run coverage && codecov",
"debug": "nodemon $2 --exec babel-node --debug",
"git:add": "git add --all && git status",
"git:commit": "npm run git:add && git-cz",
"git:push": "git push --follow-tags",
"lint": "eslint src",
"lint:fix": "eslint --fix src",
"pre-monitor": "npm run build",
"monitor": "nodejs-dashboard node dist",
"pre-release": "npm update && npm run clean && npm run lint:fix && npm run scan:security && npm run setenv:prod && npm run test && npm run build",
"release": "standard-version",
"post-release": "npm run setenv:dev",
"scan:security": "snyk test",
"scan:updates": "ncu",
"serve": "node dist",
"setenv:dev": "npm config set production false",
"setenv:prod": "npm config set production true",
"start": "nodemon $2 --exec babel-node",
"test": "cross-env NODE_ENV=test mocha -c -S -R spec --compilers js:babel-register --check-leaks",
"test:watch": "cross-env NODE_ENV=test npm test -- -w",
"test:export": "cross-env NODE_ENV=test mocha -S -R mochawesome --compilers js:babel-register --reporter-options reportDir=reports --check-leaks"
}
ECMAScript 2015 / ES6
Node.js comes with a huge set of ES6 features out of the box. A detailed list of supported features can be found at http://node.green. To speed things up and avoid transpiling natively supported features i recommend to install only the missing parts in your current Node Version:
-
npm install --save-dev babel-preset-es2015-node6
- Node.js Version 6x -
npm install --save-dev babel-preset-es2015-node5
- Node.js Version 5x -
npm install --save-dev babel-preset-es2015-node4
- Node.js Version 4x -
npm install --save-dev babel-preset-es2015
- for all Node.js Versions
package.json
To avoid messing around with separate config files like .babelrc, .eslintrc.json and others we can put all that stuff directly in our package.json file:
{"files": [
"dist",
"readme.md"
],
"config": {
"commitizen": {
"path": "./node_modules/standard-changelog"
},
"ghooks": {
"pre-commit": "npm run clean && npm run lint:fix && npm test && npm run coverage && npm run build"
}
},
"babel": {
"presets": [
"es2015-node6",
"stage-0"
],
"env": {
"production": {
"presets": [
"babili"
]
}
}
},
"eslintConfig": {
"extends": "standard",
"installedESLint": true,
"plugins": [
"standard",
"promise"
]
},
"snyk": true
Contact / Social Media
Get the latest News about Web Development, Open Source, Tooling, Server & Security
License
Copyright (c) 2016 Maik Ellerbrock