Advanced configuration with includes, variables and placeholders.
Simple configuration module to handle complex problems
npm install -g conf-fu
var ConfFu = ;// init from filesvar config =configFile: pathfixupFile: path;configverbose = globalVerbose || false;config;config;// init from structuresvar config =config: a: b: c: "<#who knows>" x: true;
Easy to use
Common formats, you can set up a location of configuration files. If you already have one, you do not need to change files location for each project, you can just point this location (set up environment) for all needed projects.
Hierarchical, any section can live in a separate file, easy access to frequently changing sections.
Configuration is actually is splitted to the project configuration and the instance fixup. You can have as many fixups as you want, not only development and production.
Current configuration snapshot is always on disk and in vcs. No code allowed within configuration. Tools never change project config, only fixup allowed to change.
Those is not acceptable:
require ('config.json')— 1, 2, 3;
Configuration format when parsed must be presented with tree or key-value structure.
Each string can be basic or enchanted.
conf-fu supports those enchantments:
<$db.mongo.collection>— linked to the other value in configuration
<$bool(on|off):db_unix_sock=on>— variable with type and default value
<$http_domain>:<$http_port>— string concatenation
<#placeholder>— just a placeholder, need to be fullfilled
<#optional:placeholder>— you can omit this value in fixup
<#default:127.0.0.1>— you can omit this value in fixup and default value will be used
<<filename>>— parsed content from filename need to be inserted into that node
You can use
conf-fu standalone, integrate within project or use it in browser.
conf-fu configuration is located within
.conf-fu directory in project root.
Main configuration file named
project.json, fixup directories located at same level as the
project.jsonfile is loaded and parsed.
yamlformats supported, new formats can be added easily;
project.jsoncontents is scanned for includes in form
"<$config.path.variable>") and placeholders (
"<#please fix me>",
"<#optional:please fix me>",
fixup.jsonfile loaded and checked, whether all variables and placeholders fulfilled;
CONF_FUcore file path, parent directory is assumed as config location
CONF_FU_FIXUPfixup file path
CONF_FU_PROJECT(relative to project root, dir name to search for
You have two options to integrate conf-fu to existing projects:
Use as configuration management script
For example, one part of your project written on
php and you want to add
You'll need to install
conf-fu from npm, then just use it from command line to edit configuration,
validate it, fullfill variables and placeholders. Then, just ask
conf-fu to store
configuration artifact in place where you can read it with
Use within code to get a configuration.