0.1.1 • Published 4 years ago

sourcebit-sourcebit-sample-plugin v0.1.1

Weekly downloads
5
License
ISC
Repository
github
Last release
4 years ago

sourcebit-sample-plugin

npm version

A sample plugin for Sourcebit

👩‍🏫 Introduction

This is a simple Sourcebit plugin for development and educational purposes. It operates on a model with three fields (firstName, lastName and points) and creates two entries with a pre-defined value for points. If the watch option is supplied, then every 3 seconds one of the entries will be randomly picked and its points will be incremented by one.

⚙️ Configuration

The plugin accepts the following configuration parameters. They can be supplied in any of the following ways:

  • In the options object of the plugin configuration block inside sourcebit.js, with the value of the Property column as a key;
  • As an environment variable named after the Env variable column, when running the sourcebit fetch command;
  • As part of a .env file, with the value of the Env variable column separated by the value with an equals sign (e.g. MY_VARIABLE=my-value);
  • As a CLI parameter, when running the sourcebit fetch command, using the value of the Parameter column as the name of the parameter (e.g. sourcebit fetch --my-parameter).
PropertyTypeVisibilityDefault valueEnv variableParameterDescription
mySecretStringPrivateMY_SECRETA secret value. Not actually used by the plugin, purely for demonstration purposes.
watchBooleanPublicfalsewatchWhether to update entries on a regular interval.
pointsForJaneNumberPublic0The initial number of points assigned to Jane
pointsForJohnNumberPublic0The initial number of points assigned to John

👀 Example configuration

sourcebit.js

module.exports = {
  plugins: [
    {
      module: require("sourcebit-sample-plugin"),
      options: {
        pointsForJane: 5,
        pointsForJohn: 3
      }
    }
  ]
};

🧞‍♂️ Interactive setup process

This plugin offers an interactive setup process via the npx create-sourcebit command.

📥 Input

N/A

📤 Output

This plugin adds normalized entries to the objects data bucket and normalized model objects to the models data bucket.