Environment Sync
A lightweight developer utility for synchronizing environment configurations across projects and machines, helping teams maintain consistent .env setups with minimal friction. Built to simplify configuration management, reduce setup time, and streamline local development workflows.
Environment Manager
Overview
The Environment Manager is a comprehensive tool-set for managing and tracking the current environment configuration across UI applications. It consists of:
- JavaScript File: A script to get the current environment and app related configurations.
- Node.js Application: An app to set and store the environment in a file.
- Chrome Extension: An extension to set the environment directly from the Chrome browser.
Components
1. JavaScript File
Purpose: Returns the current environment and app configs.
Usage:
- Include the script at the top of your project in
app.ts. - pass the
appNameto get the app relate configuration
| Application | appName |
|---|---|
| Web Service | web-service |
| OMS | oms |
| Manage | manage |
Code:
/**
* LOCAL CONFIGURATION
* [Should never be pushed]
*/
import getEnvironmentConfig from '[PATH-TO-ENVIRONMENT-SYNC]/local-config/activeConfig';
const currentConfig = getEnvironmentConfig('appName');
/**
* Local configuration ends here
*/
2. Chrome Extension
Purpose: Allows you to set the environment directly from your Chrome browser.
Usage:
- Load the extension into Chrome:
- Open
chrome://extensions/in your Chrome browser. - Enable "Developer mode".
- Click "Load unpacked" and select the extension directory, in this case
chrome-extension.
- Open
- Click on
extensionsicon and selectEnvironment Selector. - A popup will appear offering a dropdown with option
Development,QA,Stagingfor now. you can add more by yourself in thepopup.html. - Click on
Save Environment. - An alert will be shown saying
current environment: [user selected Environment]
3. Node.js Application
Purpose: Sets the current environment and saves it to a file.
Usage:
- Run the application using Node.js using the command
npm start. - Application will run on port
4000. - As the environment is selected from the
chrome-extensionit will be saved toenvironment.jsonof the Node application
Steps to use
- import the script into your application
- Start the Environment Manager Node.js server
- Load the Chrome extension
- Select the environment and refresh the page
Contributing
Feel free to open issues or submit pull requests if you have suggestions or improvements!
Note
Add all your domains in host_permissions of manifest.json
"host_permissions": [
"https://dev-runner.cargoes.com/*",
"https://qa-runner.cargoes.com/*",
"https://staging-runner.cargoes.com/*"
],