
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Gulp tool for generating configuration files for multiple environments on your app. Simply lets you generate templated files based on a specific environment config.
Install Configon
$ npm install configon --save-dev
You can simply add the following code on to your gulp file and start using it
var EnvConfig = require('configon');
const config = new EnvConfig( './example/config/config.@@ENV.json' )
.addTemplate( './example/config/template.ts','./bin/config.ts' )
.addTemplate( './example/config/template.xml','./bin/config.xml' );
gulp.task('config', function() {
var defaultEnv = 'dev';
config.build( defaultEnv );
});
You can pass parameters with arguments through CLI or also set NODE_ENV environment variable or pass a parameter when you call build in your gulp task.
Following examples assumes that your gulp task is config
$ gulp config --env:< environment >
$ gulp config --env:dev
$ gulp config --env:prod
You can set environment variable with the identifier NODE_ENV
For just one run (from the unix shell prompt):
$ NODE_ENV=dev gulp config
More permanently:
$ export NODE_ENV=dev
$ gulp config
In Windows:
$ SET NODE_ENV=dev
This is useful if you are developing a mobile application and you want to point you app to a custom IP Address in your LAN
$ gulp config --ip:< IP Address >
$ gulp config --ip:192.168.0.100 --env:device
This section tells you how to change configuration for environment
Configon uses gulp to change the configuration. It generates a file from a template file applying all configuration values from the configuration (value) files. It matches the key in template file with values in configuration file.
NOTE: Any text based files can be used as a template
Example template.ts
/**
* Contains all Application configuration
*/
export const AppConfig = {
/**
* Logging level
*/
LOG_LEVEL : '@@LOG_LEVEL',
/**
* API URL of the server
*/
API_URL : '@@API_URL'
}
config.json
{
"LOG_LEVEL": "debug",
"API_URL": "http://localhost:8080"
}
output.ts
/**
* Contains all Application configuration
*/
export const AppConfig = {
/**
* Logging level
*/
LOG_LEVEL : 'debug',
/**
* API URL of the server
*/
API_URL : 'http://localhost:8080'
}
You can add the following keys in your configuration file to automatically fetch the application name and version from package.json and build date from the system.
@@APP_NAME
- Application Name@@VERSION
- Application version@@BUILD_DATE
- Application build date@@ENV
- Environment nameExample template.ts
...
/**
* Name of the app
*/
APP_NAME : '@@APP_NAME',
/**
* Version of the app
*/
VERSION : '@@VERSION',
/**
* Build date of the app
*/
BUILD_DATE : '@@BUILD_DATE',
/**
* Build date of the app
*/
ENV : '@@ENV',
...
You can add the key "@@MY_IP_ADDRESS" to your configuration to load your local IP Address.
Eg.
API_URL : 'http://@@MY_IP_ADDRESS:8080'
key "@@MY_IP_ADDRESS" will replaced with Custom IP Address, if retrieving IP Address fails localhost
will used.
NOTE:
name | arguments | description |
---|---|---|
Configon constructor | configFilePattern:String | Creates an instance var EnvConfig = require('configon'); var config = EnvConfig( './config/config.@@ENV.json' ); Key @@ENV denotes the environment name in the file path |
build | environment:String(optional) ipAddress:String(optional) | Builds the configuraation and apply all the changes to templates and export them in to the required location |
addTemplate | templateFile:String outputFile:String | Add template file path and its destination path. |
removeTemplate | templateFile:String | Removes detail of template file from the list of templates |
setDefaultEnv | env:String | Sets default environment for configuration |
Key | description |
---|---|
@@ENV | Name of the environment |
@@APP_NAME | Name of the application |
@@APP_VERSION | Version of the application |
@@BUILD_DATE | Build date of the current build |
@@MY_IP_ADDRESS | Your local IP Address |
See the contribute file!
PRs accepted.
FAQs
Configuration management for apps for multiple environments
The npm package configon receives a total of 0 weekly downloads. As such, configon popularity was classified as not popular.
We found that configon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.