-
Notifications
You must be signed in to change notification settings - Fork 33
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
Vault via CLI? #253
Comments
Also wondering how to do this We could run But this will only work when logged in, therefore this would only work for development environment Curious how to do this without being signed in, when we set the ChatGPT is suggesting:
Well, this command doesn't exit. LOL |
Probably duplicate of #174 |
It's probably not the exact equivalent of
You can then go through that file to export the variables into your shell environment or adapt your CLI script / tool to read that .env file directly (like the original dotenv). Similar to what @devidw proposed by using the DOTENV_KEY, without the need of being signed in or having a .env.me file around. |
I created dotenv-vault-core-cli to achieve this npx dotenv-vault-core-cli -e .env -- my-script The sooner the package is made irrelevant by upstream changes the better UpdateYou can now use |
Thank you, @hbriese. We want to make There is an RC candidate here: https://github.com/motdotla/dotenv/tree/v16.1.0-rc1 That is just about ready. We're now wrapping up work on local support (no remote API calls) to generate your It's coming for node soon. We've been working in languages where it will have less impact. This update to dotenv nodejs will be its most significant update in many years. Then everyone downstream using dotenv will have the option to use All local commands will live here: https://github.com/dotenv-org/dotenv-vault/tree/master/src/commands/local |
I just want to bump I believe this is resolved now? I see that support is now in dotenv, and theoretically dotenv-cli can handle it. There aren't any documented examples though |
Yep npx dotenv <command with arguments> |
Yep, their package.json as 16 or greater in it: https://github.com/entropitor/dotenv-cli/blob/master/package.json#L11 so as long as you install fresh, you'll get 16.1.4 and should be able to decode .env.vault files. I haven't tried this, though, yet. We'll try to get a guide on our dotenv.org/docs soon. |
Any thoughts on what to do with a non-standard .env path? Just reference the vault file? for example inside a nested folder that uses a require like this:
I guess |
Currently, you'll have to cd to the directory where the .env file is and then run: dotenv-vault push/pull/etc from there. |
On our todos is a better way to handle this - especially with multiple .env files in a monorepo. |
Hmmm little confused, so just to clarify:
Both workspaces use the same enviroronment variables (So just 1 .env for all) With the update you shouldn't have to decode the .env.vault file into an actual .env file anymore dotenv-cli should be able to just read in the .env.vault, and as long as the process.env.DOTENV_KEY exists it should work? |
Ah yes, I think you are right. Give it a shot.
I haven't used personally with dotenv-cli yet.
On Wed, Jun 7, 2023, at 4:51 PM, Tom Rowe wrote:
Hmmm little confused, so just to clarify:
`.env.vault
/workspaces
/workspace-1
package.json <-- run script in here with environment variables
/workspace-2
`
… Bot hworkspaces use the same enviroronment variables (So just 1 .env for all)
With the update you shoudln't have to decode the .env.vault file into an actual .env file anymore
dotenv-cli should be able to just read in the .env.vault, and as long as the process.env.DOTENV_KEY exists it should work?
—
Reply to this email directly, view it on GitHub <#253 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAA6CA4V6VIRVOUQ6YJNT3XKEHZ3ANCNFSM6AAAAAAVIZQ4ZE>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Yeah I can't get any configuration to work, i'm not sure how you are doing it @hbriese? This is ignoring my path stuff from before, we are just talking: .env.vault
So to test locally I add it with a few different configurations:
None of them load the environment variables in |
Looks like you're trying to use Not 100% if this is required, but "resolutions": {
"dotenv": "^16.1.3"
}, You can verify it worked with I don't think passing the |
I did the same ^
I was just about to try this thinking the same thing ^^^ It's fine on the server, because it's already running DOTENV_KEY before any scripts are called, just locally is the problem Will confirm if this works in a little while |
Confirming @hbriese that the resolutions is indeed necessary! I'll raise a ticket for them to bump it up to support vault Pushing the DOTENV_KEY in early was the fix.... they might need to implement a way to pass it for Vault files in the future. I guess we can close this now! |
If they need to set it directly in the library that is supported as of a few weeks ago: https://github.com/motdotla/dotenv#dotenv_key
|
In order to get the same .pnpmfile.cjs module.exports = {
hooks: {
readPackage(packageJson) {
if (packageJson.name === 'dotenv-cli') {
packageJson.dependencies['dotenv'] = '^16.1.3'
}
return packageJson
},
},
} |
It doesn't seem to be mentioned anywhere, is there a way to initiate the environment variables similar to
dotenv-cli
prior to running a CLI only script?The text was updated successfully, but these errors were encountered: