Name: node-nmconfig
Owner: Namshi
Description: An opinionated configurator
Created: 2015-04-20 11:42:22.0
Updated: 2016-11-15 13:12:48.0
Pushed: 2018-02-28 12:31:00.0
Homepage: null
Size: 15
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Handy and strongly opinionated config helper on top of reconfig.
Here in Namshi we like our configuration: incremental, overridable, and defined in a compact way.
As well as we like to don't go nuts when we clone a project repo for the 1st time.
This is why we came up with tools like reconfig and file-ensure. With nmConfig we put all this things together in a convenient lib that turns all of this in a matter of a require()
instruction.
config/
directory and the needed files if they are not present:ig/
|- base.yml
|- dev.example.yml
|- staging.yml
|- live.yml
base.yml
one:e.yml
acters:
da: jedi
akin: jedi
iWan: jedi
.yml
acters:
akin: sith
will result in:
aracters: {
yoda: 'jedi',
anakin: 'sith',
obiWan: 'jedi'
You can eventually define configuration paths in your app's package.json
too, using your app's name as key,
and they'll be added to the final configuration:
ut something like this in your package.json
ame": "myConfigurableApp",
ersion": "0.0.1",
escription": "I can configure apps",
yConfigurableApp": {
"characters": {
"benSolo": "sith"
}
nd you'll obtain:
aracters: {
yoda: 'jedi',
anakin: 'sith',
obiWan: 'jedi',
benSolo: 'sith'
reconfig
instance:ole.log(config.get('characters.anakin'));
// ==> 'sith'
gures out a `reconfig`'s env overrider prefix from your `package.json`:
//pacakage.json { “name”: “myApp”, “version”: “0.1.0”, “description”: “this is my app, there are many like it, but this one is mine!” // […] }
yield a `MYAPP_CONFIG` env prefix for `reconfig` (check [this section](https://github.com/namshi/reconfig#nodejs-specifics) on `reconfig`'s doc for more infos on what this does)
sure you've a `dev.yml` on your dev machine, or eventually creates one from `dev.example.yml`
ptions Params:
ons parameters:
baseFiles**: A list of files creating the base configuration
before applying the environment specific config.
These files will be merged in order, the env file
will be the last applied.
separator**: The separator Reconfig will use for console vars
overlays.
projectName**: Defines Your project's name. If none is given, the project's name
will be inferred form your package.json "name" value. All spaces will be removed.
prefix**: The prefix that Reconfig will use while grabbing
console variable and applying overlays.
ensure**: Tells to nmConfig to check for the existence of <filename>.yml file.
If a <fileName>.example.yml is found, it will be used to produce
the ensured file.
env**: Forced value for the environment:
by default nmConfig will read you env form:<br/>
- PROJECTNAME_ENV <br/>
- NODE_ENV<br/>
- or default to "dev"
nstallation
all this library via [NPM](https://www.npmjs.org/package/node-nmconfig):
npm install node-nmconfig
sage
var config = require('node-nmconfig')();
// or
var config = require('node-nmconfig')({ / options / });
ou need it on the client side we highly recommend
wserify](http://browserify.org/).
ests
library is a little convenience wrapper on top of extensively tested projects,
or once we can be a little bit lazy and skip them ;)<br/>
o like tests tho, so if you feel giving us a hand we'll be more than happy
ee some PR love on this side :D