Giter Club home page Giter Club logo

sync-dotenv's People

Contributors

akhilome avatar allcontributors[bot] avatar bolajiolajide avatar cmckni3 avatar danieldspx avatar dependabot[bot] avatar luqmanoop avatar x3rax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sync-dotenv's Issues

Reverse sync?

I have a use-case to sync .env and .env.example (or .env.dist in my case) in the opposite direction - pushing updates on the .env file whenever .env.dist additions are made. Not the immediate use-case you cover, but it feels possible and equivalent.

Currently this fails, due to some check on the .env file name. Is this check necessary?

> sync-dotenv --env .env.dist --sample .env

Cannot sync .env with .env

'=' characters present in values get deleted, along with any text following

Take this .env file:
MY_URL=https://my.website.com?this=that

With a .env.example equivalent of:
MY_URL=

After processing with sync-dotenv this is changed to:
MY_URL=https://my.website.com?this

Whatever is parsing the = for delimiting Key and Value appears to be doing something else for any subsequent = occurrences.

Keys deleted from .env.example when not in .env

Hi @codeshifu , I have this problem.

Sometimes I keep some keys in .env.example for documentation but not in .env because I use defaults or something.

So, if you have keys in .env.example but not in .env, when you sync they are deleted from .env.example.

Example

.env:

BOTH=1
ENV=0

.env.example:

BOTH=2
EXAMPLE=42
ANOTHER=24
ENV=3

run sync-dotenv then

.env.example:

BOTH=2
ENV=3

The keys EXAMPLE and ANOTHER were deleted.

Thanks

Preserving variables in sample env ?

Hello

It's not clear from the README but what does this do...

"sync-dotenv": {
  "preserve": ["CHANNEL"]
}

Is "CHANNEL" a variable name that is to be preserved ?

Thanks,
Nick

Strange behaviour with KEY=#value

I have to store an env variable with a slack channel starting with # character.

Scenario 1:

.env:

# Default channel
CHANNEL=#general

.env.example:

# Default channel
CHANNEL=#random

run sync-dotenv then

.env.example:

CHANNEL= #general

Comment was deleted and value was overwritten with .env value and a spaces was added.

Scenario 2:

If I use quotes (singles or doubles)

.env:

# Default channel
CHANNEL='#general'

.env.example:

# Default channel
CHANNEL='#random'

run sync-dotenv then

.env.example:

CHANNEL= 

It deletes both, comment and value from key.

So I can't keep my .env.example with a useful example.

It would be great if you could consider this case.

Thanks

[Suggestion]: Support for syncing multiple `.env.*` files

Thanks for this great library. It solves an issue we've had with keeping .env files in sync and we're super glad we've found it.

We are wondering if it would be of interest for the library to support "fan-out" to multiple .env files from one .env.template.

Our setup often looks like:

.env.template
.env.local
.env.staging
.env.production

this helps us simulating and configuring interaction with different parts of the system. We would love to sync from the .env.template to all other env files. This would require, to my understanding, some globbing (in the root) by the library instead of relying on one file.

Thanks.

[Feature Proposal]: Opt-in Preservation of Public Variables in .env to .example.env Syncing

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:

  1. 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_PUBLIC will keep its original value in the .example.env file.

    Default behavior (when flag is used without a value): An error will be thrown requesting for a prefix input.

  2. Keyword Comment Preservation: Allow users to mark variables for preservation using a default or custom keyword comment at the end of the line.

    .env file 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_VALUE will keep its original value in the .example.env file.

    Default behavior (when flag is used without a value): An error will be thrown requesting for a keyword input.

Considerations:

  1. Need to ensure these changes are well documented in the CLI help text.

  2. Need to provide examples in the readme for the new flag and potential use cases.

  3. Error handling needs to be designed carefully to provide meaningful error messages, especially when the new flags are used without necessary inputs.

Weird empty line entries after tenth new line

No matter how I order the .env file always it always gets screwed up after the tenth extra new line. The following gets inserted instead of new lines: __EMPTYLINE_10__= __EMPTYLINE_11__= etc instead of a blank line.

As a convoluted example:

APP_NAME=

APP_ENV=

APP_KEY=

APP_DEBUG=

APP_URL=

LOG_CHANNEL=

DB_CONNECTION=

DB_HOST=

DB_PORT=

DB_DATABASE=

DB_USERNAME=

DB_PASSWORD=

OTHER_ENV=

Gets synced as:

APP_NAME=

APP_ENV=

APP_KEY=

APP_DEBUG=

APP_URL=

LOG_CHANNEL=

DB_CONNECTION=

DB_HOST=

DB_PORT=

DB_DATABASE=
__EMPTYLINE_10__=
DB_USERNAME=
__EMPTYLINE_11__=
DB_PASSWORD=
__EMPTYLINE_12__=

Not sure if its on my end or the scripts end but was hoping you might have some answers

undefined not found

If no .env.example file is already created, the script just says undefined not found. I expected it to create the file automatically if it didn't already exist.

Update globby due to deprecated dependencies

Please update globby to at least 10.0.

So ever since those packages were deprecated 2 months ago, when I run npm install with sync-dotenv 2.7.0 as a dependency, I get these deprecation warnings:

$ npm install

npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated

sync-dotenv is using globby.sync which has the same input and output from 9.2.0 up until 12.0.0, at which point globby.sync became globbySync.

Summary

globby 9.2 could be updated to 10 or 11 without API breaking changes. It could be updated to 13.1 with 1 breaking change, which would simply require importing { globbySync } instead of globby, and calling globbySync directly instead of calling globby.sync.

I will open a pull request to update globby to 11.1 without the breaking change.

Cannot use 'example.env' as example file name

Not a big deal, of course, but it's a tiny issue nonetheless -

Currently, any sample filename provided via the CLI that ends with .env throws an error.
While I understand the reasoning - can't sync .env itself with .env - my team uses example.env as the filename for the example file (as if to say, "here's an example .env file").
Would it be OK to change the check for exclusively .env files - not all files that end with .env, or is this a matter of policy (or a best practice I'm unaware of)?

Thanks for your help!

Synchronize Comments

Dear @codeshifu ,

thanks for this wonderful package - i really like it.
I recently stumbled upon the issue, that i have comments in my .env file. I would like to synchronize these comments with my .env.example file.

Would you consider adding this feature to your library?
Thanks a lot!

Symfony .env & .env.local

Hi ,

In symfony 4.3 they changed the way to use .env files , now .env file are the example & are commited into repo & we have to overwrite them with .env.local.

So to use sync-dotenv we should be able to indicate source / destination .

I will do a PR if got some time

'=' characters present in values get deleted, along with any text following

Take this .env file:
MY_URL=https://my.website.com?this=that

With a .env.example equivalent of:
MY_URL=

After processing with sync-dotenv this is changed to:
MY_URL=https://my.website.com?this

Whatever is parsing the = for delimiting Key and Value appears to be doing something else for any subsequent = occurrences.

"TypeError: Cannot read property 'inherits' of undefined" in version 2.5.0

First things first: Great work, thanks for this tool πŸ˜ƒ

I encounter the following error when I try to run sync-dotenv in version 2.5.0:

TypeError: Cannot read property 'inherits' of undefined                                                            β”‚
    at Object.<anonymous> (/home/x3ro/.local/opt/n/lib/node_modules/sync-dotenv/dist/index.js:2:16669)             β”‚found 0 vulnerabilities
    at Module._compile (internal/modules/cjs/loader.js:1147:30)                                                    β”‚
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)                                      β”‚x3ro@K1STE:~/Projects/x3ro/hacker-news-bot$ ^C
    at Module.load (internal/modules/cjs/loader.js:996:32)                                                         β”‚x3ro@K1STE:~/Projects/x3ro/hacker-news-bot$ tail -f .env.example 
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)                                               β”‚ # Copy this file to `.env` and change values as needed.
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)                            β”‚
    at internal/main/run_main_module.js:17:47

I tried installing it globally, in a project and even in an empty project.

Installing [email protected] works flawlessly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.