node-package
JavaScript code bricks package helpers as a npm module.
Used in js-algo, js-data-structures and all their subpackages to handle building and testing.
Use together with sak to get automated package creation as well as duo, component, bower, and npm registration and releases.
Automated package creation and registration:
To run the following command you must:
The following command will:
- Create a new directory named
js-<namespace>
in the current working directory; - Initialize a new git repository in this directory;
- Create a repository named
js-<namespace>
on github.com for<username>
; - Add an AGPL LICENSE file to the repository;
- Configure the local git repository with
https://<username>@github.com/<username>/js-<namespace>
as its origin remote; - Create a gh-pages branch that will be populated by the
npm run doc
command using groc; - Create a
README.md
with badges; - Create a configuration file for travis-ci.org or drone.io;
- Create a
pkg.json
, apackage.json
, abower.json
and acomponent.json
; - Register a package named
<username>-js-<namespace>
on npm and bower.
After running the command you will have to:
- Register the github.com repository on travis-ci.org or drone.io;
- Register the github.com repository on codeclimate.com;
- Register the github.com repository on coveralls.io.
The sak $ command to run is:
$ codebricks new <namespace> <description> --keywords <keyword>* --username <username> --ci
Or the shortened version of it:
$ cdb n <namespace> <description> -k <keyword>* -u <username> -c
Note that --ci travis-ci
is the default. --keywords
can be left empty.
If --username
is not given then either sak
can find it in your ~/.sak
config file or will prompt for it.
Automated releases
Release a major version for duo, component, bower, and npm:
$ npm release major
Release a minor version for duo, component, bower, and npm:
$ npm release minor
Release a patch version for duo, component, bower, and npm:
$ npm release patch
Release version <semver>
for duo,
component,
bower, and npm:
$ npm release <semver>
Note that $ npm release <...>
can be shortened to $ npm r <...>
.
How does the doc, build and test commands work?
Running the package creation command explained earlier will install
aureooms-node-package
as a development dependency of your package. This is
equivalent to running:
npm install --save-dev aureooms-node-package
This will give your project access to tree runnables located in
node_modules/.bin
. The package creation command will add these scripts to
your package.json
:
..."scripts": ,...
It will also create a pkg.json
file, assuming your code tree is located in
js/src
and your testing index.js
is located in test/js
:
Running npm run build
will parse your code tree recursively and in
lexicographical order, concatenating all the files it encounters in
js/dist/<namespace>.js
and minify this file to js/dist/<namespace>.min.js
.
Running npm run doc
will generate the documentation using
groc and publish it on
github.com (gh-pages branch). Before running this command you must make
sure to have committed all your local changes.
Running npm run test
will test the main code file using the test code
referenced by test/js/index.js
.