A boilerplate for your rock-solid node.js projects. Includes static code analysis, development and building tools.
-
Babel transpiling
npm start
(using babel)Write your code in ES6.
-
Watch files and reload
npm run dev
(using nodemon)Run your script and watch for changes.
-
Debugging
npm run debug
(using babel-node-debug)Debug your application using a babel-compatible version of node-inspector.
-
Test runner
npm test
(using lab)Write your tests in the
test
folder and run them withnpm test
. -
Code coverage
npm run coverage
(using lab)Lab can also calculate the code coverage.
-
Code linting
npm run lint
(using xo)Lint your code (even ES6/7 and JSX).
-
Code format
npm run format
(using xo)Beautify and format you code. Fix errors found by xo
-
Recognize duplicate code
npm run inspect
(using jsinspect)Recognize duplicate, copy-pasted and similar code.
-
License checker
npm run licenses
(using license-checker)Print the link and the license type of each dependency
-
Package building
npm run build
(using nar)You can build an executable file out of your project including all dependencies.
Please refer to nar's documentation if you like to include a custom node.js version or to build a package for a different system-architecture/OS. You should simple edit the
build
property in thescripts
section ofpackage.json
to something like:
nar create --executable --os darwin --arch x64 --node 0.12.0
-
Find vulnerabilities
npm run deps:sec
(using nsp)nsp (Node Security Project) will check if any dependency is affected by a known vulnerability.
-
Keep dependencies up-to-date
npm run deps:updates
(using david)David keeps dependencies up-to-date and will help you to update them.
-
README generator
npm run readme
(using node-readme)Generate a README like this from an ES6 template extracting data from
package.json
. Edit the.README.md
template and run the command. Check the node-readme documentation for all available variables/functions.Do not edit the
README.md
in your project folder, since this will be overwritten running thenpm run readme
command. -
Git hooks (using husky)
Custom
precommit
andprepush
are defined in order to run tests (and vulnerabilities discovery) on commit and push. You can define your own in thepackage.json
git clone https://github.com/g-div/nodeplate
cd nodeplate
npm install
Use npm
commands listed above as following:
npm run lint
npm run test:deps
or use npm-run-all:
npm-run-all --parallel lint test:deps test --sequential build
- npm run readme :
node-readme
- npm run precommit :
npm test
- npm run prepush :
npm-run-all lint test test:deps
- npm run start :
npm run boot
- npm run boot :
babel-node $npm_package_main
- npm run dev :
nodemon --exec babel-node -- $npm_package_main
- npm run debug :
babel-node-debug $npm_package_main
- npm run lint :
xo
- npm run format :
xo --fix
- npm run inspect :
jsinspect
- npm run test :
lab
- npm run coverage :
lab -r lcov
- npm run build :
nar create --executable
- npm run deps:sec :
nsp audit-package
- npm run deps:updates :
david
- npm run test:deps :
npm-run-all deps:sec deps:updates
- npm run licenses :
license-checker
Package | Version | Dev |
---|---|---|
babel | ^5.8.29 | ✖ |
babel-node-debug | ^1.3.0 | ✔ |
david | ^6.4.0 | ✔ |
husky | ^0.10.1 | ✔ |
jsinspect | ^0.7.0 | ✔ |
lab | ^7.0.0 | ✔ |
license-checker | ^4.2.0 | ✔ |
nar | ^0.3.20 | ✔ |
node-readme | ^0.1.9 | ✔ |
nodemon | ^1.8.0 | ✔ |
npm-run-all | ^1.2.12 | ✔ |
nsp | ^1.1.0 | ✔ |
xo | ^0.10.1 | ✔ |
- Documentation tool (JSDoc, dox, ...)
- Aggregate commands using npm-run-all
- Use a scaffolding system (init)
- Consider standard instead of xo
- Fix nar: should be able to use $npm_package_main variable (see h2non/nar#115 and h2non/nar#116)
- Consider strong-build instead of nar
- Consider semantic-release
- Consider hotel and minihost
Contributions welcome; Please submit all pull requests the against master branch.
g-div http://github.com/g-div