node-confmanager
v1.14.0
Published
A configuration manager.
Maintainers
Readme
node-confmanager
A configuration manager.
Installation
$ npm install node-confmanagerFeatures
- All the features of the node-containerpattern package
- clone data in "get" action to avoid unwanted changes
- Saving the data in a JSON file
- Load the data from this JSON file and/or commandline
- access to the data with shortcuts in commandline
- load data from ENV data
- load data from specified env file (like ".env")
- prio : env > console > envfile > conf file
Doc
Inheritance and behaviour
See the node-containerpattern documentation for skeletons, set / get, recursion, and validation.
Types and implementation
- Published typings:
lib/cjs/main.d.cts - Implementation:
lib/src/NodeConfManager.ts
Examples
Full flow (save, load, typed get): test/typescript/compilation.cts
CLI usage
# if "debug" skeleton is set and defined as a boolean
node mysoft.js -d # if "debug" shortcut is set with shortcut("debug", "d")
node mysoft.js --debug
node mysoft.js --debug "true"
node mysoft.js --debug "yes"
node mysoft.js --debug "y"# if "arr" skeleton is defined as an array
node mysoft.js --arr test1 test2
node mysoft.js --arr "[ \"test1\", \"test2\" ]"Programmatic snippet
const ConfManager = require("node-confmanager");
const conf = new ConfManager("./config.json", true /* pretty JSON */);
conf.skeleton("debug", "boolean").shortcut("debug", "d");
await conf.load({
loadEnvFile: ".env",
loadConsole: true,
loadEnv: true,
});
await conf.set("name", "app").save();Tests
npm run tests