Create package.json file
//npm settings npm set init-author-name 'username' npm set init-author-email 'username@gmail.com' npm set init-author-url 'http://username.com' npm set save-exact true //create package.json npm init
Pubish to github and tag it
git status git add -A git commit -m "commit message" git push git tag 1.0.0 git push --tags
Publish to npm
npm publish
npm info <project_name>
Release a new version
1. according to the changes to change the version in package.json 2. publish to git 3. publish tag to git 4. npm publish 5. npm info
Publishing a beta version
1. In package.json: "version": "1.2.0-beta.0", 2. publish to git 3. tag it in git 4. npm publish --tag beta 5. npm info //install npm install starwars-ns@beta npm install starwars-ns@1.2.0-beta.0
Mocha, chai testing:
var expect = require('chai').expect; var starWars = require('./index'); describe('starwars-names', function() { describe('all', function(){ //check return type it('should be an array of strings', function(){ expect(starWars.all).to.satisfy(isArrayOfString); function isArrayOfString(array){ return array.every(function(item){ return typeof item === 'string'; }); } }); //ccheck one of the value it('should includ Asajj Ventress', function(){ expect(starWars.all).to.include('Asajj Ventress'); }); }); describe('random', function(){ it('should return one of the starwar names form all', function(){ expect(starWars.all).to.include(starWars.random()); }) }); });
semantic-release:
npm install -g semantic-release-cli //Install //RUN semantic-release-cli setup
Writing conventional commits with commitizen:
npm install -D cz-conventional-changelog
npm install -D commitizen
Add script:
"commit": "git-cz"
Add Config:
"czConfig": { "path": "node_modules/cz-conventional-changelog" },
Add Badges:
![Downloads](https://img.shields.io/npm/dm/angular-md-table.svg) ![npm](https://img.shields.io/npm/v/angular-md-table.svg) ![node](https://img.shields.io/node/v/angular-md-table.svg)
http://shields.io/