node package manager


SpringbokJS Library


⚠️ After 9.0.0, springbokjs-library doesn't supports node < 3.1.0

Recommended version: node > 4.1.0 with --es_staging

npm install -g yo generator-springbokjs-library
yo springbokjs-library
npm install --save-dev springbokjs-library && npm install --save babel-runtime
include node_modules/springbokjs-library/
include node_modules/springbokjs-library/
include node_modules/springbokjs-library/
make init
# is equals to: make install-config-files install-scripts install-githooks

You can now use make watch !

Write code in es6 in the src directory, it's then transpiled with babel to lib. Use the task make build or make watch to transpile the code.

Eslint and jscs are used to ensure a common coding style. I mostly follow the Airbnb coding style except for this points:

  • 4 spaces indentation (instead of 2)
  • Maximum line length is 120
  • Always use { } to delimit blocks
  • Don't use void
  • You can declare multiple var one the same line if there are all undefined (let i, j;)
  • " is allowed to escape ': "'hi'" is more readable than '\'hi\''

You can check the code by running the task make lint. With an editor, install the plugins to validate the code as you type !

jsdoc allows to document the code and generate the api. istanbul is used to generate the coverage. You can generate the documentation with make docs, a shortcut for make api tests-coverage

Tests are in the directory tests/src, transpiled with babel to tests/lib. Use the task make tests to run the tests. Compilation to tests/lib is done by make build or make watch. Prefer to follow the structure in tests/src like src and tests each file.

  • install-config-files: install symbolic links to .jscsrc, .jshintrc, .eslintrc, .babelrc and .npmignore
  • install-scripts: modify package.json to install npm scripts and hooks
  • update: run npm prune and npm install
  • clean: remove lib, tests/lib and dist directories.
  • build: clean the directory, build src to lib, tests/src to tests/lib and then lint the code
  • watch: clean then build and watch src and tests/src directories
  • lint: execute jshint (if .jshintrc exists), jscs and eslint (if .eslintrc exists)
  • lint-fix: execute jscs -x
  • tests: run tests with mocha (execute build/watch before if needed)
  • docs: run api and tests-coverage
  • api: generate api with jsdoc
  • tests-coverage: generate coverage documentation

In the process, this will pre-generate a changelog based on the commits, then open nano so you can adapt it if you want.