DEV Community

Cover image for Maintain Javascript Project Efficiently with GitHub Actions
Abel Mathew
Abel Mathew

Posted on

Maintain Javascript Project Efficiently with GitHub Actions

My Workflow

GitHub Actions to analyze the packages used in a JavaScript project. Helps maintainers have control over the packages used in the project.

What it does:

  • Lists the unused packages
  • Lists the expected size of the node modules after deployment

Submission Category:

Maintainer Must-Haves

Usage

Adding the following to your workflow will create a new job using the js-package-info Action.

on: [pull_request]

jobs:
  js-package-info:
    runs-on: ubuntu-latest
    name: An Action to analyze javascript packages
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v1
      with:
        node-version: '12'
    - run: npm install -g bundle-phobia-cli
    - run: npm install -g depcheck
    - name: Get Package Info
      uses: DesignrKnight/js-package-info@v2
      with:
        node_dir: './'
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

Link to Code

GitHub logo DesignrKnight / js-package-info

GitHub Actions to analyze the packages used in a JavaScript project

JS Package Info

GitHub Action to analyze the packages used in a JavaScript project. Helps maintainers have control over the packages used in the project.

What it does:

  • Lists the unused packages
  • Lists the expected size of the node modules after deployment

Usage

Adding the following to your workflow will create a new job using the js-package-info Actions.


jobs:
  js-package-info:
    runs-on: ubuntu-latest
    name: An Action to analyze javascript packages
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v1
      with:
        node-version: '12'
    - run: npm install -g bundle-phobia-cli
    - run: npm install -g depcheck
    - name: Get Package Info
      uses: DesignrKnight/js-package-info@v2
      with:
        node_dir: './'
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Inputs

node_dir

The default is ./. Change it to point to the relative location of the package.json file in the git repo. If the location is ./server/package.json, then the environment variable will be ./server/

GITHUB_TOKEN

The GitHub token from context is used to…

Input Parameters

node_dir

The default is

./

. Change it to point to the relative location of the package.json file in the git repo. If the location is

./server/package.json

, then the environment variable will be

./server/

GITHUB_TOKEN

The GitHub token from context is used to run this Action. Leaving this unchanged should work for almost all use cases.

Additional Resources / Info

The Actions uses the following for its working

Cover Photo by Stanley Dai on Unsplash

Top comments (0)