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

Load env variables from .env #18

Open
chronark opened this issue Mar 12, 2021 · 5 comments
Open

Load env variables from .env #18

chronark opened this issue Mar 12, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@chronark
Copy link
Contributor

You could export them before running any command but I think it would be nice to load them from a .env file for convenience.
Maybe even specify the path and/or variable names in .fauna-migrate.js :)

@fauna-brecht
Copy link
Contributor

supporting dotenv would probably be most logical right?

@chronark
Copy link
Contributor Author

yeah I think that would be best. If I have some time later, I'll add it but I can't promise.

@fauna-brecht fauna-brecht added the enhancement New feature or request label Mar 15, 2021
@ptpaterson
Copy link

If you've got a repo that uses fauna-schema-migrate packed in with app code there could be conflicts with where you would want to stash the variables for just fauna-schema-migrate. Possibly even keeping them separate from serverless-function env variable and also from those exposed to the browser.

I am thinking of at least CreateReactApp and NextJS apps. There's like a whole hierarchy for which files to use when...

Maybe ".env" located inside the required fauna folder would be appropriate?

DOTENV specifically advises against having multiple env files, but when a single repo comprises dev tools, node server code, and browser app code, I feel like it's kindof inevitable. So conflicts and preferences should be accounted for.

@fauna-brecht
Copy link
Contributor

Those are good points @ptpaterson. I might opt to make it configurable as well via the fauna migrate config that is already there. Some users might want to use the same FAUNA admin key and don't want to have two .env files. The default probably should go in the fauna folder. Would also make it easy to generate it initially, considering adding an option in the init to generate that file.

@MKRazz
Copy link

MKRazz commented Feb 25, 2022

Maybe there are better variations on this, but I was experimenting with a temporary workaround, adding this script to package.json:

  "scripts": {
    "fauna-schema-migrate": "DOTENV_CONFIG_PATH=./.env node -r dotenv/config ./node_modules/@fauna-labs/fauna-schema-migrate/dist/cli.js"
  },

Then run with:

npm run fauna-schema-migrate apply

and it will apply the config from a .env file at the root of your project. Or change the path to ./fauna/.env if you want a separate .env file at the root of the fauna folder as @ptpaterson mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants