Socket
Socket
Sign inDemoInstall

nx-remotecache-custom

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nx-remotecache-custom

Build custom caching for @nrwl/nx in a few lines of code


Version published
Maintainers
1
Created
Source

https://www.npmjs.com/package/nx-remotecache-custom Downloads Sponsored by LastBIM

nx-remotecache-custom

nx-remotecache-custom is a simple package which includes a helper function to create custom nx remote cache implementations. You'll only need to add functions for:

  1. storing a file / buffer
  2. retrieving a file / buffer
  3. checking if a file / buffer exists

and createCustomRunner() is taking care of everything else. Not convinced yet? The package will also:

  • Print beautiful & colored nx-style messages to the console 💅🎆
  • Allow you to execute asynchronous code in the setup phase of your runner 🤖
  • Handle all thrown errors ➡ No broken builds to offline remote caches 🚀
  • Automagically zip all the cached files ➡ Minimal storage & traffic consumption 📦
  • Provide a small defined and documented API 📚

Compatability

 NxRemote Cache
 >= 19.0.0 < 20>= 19.0.0 < 20
 >= 18.0.0 < 19>= 18.0.0 < 19
 >= 17.0.0 < 18>= 17.0.0 < 18
 >= 16.9.0 < 17>= 5.0.0 < 17
 < 16.9.0< 5.0.0

Usage

npm i nx-remotecache-custom
// define custom parameters for your nx.json here
interface MyRunnerOptions {
  remoteUrl: string;
}

export default createCustomRunner<MyRunnerOptions>(async (options) => {
  // initialize environment variables from dotfile
  initEnv(options);

  // initialize the connection to your remote storage here
  const myStorage = new MyStorage(options.remoteUrl);

  return {
    // name is used for logging purposes
    name: "My Storage",

    // fileExists checks whether a file exists on your remote storage
    fileExists: (filename) => myStorage.exists(filename),

    // retrieveFile downloads a file from your remote storage
    retrieveFile: (filename) => myStorage.download(filename),

    // storeFile uploads a file from a buffer to your remote storage
    storeFile: (filename, buffer) => myStorage.upload(filename, buffer),
  };
});
{
  "name": "nx-remotecache-mystorage",
  "main": "index.js"
}

After this your package is already ready for usage. Publish it to npm (or an internal registry) and consume it in your client library. Install it and adjust your nx.json to use the newly created runner:

"tasksRunnerOptions": {
  "default": {
    "runner": "nx-remotecache-mystorage",
    "options": {
      "remoteUrl": "http://127.0.0.1:1337",
      "cacheableOperations": ["build", "test", "lint", "e2e"]
    }
  }
}

For a more in-depth code example you can take a look at the implementation of nx-remotecache-azure which uses this package to implement a nx cache on the Azure Blob Storage.

Advanced Configuration

OptionEnvironment Variable / .envDescription
nameNXCACHE_NAMESet to provide task runner name for logging. Overrides name provided in implementation.
verboseSet to receive full stack traces whenever errors occur. Best used for debugging. Default: false
silentSet to mute success and info logs. Default: false
readNXCACHE_READSet to enable / disable reading from the remote cache. Default: true
writeNXCACHE_WRITESet to enable / disable writing to the remote cache. Default: true
dotenvSet to false to disable reading .env into process.env. Default: true
dotenvPathSet to read .env files from a different folder.
"tasksRunnerOptions": {
  "default": {
    "options": {
      "name": "My Storage",
      "verbose": true,
      "silent": true
    }
  }
}

All Custom Runners

RunnerStorage
nx-remotecache-azure Azure Blob Storage
@pellegrims/nx-remotecache-s3 S3 Storage
nx-remotecache-minio MinIO Storage
@vercel/remote-nxVercel Cache
nx-remotecache-redisRedis Cache

... and many more!

Keywords

FAQs

Package last updated on 17 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc