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

nx-remotecache-gcp

v2.4.0

Published

Remote caching for @nrwl/nx using Google Cloud Buckets

Downloads

3,979

Readme

npm package link

nx-remotecache-gcp

A task runner for @nrwl/nx that uses a Google Cloud Storage bucket as a remote cache. This enables all team members and CI servers to share a single cache. The concept and benefits of Cache Task Results are explained in the Nx documentation.

This package was built with nx-remotecache-custom 🙌

Compatability

| Nx | Remote Cache | |-----------|--------------| | >= 16.9.0 | >= 2.0.2 | | < 16.9.0 | < 1.2.1 |

Setup

  1. Add Nx to your workspace guide

  2. Install this package as dev dependency.

    npm install --save-dev nx-remotecache-gcp
  3. Authenticate to Google Cloud The user authenticating must have read/write access to the bucket as well as storage.buckets.get permission

    1. Locally using google cloud CLI using gcloud auth
    2. For Github actions use google-github-actions/auth
    3. You may provide NX_GOOGLE_APPLICATION_CREDENTIALS_PATH and point to your own Google service account credentials.
  4. Create a Google bucket to store the cache in

Creating a service account with the right permissions

To authenticate on CI it is recommended to create a service account that only has the required permissions.

  1. Create a custom role with only the storage.buckets.get permission

  2. Create a service account with the custom Role and limit it only manage the nx-cache bucket using this CEL Expression resource.name.startsWith(\"projects/_/buckets/<nx_cache_bucket.name>\")

  3. Add Object Admin to the bucket from the page of the Bucket

Configuration

Note: Environment variables have precedence over configured variables

Additionally all parameters defined in nx-remotecache-custom are valid here

| Parameter | Description | Environment Variable / .env | nx.json | |-----------------------------|-------------------------------------------------|------------------------------------------|------------------------------------| | Google Project | Project Name in which the Bucket resides | NXCACHE_GCP_PROJECT | googleProject | | Bucket Name | Bucket name in which the cache will be stored | NXCACHE_GCP_BUCKET_NAME | bucketName | | Read from Remote Cache | Allow reading from the the remote cache | NXCACHE_READ | read (true/false) | | Write to Remote Cache | Allow writing to the the remote cache | NXCACHE_WRITE | write (true/false) | | Credentials path (optional) | Provide your own google application credentials | NX_GOOGLE_APPLICATION_CREDENTIALS_PATH | googleApplicationCredentialsPath |

{
   "tasksRunnerOptions": {
      "default": {
         "runner": "nx-remotecache-gcp",
         "options": {
            "googleProject": "my-google-project-id",
            "bucketName": "my-nx-cache-bucket",
            "read": true,
            "write": false,
            "cacheableOperations": [
               "build",
               "test",
               "lint",
               "e2e"
            ]
         }
      }
   }
}

Run it 🚀

Running tasks should now show the storage or retrieval from the remote cache:

------------------------------------------------------------------------------
Remote cache hit: Google Cloud Bucket
File: 1fb268062785d739b5a43c1e4032fd7731c6080e2249e87a00e568b3c41acf9c.tar.gz
------------------------------------------------------------------------------