@dotenvx/dotenvx 1.47.2 → 1.47.4
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 +17 -1
- package/package.json +1 -3
- package/src/cli/actions/run.js +4 -2
- package/src/lib/helpers/proKeypair.js +4 -3
- package/src/lib/main.js +5 -0
- package/src/lib/services/radar.js +60 -0
- package/src/lib/helpers/logRadar.js +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,23 @@
|
|
|
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.47.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.47.4...main)
|
|
6
|
+
|
|
7
|
+
## 1.47.4
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* Smarter require of non-installed libs like [`dotenvx-radar`](https://dotenvx.com/radar) ([#638](https://github.com/dotenvx/dotenvx/pull/638))
|
|
12
|
+
|
|
13
|
+
## 1.47.3
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
* Send to `radar#observe` if [Radar](https://dotenvx.com/radar) installed by user ([#631](https://github.com/dotenvx/dotenvx/pull/631))
|
|
18
|
+
|
|
19
|
+
### Removed
|
|
20
|
+
|
|
21
|
+
* Remove `cli` in package.json ([#632](https://github.com/dotenvx/dotenvx/pull/632))
|
|
6
22
|
|
|
7
23
|
## 1.47.2
|
|
8
24
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.47.
|
|
2
|
+
"version": "1.47.4",
|
|
3
3
|
"name": "@dotenvx/dotenvx",
|
|
4
4
|
"description": "a better dotenv–from the creator of `dotenv`",
|
|
5
5
|
"author": "@motdotla",
|
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
"require": "./src/lib/main.js",
|
|
26
26
|
"default": "./src/lib/main.js"
|
|
27
27
|
},
|
|
28
|
-
"./cli": "./src/cli/dotenvx.js",
|
|
29
|
-
"./cli.js": "./src/cli/dotenvx.js",
|
|
30
28
|
"./config": "./src/lib/config.js",
|
|
31
29
|
"./config.js": "./src/lib/config.js",
|
|
32
30
|
"./package.json": "./package.json"
|
package/src/cli/actions/run.js
CHANGED
|
@@ -3,10 +3,10 @@ const { logger } = require('./../../shared/logger')
|
|
|
3
3
|
|
|
4
4
|
const executeCommand = require('./../../lib/helpers/executeCommand')
|
|
5
5
|
const Run = require('./../../lib/services/run')
|
|
6
|
+
const Radar = require('./../../lib/services/radar')
|
|
6
7
|
|
|
7
8
|
const conventions = require('./../../lib/helpers/conventions')
|
|
8
9
|
const DeprecationNotice = require('./../../lib/helpers/deprecationNotice')
|
|
9
|
-
const logRadar = require('./../../lib/helpers/logRadar')
|
|
10
10
|
|
|
11
11
|
async function run () {
|
|
12
12
|
const commandArgs = this.args
|
|
@@ -41,7 +41,7 @@ async function run () {
|
|
|
41
41
|
|
|
42
42
|
new DeprecationNotice().dotenvKey() // DEPRECATION NOTICE
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
const radar = new Radar()
|
|
45
45
|
|
|
46
46
|
const {
|
|
47
47
|
processedEnvs,
|
|
@@ -50,6 +50,8 @@ async function run () {
|
|
|
50
50
|
uniqueInjectedKeys
|
|
51
51
|
} = new Run(envs, options.overload, process.env.DOTENV_KEY, process.env, options.envKeysFile).run()
|
|
52
52
|
|
|
53
|
+
radar.observe(processedEnvs)
|
|
54
|
+
|
|
53
55
|
for (const processedEnv of processedEnvs) {
|
|
54
56
|
if (processedEnv.type === 'envVaultFile') {
|
|
55
57
|
logger.verbose(`loading env from encrypted ${processedEnv.filepath} (${path.resolve(processedEnv.filepath)})`)
|
|
@@ -15,9 +15,10 @@ class ProKeypair {
|
|
|
15
15
|
try {
|
|
16
16
|
// if installed as sibling module
|
|
17
17
|
const projectRoot = path.resolve(process.cwd())
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
|
|
18
|
+
// eslint-disable-next-line no-eval
|
|
19
|
+
const dotenvxProPath = eval('require').resolve('@dotenvx/dotenvx-pro', { paths: [projectRoot] }) // necessary for webpack builds
|
|
20
|
+
// eslint-disable-next-line no-eval
|
|
21
|
+
const { keypair } = eval('require')(dotenvxProPath) // necessary for webpack builds
|
|
21
22
|
result = keypair(this.envFilepath)
|
|
22
23
|
} catch (_e) {
|
|
23
24
|
try {
|
package/src/lib/main.js
CHANGED
|
@@ -12,6 +12,7 @@ const Sets = require('./services/sets')
|
|
|
12
12
|
const Get = require('./services/get')
|
|
13
13
|
const Keypair = require('./services/keypair')
|
|
14
14
|
const Genexample = require('./services/genexample')
|
|
15
|
+
const Radar = require('./services/radar')
|
|
15
16
|
|
|
16
17
|
// helpers
|
|
17
18
|
const buildEnvs = require('./helpers/buildEnvs')
|
|
@@ -21,6 +22,8 @@ const isIgnoringDotenvKeys = require('./helpers/isIgnoringDotenvKeys')
|
|
|
21
22
|
|
|
22
23
|
/** @type {import('./main').config} */
|
|
23
24
|
const config = function (options = {}) {
|
|
25
|
+
const radar = new Radar()
|
|
26
|
+
|
|
24
27
|
// allow user to set processEnv to write to
|
|
25
28
|
let processEnv = process.env
|
|
26
29
|
if (options && options.processEnv != null) {
|
|
@@ -59,6 +62,8 @@ const config = function (options = {}) {
|
|
|
59
62
|
uniqueInjectedKeys
|
|
60
63
|
} = new Run(envs, overload, DOTENV_KEY, processEnv, envKeysFile).run()
|
|
61
64
|
|
|
65
|
+
radar.observe(processedEnvs)
|
|
66
|
+
|
|
62
67
|
let lastError
|
|
63
68
|
/** @type {Record<string, string>} */
|
|
64
69
|
const parsedAll = {}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const childProcess = require('child_process')
|
|
3
|
+
|
|
4
|
+
const { logger } = require('./../../shared/logger')
|
|
5
|
+
|
|
6
|
+
class Radar {
|
|
7
|
+
constructor () {
|
|
8
|
+
this.radarLib = null
|
|
9
|
+
|
|
10
|
+
// check npm lib
|
|
11
|
+
try {
|
|
12
|
+
this.radarLib = this._radarNpm()
|
|
13
|
+
logger.successv('📡 radar active')
|
|
14
|
+
} catch (e) {
|
|
15
|
+
// check binary cli
|
|
16
|
+
try {
|
|
17
|
+
this.radarLib = this._radarCli()
|
|
18
|
+
logger.successv('📡 radar active')
|
|
19
|
+
} catch (_e2) {
|
|
20
|
+
// noop
|
|
21
|
+
}
|
|
22
|
+
// noop
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
observe (payload) {
|
|
27
|
+
if (this.radarLib) {
|
|
28
|
+
const encoded = this.encode(payload)
|
|
29
|
+
this.radarLib.observe(encoded)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
encode (payload) {
|
|
34
|
+
return Buffer.from(JSON.stringify(payload)).toString('base64')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_radarNpm () {
|
|
38
|
+
const projectRoot = path.resolve(process.cwd())
|
|
39
|
+
// eslint-disable-next-line no-eval
|
|
40
|
+
const npmPath = eval('require').resolve('@dotenvx/dotenvx-radar', { paths: [projectRoot] }) // necessary for webpack builds
|
|
41
|
+
// eslint-disable-next-line no-eval
|
|
42
|
+
return eval('require')(npmPath) // necessary for webpack builds
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_radarCli () {
|
|
46
|
+
childProcess.execSync('dotenvx-radar help', { stdio: ['pipe', 'pipe', 'ignore'] })
|
|
47
|
+
return {
|
|
48
|
+
observe: (payload) => {
|
|
49
|
+
const encoded = this.encode(payload)
|
|
50
|
+
try {
|
|
51
|
+
childProcess.execSync(`dotenvx-radar observe ${encoded}`, { stdio: 'ignore' })
|
|
52
|
+
} catch (e) {
|
|
53
|
+
// noop
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = Radar
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const childProcess = require('child_process')
|
|
3
|
-
|
|
4
|
-
const { logger } = require('./../../shared/logger')
|
|
5
|
-
|
|
6
|
-
function logRadar () {
|
|
7
|
-
let installed = false
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
// if installed as sibling module
|
|
11
|
-
const projectRoot = path.resolve(process.cwd())
|
|
12
|
-
const dotenvxRadarPath = require.resolve('@dotenvx/dotenvx-radar', { paths: [projectRoot] })
|
|
13
|
-
require(dotenvxRadarPath)
|
|
14
|
-
installed = true
|
|
15
|
-
} catch (_e) {
|
|
16
|
-
try {
|
|
17
|
-
// if installed as binary cli
|
|
18
|
-
childProcess.execSync('dotenvx-radar help', { stdio: ['pipe', 'pipe', 'ignore'] }).toString().trim()
|
|
19
|
-
installed = true
|
|
20
|
-
// if succeeds
|
|
21
|
-
} catch (_e) {
|
|
22
|
-
// do nothing
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (installed) {
|
|
27
|
-
logger.successv('radar active 📡')
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = logRadar
|