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

remove dotenv #946

Merged
merged 3 commits into from
Dec 5, 2023
Merged

remove dotenv #946

merged 3 commits into from
Dec 5, 2023

Conversation

gwbischof
Copy link
Contributor

@gwbischof gwbischof commented Dec 4, 2023

The .env file is needed to build the app.
Github workflows to build the app will fail without it.

I did a bit of googling and I didn't find a way to change the pubspec.yaml (which uses the .env) to handle a missing .env file.

Adding an empty .env file removes a step from getting thunder running.
I left the .env in the gitignore so peoples changes to .env wont accidentally get pushed.

@micahmo
Copy link
Member

micahmo commented Dec 4, 2023

I left the .env in the gitignore so peoples changes to .env wont accidentally get pushed.

Unfortunately that doesn't work. 😞 The .gitignore only has effect when Git is considering which files to track. Once you've tracked a file (either it wasn't in .gitignore at the time, or you force added it, etc.), the .gitignore has no effect.

As a test, I grabbed your branch and appended to the .env file, and you can see that it has a pending change. And I tailed the .gitignore to show it's still there.

image

If the workflow or any scripts need the file, maybe they can create it on the fly?

EDIT: Alternatively, if we never intend for anyone to add contents to this file, then it's probably safe to have in source control. We just probably should take it out of .gitignore so it doesn't provide a false sense of security.

@gwbischof
Copy link
Contributor Author

Ohh thanks! I didn't consider that. I wonder if there is some better way to have a default .env file.

@gwbischof
Copy link
Contributor Author

gwbischof commented Dec 4, 2023

I removed .env from the gitignore.
I did another search and couldn't figure out how to get this line not to error out when the .env doesn't exist: https://github.com/thunder-app/thunder/blob/develop/pubspec.yaml#L131

@gwbischof
Copy link
Contributor Author

gwbischof commented Dec 4, 2023

Here is a related issue:
java-james/flutter_dotenv#70

Maybe we can just add the empty file? and remove from gitignore?

@gwbischof gwbischof changed the title add empty .env file, but keep it in the gitignore add empty .env file Dec 4, 2023
@micahmo
Copy link
Member

micahmo commented Dec 4, 2023

I did another search and couldn't figure out how to get this line not to error out when the .env doesn't exist

Do we need that line at all of the .env is always empty?

Maybe we can just add the empty file? and remove from gitignore?

That sounds reasonable too, with our current usage.

@hjiangsu
Copy link
Member

hjiangsu commented Dec 4, 2023

I believe we might just be able to get rid of dotenv package and related implementation completely. It was previously used for Sentry to allow me to detect errors in production but its no longer used.

In the future, we might want to add in secrets for API endpoints (Imgur, or other APIs). If that's the case, then we can revisit this discussion. Thoughts?

@gwbischof
Copy link
Contributor Author

This is a decent summary: https://www.sandromaglione.com/articles/how-to-use-environmental-variables-in-flutter

I think we can use --dart-define to pass environment variables or secrets.
The build scripts can pass the environment variables to flutter build with --dart-define.
If you are using github workflows to build, then you can use github secrets to store your secrets and pass them into the build: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions

And .vscode/launch.json can be used to pass variables for development.

So I think getting rid of the dotenv makes sense.

@gwbischof gwbischof changed the title add empty .env file remote dotenv Dec 4, 2023
@gwbischof gwbischof changed the title remote dotenv remove dotenv Dec 4, 2023
@gwbischof
Copy link
Contributor Author

gwbischof commented Dec 4, 2023

Just updated it and removed it, I can change it back if that's not what you want

@hjiangsu
Copy link
Member

hjiangsu commented Dec 5, 2023

Looks good to me! Thanks for doing this @gwbischof

@hjiangsu hjiangsu merged commit a7c3578 into thunder-app:develop Dec 5, 2023
1 check passed
@hjiangsu hjiangsu mentioned this pull request Jan 4, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants