Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inline comments #568

Merged
merged 4 commits into from
Jan 17, 2022
Merged

Support inline comments #568

merged 4 commits into from
Jan 17, 2022

Conversation

jonathan-reisdorf
Copy link
Contributor

fixes #524
fixes #545
fixes #156
fixes #484

@PodaruDragos
Copy link

Hello. Is there anything that's blocking this one from getting merged?

@motdotla
Copy link
Owner

@PodaruDragos no, nothing blocking. We are just prioritizing some cleanup and tightening up of the project before this. This will be a major new upgrade.

@motdotla
Copy link
Owner

motdotla commented Jan 17, 2022

@jonathan-reisdorf thank you for this and for your patience. Apologies for the delay. If you end up joining Dotenv Sync, let me know and I will make sure they get you 6 months free for your organization.

@motdotla motdotla merged commit a02d32d into motdotla:master Jan 17, 2022
@renandecarlo
Copy link

This broke using # in the variable itself. Such as:
MSG=Hello, you've got a new order (#%order_n%)

How should I use it now?

@jonathan-reisdorf
Copy link
Contributor Author

jonathan-reisdorf commented Jan 21, 2022

@renandecarlo Yes, unquoted # characters mark now the beginning of a comment. In order to use the character in the value, you now have to put it in quotes, e.g.

MSG="Hello, you've got a new order (#%order_n%)"

@jonathan-reisdorf
Copy link
Contributor Author

(We could also take into account if there is a space before the # character. E.g. the GNU coreutils' env does that. Then again, I've seen other frameworks/tools behaving exactly as dotenv is now. Let me know @motdotla if you want the # only to mark the beginning of a comment if it's preceded by a space character or if it's the first character, then I'm happy to create a PR for this)

@motdotla
Copy link
Owner

Thanks @jonathan-reisdorf. Let's leave it as is. That has the least surprise.

Sorry about this breaking your line @renandecarlo, but, as @jonathan-reisdorf mentioned, just put double quotes around it and you will be good to go.

@renandecarlo
Copy link

I had to stick with version 13, otherwise it would break my program for everyone already using it without quotes. But that's ok.
I think most comments would have had a space before # though

@motdotla
Copy link
Owner

Ah darn. As a developer myself I never enjoy getting stuck like that. We'll consider an optional flag where you can switch to an older mode.

When you say all your devs would have to switch, can you elaborate on that? You mean they would each have to update their own .env file locally?

@renandecarlo
Copy link

renandecarlo commented Jan 21, 2022

Yes. The example env file shipped with some default values which contained #, like the example above, and those could be changed or not. Everyone would then have to add the quotes to it, otherwise it would break.
Version 13 works just fine for me though.

@Devtronyx
Copy link

Thanks @jonathan-reisdorf. Let's leave it as is. That has the least surprise.

Sorry about this breaking your line @renandecarlo, but, as @jonathan-reisdorf mentioned, just put double quotes around it and you will be good to go.

It is still treated as a comment even inside double quotes. I'm on version 14.2.0. And the value represents a password so it's not much I can do about it

@motdotla
Copy link
Owner

@jonathan-reisdorf can you double check that, please, if you get a chance before I do?

@jonathan-reisdorf
Copy link
Contributor Author

Thanks @jonathan-reisdorf. Let's leave it as is. That has the least surprise.
Sorry about this breaking your line @renandecarlo, but, as @jonathan-reisdorf mentioned, just put double quotes around it and you will be good to go.

It is still treated as a comment even inside double quotes. I'm on version 14.2.0. And the value represents a password so it's not much I can do about it

See #601 (comment)
Typically the wrapping quotes would be outside of the value

@jonathan-reisdorf
Copy link
Contributor Author

jonathan-reisdorf commented Jan 24, 2022

When you say all your devs would have to switch, can you elaborate on that? You mean they would each have to update their own .env file locally?

@motdotla if @renandecarlo uses dotenv the same way as we are in our organization, there's a .env.example file that's committed to git containing the default values, and developers copy that file to their own local .env which is gitignored.
That way, devs can make local changes to the values without creating unstaged changes potentially containing secrets which they might accidentally commit. The disadvantage to this is that there's usually no migration/syncing mechanism between the two files.

Ah, sorry, just read @renandecarlo's comment where he says they are indeed using example env files 👍

@motdotla
Copy link
Owner

The disadvantage to this is that there's usually no migration/syncing mechanism between the two files.

Indeed. We've been building out Dotenv Sync to help solve this problem. @renandecarlo you can give that a try. Then you could make the updates to the .env file (adding quotes), and then all your team members would just run dotenv-cli pull to instantly update their local .env file.

Vylpes pushed a commit to Vylpes/Droplet that referenced this pull request Sep 14, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [dotenv](https://github.com/motdotla/dotenv) | dependencies | major | [`^10.0.0` -> `^16.0.0`](https://renovatebot.com/diffs/npm/dotenv/10.0.0/16.0.3) |

---

### Release Notes

<details>
<summary>motdotla/dotenv</summary>

### [`v16.0.3`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1603-httpsgithubcommotdotladotenvcomparev1602v1603-2022-09-29)

[Compare Source](motdotla/dotenv@v16.0.2...v16.0.3)

##### Changed

-   Added library version to debug logs ([#&#8203;682](motdotla/dotenv#682))

### [`v16.0.2`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1602-httpsgithubcommotdotladotenvcomparev1601v1602-2022-08-30)

[Compare Source](motdotla/dotenv@v16.0.1...v16.0.2)

##### Added

-   Export `env-options.js` and `cli-options.js` in package.json for use with downstream [dotenv-expand](https://github.com/motdotla/dotenv-expand) module

### [`v16.0.1`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1601-httpsgithubcommotdotladotenvcomparev1600v1601-2022-05-10)

[Compare Source](motdotla/dotenv@v16.0.0...v16.0.1)

##### Changed

-   Minor README clarifications
-   Development ONLY: updated devDependencies as recommended for development only security risks ([#&#8203;658](motdotla/dotenv#658))

### [`v16.0.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1600-httpsgithubcommotdotladotenvcomparev1501v1600-2022-02-02)

[Compare Source](motdotla/dotenv@v15.0.1...v16.0.0)

##### Added

-   *Breaking:* Backtick support 🎉 ([#&#8203;615](motdotla/dotenv#615))

If you had values containing the backtick character, please quote those values with either single or double quotes.

### [`v15.0.1`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1501-httpsgithubcommotdotladotenvcomparev1500v1501-2022-02-02)

[Compare Source](motdotla/dotenv@v15.0.0...v15.0.1)

##### Changed

-   Properly parse empty single or double quoted values 🐞 ([#&#8203;614](motdotla/dotenv#614))

### [`v15.0.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1500-httpsgithubcommotdotladotenvcomparev1432v1500-2022-01-31)

[Compare Source](motdotla/dotenv@v14.3.2...v15.0.0)

`v15.0.0` is a major new release with some important breaking changes.

##### Added

-   *Breaking:* Multiline parsing support (just works. no need for the flag.)

##### Changed

-   *Breaking:* `#` marks the beginning of a comment (UNLESS the value is wrapped in quotes. Please update your `.env` files to wrap in quotes any values containing `#`. For example: `SECRET_HASH="something-with-a-#-hash"`).

..Understandably, (as some teams have noted) this is tedious to do across the entire team. To make it less tedious, we recommend using [dotenv cli](https://github.com/dotenv-org/cli) going forward. It's an optional plugin that will keep your `.env` files in sync between machines, environments, or team members.

##### Removed

-   *Breaking:* Remove multiline option (just works out of the box now. no need for the flag.)

### [`v14.3.2`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1432-httpsgithubcommotdotladotenvcomparev1431v1432-2022-01-25)

[Compare Source](motdotla/dotenv@v14.3.1...v14.3.2)

##### Changed

-   Preserve backwards compatibility on values containing `#` 🐞 ([#&#8203;603](motdotla/dotenv#603))

### [`v14.3.1`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1431-httpsgithubcommotdotladotenvcomparev1430v1431-2022-01-25)

[Compare Source](motdotla/dotenv@v14.3.0...v14.3.1)

##### Changed

-   Preserve backwards compatibility on exports by re-introducing the prior in-place exports 🐞 ([#&#8203;606](motdotla/dotenv#606))

### [`v14.3.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1430-httpsgithubcommotdotladotenvcomparev1420v1430-2022-01-24)

[Compare Source](motdotla/dotenv@v14.2.0...v14.3.0)

##### Added

-   Add `multiline` option 🎉 ([#&#8203;486](motdotla/dotenv#486))

### [`v14.2.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1420-httpsgithubcommotdotladotenvcomparev1411v1420-2022-01-17)

[Compare Source](motdotla/dotenv@v14.1.1...v14.2.0)

##### Added

-   Add `dotenv_config_override` cli option
-   Add `DOTENV_CONFIG_OVERRIDE` command line env option

### [`v14.1.1`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1411-httpsgithubcommotdotladotenvcomparev1410v1411-2022-01-17)

[Compare Source](motdotla/dotenv@v14.1.0...v14.1.1)

##### Added

-   Add React gotcha to FAQ on README

### [`v14.1.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1410-httpsgithubcommotdotladotenvcomparev1401v1410-2022-01-17)

[Compare Source](motdotla/dotenv@v14.0.1...v14.1.0)

##### Added

-   Add `override` option 🎉 ([#&#8203;595](motdotla/dotenv#595))

### [`v14.0.1`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1401-httpsgithubcommotdotladotenvcomparev1400v1401-2022-01-16)

[Compare Source](motdotla/dotenv@v14.0.0...v14.0.1)

##### Added

-   Log error on failure to load `.env` file ([#&#8203;594](motdotla/dotenv#594))

### [`v14.0.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1400-httpsgithubcommotdotladotenvcomparev1301v1400-2022-01-16)

[Compare Source](motdotla/dotenv@v13.0.1...v14.0.0)

##### Added

-   *Breaking:* Support inline comments for the parser 🎉 ([#&#8203;568](motdotla/dotenv#568))

### [`v13.0.1`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1301-httpsgithubcommotdotladotenvcomparev1300v1301-2022-01-16)

[Compare Source](motdotla/dotenv@v13.0.0...v13.0.1)

##### Changed

-   Hide comments and newlines from debug output ([#&#8203;404](motdotla/dotenv#404))

### [`v13.0.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1300-httpsgithubcommotdotladotenvcomparev1204v1300-2022-01-16)

[Compare Source](motdotla/dotenv@v12.0.4...v13.0.0)

##### Added

-   *Breaking:* Add type file for `config.js` ([#&#8203;539](motdotla/dotenv#539))

### [`v12.0.4`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1204-httpsgithubcommotdotladotenvcomparev1203v1204-2022-01-16)

[Compare Source](motdotla/dotenv@v12.0.3...v12.0.4)

##### Changed

-   README updates
-   Minor order adjustment to package json format

### [`v12.0.3`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1203-httpsgithubcommotdotladotenvcomparev1202v1203-2022-01-15)

[Compare Source](motdotla/dotenv@v12.0.2...v12.0.3)

##### Changed

-   Simplified jsdoc for consistency across editors

### [`v12.0.2`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1202-httpsgithubcommotdotladotenvcomparev1201v1202-2022-01-15)

[Compare Source](motdotla/dotenv@v12.0.1...v12.0.2)

##### Changed

-   Improve embedded jsdoc type documentation

### [`v12.0.1`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1201-httpsgithubcommotdotladotenvcomparev1200v1201-2022-01-15)

[Compare Source](motdotla/dotenv@v12.0.0...v12.0.1)

##### Changed

-   README updates and clarifications

### [`v12.0.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1200-httpsgithubcommotdotladotenvcomparev1100v1200-2022-01-15)

[Compare Source](motdotla/dotenv@v11.0.0...v12.0.0)

##### Removed

-   *Breaking:* drop support for Flow static type checker ([#&#8203;584](motdotla/dotenv#584))

##### Changed

-   Move types/index.d.ts to lib/main.d.ts ([#&#8203;585](motdotla/dotenv#585))
-   Typescript cleanup ([#&#8203;587](motdotla/dotenv#587))
-   Explicit typescript inclusion in package.json ([#&#8203;566](motdotla/dotenv#566))

### [`v11.0.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#&#8203;1100-httpsgithubcommotdotladotenvcomparev1000v1100-2022-01-11)

[Compare Source](motdotla/dotenv@v10.0.0...v11.0.0)

##### Changed

-   *Breaking:* drop support for Node v10 ([#&#8203;558](motdotla/dotenv#558))
-   Patch debug option ([#&#8203;550](motdotla/dotenv#550))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC43NC4yIiwidXBkYXRlZEluVmVyIjoiMzQuNzQuMiJ9-->

Co-authored-by: Renovate Bot <renovate@vylpes.com>
Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/Droplet/pulls/105
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: RenovateBot <renovate@vylpes.com>
Co-committed-by: RenovateBot <renovate@vylpes.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants