node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

aureooms-node-package

node-package

JavaScript code bricks package helpers as a npm module.

NPM license NPM version Build Status Coverage Status Dependencies Status devDependencies Status Code Climate NPM downloads per month GitHub issues

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:

  • install npm
  • install bower
  • install sak
  • log in for npm in the terminal

The following command will:

  1. Create a new directory named js-<namespace> in the current working directory;
  2. Initialize a new git repository in this directory;
  3. Create a repository named js-<namespace> on github.com for <username>;
  4. Add an AGPL LICENSE file to the repository;
  5. Configure the local git repository with https://<username>@github.com/<username>/js-<namespace> as its origin remote;
  6. Create a gh-pages branch that will be populated by the npm run doc command using groc;
  7. Create a README.md with badges;
  8. Create a configuration file for travis-ci.org or drone.io;
  9. Create a pkg.json, a package.json, a bower.json and a component.json;
  10. Register a package named <username>-js-<namespace> on npm and bower.

After running the command you will have to:

  1. Register the github.com repository on travis-ci.org or drone.io;
  2. Register the github.com repository on codeclimate.com;
  3. Register the github.com repository on coveralls.io.

The sak $ command to run is:

$ codebricks new <namespace> <description> --keywords <keyword>* --username <username> --ci (travis-ci|drone.io)

Or the shortened version of it:

$ cdb n <namespace> <description> -k <keyword>* -u <username> -c (travis-ci|drone.io)

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"{
    "doc": "./node_modules/.bin/groc",
    "build": "./node_modules/.bin/aureooms-node-package-build",
    "test": "./node_modules/.bin/aureooms-node-package-test"
},
...

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:

{
    "name": "{namespace}",
    "code": {
        "main": [ "js", "dist", "<namespace>.js" ],
        "test": [ "test", "js" ]
    },
    "debug": false,
    "src": "js/src/",
    "out": "js/dist/"
}

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.