
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.
npm install configon --save-dev
Configon uses configuration value files and template files to generate the configuration required by applying all configuration values to the templates for the respective environment.
Given below is a sample implementation of Configon, please take a look at the example folder for a detailed example.
var Configon = require( 'configon' );
const config = new Configon( './path-to-config-files/config.@@ENV.json' )
.addTemplate( './path-to-template-files/template1.ts','./output-dir/output-filename1.ts' )
.addTemplate( './path-to-template-files/template2.xml','./output-dir/output-filename2.xml' )
.build( 'environment-name' );
The key @@ENV denotes the environment name, The value for @@ENV on the filename will be used as the environment name.
Configurations are stored as key, value pairs in configuration file specific for an environment and the key is used with the "@@" symbol in the front in template files which will be replaced with respective value while configuration is built.
NOTE: All text based files can be used as a template
Example template1.ts
/**
* Contains all Application configuration
*/
export const AppConfig = {
/**
* Logging level
*/
LOG_LEVEL : '@@LOG_LEVEL',
/**
* API URL of the server
*/
API_URL : '@@API_URL'
}
config.development.json
{
"LOG_LEVEL": "debug",
"API_URL": "http://localhost:8080"
}
output-filename1.ts
/**
* Contains all Application configuration
*/
export const AppConfig = {
/**
* Logging level
*/
LOG_LEVEL : 'debug',
/**
* API URL of the server
*/
API_URL : 'http://localhost:8080'
}
Following keys are available on configon and can be used in the templates to fill data
Key | Description |
---|---|
@@ENV | Name of the environment which is taken from the file name |
@@APP_NAME | Name of the application retrieved from package.json |
@@VERSION | Version of the application retrieved from package.json |
@@BUILD_DATE | It takes current system date/time during the build as the build date |
@@MY_IP_ADDRESS | Your local IP Address of the system or the value passed as parameters, if retrieving IP Address fails localhost will used. |
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 >
Eg.
gulp config --env:development
You can set environment variable with the identifier NODE_ENV
For just one run (from the unix shell prompt):
NODE_ENV=development gulp config
More permanently:
export NODE_ENV=development
gulp config
In Windows:
SET NODE_ENV=production
gulp config --env:development
NODE_ENV
environment variableThis 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`
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 |
See the contribute file!
PRs accepted.
FAQs
Configuration management for apps for multiple environments
The npm package configon receives a total of 1 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.