GithubHelp home page GithubHelp logo

npm-package-template's Introduction

NPM Package Template

Template for creating npm modules. Including react components.

Example using this template.

Using the template

clone or click use this template feature

  • Tweak necessary values in package.json

npm install

Installs dependencies.

npm run test

runs unit test cases using jest (and enzyme for react components)

npm run coverage

gives unit tests coverage report.

npm run build

creates ./dist prod build folder.

npm link

For local testing. More info

npm publish

Publishes to npm. (have to login if needed using npm login)

Github actions for CI/CD

create .yml file for github actions in .github/workflows and paste the code

name: Publishing to npm

on:
  push:
    branches:
    - master

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: installing dependencies
      run: npm install
    - name: running unit tests
      run: npm run test
    - name: generating production build
      run: npm run build
    - uses: actions/setup-node@v1
      with:
        node-version: '10.x'
        registry-url: 'https://registry.npmjs.org'
    - run: npm publish
      env:
        NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
  • Above code was simple CI/CD for pushing to npm when some code is pushed to master branch
  • ${{ secrets.NPM_AUTH_TOKEN }} was set using github secrets
  • NPM_AUTH_TOKEN is obtained from npm

Storybook Integration

  • code example with integrated storybook is on story-book branch

npm-package-template's People

Contributors

sriramrudraraju avatar

Stargazers

Kamil Trusiak avatar Sanjay Soundarajan avatar  avatar Voltaire avatar Sikender Khan avatar mynane avatar

Watchers

James Cloos avatar  avatar

Forkers

hyl01

npm-package-template's Issues

scripts for cleaning and moving files

 "build": "yarn run clean && tsc",
 "postbuild": "ef-tspm && yarn run copy-files",
 "clean": "rimraf lib/",
 "prepare": "yarn run build",
 "copy-files": "copyfiles -u 1 src/**/*.js dist"

more info

add webpack support

Now

  • only .ts and .tsx files being compiled (cause of typescript)

Future

  • need set up to build minified files, etc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.