config-butler

0.0.3 • Public • Published

Config Butler 🕴

Introduction

A uniform and elegant way to manage multi-environment native web config files

An easy way to manage native web config files in a purposeful, modularised and uniform manner.

This set up allows for a centralised way of managing web configuration, keep things clean and trackable across multiple environments. A modern approach toward configuration which promote sound development practices and allow business logics to remain in the centre.

Installation:

npm install config-butler 

Usage

  1. Create a new configuration template in your project's configuration folder with the following format
// e.g: configurations/appConfig.js

module.exports = {
  appConfig: {
    topBanner: {
      disclaimer: {
        dev: 'this project is open source and will never ask for your money ',
        prod: 'this project is open source and will never ask for your money',
      }
    }
  }
};
  1. Create a config-files.json (you can name it however you like) in the same folder, then add a new entry as the same name of the config file created.
// configurations/config-files.json
[  
  "appConfig"
]

That's it! Simple isn't it? 🍰

  1. Now, before your project is built, add an entry to compile your config like follow
$ config-compile  'configurations' 'dev prod' 'Dev Production' 
                        $1             $2            $3 

# $1: Configs location 
# $2: Environments to compile 
# $3: Folders to return configuration files on 

The end result is the compiler will compile a corresponding configuration.js file to each specified environment like follow

// Dev/configuration.js 

window.sample = "https://dev.butlerio.com.au"
window.logServer = "https://dev.butlerio-logs.com.au"
window.apiSocket = "https://dev.api.butlerio.com.au"

🍻🍻🍻

Notes

Arrays are considered the last object in a config, reason being arrays might be of different sizes for each environment. This means each environment must have their own array

"availableCurrencies": {
      "dev": [
        "AUD",
        "USD",
        "EUR",
      ],
      "prod": [
        "USD"
      ]
    }

Copyright and license

Code and documentation copyright 2018 @coffeemood. Code released under the MIT License. Docs released under Creative Commons.

Readme

Keywords

none

Package Sidebar

Install

npm i config-butler

Weekly Downloads

3

Version

0.0.3

License

UNLICENSED

Unpacked Size

190 kB

Total Files

12

Last publish

Collaborators

  • coffeemood