@dotenvx/dotenvx 1.21.1 → 1.22.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 +17 -1
- package/README.md +5 -5
- package/package.json +1 -1
- package/src/cli/actions/encrypt.js +2 -2
- package/src/cli/actions/ext/gitignore.js +44 -23
- package/src/cli/actions/set.js +2 -2
- package/src/cli/commands/ext.js +1 -0
- package/src/cli/examples.js +2 -1
- package/src/lib/helpers/parseDecryptEvalExpand.js +3 -1
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.
|
|
5
|
+
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.22.1...main)
|
|
6
|
+
|
|
7
|
+
## 1.22.1
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* 🐞 patch loading order issue with single quotes ([#436](https://github.com/dotenvx/dotenvx/pull/436))
|
|
12
|
+
|
|
13
|
+
## 1.22.0
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
* add `--pattern` argument to `ext gitignore` (`dotenvx ext gitignore --pattern .env.keys`) ([#430](https://github.com/dotenvx/dotenvx/pull/430))
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
* clarify next steps after first time encrypting ([#430](https://github.com/dotenvx/dotenvx/pull/430))
|
|
6
22
|
|
|
7
23
|
## 1.21.1
|
|
8
24
|
|
package/README.md
CHANGED
|
@@ -867,7 +867,7 @@ More examples
|
|
|
867
867
|
|
|
868
868
|
```sh
|
|
869
869
|
$ touch .env.ci
|
|
870
|
-
$ dotenvx set HELLO "ci encrypted" -f .env.
|
|
870
|
+
$ dotenvx set HELLO "ci encrypted" -f .env.ci
|
|
871
871
|
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
872
872
|
|
|
873
873
|
# check .env.keys for your privateKey
|
|
@@ -1222,8 +1222,8 @@ More examples
|
|
|
1222
1222
|
$ dotenvx encrypt
|
|
1223
1223
|
✔ encrypted (.env)
|
|
1224
1224
|
✔ key added to .env.keys (DOTENV_PRIVATE_KEY)
|
|
1225
|
-
|
|
1226
|
-
|
|
1225
|
+
⮕ next run [dotenvx ext gitignore --pattern .env.keys] to gitignore .env.keys
|
|
1226
|
+
⮕ next run [DOTENV_PRIVATE_KEY='122...0b8' dotenvx run -- yourcommand] to test decryption locally
|
|
1227
1227
|
```
|
|
1228
1228
|
|
|
1229
1229
|
</details>
|
|
@@ -1238,8 +1238,8 @@ More examples
|
|
|
1238
1238
|
$ dotenvx encrypt -f .env.production
|
|
1239
1239
|
✔ encrypted (.env.production)
|
|
1240
1240
|
✔ key added to .env.keys (DOTENV_PRIVATE_KEY_PRODUCTION)
|
|
1241
|
-
|
|
1242
|
-
|
|
1241
|
+
⮕ next run [dotenvx ext gitignore --pattern .env.keys] to gitignore .env.keys
|
|
1242
|
+
⮕ next run [DOTENV_PRIVATE_KEY='bff...bc4' dotenvx run -- yourcommand] to test decryption locally
|
|
1243
1243
|
```
|
|
1244
1244
|
|
|
1245
1245
|
</details>
|
package/package.json
CHANGED
|
@@ -64,10 +64,10 @@ function encrypt () {
|
|
|
64
64
|
logger.success(`✔ key added to .env.keys (${processedEnv.privateKeyName})`)
|
|
65
65
|
|
|
66
66
|
if (!isIgnoringDotenvKeys()) {
|
|
67
|
-
logger.
|
|
67
|
+
logger.help('⮕ next run [dotenvx ext gitignore --pattern .env.keys] to gitignore .env.keys')
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
logger.
|
|
70
|
+
logger.help(`⮕ next run [${processedEnv.privateKeyName}='${processedEnv.privateKey}' dotenvx run -- yourcommand] to test decryption locally`)
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
} catch (error) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const fsx = require('./../../../lib/helpers/fsx')
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const DEFAULT_PATTERNS = ['.env*']
|
|
4
4
|
const { logger } = require('./../../../shared/logger')
|
|
5
5
|
|
|
6
6
|
class Generic {
|
|
7
|
-
constructor (filename, touchFile = false) {
|
|
7
|
+
constructor (filename, patterns = DEFAULT_PATTERNS, touchFile = false) {
|
|
8
8
|
this.filename = filename
|
|
9
|
-
this.
|
|
9
|
+
this.patterns = patterns
|
|
10
10
|
this.touchFile = touchFile
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -15,10 +15,9 @@ class Generic {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
run () {
|
|
18
|
+
const changedPatterns = []
|
|
18
19
|
if (!fsx.existsSync(this.filename)) {
|
|
19
|
-
if (this.touchFile === true) {
|
|
20
|
-
logger.info(`creating ${this.filename}`)
|
|
21
|
-
|
|
20
|
+
if (this.touchFile === true && this.patterns.length > 0) {
|
|
22
21
|
fsx.writeFileX(this.filename, '')
|
|
23
22
|
} else {
|
|
24
23
|
return
|
|
@@ -26,41 +25,63 @@ class Generic {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
const lines = fsx.readFileX(this.filename).split(/\r?\n/)
|
|
29
|
-
this.
|
|
30
|
-
if (!lines.includes(
|
|
31
|
-
|
|
28
|
+
this.patterns.forEach(pattern => {
|
|
29
|
+
if (!lines.includes(pattern.trim())) {
|
|
30
|
+
this.append(pattern)
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
changedPatterns.push(pattern.trim())
|
|
34
33
|
}
|
|
35
34
|
})
|
|
35
|
+
|
|
36
|
+
if (changedPatterns.length > 0) {
|
|
37
|
+
logger.success(`✔ ignored ${this.patterns} (${this.filename})`)
|
|
38
|
+
} else {
|
|
39
|
+
logger.info(`no changes (${this.filename})`)
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
class Git {
|
|
45
|
+
constructor (patterns = DEFAULT_PATTERNS) {
|
|
46
|
+
this.patterns = patterns
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
run () {
|
|
41
|
-
logger.verbose('
|
|
42
|
-
new Generic('.gitignore', true).run()
|
|
50
|
+
logger.verbose('add to .gitignore')
|
|
51
|
+
new Generic('.gitignore', this.patterns, true).run()
|
|
43
52
|
}
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
class Docker {
|
|
56
|
+
constructor (patterns = DEFAULT_PATTERNS) {
|
|
57
|
+
this.patterns = patterns
|
|
58
|
+
}
|
|
59
|
+
|
|
47
60
|
run () {
|
|
48
|
-
logger.verbose('
|
|
49
|
-
new Generic('.dockerignore').run()
|
|
61
|
+
logger.verbose('add to .dockerignore (if exists)')
|
|
62
|
+
new Generic('.dockerignore', this.patterns).run()
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
65
|
|
|
53
66
|
class Npm {
|
|
67
|
+
constructor (patterns = DEFAULT_PATTERNS) {
|
|
68
|
+
this.patterns = patterns
|
|
69
|
+
}
|
|
70
|
+
|
|
54
71
|
run () {
|
|
55
|
-
logger.verbose('
|
|
56
|
-
new Generic('.npmignore').run()
|
|
72
|
+
logger.verbose('add to .npmignore (if existing)')
|
|
73
|
+
new Generic('.npmignore', this.patterns).run()
|
|
57
74
|
}
|
|
58
75
|
}
|
|
59
76
|
|
|
60
77
|
class Vercel {
|
|
78
|
+
constructor (patterns = DEFAULT_PATTERNS) {
|
|
79
|
+
this.patterns = patterns
|
|
80
|
+
}
|
|
81
|
+
|
|
61
82
|
run () {
|
|
62
|
-
logger.verbose('
|
|
63
|
-
new Generic('.vercelignore').run()
|
|
83
|
+
logger.verbose('add to .vercelignore (if existing)')
|
|
84
|
+
new Generic('.vercelignore', this.patterns).run()
|
|
64
85
|
}
|
|
65
86
|
}
|
|
66
87
|
|
|
@@ -68,12 +89,12 @@ function gitignore () {
|
|
|
68
89
|
const options = this.opts()
|
|
69
90
|
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
70
91
|
|
|
71
|
-
|
|
72
|
-
new Docker().run()
|
|
73
|
-
new Npm().run()
|
|
74
|
-
new Vercel().run()
|
|
92
|
+
const patterns = options.pattern
|
|
75
93
|
|
|
76
|
-
|
|
94
|
+
new Git(patterns).run()
|
|
95
|
+
new Docker(patterns).run()
|
|
96
|
+
new Npm(patterns).run()
|
|
97
|
+
new Vercel(patterns).run()
|
|
77
98
|
}
|
|
78
99
|
|
|
79
100
|
module.exports = gitignore
|
package/src/cli/actions/set.js
CHANGED
|
@@ -68,10 +68,10 @@ function set (key, value) {
|
|
|
68
68
|
logger.success(`✔ key added to .env.keys (${processedEnv.privateKeyName})`)
|
|
69
69
|
|
|
70
70
|
if (!isIgnoringDotenvKeys()) {
|
|
71
|
-
logger.
|
|
71
|
+
logger.help('⮕ next run [dotenvx ext gitignore --pattern .env.keys] to gitignore .env.keys')
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
logger.
|
|
74
|
+
logger.help(`⮕ next run [${processedEnv.privateKeyName}='${processedEnv.privateKey}' dotenvx get ${key}] to test decryption locally`)
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
} catch (error) {
|
package/src/cli/commands/ext.js
CHANGED
|
@@ -40,6 +40,7 @@ ext.command('genexample')
|
|
|
40
40
|
ext.command('gitignore')
|
|
41
41
|
.description('append to .gitignore file (and if existing, .dockerignore, .npmignore, and .vercelignore)')
|
|
42
42
|
.addHelpText('after', examples.gitignore)
|
|
43
|
+
.option('--pattern <patterns...>', 'pattern(s) to gitignore', ['.env*'])
|
|
43
44
|
.action(require('./../actions/ext/gitignore'))
|
|
44
45
|
|
|
45
46
|
// dotenvx ext prebuild
|
package/src/cli/examples.js
CHANGED
|
@@ -20,6 +20,7 @@ function parseDecryptEvalExpand (src, privateKey = null, processEnv = process.en
|
|
|
20
20
|
const parsed = dotenv.parse(src)
|
|
21
21
|
const _quotes = quotes(src)
|
|
22
22
|
const originalParsed = { ...parsed }
|
|
23
|
+
const originalProcessEnv = { ...processEnv }
|
|
23
24
|
for (const key in parsed) {
|
|
24
25
|
try {
|
|
25
26
|
const decryptedValue = decryptValue(parsed[key], privateKey)
|
|
@@ -56,10 +57,11 @@ function parseDecryptEvalExpand (src, privateKey = null, processEnv = process.en
|
|
|
56
57
|
warnings.push(warning(e, key, privateKey))
|
|
57
58
|
}
|
|
58
59
|
}
|
|
60
|
+
|
|
59
61
|
for (const key in processEnv) {
|
|
60
62
|
// unset eval and expansion for single quotes
|
|
61
63
|
if (_quotes[key] === "'") {
|
|
62
|
-
processEnv[key] = originalParsed[key] // reset to original
|
|
64
|
+
processEnv[key] = originalProcessEnv[key] || originalParsed[key] // reset to original
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
try {
|