@dotenvx/dotenvx 1.2.0 → 1.3.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 +19 -1
- package/README.md +21 -9
- package/package.json +2 -2
- package/src/cli/actions/encrypt.js +1 -1
- package/src/cli/dotenvx.js +1 -0
- package/src/lib/main.d.ts +3 -1
- package/src/lib/main.js +2 -2
- package/src/lib/services/encrypt.js +20 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,25 @@
|
|
|
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.2
|
|
5
|
+
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.3.2...main)
|
|
6
|
+
|
|
7
|
+
## 1.3.2
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* 🐞 remove risky `prepare` and `postinstall` scripts and replace with `npm run patch` for development and binary building ([#286](https://github.com/dotenvx/dotenvx/pull/286))
|
|
12
|
+
|
|
13
|
+
## 1.3.1
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
* 🐞 make `patch-package` only run locally with `prepare` ([#283](https://github.com/dotenvx/dotenvx/pull/283))
|
|
18
|
+
|
|
19
|
+
## 1.3.0
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
* encrypt specified keys with `--key` option - `dotenvx encrypt -k HELLO` ([#281](https://github.com/dotenvx/dotenvx/pull/281))
|
|
6
24
|
|
|
7
25
|
## 1.2.0
|
|
8
26
|
|
package/README.md
CHANGED
|
@@ -1114,6 +1114,18 @@ More examples
|
|
|
1114
1114
|
ℹ run [DOTENV_PRIVATE_KEY_PRODUCTION='bff..bc4' dotenvx run -- yourcommand] to test decryption locally
|
|
1115
1115
|
```
|
|
1116
1116
|
|
|
1117
|
+
</details>
|
|
1118
|
+
* <details><summary>`encrypt -k`</summary><br>
|
|
1119
|
+
|
|
1120
|
+
Specify the key(s) to encrypt by passing `--key`.
|
|
1121
|
+
|
|
1122
|
+
```sh
|
|
1123
|
+
$ echo "HELLO=World\nHELLO2=Universe" > .env
|
|
1124
|
+
|
|
1125
|
+
$ dotenvx encrypt -k HELLO2
|
|
1126
|
+
✔ encrypted (.env)
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1117
1129
|
</details>
|
|
1118
1130
|
* <details><summary>`help`</summary><br>
|
|
1119
1131
|
|
|
@@ -1372,18 +1384,18 @@ More examples
|
|
|
1372
1384
|
> Go deeper into using `dotenvx` with detailed framework and platform guides.
|
|
1373
1385
|
>
|
|
1374
1386
|
|
|
1375
|
-
* <a href="https://dotenvx.com/docs/platforms/digital-ocean">Digital Ocean <img src="https://
|
|
1376
|
-
* <a href="https://dotenvx.com/docs/platforms/docker">Docker <img src="https://
|
|
1377
|
-
* <a href="https://dotenvx.com/docs/platforms/fly">Fly.io
|
|
1378
|
-
* <a href="https://dotenvx.com/docs/cis/github-actions">GitHub Actions <img src="https://
|
|
1379
|
-
* <a href="https://dotenvx.com/docs/platforms/heroku">Heroku <img src="https://
|
|
1380
|
-
* <a href="https://dotenvx.com/docs/platforms/netlify">Netlify <img src="https://
|
|
1387
|
+
* <a href="https://dotenvx.com/docs/platforms/digital-ocean">Digital Ocean <img src="https://api.iconify.design/devicon/digitalocean.svg" alt="Digital Ocean" width="20" /></a>
|
|
1388
|
+
* <a href="https://dotenvx.com/docs/platforms/docker">Docker <img src="https://api.iconify.design/skill-icons/docker.svg" alt="Docker" width="20" /></a>
|
|
1389
|
+
* <a href="https://dotenvx.com/docs/platforms/fly">Fly.io <img src="https://api.iconify.design/logos/fly-icon.svg" alt="Fly.io" width="20" /></a>
|
|
1390
|
+
* <a href="https://dotenvx.com/docs/cis/github-actions">GitHub Actions <img src="https://api.iconify.design/devicon/github.svg" alt="GitHub" width="20" /></a>
|
|
1391
|
+
* <a href="https://dotenvx.com/docs/platforms/heroku">Heroku <img src="https://api.iconify.design/skill-icons/heroku.svg" alt="Heroku" width="20" /></a>
|
|
1392
|
+
* <a href="https://dotenvx.com/docs/platforms/netlify">Netlify <img src="https://api.iconify.design/skill-icons/netlify-light.svg" alt="Netlify" width="20" /></a>
|
|
1381
1393
|
* <a href="https://dotenvx.com/docs/package-managers/npm">NPM <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/npm.svg" alt="NPM Logo" width="20" height="20" style="fill:#CB3837;"></a>
|
|
1382
1394
|
* <a href="https://dotenvx.com/docs/monorepos/nx">Nx <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/nx.svg" alt="Nx Logo" width="20" height="20" style="fill:#143055;"></a>
|
|
1383
|
-
* <a href="https://dotenvx.com/docs/platforms/render">Render <img src="https://
|
|
1384
|
-
* <a href="https://dotenvx.com/docs/platforms/railway">Railway <img src="https://
|
|
1395
|
+
* <a href="https://dotenvx.com/docs/platforms/render">Render <img src="https://api.iconify.design/simple-icons/render.svg" alt="Render" width="20" /></a>
|
|
1396
|
+
* <a href="https://dotenvx.com/docs/platforms/railway">Railway <img src="https://api.iconify.design/simple-icons/railway.svg" alt="Railway" width="20" /></a>
|
|
1385
1397
|
* <a href="https://dotenvx.com/docs/monorepos/turborepo">Turborepo <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/turborepo.svg" alt="Turborepo Logo" width="20" height="20" style="fill:#EF4444;"></a>
|
|
1386
|
-
* <a href="https://dotenvx.com/docs/platforms/vercel">Vercel <img src="https://
|
|
1398
|
+
* <a href="https://dotenvx.com/docs/platforms/vercel">Vercel <img src="https://api.iconify.design/devicon/vercel.svg" alt="Vercel" width="20" /></a>
|
|
1387
1399
|
* [more](https://dotenvx.com/docs/guides)
|
|
1388
1400
|
* <a href="https://dotenvx.com/docs/guides#node-js">Node.js <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/nodejs.svg" alt="Node.js Logo" width="20" height="20" style="fill:#5FA04E;"></a>
|
|
1389
1401
|
* <a href="https://dotenvx.com/docs/guides#python">Python <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/python.svg" alt="Python Logo" width="20" height="20" style="fill:#3776AB;"></a>
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2
|
|
2
|
+
"version": "1.3.2",
|
|
3
3
|
"name": "@dotenvx/dotenvx",
|
|
4
4
|
"description": "a better dotenv–from the creator of `dotenv`",
|
|
5
5
|
"author": "@motdotla",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"testshell": "bash shellspec",
|
|
28
28
|
"prerelease": "npm test && npm run testshell",
|
|
29
29
|
"release": "standard-version",
|
|
30
|
-
"
|
|
30
|
+
"patch": "patch-package"
|
|
31
31
|
},
|
|
32
32
|
"funding": "https://dotenvx.com",
|
|
33
33
|
"dependencies": {
|
|
@@ -16,7 +16,7 @@ async function encrypt () {
|
|
|
16
16
|
processedEnvFiles,
|
|
17
17
|
changedFilepaths,
|
|
18
18
|
unchangedFilepaths
|
|
19
|
-
} = main.encrypt(options.envFile)
|
|
19
|
+
} = main.encrypt(options.envFile, options.key)
|
|
20
20
|
|
|
21
21
|
for (const processedEnvFile of processedEnvFiles) {
|
|
22
22
|
logger.verbose(`encrypting ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
|
package/src/cli/dotenvx.js
CHANGED
|
@@ -94,6 +94,7 @@ const encryptAction = require('./actions/encrypt')
|
|
|
94
94
|
program.command('encrypt')
|
|
95
95
|
.description('convert .env file(s) to encrypted .env file(s)')
|
|
96
96
|
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)')
|
|
97
|
+
.option('-k, --key <keys...>', 'keys(s) to encrypt (default: all keys in file)')
|
|
97
98
|
.action(encryptAction)
|
|
98
99
|
|
|
99
100
|
// dotenvx pro
|
package/src/lib/main.d.ts
CHANGED
|
@@ -144,8 +144,9 @@ export type EncryptOutput = {
|
|
|
144
144
|
*
|
|
145
145
|
* @see https://dotenvx.com/docs
|
|
146
146
|
* @param envFile - path to the .env file
|
|
147
|
+
* @param key - keys(s) to encrypt (default: all keys in .env file)
|
|
147
148
|
*/
|
|
148
|
-
export function encrypt(envFile: string): EncryptOutput;
|
|
149
|
+
export function encrypt(envFile: string, key: string): EncryptOutput;
|
|
149
150
|
|
|
150
151
|
export type VaultEncryptOutput = {
|
|
151
152
|
dotenvKeys: Record<string, string>;
|
|
@@ -157,6 +158,7 @@ export type VaultEncryptOutput = {
|
|
|
157
158
|
existingVaults: string[];
|
|
158
159
|
addedDotenvFilenames: string[];
|
|
159
160
|
envFile: string | string[];
|
|
161
|
+
key: string | string[];
|
|
160
162
|
};
|
|
161
163
|
|
|
162
164
|
/**
|
package/src/lib/main.js
CHANGED
|
@@ -194,8 +194,8 @@ const set = function (key, value, envFile, encrypt) {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
/** @type {import('./main').encrypt} */
|
|
197
|
-
const encrypt = function (envFile) {
|
|
198
|
-
return new Encrypt(envFile).run()
|
|
197
|
+
const encrypt = function (envFile, key) {
|
|
198
|
+
return new Encrypt(envFile, key).run()
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
/** @type {import('./main').status} */
|
|
@@ -11,8 +11,9 @@ const replace = require('./../helpers/replace')
|
|
|
11
11
|
const ENCODING = 'utf8'
|
|
12
12
|
|
|
13
13
|
class Encrypt {
|
|
14
|
-
constructor (envFile = '.env') {
|
|
14
|
+
constructor (envFile = '.env', key = []) {
|
|
15
15
|
this.envFile = envFile
|
|
16
|
+
this.key = key
|
|
16
17
|
this.processedEnvFiles = []
|
|
17
18
|
this.changedFilepaths = new Set()
|
|
18
19
|
this.unchangedFilepaths = new Set()
|
|
@@ -20,6 +21,7 @@ class Encrypt {
|
|
|
20
21
|
|
|
21
22
|
run () {
|
|
22
23
|
const envFilepaths = this._envFilepaths()
|
|
24
|
+
const keys = this._keys()
|
|
23
25
|
for (const envFilepath of envFilepaths) {
|
|
24
26
|
const filepath = path.resolve(envFilepath)
|
|
25
27
|
|
|
@@ -52,15 +54,17 @@ class Encrypt {
|
|
|
52
54
|
// iterate over all non-encrypted values and encrypt them
|
|
53
55
|
const parsed = dotenv.parse(src)
|
|
54
56
|
for (const [key, value] of Object.entries(parsed)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
if (keys.length < 1 || keys.includes(key)) { // optionally control which key to encrypt
|
|
58
|
+
const encrypted = isEncrypted(key, value)
|
|
59
|
+
if (!encrypted) {
|
|
60
|
+
row.keys.push(key) // track key(s)
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
const encryptedValue = encryptValue(value, publicKey)
|
|
63
|
+
// once newSrc is built write it out
|
|
64
|
+
src = replace(src, key, encryptedValue)
|
|
62
65
|
|
|
63
|
-
|
|
66
|
+
row.changed = true // track change
|
|
67
|
+
}
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
|
|
@@ -99,6 +103,14 @@ class Encrypt {
|
|
|
99
103
|
|
|
100
104
|
return this.envFile
|
|
101
105
|
}
|
|
106
|
+
|
|
107
|
+
_keys () {
|
|
108
|
+
if (!Array.isArray(this.key)) {
|
|
109
|
+
return [this.key]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return this.key
|
|
113
|
+
}
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
module.exports = Encrypt
|