Giter VIP home page Giter VIP logo

cowfig's Introduction

Cowfig

Cowfig in a JSON format template parser to generate config.json files.

JSON file is easy to use for a developer, but hard for non-developer.

In most real cases, project always co-works with some non-RD team. They are used to use Excel file to evaluate value set. JSON file is too hard to read and maintenance for them. A tool to translate excel to JSON config file is necessary.

Also, different develop staging uses different setting. Ex: IP, port, account ... etc. It also needs a config management tools.

Cowfig is a JSON format template parser. It parse Excel, JSON, YAML files, provides query method to get value set.

Developer write the cowfig template files. Cowfig take care Excel parsing, different environment value set maping then generate final config.json files.

Features

  • Environment awared
    • Parse same template with different environment value set
    • Extend environment only template _ Parser plugin system
    • Write your file parser as plugin and use it
    • Builtin parser: JSON, Excel, YAML, INI
  • Customize scripts
    • Macro function for on-the-fly processing
    • Post process after template been parsed

Installation

npm install -g https://github.com/kywk/cowfig

Quick Start

Write your template

$ mkdir config config/template config/source
$ vi config/template/configTemplate.cowfig
  ...
$ vi config/source/dataSet.json
  ...

Generate config.json files

$ cowfig -h
Usage: cowfig [-t TEMPLATE] [-s RESOURCE] [-d DESTINATION] [-e ENV] [-o overwrite]
$ cowfig -d .

Arguments descript

  • -t TemplateBase: The cowfig template files path.
    Cowfig find all .cowfig files includes sub directory under TemplateBase. Build the files tree, then parse those template files.
  • -s ResourceBase: The value set files path.
    Store your excel or json value set file. Cowfig load the .xlsx .json files and provides query method to get value set.
  • -d DestinationBase: Where the final JSON file stores.
    Cowfig write out find JSON files based on where they find under TemplateBase.
  • -e Environment: Specify the target enviroment.
  • -o Overwrite:
    If target file is already exist, overwrite it or not?
    • 'auto': (default) auto detect last modified date. Overwrite if newer verseion is out.
    • 'always': always overwrite target file.
    • 'never': never overwrite target file.
  • -c Cowfig option file:
    A cowfigOpt config file for those setting.

Simple example

Cowfig config file: cowfig.json

{
  "env": "stage",
  "templateBase": "example/template/",
  "parser": {
    "srcBase": "example/source/"
  },
  "writer": {
    "destBase": "config",
    "overwrite": "auto",
  }
};

Source file tree

└── example
    ├── source
    │   ├── valueSet.xlsx
    │   ├── hostInfo.json
    │   └── stage
    │       └── hostInfo.json
    └── template
        ├── host
        │   └── servers.cowfig
        └── config.cowfig

Generate config.json Use CLI args

$ cowfig -t example/template -s example/source -d config -e stage

or Use cowfig config file

$ cowfig -c cowfig.json

Result target files

└── config
    ├── host
    │   └── servers.json
    └── config.json

More Information

Read the documentation

License

MIT

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.