Skip to content

Latest commit

 

History

History

plugin-config

@sdeverywhere/plugin-config

This package provides a plugin that reads CSV files used to configure a library or app around a System Dynamics model generated by SDEverywhere.

Quick Start

The best way to get started with SDEverywhere is to follow the Quick Start instructions. If you follow those instructions, the @sdeverywhere/plugin-config package will be added to your project automatically, in which case you can skip the next section and jump straight to the "Usage" section below.

Install

# npm
npm install --save-dev @sdeverywhere/plugin-config

# pnpm
pnpm add -D @sdeverywhere/plugin-config

# yarn
yarn add -D @sdeverywhere/plugin-config

Usage

Note: If you followed the "Quick Start" instructions above, the create script will have already performed the following steps for you. Reading these instructions can still be helpful if you are setting up a project manually or want to understand how plugin-config can be integrated into your project.

To get started:

  1. Copy the included template config files to your local project:
cd your-model-project
npm install --save-dev @sdeverywhere/plugin-config
cp -rf "./node_modules/@sdeverywhere/plugin-config/template-config" ./config
  1. Replace the placeholder values in the CSV files with values that are suitable for your model.

  2. Add a line to your sde.config.js file that uses the configProcessor function supplied by this package:

import { configProcessor } from '@sdeverywhere/plugin-config'

export async function config() {
  return {
    // Specify the Vensim model to read
    modelFiles: ['example.mdl'],

    // Read csv files from `config` directory and write to the recommended output
    // directory structure.  See `ConfigProcessorOptions` for more details.
    modelSpec: configProcessor({
      config: 'config'
    }),

    plugins: [
      // ...
    ]
  }
}
  1. Run sde bundle or sde dev; your config files will be used to drive the build process.

Documentation

API documentation (for plugin configuration options) is available in the docs directory.

License

SDEverywhere is distributed under the MIT license. See LICENSE for more details.