Skip to content

support custom dotenv path #613

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

Merged
merged 1 commit into from
Jul 8, 2019

Conversation

jaredh159
Copy link
Contributor

@jaredh159 jaredh159 commented Feb 12, 2019

Fixes #517.

Uses pkg-conf to allow this sort of thing in the package.json:

{
  "dbMigrate": {
    "dotenvCustomPath": "../../.env"
  }
}

The above example allows for usage in a typical monorepo setup, which has packages in <root>/packages/* and typically a single .env file in the monorepo root.

I didn't add any tests because I was a bit intimidated by the tests in api_test.js -- Lab is not a framework I'm familiar with at all, and the complexity of the setup/mocking/spy etc. was sort of formidable. But the change here is really straightforward, and I think would help a lot of folks.

@commitlint-wzrdtales
Copy link

There were the following issues with this Pull Request

  • Commit: 4470a9a
    • ✖ message may not be empty
      , - ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

@jaredh159 jaredh159 force-pushed the custom-dotenv-path branch 5 times, most recently from 0d5e13e to 7cdab3a Compare February 19, 2019 20:22
@stale
Copy link

stale bot commented Mar 21, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 21, 2019
@jaredh159
Copy link
Contributor Author

@wzrdtales have you had a chance to look at this PR?

@stale stale bot removed the stale label Mar 21, 2019
@stale
Copy link

stale bot commented Apr 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 20, 2019
@jaredh159
Copy link
Contributor Author

@wzrdtales any thoughts?

@stale stale bot removed the stale label Apr 20, 2019
@wzrdtales
Copy link
Member

I wouldn't like to introduce this dependency to do that. Maybe via rc configs + a command line param.

@jaredh159
Copy link
Contributor Author

Thanks for the reply. I'm not sure what you mean by "Maybe via rc configs + a command line param." Could you elaborate? Or were you thinking you'd provide an alternate implementation? I don't understand enough from that to revise this PR, and I still think monorepo support seems pretty important.

Is there a reason you're hesitant to introduce the pkg-config dependency? It's seems to be sort of the de-facto community standard package for retrieving configuration in the package.json -- which itself seems like a really good pattern because then we don't have to add a dotfile for every single tool we use.

@wzrdtales
Copy link
Member

Yes, the reason is, I don't want 1 trillion ways to configure db-migrate. I added already rc https://www.npmjs.com/package/rc to cover the need of dynamic environmental configuration. So rc itself covers pretty much everything dotenv covers and more. But dotenv has been there for long and has some standing in the developer community, which is the only reason beneath a breaking change, that I did not removed it. So if there is a custom option to enable these rather get this via the already existing integrated rc module, see the modules docs for that.

@wzrdtales
Copy link
Member

rc configs are by the way the oldest standard for user configs in the unix universe, so you probably already now how to handle it :)

@jaredh159
Copy link
Contributor Author

So, are you proposing that a monorepo setup not use .dotenv, but rather use an .rc file? Or are you saying that we should use an .rc file to config .env?

@wzrdtales
Copy link
Member

both is a valid answer. if there is a need to configure an option for .env files do it via a command line param + from the rc configs.

@jaredh159 jaredh159 force-pushed the custom-dotenv-path branch from 7cdab3a to d03f0b6 Compare May 17, 2019 14:24
@commitlint-wzrdtales
Copy link

There were the following issues with this Pull Request

  • Commit: d03f0b6
    • ✖ message may not be empty
      , - ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

@jaredh159 jaredh159 force-pushed the custom-dotenv-path branch from d03f0b6 to aef82c3 Compare May 17, 2019 14:28
@jaredh159
Copy link
Contributor Author

jaredh159 commented May 17, 2019

@wzrdtales updated, per your recommendation. Now you can do something like:

npm run db-migrate up --dotenvCustomPath "../../.env"

or put it in a .db-migraterc file.

@jaredh159
Copy link
Contributor Author

Whoops, my example should have read:

npm run db-migrate up --dotenvCustomPath "../../.env"

@stale
Copy link

stale bot commented Jul 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 8, 2019
@jaredh159
Copy link
Contributor Author

@wzrdtales did you have a chance to look at the PR? I think I did what you asked.

@stale stale bot removed the stale label Jul 8, 2019
@wzrdtales
Copy link
Member

Went under the radar, I'm completely fine with this

@wzrdtales wzrdtales merged commit 805d95e into db-migrate:master Jul 8, 2019
@magesh-memorres
Copy link

When I pass this argument in version 0.11.14 of db-migrate. it completely ignores it. when I switched to 1.0.0-beta.27 it works like a charm. I can see that this is merged to master but I can't use it

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.

Allow configuration option for dotenv path.
3 participants