Git Product home page Git Product logo

nx-remotecache-custom's Introduction

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

 Nx Remote Cache
 >= 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

Option Environment Variable / .env Description
name NXCACHE_NAME Set to provide task runner name for logging. Overrides name provided in implementation.
verbose Set to receive full stack traces whenever errors occur. Best used for debugging. Default: false
silent Set to mute success and info logs. Default: false
read NXCACHE_READ Set to enable / disable reading from the remote cache. Default: true
write NXCACHE_WRITE Set to enable / disable writing to the remote cache. Default: true
dotenv Set to false to disable reading .env into process.env. Default: true
dotenvPath Set to read .env files from a different folder.
"tasksRunnerOptions": {
  "default": {
    "options": {
      "name": "My Storage",
      "verbose": true,
      "silent": true
    }
  }
}

All Custom Runners

Runner Storage
nx-remotecache-azure  Azure Blob Storage
nx-remotecache-minio  MinIO Storage

nx-remotecache-custom's People

Contributors

niklaspor avatar john98zakaria avatar rathpc avatar chentsulin avatar comp615 avatar markusvoelk-zr avatar mikefear avatar minijus avatar stixx200 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.