-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Feature Proposal: Enhancements for Syncing .env Files
Objective:
Improve the functionality of our CLI tool that synchronises .env files to .example.env files by providing an escape mechanism to preserve specific values for public variables.
Problem:
Currently, all variables in the .example.env file exist as empty strings after the syncing process. It would be helpful for public variables to retain their values.
Proposed Solution:
I thought of two way to achive this:
-
Public Prefix Preservation: Allow users to specify a custom or default prefix for variable names that they want to remain public. Any variable with this prefix will retain its value during the sync process.
CLI Example:
sync-dotenv --preserve-public-prefix=NEXT_PUBLIC
In this example, any variable starting with
NEXT_PUBLICwill keep its original value in the.example.envfile.Default behavior (when flag is used without a value): An error will be thrown requesting for a prefix input.
-
Keyword Comment Preservation: Allow users to mark variables for preservation using a default or custom keyword comment at the end of the line.
.envfile Example:SENTRY_URL='https://example.ingest.sentry.io/example' #SYNC_VALUE
CLI Example:
sync-dotenv --preserve-keyword-comment=SYNC_VALUE
In this example, any variable line ending with
#SYNC_VALUEwill keep its original value in the.example.envfile.Default behavior (when flag is used without a value): An error will be thrown requesting for a keyword input.
Considerations:
-
Need to ensure these changes are well documented in the CLI help text.
-
Need to provide examples in the readme for the new flag and potential use cases.
-
Error handling needs to be designed carefully to provide meaningful error messages, especially when the new flags are used without necessary inputs.