@dotenvx/dotenvx 1.31.0 β†’ 1.31.2

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,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.31.0...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.31.2...main)
6
+
7
+ ## [1.31.2](https://github.com/dotenvx/dotenvx/compare/v1.31.1...v1.31.2)
8
+
9
+ ### Changed
10
+
11
+ * use wingetcreate for releasing to WinGet ([#498](https://github.com/dotenvx/dotenvx/pull/498))
12
+
13
+ ## [1.31.1](https://github.com/dotenvx/dotenvx/compare/v1.31.0...v1.31.1)
14
+
15
+ ### Changed
16
+
17
+ * 🐞 fix encryption of values containing explicit `\n` newlines ([#495](https://github.com/dotenvx/dotenvx/pull/495))
6
18
 
7
19
  ## [1.31.0](https://github.com/dotenvx/dotenvx/compare/v1.30.1...v1.31.0)
8
20
 
package/README.md CHANGED
@@ -80,7 +80,7 @@ tar -xzf dotenvx.tar.gz
80
80
  </details>
81
81
 
82
82
 
83
- <details><summary>or with windows 🟦🟩πŸŸ₯🟨</summary><br>
83
+ <details><summary>or with windows πŸͺŸ</summary><br>
84
84
 
85
85
  ```sh
86
86
  winget install dotenvx
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.31.0",
2
+ "version": "1.31.2",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -52,7 +52,7 @@
52
52
  "sinon": "^14.0.1",
53
53
  "standard": "^17.1.0",
54
54
  "standard-version": "^9.5.0",
55
- "tap": "^19.2.0"
55
+ "tap": "^21.0.1"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public",
@@ -0,0 +1,43 @@
1
+ // historical dotenv.parse - https://github.com/motdotla/dotenv)
2
+ const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
3
+
4
+ function dotenvParse (src, skipExpandForDoubleQuotes = false) {
5
+ const obj = {}
6
+
7
+ // Convert buffer to string
8
+ let lines = src.toString()
9
+
10
+ // Convert line breaks to same format
11
+ lines = lines.replace(/\r\n?/mg, '\n')
12
+
13
+ let match
14
+ while ((match = LINE.exec(lines)) != null) {
15
+ const key = match[1]
16
+
17
+ // Default undefined or null to empty string
18
+ let value = (match[2] || '')
19
+
20
+ // Remove whitespace
21
+ value = value.trim()
22
+
23
+ // Check if double quoted
24
+ const maybeQuote = value[0]
25
+
26
+ // Remove surrounding quotes
27
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2')
28
+
29
+ // Expand newlines if double quoted
30
+ if (maybeQuote === '"' && !skipExpandForDoubleQuotes) {
31
+ value = value.replace(/\\n/g, '\n') // newline
32
+ value = value.replace(/\\r/g, '\r') // carriage return
33
+ value = value.replace(/\\t/g, '\t') // tabs
34
+ }
35
+
36
+ // Add to object
37
+ obj[key] = value
38
+ }
39
+
40
+ return obj
41
+ }
42
+
43
+ module.exports = dotenvParse
@@ -1,4 +1,3 @@
1
- const fsx = require('./fsx')
2
1
  const path = require('path')
3
2
  const childProcess = require('child_process')
4
3
  const { logger } = require('../../shared/logger')
@@ -27,7 +26,29 @@ function executeDynamic (program, command, rawArgs) {
27
26
  // logger.warn(`[INSTALLATION_NEEDED] install dotenvx-${command} to use [dotenvx ${command}] commands πŸ†`)
28
27
  // logger.help('? see installation instructions [https://github.com/dotenvx/dotenvx-pro]')
29
28
 
30
- const pro = fsx.readFileX(path.join(__dirname, './../../cli/pro.txt'))
29
+ const pro = `_______________________________________________________________
30
+ | |
31
+ | coming soon! (for small business) |
32
+ | |
33
+ | | | | | |
34
+ | __| | ___ | |_ ___ _ ____ ____ __ _ __ _ __ ___ |
35
+ | / _\` |/ _ \\| __/ _ \\ '_ \\ \\ / /\\ \\/ / | '_ \\| '__/ _ \\ |
36
+ | | (_| | (_) | || __/ | | \\ V / > < | |_) | | | (_) | |
37
+ | \\__,_|\\___/ \\__\\___|_| |_|\\_/ /_/\\_\\ | .__/|_| \\___/ |
38
+ | | | |
39
+ | |_| |
40
+ | ## learn more on github πŸ™ |
41
+ | |
42
+ | >> https://github.com/dotenvx/dotenvx/issues/259 |
43
+ | |
44
+ | ## subscribe on github to be notified πŸ“£ |
45
+ | |
46
+ | >> https://github.com/dotenvx/dotenvx/issues/259 |
47
+ | |
48
+ | ----------------------------------------------------------- |
49
+ | - thank you for using dotenvx! - @motdotla |
50
+ |_____________________________________________________________|`
51
+
31
52
  console.log(pro)
32
53
  } else {
33
54
  logger.info(`error: unknown command '${command}'`)
@@ -1,10 +1,9 @@
1
- const dotenv = require('dotenv')
2
-
1
+ const dotenvParse = require('./dotenvParse')
3
2
  const isEncrypted = require('./isEncrypted')
4
3
  const isPublicKey = require('./isPublicKey')
5
4
 
6
5
  function isFullyEncrypted (src) {
7
- const parsed = dotenv.parse(src)
6
+ const parsed = dotenvParse(src)
8
7
 
9
8
  for (const [key, value] of Object.entries(parsed)) {
10
9
  const result = isEncrypted(value) || isPublicKey(key, value)
@@ -1,6 +1,5 @@
1
- const dotenv = require('dotenv')
2
-
3
1
  const quotes = require('./quotes')
2
+ const dotenvParse = require('./dotenvParse')
4
3
  const escapeForRegex = require('./escapeForRegex')
5
4
  const escapeDollarSigns = require('./escapeDollarSigns')
6
5
 
@@ -8,7 +7,7 @@ function replace (src, key, replaceValue) {
8
7
  let output
9
8
  let newPart = ''
10
9
 
11
- const parsed = dotenv.parse(src)
10
+ const parsed = dotenvParse(src, true) // skip expanding \n
12
11
  const _quotes = quotes(src)
13
12
  if (Object.prototype.hasOwnProperty.call(parsed, key)) {
14
13
  const quote = _quotes[key]
@@ -1,10 +1,10 @@
1
1
  const fsx = require('./fsx')
2
2
  const path = require('path')
3
- const dotenv = require('dotenv')
4
3
 
5
4
  const PUBLIC_KEY_SCHEMA = 'DOTENV_PUBLIC_KEY'
6
5
  const PRIVATE_KEY_SCHEMA = 'DOTENV_PRIVATE_KEY'
7
6
 
7
+ const dotenvParse = require('./dotenvParse')
8
8
  const guessPrivateKeyName = require('./guessPrivateKeyName')
9
9
 
10
10
  function searchProcessEnv (privateKeyName) {
@@ -21,7 +21,7 @@ function searchKeysFile (privateKeyName, envFilepath, envKeysFilepath = null) {
21
21
 
22
22
  if (fsx.existsSync(keysFilepath)) {
23
23
  const keysSrc = fsx.readFileX(keysFilepath)
24
- const keysParsed = dotenv.parse(keysSrc)
24
+ const keysParsed = dotenvParse(keysSrc)
25
25
 
26
26
  if (keysParsed[privateKeyName] && keysParsed[privateKeyName].length > 0) {
27
27
  return keysParsed[privateKeyName]
@@ -35,7 +35,7 @@ function invertForPrivateKeyName (envFilepath) {
35
35
  }
36
36
 
37
37
  const envSrc = fsx.readFileX(envFilepath)
38
- const envParsed = dotenv.parse(envSrc)
38
+ const envParsed = dotenvParse(envSrc)
39
39
 
40
40
  let publicKeyName
41
41
  for (const keyName of Object.keys(envParsed)) {
@@ -1,5 +1,5 @@
1
1
  const fsx = require('./fsx')
2
- const dotenv = require('dotenv')
2
+ const dotenvParse = require('./dotenvParse')
3
3
 
4
4
  const guessPublicKeyName = require('./guessPublicKeyName')
5
5
 
@@ -12,7 +12,7 @@ function searchProcessEnv (publicKeyName) {
12
12
  function searchEnvFile (publicKeyName, envFilepath) {
13
13
  if (fsx.existsSync(envFilepath)) {
14
14
  const keysSrc = fsx.readFileX(envFilepath)
15
- const keysParsed = dotenv.parse(keysSrc)
15
+ const keysParsed = dotenvParse(keysSrc)
16
16
 
17
17
  if (keysParsed[publicKeyName] && keysParsed[publicKeyName].length > 0) {
18
18
  return keysParsed[publicKeyName]
@@ -1,6 +1,5 @@
1
1
  const fsx = require('./../helpers/fsx')
2
2
  const path = require('path')
3
- const dotenv = require('dotenv')
4
3
  const picomatch = require('picomatch')
5
4
 
6
5
  const TYPE_ENV_FILE = 'envFile'
@@ -10,6 +9,7 @@ const guessPrivateKeyName = require('./../helpers/guessPrivateKeyName')
10
9
  const findPrivateKey = require('./../helpers/findPrivateKey')
11
10
  const decryptKeyValue = require('./../helpers/decryptKeyValue')
12
11
  const isEncrypted = require('./../helpers/isEncrypted')
12
+ const dotenvParse = require('./../helpers/dotenvParse')
13
13
  const replace = require('./../helpers/replace')
14
14
  const detectEncoding = require('./../helpers/detectEncoding')
15
15
  const determineEnvs = require('./../helpers/determineEnvs')
@@ -63,7 +63,7 @@ class Decrypt {
63
63
  try {
64
64
  const encoding = this._detectEncoding(filepath)
65
65
  let envSrc = fsx.readFileX(filepath, { encoding })
66
- const envParsed = dotenv.parse(envSrc)
66
+ const envParsed = dotenvParse(envSrc)
67
67
 
68
68
  const privateKey = findPrivateKey(envFilepath, this.envKeysFilepath)
69
69
  const privateKeyName = guessPrivateKeyName(envFilepath)
@@ -1,6 +1,5 @@
1
1
  const fsx = require('./../helpers/fsx')
2
2
  const path = require('path')
3
- const dotenv = require('dotenv')
4
3
  const picomatch = require('picomatch')
5
4
 
6
5
  const TYPE_ENV_FILE = 'envFile'
@@ -10,6 +9,7 @@ const guessPrivateKeyName = require('./../helpers/guessPrivateKeyName')
10
9
  const guessPublicKeyName = require('./../helpers/guessPublicKeyName')
11
10
  const encryptValue = require('./../helpers/encryptValue')
12
11
  const isEncrypted = require('./../helpers/isEncrypted')
12
+ const dotenvParse = require('./../helpers/dotenvParse')
13
13
  const replace = require('./../helpers/replace')
14
14
  const detectEncoding = require('./../helpers/detectEncoding')
15
15
  const determineEnvs = require('./../helpers/determineEnvs')
@@ -69,7 +69,7 @@ class Encrypt {
69
69
  try {
70
70
  const encoding = this._detectEncoding(filepath)
71
71
  let envSrc = fsx.readFileX(filepath, { encoding })
72
- const envParsed = dotenv.parse(envSrc)
72
+ const envParsed = dotenvParse(envSrc)
73
73
 
74
74
  let publicKey
75
75
  let privateKey
@@ -173,6 +173,7 @@ class Encrypt {
173
173
  row.keys.push(key) // track key(s)
174
174
 
175
175
  const encryptedValue = encryptValue(value, publicKey)
176
+
176
177
  // once newSrc is built write it out
177
178
  envSrc = replace(envSrc, key, encryptedValue)
178
179
 
@@ -1,10 +1,10 @@
1
1
  const fsx = require('./../helpers/fsx')
2
2
  const path = require('path')
3
- const dotenv = require('dotenv')
4
3
 
5
4
  const Errors = require('../helpers/errors')
6
5
  const findEnvFiles = require('../helpers/findEnvFiles')
7
6
  const replace = require('../helpers/replace')
7
+ const dotenvParse = require('../helpers/dotenvParse')
8
8
 
9
9
  class Genexample {
10
10
  constructor (directory = '.', envFile) {
@@ -47,7 +47,7 @@ class Genexample {
47
47
 
48
48
  // get the original src
49
49
  let src = fsx.readFileX(filepath)
50
- const parsed = dotenv.parse(src)
50
+ const parsed = dotenvParse(src)
51
51
  for (const key in parsed) {
52
52
  // used later
53
53
  keys.add(key)
@@ -72,7 +72,7 @@ class Genexample {
72
72
  // it already exists (which means the user might have it modified a way in which they prefer, so replace exampleSrc with their existing .env.example)
73
73
  exampleSrc = fsx.readFileX(this.exampleFilepath)
74
74
 
75
- const parsed = dotenv.parse(exampleSrc)
75
+ const parsed = dotenvParse(exampleSrc)
76
76
  for (const key of [...keys]) {
77
77
  if (key in parsed) {
78
78
  preExisted[key] = parsed[key]
@@ -1,6 +1,5 @@
1
1
  const fsx = require('./../helpers/fsx')
2
2
  const path = require('path')
3
- const dotenv = require('dotenv')
4
3
 
5
4
  const TYPE_ENV = 'env'
6
5
  const TYPE_ENV_FILE = 'envFile'
@@ -9,6 +8,7 @@ const TYPE_ENV_VAULT_FILE = 'envVaultFile'
9
8
  const decrypt = require('./../helpers/decrypt')
10
9
  const Parse = require('./../helpers/parse')
11
10
  const Errors = require('./../helpers/errors')
11
+ const dotenvParse = require('./../helpers/dotenvParse')
12
12
  const parseEnvironmentFromDotenvKey = require('./../helpers/parseEnvironmentFromDotenvKey')
13
13
  const detectEncoding = require('./../helpers/detectEncoding')
14
14
  const findPrivateKey = require('./../helpers/findPrivateKey')
@@ -196,7 +196,7 @@ class Run {
196
196
  // { "DOTENV_VAULT_DEVELOPMENT": "<ciphertext>" }
197
197
  _parsedVault (filepath) {
198
198
  const src = fsx.readFileX(filepath)
199
- return dotenv.parse(src)
199
+ return dotenvParse(src)
200
200
  }
201
201
 
202
202
  _decrypted (dotenvKey, parsedVault) {
@@ -1,6 +1,5 @@
1
1
  const fsx = require('./../helpers/fsx')
2
2
  const path = require('path')
3
- const dotenv = require('dotenv')
4
3
 
5
4
  const TYPE_ENV_FILE = 'envFile'
6
5
 
@@ -10,6 +9,7 @@ const guessPublicKeyName = require('./../helpers/guessPublicKeyName')
10
9
  const encryptValue = require('./../helpers/encryptValue')
11
10
  const decryptKeyValue = require('./../helpers/decryptKeyValue')
12
11
  const replace = require('./../helpers/replace')
12
+ const dotenvParse = require('./../helpers/dotenvParse')
13
13
  const detectEncoding = require('./../helpers/detectEncoding')
14
14
  const determineEnvs = require('./../helpers/determineEnvs')
15
15
  const findPrivateKey = require('./../helpers/findPrivateKey')
@@ -66,7 +66,7 @@ class Sets {
66
66
  try {
67
67
  const encoding = this._detectEncoding(filepath)
68
68
  let envSrc = fsx.readFileX(filepath, { encoding })
69
- const envParsed = dotenv.parse(envSrc)
69
+ const envParsed = dotenvParse(envSrc)
70
70
  row.originalValue = envParsed[row.key] || null
71
71
  const wasPlainText = !isEncrypted(row.originalValue)
72
72
  this.readableFilepaths.add(envFilepath)
package/src/cli/pro.txt DELETED
@@ -1,22 +0,0 @@
1
- _______________________________________________________________
2
- | |
3
- | coming soon! (for small business) |
4
- | |
5
- | | | | | |
6
- | __| | ___ | |_ ___ _ ____ ____ __ _ __ _ __ ___ |
7
- | / _` |/ _ \| __/ _ \ '_ \ \ / /\ \/ / | '_ \| '__/ _ \ |
8
- | | (_| | (_) | || __/ | | \ V / > < | |_) | | | (_) | |
9
- | \__,_|\___/ \__\___|_| |_|\_/ /_/\_\ | .__/|_| \___/ |
10
- | | | |
11
- | |_| |
12
- | ## learn more on github πŸ™ |
13
- | |
14
- | >> https://github.com/dotenvx/dotenvx/issues/259 |
15
- | |
16
- | ## subscribe on github to be notified πŸ“£ |
17
- | |
18
- | >> https://github.com/dotenvx/dotenvx/issues/259 |
19
- | |
20
- | ----------------------------------------------------------- |
21
- | - thank you for using dotenvx! - @motdotla |
22
- |_____________________________________________________________|