@dotenvx/dotenvx
Advanced tools
Comparing version
@@ -5,4 +5,12 @@ # Changelog | ||
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.38.5...main) | ||
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.39.0...main) | ||
### Added | ||
* Add `--convention flow` option to `dotenvx run` ([#551](https://github.com/dotenvx/dotenvx/pull/551)) | ||
### Changed | ||
* Fix typos ([#550](https://github.com/dotenvx/dotenvx/pull/550)) | ||
## [1.38.5](https://github.com/dotenvx/dotenvx/compare/v1.38.4...v1.38.5) | ||
@@ -310,3 +318,3 @@ | ||
* for `--convention nextjs` ingnore `.env.local` for TEST environment ([#425](https://github.com/dotenvx/dotenvx/pull/425)) | ||
* for `--convention nextjs` ignore `.env.local` for TEST environment ([#425](https://github.com/dotenvx/dotenvx/pull/425)) | ||
* for `precommit` redirect missing `dotenvx` command using POSIX compliant redirection ([#424](https://github.com/dotenvx/dotenvx/pull/424)) | ||
@@ -852,3 +860,3 @@ * make parent `dotenvx help` command less noisy by removing `[options]`. run `dotenvx COMMAND -h` to list all available options like always ([#429](https://github.com/dotenvx/dotenvx/pull/429)) | ||
* Support encryption replacemnt of multiline values ([#220](https://github.com/dotenvx/dotenvx/pull/220)) | ||
* Support encryption replacement of multiline values ([#220](https://github.com/dotenvx/dotenvx/pull/220)) | ||
@@ -906,3 +914,3 @@ ## 0.40.0 | ||
* `DOTENV_PRIVATE_KEY` lives in your `.env.keys` file. Share this only with those you trust to decrypt your secrets. | ||
* If using encrypted `.env` files like this it is safe to commmit them to source code. This makes reviewing PRs that contain secrets much easier. | ||
* If using encrypted `.env` files like this it is safe to commit them to source code. This makes reviewing PRs that contain secrets much easier. | ||
* Tell your contributors to contribute a secret using the command `dotenvx set HELLO world --encrypt`. | ||
@@ -909,0 +917,0 @@ * Set your `DOTENV_PRIVATE_KEY` on your server to decrypt these values using `dotenvx run -- yourcommand` |
{ | ||
"version": "1.38.5", | ||
"version": "1.39.0", | ||
"name": "@dotenvx/dotenvx", | ||
@@ -4,0 +4,0 @@ "description": "a better dotenv–from the creator of `dotenv`", |
@@ -607,3 +607,3 @@ [](https://dotenvx.com) | ||
Load envs using [Next.js' convention](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#environment-variable-load-order). Set `--convention` to `nextjs`: | ||
Load envs using [Next.js' convention](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#environment-variable-load-order) or [dotenv-flow convention](https://www.npmjs.com/package/dotenv-flow). Set `--convention` to `nextjs` or `flow`: | ||
@@ -1034,2 +1034,27 @@ ```sh | ||
</details> | ||
* <details><summary>`run --convention=flow`</summary><br> | ||
Load envs using [dotenv-flow's convention](https://www.npmjs.com/package/dotenv-flow). Set `--convention` to `flow`: | ||
```sh | ||
$ echo "HELLO=development local" > .env.development.local | ||
$ echo "HELLO=development" > .env.development | ||
$ echo "HELLO=local" > .env.local | ||
$ echo "HELLO=env" > .env | ||
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js | ||
$ NODE_ENV=development dotenvx run --convention=flow -- node index.js | ||
[dotenvx@1.X.X] injecting env (1) from .env.development.local, .env.development, .env.local, .env | ||
Hello development local | ||
``` | ||
Further, we recommend using `DOTENV_ENV` over `NODE_ENV`– as `dotenvx` works everywhere, not just node. | ||
```sh | ||
$ DOTENV_ENV=development dotenvx run --convention=flow -- node index.js | ||
[dotenvx@1.X.X] injecting env (1) from .env.development.local, .env.development, .env.local, .env | ||
Hello development local | ||
``` | ||
</details> | ||
* <details><summary>`run -fk`</summary><br> | ||
@@ -1513,3 +1538,3 @@ | ||
Decrypt the contents inside an encrypted `.env` file except for an exluded key. | ||
Decrypt the contents inside an encrypted `.env` file except for an excluded key. | ||
@@ -1612,3 +1637,3 @@ ```sh | ||
Print a shell formatted reponse of public/private keys. | ||
Print a shell formatted response of public/private keys. | ||
@@ -1764,3 +1789,3 @@ ```sh | ||
Rotate the encrypted contents inside an encrypted `.env` file except for an exluded key. | ||
Rotate the encrypted contents inside an encrypted `.env` file except for an excluded key. | ||
@@ -2220,3 +2245,3 @@ ```sh | ||
Programatically set an environment variable. | ||
Programmatically set an environment variable. | ||
@@ -2232,3 +2257,3 @@ ```js | ||
Programatically get an environment variable at access/runtime. | ||
Programmatically get an environment variable at access/runtime. | ||
@@ -2235,0 +2260,0 @@ ```js |
@@ -64,3 +64,3 @@ const { Command } = require('commander') | ||
// overide helpInformation to hide dynamic commands | ||
// override helpInformation to hide dynamic commands | ||
ext.helpInformation = function () { | ||
@@ -67,0 +67,0 @@ const originalHelp = Command.prototype.helpInformation.call(this) |
@@ -63,3 +63,3 @@ #!/usr/bin/env node | ||
.option('--strict', 'process.exit(1) on any errors', false) | ||
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\'])') | ||
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\', \'flow\'])') | ||
.option('--ignore <errorCodes...>', 'error code(s) to ignore (example: --ignore=MISSING_ENV_FILE)') | ||
@@ -83,3 +83,3 @@ .action(function (...args) { | ||
.option('--strict', 'process.exit(1) on any errors', false) | ||
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\'])') | ||
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\', \'flow\'])') | ||
.option('--ignore <errorCodes...>', 'error code(s) to ignore (example: --ignore=MISSING_ENV_FILE)') | ||
@@ -224,3 +224,3 @@ .option('-a, --all', 'include all machine envs as well') | ||
// overide helpInformation to hide DEPRECATED and 'ext' commands | ||
// override helpInformation to hide DEPRECATED and 'ext' commands | ||
program.helpInformation = function () { | ||
@@ -227,0 +227,0 @@ const originalHelp = Command.prototype.helpInformation.call(this) |
function conventions (convention) { | ||
const env = process.env.DOTENV_ENV || process.env.NODE_ENV || 'development' | ||
if (convention === 'nextjs') { | ||
const nodeEnv = process.env.NODE_ENV || 'development' | ||
const canonicalEnv = ['development', 'test', 'production'].includes(nodeEnv) && nodeEnv | ||
const canonicalEnv = ['development', 'test', 'production'].includes(env) && env | ||
@@ -12,4 +13,12 @@ return [ | ||
].filter(Boolean) | ||
} else if (convention === 'flow') { | ||
return [ | ||
{ type: 'envFile', value: `.env.${env}.local` }, | ||
{ type: 'envFile', value: `.env.${env}` }, | ||
{ type: 'envFile', value: '.env.local' }, | ||
{ type: 'envFile', value: '.env' }, | ||
{ type: 'envFile', value: '.env.defaults' } | ||
] | ||
} else { | ||
throw new Error(`INVALID_CONVENTION: '${convention}'. permitted conventions: ['nextjs']`) | ||
throw new Error(`INVALID_CONVENTION: '${convention}'. permitted conventions: ['nextjs', 'flow']`) | ||
} | ||
@@ -16,0 +25,0 @@ } |
@@ -124,3 +124,3 @@ import type { URL } from 'url'; | ||
/** | ||
* Load a .env convention (available conventions: 'nextjs') | ||
* Load a .env convention (available conventions: 'nextjs, flow') | ||
*/ | ||
@@ -195,3 +195,3 @@ convention?: string; | ||
/** | ||
* Set a .env convention (available conventions: 'nextjs') | ||
* Set a .env convention (available conventions: 'nextjs, flow') | ||
*/ | ||
@@ -198,0 +198,0 @@ convention?: string; |
@@ -49,3 +49,3 @@ /* istanbul ignore file */ | ||
// check if file is going to be commited | ||
// check if file is going to be committed | ||
if (this._isFileToBeCommitted(file)) { | ||
@@ -52,0 +52,0 @@ // check if that file is being ignored |
270557
0.6%4364
0.18%2381
1.06%