T-Configurator
Allows to create and manage configuration files in your project. You can use gulp-config-parameters plugin to automate how your configuration is created and managed.
Usage
Create your configuration file, lets say ./config.json
:
Then register your configuration file in configurator and use it to get your configuration properties:
; defaultConfigurator.setConfigurationrequire'./config.json';console.log'factory name: ', configurator.get'factoryName'; // prints: factory name: BMWconsole.log'show engine info?: ', configurator.get'showEngineInfo'; // prints: show engine info?: trueconsole.log'car engine: ', configurator.get'engine'; // prints: car engine: [Object object]
If you have separate parameters file you can use it this way:
Lets say you have created ./parameters.json
And your ./config.json
is like this:
Now you can use configuration (with replaced parameters) this way:
; defaultConfigurator.setConfigurationrequire'./config.json';defaultConfigurator.replaceWithParametersrequire'./parameters.json';console.log'factory name: ', configurator.get'factoryName'; // prints: factory name: BMWconsole.log'show engine info?: ', configurator.get'showEngineInfo'; // prints: show engine info?: trueconsole.log'car engine: ', configurator.get'engine'; // prints: car engine: [Object object]
This allows you to create a common configuration file for your app, and use different parameters on different platforms. You can use gulp-config-parameters plugin to automate this process.
typedi you can inject your configuration in your classes
If you are using;;;
You can also inject right to the properties:
;;;
Take a look on samples in ./sample
for more examples of usages.
Todos
- cover with tests
- more documentation and samples