A no-frills pre-bootstraped NodeJS repo to quick start your NodeJS projects.
- NPM package.json actions
- Gulp / Basic Gulp Script
- ESLint / ESLint Configuration
- Mocha / Unit.js
- Istanbul / nyc
- Codacy Integration / Coverage
- Cross Env (for environment variables)
- Basic TravisCI Configuration
To use this repository as a base for your own projects, simply clone this repo and then remove .git folder from the project root.
NPM actions are included to facilitate most project needs
The build process utilizes Gulp and the included gulpfile.js
. The defaul
gulp taks runs linting and testing only.
However, this gulpfile comes preloaded with a number of other helpful tasks that include linting, testing, and code
reformatting. Changes and additional tasks can be added based on the requirements and needs of the project's build,
packaging and deployment goals.
The linting process utilizes ESLint and is preloaded with over 150 rules to validating and quality checking of code.
The ESLint Rules can be altered by editing the .eslintrc.json
file.
The testing process utilizes Mocha and Unit.JS, and includes a base unit test file located in the test/
folder.
Additional test files and test can be added to the included test/index.js
file or within the test/
folder itself.
Further, the tests are piped through Istanbul by using NYC to provide test coverage reporting
Test coverage reporting is facilitated using Instanbul through NYC and then pushing the reporting to Codacy. The reporting integrates with Codacy and requires extra steps outlined below.
Some automatic code styling fixes are possible with the preloaded ESLint rules. This command runs ESLint in fix mode to correct styling issues.
Automatic code prettification for standardized code styling is performed by Prettier, the outputted prettified code is
then sent through ESLint in fix mode to correct some minor styling issues that Prettier introduces. The
prettier options can be configured in the .prettierrc.json
file, and if
no piping through ESLint is desired, then the pretty
action in the gulpfile.js
can be modified. However, if this is
desired then all formatting rules in .eslintrc.json
should be removed.
It is highly recommended that you install the TravisCI CLI tool before
beginning. The .travis.yml
file is included for use with TravisCI.
In order for Codacy Coverage to work this to work, the Codacy Project Token must be added to your environment variables.
This can be done by setting the appropriate environment variable:
export CODACY_PROJECT_TOKEN=<Token_from_Codacy>
Or, by updating the package.json
file to update the coverage action as follows
"coverage": "cross-env CODACY_PROJECT_TOKEN=<Token_from_Codacy> nyc --reporter=lcov mocha && cat ./coverage/lcov.info | codacy-coverage"
When integrating with Travis you will also need to configure travis with the environment variable for building by performing:
travis encrypt CODACY_PROJECT_TOKEN=<Token_from_Codacy> --add