This package has been deprecated

Author message:

not longer maintained

@car2go/spicker

1.2.1 • Public • Published

spicker

Environment-based Configuration with YAML Export

node npm npm

Lead Maintainer: Felix Heck


  1. Introduction
  2. Installation
  3. Usage
  4. API
  5. Developing and Testing
  6. Contribution
  7. License

Introduction

spicker is oriented at node-config and enables to organize simple hierarchical configuration for deployments. It lets you define default parameters and extend them for different deployment environments.

The functionality of node-config is simplified and extended with a YAML export.
So instead of using const config = require('config')() to access the built configuration set, a YAML file is created.
This gives your application a consistent configuration interface for uses cases like in kubernetes.

spicker is the German translation for cheat sheet.

This util is implemented in ECMAScript 6 without any transpilers like babel.
Additionally eslint and ava are used to grant a high quality implementation.

Installation

For installation use the Node Package Manager:

$ npm install --save @car2go/spicker

or clone the repository:

$ git clone https://github.com/car2go/spicker

Alternatively use the Yarn Package Manager:

$ yarn add @car2go/spicker

Usage

Import

First you have to import the module:

const spicker = require('@car2go/spicker');

Define your configuration files split in stage-specific diretories

Use YAML or JSON files.
Files located in /default are used as default.

/
  /config
    /default
      deployment.yaml
    /development
      deployment.json

Load Configs and Generate File

Afterwards call the method with the fitting arguments and save the generated config file.

spicker('deployment', '/config', {}).then(() => { console.log('finished'); });

It uses lodash's merge to deep merge the files.

API

spicker(name, source, options) – Returns a promise handling both success and failure cases.

  • name {string} – Name of the resource files without any suffix.
    Required.
  • source {string} - Path to the directory containing stage-specific files. Relative to options.cwd.
    Default: config.
  • options {Object}
    • cwd {string} – The current working directory. Have to be an absolute path.
      Default: process.cwd().
    • destination {string} - Path to the generated file. Relative to options.cwd.
      Default: ${source}/${name}.yaml.
    • debug {boolean} – Log the composed files to the console.
      Default: false.

Developing and Testing

First you have to install all dependencies:

$ npm install

To execute all unit tests once, use:

$ npm test

or to run tests based on file watcher, use:

$ npm start

To get information about the test coverage, use:

$ npm run coverage

Contribution

Fork this repository and push in your ideas.

Do not forget to add corresponding tests to keep up 100% test coverage.

License

The MIT License

Copyright (c) 2017 car2go group GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Dependencies (6)

Dev Dependencies (5)

Package Sidebar

Install

npm i @car2go/spicker

Weekly Downloads

2

Version

1.2.1

License

MIT

Last publish

Collaborators

  • npmofsumit
  • whotheheck