← Project archive
EXPLORATION / OPEN SOURCE

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.

PRESERVED PROJECT DOCUMENTATION

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:

  1. JavaScript File: A script to get the current environment and app related configurations.
  2. Node.js Application: An app to set and store the environment in a file.
  3. 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 appName to 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.
  • Click on extensions icon and select Environment Selector.
  • A popup will appear offering a dropdown with option Development, QA, Staging for now. you can add more by yourself in the popup.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-extension it will be saved to environment.json of the Node application

Steps to use

  1. import the script into your application
  2. Start the Environment Manager Node.js server
  3. Load the Chrome extension
  4. 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/*"
  ],
Keep exploring.Return to the archive