Skip to content

Latest commit

 

History

History
163 lines (122 loc) · 6.41 KB

README.md

File metadata and controls

163 lines (122 loc) · 6.41 KB

library-boilerplate

Rollup based javascript library boilerplate featuring Babel 7, ESLint, flow, jest, ESDoc, Rollup, semantic-release and live debugging.

Commitizen friendly coverage statements coverage lines coverage functions dependencies devDependencies semantic-release build status

library-boilerplate logo

Getting Started:

This boilerplate including a basic code to start creating a js based library.

Start with cloning the project:

$ git clone --depth=1 git://github.com/Ziv-Barber/library-boilerplate.git your-project-name
  • Remove the .git directory (rm -rf your-project-name/.git).
  • Edit package.json and change the name of the project to your project name.
  • The boilerplate without any changes supporting creating a library for both CommonJS, es6 modules, amd and browser. If you don't need all of this then just edit the rollup.config.js file and remove the inputs that you don't need.

Now, create a new github project and do:

$ git init
$ git remote add origin https://github.com/your-name/your-project-name.git
$ git add -A
$ npm run commit
$ git push origin master

This project is using semantic-release to automatic handling of the version of your library. To be able to automatic release a new version you must configure Travis-CI to your new project:

  • Go to https://travis-ci.org/ and either signup or signin.
  • Select your new project and click setting.
  • You MUST configure a token or semantic-release will not be able to commit changes:
    • Create a new token (see here how to do it).
    • Permissions needed in the github token:
      • repo:
        • repo:status
        • repo_deployment
        • public_repo
      • admin:org:
        • read:org
      • admin:repo_hook:
        • write:repo_hook
      • user:
        • user:email
    • In your Travis-CI project setting, go to the environment settings section and add a new environment variable with the name 'GH_TOKEN' and the generated token as the data.
  • To test everything just push something into github and it should update everything automatic!

Allow doing npm publish automatically by semantic-release:

  • You need a npm token (see here) and add it as the NPM_TOKEN environment variable to Travis-CI like you did with the GH_TOKEN for github.
  • Update the release section in package.json and add '@semantic-release/npm' to both 'prepare', 'publish' and 'verifyConditions'.

External dependencies:

This project is using the following awesome libraries/utilities/services:

Installation:

via yarn:

$ yarn add library-boilerplate

via npm:

$ npm install library-boilerplate

The API:

To create the library api:

$ yarn esdoc

or:

$ npm run esdoc

☕ The source code:

The project structure:

- library-boilerplate/lib/ - All the sources should be here.
- library-boilerplate/lib/types/ - All the flow type declarations.
- library-boilerplate/__tests__/ - All the unit tests.
- rollup.config.js - The configuration for [rollup](https://rollupjs.org/).
- .editorconfig - The [coding style settings](https://editorconfig.org/) for this project.

Npm scripts:

When using with yarn then use the following syntax:

$ yarn name params

Or with just npm:

$ npm name params
  • start - Run the code in development mode.
  • build - Build the production mode.
  • lint - Lint 👮 using ESLint.
  • flow - Flow checks.

Variations:

  • library-boilerplate (this project) - Rollup based javascript library boilerplate featuring Babel 7, ESLint, flow, jest, ESDoc, Rollup, semantic-release and live debugging.
  • library-boilerplate-mocha - Rollup based javascript library boilerplate featuring Babel 7, ESLint, flow, mocha, ESDoc, Rollup, semantic-release and live debugging.
  • react-boilerplate - React 16.5 based frontend boilerplate featuring Babel 7, ESLint, flow, Jest, ESDoc, Webpack 4, React 16.5, Redux, redux-thunk, semantic-release and react-hot-loader debugging.
  • react-boilerplate-mocha - React 16.5 based frontend boilerplate featuring Babel 7, ESLint, flow, mocha, ESDoc, Webpack 4, React 16.5, Redux, redux-thunk, semantic-release and react-hot-loader debugging.

Credit:

  • Created by Ziv Barber.