Simple tool for working with configuration files containing sensitive information.
FCB simplifies the process of handling sensitive data required by software
and shared among coders via git.
The idea originated from the way Symfony handles parameters.yml andparameters.yml.dist files.
npm install --save @fulminate/fulminate-config-builder
After the package was successfully installed, it is required to run the
following script once to simplify usage of FCB:
node ./node_modules/@fulminate/fulminate-config-builder/prepare.js
It will first ask you if you want to make changes to ignore files (currently, only .gitignore is supported).
You can provide js or ts as a parameter. If no parameter was provided,
the script will prompt for preferred type of dist file (TypeScript or JavaScript).
In the root directory of your project you will find config.ts.dist or config.js.dist
file (depending on the preference you'd stated).
#### config.ts.dist
``
// Add config fields here if you need them in your config.ts file
// Comments may be given at new lines and begin with "//" or "/*"
`
You can populate this file line by line in the following manner:
`
...
db.host:localhost
db.name:database
db.username:root
db.password:root
// App settings:
app.domain:example.com
// API keys:
googleMapsAPIKey:AIza
`
=========================================================================
You can use //, /* or simply / to indicate comments that should
be ignored by runner. Empty lines will also be ignored.
The first part of the line is the property of config object. If it has.
a the first part will be assumed as child of config while the
second one will be a property of the child object, e.g.:
##### config.ts.dist
`
app
db.host
`
##### config.ts
`json`
{
"app": "YOUR_VALUE",
"db": {
"host": "YOUR_VALUE"
}
}
*The value that goes after : is optional and provides default value for
the property and automatically applies if no other input is given by the
user.*
After you've done all the preparations, simply run
npm run ifc
that was automatically injected to your package.json by the preparation
script.
#### What the runner does is:
* Create config.ts in the root folder of your projectconfig.ts.dist
* Analyse your config.ts.dist
* Prompt for input for each line of config.ts
* Write provided data to object and make it available asconfig object.
#### config.ts.dist
`
// Add config fields here if you need them in your config.ts file
// Comments may be given at new lines and begin with "//" or "/*"
something.awesome:FSB!!
`
Run npm run ifc
#### config.ts
`javascript
const json = {
"something": {
"awesome": "FSB!!"
}
};
export const config = JSON.parse(JSON.stringify(json));
`
`javascript
let config = require("./config.ts").config;
console.log(config.something.awesome);
// Output: FSB!!
``
* Unit testing
* Improving usability