@dotenvx/dotenvx 1.15.0 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/lib/services/run.js +28 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.
|
|
5
|
+
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.16.1...main)
|
|
6
|
+
|
|
7
|
+
## 1.16.1
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* suppress stderr using `options.stdio` ([#391](https://github.com/dotenvx/dotenvx/pull/391))
|
|
12
|
+
|
|
13
|
+
## 1.16.0
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
* for `dotenvx keypair` call out to `dotenvx pro keypair` if [pro](https://github.com/dotenvx/dotenvx/issues/259) installed ([#390](https://github.com/dotenvx/dotenvx/pull/390))
|
|
6
18
|
|
|
7
19
|
## 1.15.0
|
|
8
20
|
|
package/README.md
CHANGED
|
@@ -1320,7 +1320,7 @@ More examples
|
|
|
1320
1320
|
</details>
|
|
1321
1321
|
* <details><summary>`keypair --format shell`</summary><br>
|
|
1322
1322
|
|
|
1323
|
-
Print a shell formatted
|
|
1323
|
+
Print a shell formatted reponse of public/private keys.
|
|
1324
1324
|
|
|
1325
1325
|
```sh
|
|
1326
1326
|
$ echo "HELLO=World" > .env
|
package/package.json
CHANGED
package/src/lib/services/run.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const dotenv = require('dotenv')
|
|
4
|
+
const childProcess = require('child_process')
|
|
4
5
|
|
|
5
6
|
const ENCODING = 'utf8'
|
|
6
7
|
const TYPE_ENV = 'env'
|
|
@@ -13,10 +14,12 @@ const inject = require('./../helpers/inject')
|
|
|
13
14
|
const decrypt = require('./../helpers/decrypt')
|
|
14
15
|
const parseDecryptEvalExpand = require('./../helpers/parseDecryptEvalExpand')
|
|
15
16
|
const parseEnvironmentFromDotenvKey = require('./../helpers/parseEnvironmentFromDotenvKey')
|
|
16
|
-
const smartDotenvPrivateKey = require('./../helpers/smartDotenvPrivateKey')
|
|
17
17
|
const guessPrivateKeyFilename = require('./../helpers/guessPrivateKeyFilename')
|
|
18
|
+
const guessPrivateKeyName = require('./../helpers/guessPrivateKeyName')
|
|
18
19
|
const detectEncoding = require('./../helpers/detectEncoding')
|
|
19
20
|
|
|
21
|
+
const Keypair = require('./../services/keypair')
|
|
22
|
+
|
|
20
23
|
class Run {
|
|
21
24
|
constructor (envs = [], overload = false, DOTENV_KEY = '', processEnv = process.env) {
|
|
22
25
|
this.dotenvPrivateKeyNames = Object.keys(processEnv).filter(key => key.startsWith('DOTENV_PRIVATE_KEY')) // important, must be first. used by determineEnvs
|
|
@@ -94,8 +97,7 @@ class Run {
|
|
|
94
97
|
const src = fs.readFileSync(filepath, { encoding })
|
|
95
98
|
this.readableFilepaths.add(envFilepath)
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
const privateKey = smartDotenvPrivateKey(envFilepath)
|
|
100
|
+
const privateKey = this._determinePrivateKey(envFilepath)
|
|
99
101
|
const { parsed, processEnv, warnings } = parseDecryptEvalExpand(src, privateKey, this.processEnv)
|
|
100
102
|
row.parsed = parsed
|
|
101
103
|
row.warnings = warnings
|
|
@@ -270,6 +272,29 @@ class Run {
|
|
|
270
272
|
|
|
271
273
|
return decrypt(ciphertext, dotenvKey)
|
|
272
274
|
}
|
|
275
|
+
|
|
276
|
+
_determinePrivateKey (envFilepath) {
|
|
277
|
+
const privateKeyName = guessPrivateKeyName(envFilepath)
|
|
278
|
+
|
|
279
|
+
let privateKey
|
|
280
|
+
try {
|
|
281
|
+
// if installed as sibling module
|
|
282
|
+
const projectRoot = path.resolve(process.cwd())
|
|
283
|
+
const dotenvxProPath = require.resolve('@dotenvx/dotenvx-pro', { paths: [projectRoot] })
|
|
284
|
+
const { keypair } = require(dotenvxProPath)
|
|
285
|
+
privateKey = keypair(envFilepath, privateKeyName)
|
|
286
|
+
} catch (_e) {
|
|
287
|
+
try {
|
|
288
|
+
// if installed as binary cli
|
|
289
|
+
privateKey = childProcess.execSync(`dotenvx-pro keypair ${privateKeyName} -f ${envFilepath}`, { stdio: ['pipe', 'pipe', 'ignore'] }).toString().trim()
|
|
290
|
+
} catch (_e) {
|
|
291
|
+
// fallback to local KeyPair - smart enough to handle process.env, .env.keys, etc
|
|
292
|
+
privateKey = new Keypair(envFilepath, privateKeyName).run()
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return privateKey
|
|
297
|
+
}
|
|
273
298
|
}
|
|
274
299
|
|
|
275
300
|
module.exports = Run
|