Npm
From Wiki2
Node package manager
from egghead series https://github.com/kentcdodds/starwars-names.git
versioning
1.0.0 is typical with the major release number getting changed any time the api changes. Adding features would change the second digit and bug fixes would change the last digit.
process
- modify package.json to new version, say 1.1.0
git add . -A git commit -m 'about new version' git push git tag 1.1.0 git push --tags npm publish
beta process
from current version, say 1.3.0 to add a beta feature bump the version to 1.4.0-beta.0
- modify package.json to new version, say 1.4.0-beta.0
git add . -A git commit -m 'about new beta version' git push git tag 1.4.0-beta.0 git push --tags npm publish --tag beta
testing
npm install mocha chai --save-dev same as npm i -D mocha chai
create a test file src/index.test.js
var expect = require('chai').expect; var starWars = require('./index'); describe('starwars-names', function() { describe('all', function() { it('should be an array of strings', function() { expect(starWars.all).to.satisfy(isArrayOfStrings); function isArrayOfStrings(array) { return array.every(function(item) { return typeof item === 'string'; }); } }); it('should contain `Luke Skywalker`', function() { expect(starWars.all).to.include('Luke Skywalker'); }); }); describe('random', function() { it('should return a random item from the starWars.all', function() { var randomItem = starWars.random(); expect(starWars.all).to.include(randomItem); }); }); });
change package.json to run tests (automatically on update -w)
"scripts": { "test": "mocha src/index.test.js -w" },
npm test