npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

package-controller

v1.2.0

Published

Package Controller let's you manage SemVer and upgrade your package dependencies automatically

Downloads

90

Readme

Package Controller

Upgrade your NPM package dependencies automatically!

NOTE: Currently only compatible with gitlab

Quick Start

Install

npm i package-controller --save-dev

Add to your package.json

 "packageController": {
    "only": [
      "MY PACKAGE NAME"
    ],
    "exclude": [],
    "skipCi": false
  }

Options

  • Only

    Specify packages you want to upgrade

  • Exclude

    Exclude packages you don't want to upgrade

  • skipCi

    Disabled as default, skips builds in Merge Requests

GitLab Configuration

Requirements

  1. Create a Project Access Token
  2. Create a CI/CD Variable
  3. Configure a Repository
  4. Schedule pipeline jobs

1. Create a Project Access Token

In your GitLab project go to Settings -> Access Tokens

Now create a Project Access Token with the following information.

Name: Package-Controller-AccessToken

Scopes:

  • API
  • read_repository
  • write_repository

and don't forget to copy the token to a safe place (you will need it for the next step).

2. Create a CI/CD Variable

In your GitLab project go to Settings -> CI/CD

Expand the Variables section and click Add Variable

Create the variable with the following information:

Key: Package_Controller_AccessToken

Value: { Use the Package-Controller-AccessToken VALUE }

Flags: check Protect variable and Mask variable

Click Add Variable

3. Configure a Repository

Add to your .gitlab-ci.yml file the following code:

package-controller:
   stage: maintenance
   cache: []
   image:
      name: brunomartinspro/node-powershell:latest
      entrypoint: [""]
   script:
    - npx package-controller 
   only:
    - schedules

If you want to create also an image for your organization like brunomartinspro/node-powershell:latest

FROM mcr.microsoft.com/powershell:7.1.5-debian-buster-slim

RUN apt-get update \
 && apt-get upgrade -y \
 && apt-get install nodejs -y \
 && apt-get install npm -y \
 && apt-get install curl -y

RUN apt install git-all -y
 
RUN npm install -g n
RUN n 14.18.1

run the commands:

docker build -t registry.gitlab.com/MY_ORGANIZATION/tools/package-controller-standalone .
docker push registry.gitlab.com/MY_ORGANIZATION/tools/package-controller-standalone

and update the image name variable with:

name: registry.gitlab.com/MY_ORGANIZATION/tools/package-controller-standalone:latest

If you are using private repositories this is probably the best approach since you can add to your script the configurations for private repositories, for example:

# Set URL for your scoped packages.
# For example package with name `@foo/bar` will use this URL for download
npm config set @foo:registry https://gitlab.example.com/api/v4/packages/npm/

# Add the token for the scoped packages URL. This will allow you to download
# `@foo/` packages from private projects.
npm config set -- '//gitlab.example.com/api/v4/packages/npm/:_authToken' "<your_token>"

NOTE: generally you can replace "<your_token>" with "${CI_JOB_TOKEN}"

as described in Authenticate with a personal access token or deploy token

To ignore other jobs from being executed add a rule for each job:

except:
  - schedules

When you want to ignore other jobs on a specific branch as a manual trigger

when: manual
only:
  - master
except:
  - schedules

You may have to include a maintenance stage

stages:
  - maintenance

Also sometimes the pipeline may run in detached mode, this means it won't be building a branch but the merge request itself.

You may want to add validations for these cases like:

myJob:
  only:
    - merge_requests

4. Schedule pipeline jobs

In your GitLab project go to CI/CD -> Schedules

Click New schedule and set up the schedule to your preferences.

If you don't have any add preferences:

Description: Package ControllerInterval

Pattern: Custom and set to 0 18 * * 4 (Every Thursday at 6 PM every week)

Cron Timezone: UTC

Target Branch: master

Click "Save pipeline schedule".

That's it, everything should work now!