@dotenvx/dotenvx 1.47.2 → 1.47.3

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 CHANGED
@@ -2,7 +2,17 @@
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.2...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.47.3...main)
6
+
7
+ ## 1.47.3
8
+
9
+ ### Added
10
+
11
+ * Send to `radar#observe` if [Radar](https://dotenvx.com/radar) installed by user ([#631](https://github.com/dotenvx/dotenvx/pull/631))
12
+
13
+ ### Removed
14
+
15
+ * Remove `cli` in package.json ([#632](https://github.com/dotenvx/dotenvx/pull/632))
6
16
 
7
17
  ## 1.47.2
8
18
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.47.2",
2
+ "version": "1.47.3",
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"
@@ -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
- logRadar()
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)})`)
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,58 @@
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
+ const npmPath = require.resolve('@dotenvx/dotenvx-radar', { paths: [projectRoot] })
40
+ return require(npmPath)
41
+ }
42
+
43
+ _radarCli () {
44
+ childProcess.execSync('dotenvx-radar help', { stdio: ['pipe', 'pipe', 'ignore'] })
45
+ return {
46
+ observe: (payload) => {
47
+ const encoded = this.encode(payload)
48
+ try {
49
+ childProcess.execSync(`dotenvx-radar observe ${encoded}`, { stdio: 'ignore' })
50
+ } catch (e) {
51
+ // noop
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ 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