Code Monkey home page Code Monkey logo

artifact-registry-npm-tools's Introduction

Artifact Registry tools for npm

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

Artifact Registry Module

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

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

The module authenticates to Artifact Registry using Google Application Default Credentials.

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

    Using end user credentials:

    $ gcloud auth application-default login

    Using service account:

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

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

    $ gcloud beta artifacts print-settings npm

    registry=https://LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID/
    //LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID/:_authToken=""
    //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 google-artifactregistry-auth [path/to/.npmrc]

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

      "scripts": {
          "artifactregistry-login": "npx google-artifactregistry-auth [path/to/.npmrc]",
      }
      

      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 google-artifactregistry-auth --save-dev

      "scripts": {
          "artifactregistry-login": "./node_modules/.bin/artifactregistry-auth [path/to/.npmrc]",
      }
      

      Where [path/to/.npmrc] is the optional argument you can provide to the script. If no path is provided, .npmrc file at current directory is used.

      Run the script

      $ npm run artifactregistry-login

artifact-registry-npm-tools's People

Contributors

gridasov avatar kaylanguyen avatar

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.