zoukankan      html  css  js  c++  java
  • [Javascript] How to write a Javascript libarary

    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/

  • 相关阅读:
    03构建之法阅读笔记3—团队模式
    软件工程学习进度博客10
    第一阶段冲刺10
    第一阶段冲刺9
    第一阶段冲刺8
    第一阶段冲刺7
    第一阶段冲刺6
    第一阶段冲刺5
    团队项目冲刺第六天
    团队项目冲刺第五天
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4756412.html
Copyright © 2011-2022 走看看