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

@tkow/bun-google-artifactregistry-auth

v0.0.1

Published

google-artifactregistry-auth is an npm module that allows you to configure npm to interact with npm repositories stored in Artifact Registry with bunfig.

Downloads

502

Readme

Artifact Registry tools for npm packages using bun

This repository contains tools to simplify the process of working with npm packages using Artifact Registry and bun.

This library is inherited from https://github.com/GoogleCloudPlatform/artifact-registry-npm-tools.

Artifact Registry Module

The Artifact Registry google-artifactregistry-auth module is an npm package which allows you to configure npm to interact with npm private repositories in Artifact Registry.

For more details, see https://cloud.google.com/artifact-registry/docs/nodejs/authentication

The module automatically searches for credentials from the environment and authenticates to Artifact Registry. It looks for credentials in the following order:

  1. Google Application Default Credentials.
  2. The current active account logged in via gcloud auth login.
  3. If neither of them exist, an error occurs.

NOTE: This module would update credentials for all Artifact Registry repositories. It would not be suitable if you use multiple account credentials in npmrc file.

To use the module:

  1. Log in

    Option 1: log in as a service account:

    (1). Using a JSON file that contains a service account key:

       `$ export GOOGLE_APPLICATION_CREDENTIALS=[path/to/key.json]`

    (2). Or using gcloud:

       `$ gcloud auth application-default login`

    Option 2: log in as an end user via gcloud:

    $ gcloud auth login

  2. Add settings to connect to the repository to .npmrc. Use the output from the following command:

    $ gcloud artifacts print-settings npm

    registry=https://LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID/
    //LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID/:always-auth=true

    Where

    PROJECT_ID is the ID of the project.

    REPOSITORY_ID is the ID of the repository.

    LOCATION is the location of the repository.

  3. Use one of these below options to run the script

    1. Run the module outside of the directory containing the target npmrc file

      $ npx -y @tkow/bun-google-artifactregistry-auth --repo-config=[./.npmrc] --bunfig=[$HOME/.bunfig.toml]

    2. Include the command in the scripts in package.json

      "scripts": {
          "artifactregistry-login": "npx -y @tkow/bun-google-artifactregistry-auth(add if you change paths: --repo-config=[./.npmrc] --bunfig=[$HOME/.bunfig.toml] --bunfig=[$HOME/.bunfig.toml])",
      }

      Where:

      • --repo-config is the .npmrc file with your repository settings. If you don't specify this flag, the default location is the current directory.
      • --bunfig is the path to the bunfig.toml file where you want to write the access token. The default is your home $HOME/.bunfig.toml file.
      • --from is the path to the bunfig.toml file where you want to make it base bunfig file. The default is your user $HOME/.bunfig.toml file.

      And then run the script

      $ npm run artifactregistry-login

    3. npx should come with npm 5.2+. If npx is not available:

      Install the module from npmjs.com as a dev dependency and include the command in the script

      $ npm install @tkow/bun-google-artifactregistry-auth --save-dev

      "scripts": {
          "artifactregistry-login": "./node_modules/.bin/bun-artifactregistry-auth --repo-config=[./.npmrc] --bunfig=[./bunfig.toml]",
      }

      Run the script

      $ npm run artifactregistry-login