@dotenvx/dotenvx 1.62.0 → 1.64.0
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 +38 -6
- package/README.md +29 -0
- package/package.json +1 -1
- package/src/cli/actions/get.js +8 -0
- package/src/cli/actions/keypair.js +12 -3
- package/src/cli/dotenvx.js +12 -3
- package/src/lib/extensions/ops.js +9 -2
- package/src/lib/helpers/canonicalEnvFilename.js +13 -0
- package/src/lib/helpers/envResolution/environment.js +2 -2
- package/src/lib/helpers/keyResolution/index.js +1 -0
- package/src/lib/helpers/keyResolution/keyNames.js +2 -2
- package/src/lib/helpers/keyResolution/keyValuesFromEnvSrc.js +66 -0
- package/src/lib/main.js +8 -0
- package/src/lib/services/run.js +9 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,26 @@
|
|
|
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.64.0...main)
|
|
6
|
+
|
|
7
|
+
## [1.64.0](https://github.com/dotenvx/dotenvx/compare/v1.63.0...v1.64.0) (2026-04-27)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Add optional `dotenvx armor` command.
|
|
12
|
+
* `armor up` armor private key
|
|
13
|
+
* `armor down` dearmor private key
|
|
14
|
+
* `armor push` push armored key (from .env.keys)
|
|
15
|
+
* `armor pull` pull armored key (into .env.keys)
|
|
16
|
+
|
|
17
|
+
Move private keys off device and under access control with Dotenvx Ops ⛨. [Learn more](https://dotenvx.com/ops)
|
|
18
|
+
|
|
19
|
+
## [1.63.0](https://github.com/dotenvx/dotenvx/compare/v1.62.0...v1.63.0) (2026-04-24)
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
* Add support for encrypted values passed to `--env` flag ([#804](https://github.com/dotenvx/dotenvx/pull/804))
|
|
24
|
+
* Add support for `--format=colon` in order to support cloudflare's wrangler `--var` flag format ([#804](https://github.com/dotenvx/dotenvx/pull/804))
|
|
6
25
|
|
|
7
26
|
## [1.62.0](https://github.com/dotenvx/dotenvx/compare/v1.61.6...v1.62.0) (2026-04-23)
|
|
8
27
|
|
|
@@ -10,17 +29,30 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
10
29
|
|
|
11
30
|
* Add support for `config({ envs })`. unlocks simpler cloudflare worker integration ([#803](https://github.com/dotenvx/dotenvx/pull/803))
|
|
12
31
|
|
|
32
|
+
```sh
|
|
33
|
+
$ dotenvx encrypt -f .env.txt
|
|
34
|
+
```
|
|
13
35
|
```js
|
|
36
|
+
// src/index.js
|
|
14
37
|
import envSrc from '../.env.txt'
|
|
15
38
|
import dotenvx from '@dotenvx/dotenvx'
|
|
16
39
|
|
|
40
|
+
const config = dotenvx.config({ envs: [{ type: 'env', value: envSrc, privateKeyName: 'DOTENV_PRIVATE_KEY' }] })
|
|
41
|
+
const envx = config.parsed
|
|
42
|
+
|
|
17
43
|
export default {
|
|
18
44
|
async fetch(request, env, ctx) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
45
|
+
return new Response(`Hello ${envx.HELLO}`)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
```json
|
|
50
|
+
"scripts": {
|
|
51
|
+
"deploy": "wrangler deploy",
|
|
52
|
+
"dev": "wrangler dev --var $(dotenvx keypair -f .env.txt --format=colon)",
|
|
53
|
+
"start": "wrangler dev --var $(dotenvx keypair -f .env.txt --format=colon)",
|
|
54
|
+
"test": "vitest"
|
|
55
|
+
},
|
|
24
56
|
```
|
|
25
57
|
|
|
26
58
|
## [1.61.6](https://github.com/dotenvx/dotenvx/compare/v1.61.5...v1.61.6) (2026-04-23)
|
package/README.md
CHANGED
|
@@ -150,6 +150,35 @@ $ dotenvx run -- npx tsx index.ts
|
|
|
150
150
|
Hello Dotenvx
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
+
</details>
|
|
154
|
+
<details><summary>Cloudflare Workers ⛅️</summary><br>
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
$ dotenvx encrypt -f .env.txt
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```js
|
|
161
|
+
// src/index.js
|
|
162
|
+
import envSrc from '../.env.txt'
|
|
163
|
+
import dotenvx from '@dotenvx/dotenvx'
|
|
164
|
+
|
|
165
|
+
const config = dotenvx.config({ envs: [{ type: 'env', value: envSrc, privateKeyName: 'DOTENV_PRIVATE_KEY' }] })
|
|
166
|
+
const envx = config.parsed
|
|
167
|
+
|
|
168
|
+
export default {
|
|
169
|
+
async fetch(request, env, ctx) {
|
|
170
|
+
return new Response(`Hello ${envx.HELLO}`)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
```json
|
|
175
|
+
"scripts": {
|
|
176
|
+
"deploy": "wrangler deploy",
|
|
177
|
+
"dev": "wrangler dev --var $(dotenvx keypair -f .env.txt --format=colon)",
|
|
178
|
+
"start": "wrangler dev --var $(dotenvx keypair -f .env.txt --format=colon)",
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
153
182
|
</details>
|
|
154
183
|
<details><summary>Deno 🦕</summary><br>
|
|
155
184
|
|
package/package.json
CHANGED
package/src/cli/actions/get.js
CHANGED
|
@@ -66,6 +66,14 @@ async function get (key) {
|
|
|
66
66
|
}
|
|
67
67
|
inline = inline.trim()
|
|
68
68
|
|
|
69
|
+
console.log(inline)
|
|
70
|
+
} else if (options.format === 'colon') {
|
|
71
|
+
let inline = ''
|
|
72
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
73
|
+
inline += `${key}:${value} `
|
|
74
|
+
}
|
|
75
|
+
inline = inline.trim()
|
|
76
|
+
|
|
69
77
|
console.log(inline)
|
|
70
78
|
} else {
|
|
71
79
|
let space = 0
|
|
@@ -22,11 +22,18 @@ async function keypair (key) {
|
|
|
22
22
|
|
|
23
23
|
if (spinner) spinner.stop()
|
|
24
24
|
if (typeof results === 'object' && results !== null) {
|
|
25
|
-
// inline shell format - env $(dotenvx keypair --format=shell) your-command
|
|
26
25
|
if (options.format === 'shell') {
|
|
27
26
|
let inline = ''
|
|
28
|
-
for (const [
|
|
29
|
-
inline += `${
|
|
27
|
+
for (const [keyName, value] of Object.entries(results)) {
|
|
28
|
+
inline += `${keyName}=${value || ''} `
|
|
29
|
+
}
|
|
30
|
+
inline = inline.trim()
|
|
31
|
+
|
|
32
|
+
console.log(inline)
|
|
33
|
+
} else if (options.format === 'colon') {
|
|
34
|
+
let inline = ''
|
|
35
|
+
for (const [keyName, value] of Object.entries(results)) {
|
|
36
|
+
inline += `${keyName}:${value || ''} `
|
|
30
37
|
}
|
|
31
38
|
inline = inline.trim()
|
|
32
39
|
|
|
@@ -44,6 +51,8 @@ async function keypair (key) {
|
|
|
44
51
|
if (results === undefined) {
|
|
45
52
|
console.log('')
|
|
46
53
|
process.exit(1)
|
|
54
|
+
} else if (options.format === 'colon' && key) {
|
|
55
|
+
console.log(`${key}:${results}`)
|
|
47
56
|
} else {
|
|
48
57
|
console.log(results)
|
|
49
58
|
}
|
package/src/cli/dotenvx.js
CHANGED
|
@@ -92,7 +92,7 @@ program.command('get')
|
|
|
92
92
|
.option('-a, --all', 'include all machine envs as well')
|
|
93
93
|
.option('-pp, --pretty-print', 'pretty print output')
|
|
94
94
|
.option('--pp', 'pretty print output (alias)')
|
|
95
|
-
.option('--format <type>', 'format of the output (json, shell, eval)', 'json')
|
|
95
|
+
.option('--format <type>', 'format of the output (json, shell, colon, eval)', 'json')
|
|
96
96
|
.option('--no-ops', 'disable dotenvx-ops features')
|
|
97
97
|
.action(function (...args) {
|
|
98
98
|
this.envs = envs
|
|
@@ -171,7 +171,7 @@ program.command('keypair')
|
|
|
171
171
|
.option('--no-ops', 'disable dotenvx-ops features')
|
|
172
172
|
.option('-pp, --pretty-print', 'pretty print output')
|
|
173
173
|
.option('--pp', 'pretty print output (alias)')
|
|
174
|
-
.option('--format <type>', 'format of the output (json, shell)', 'json')
|
|
174
|
+
.option('--format <type>', 'format of the output (json, shell, colon)', 'json')
|
|
175
175
|
.action(function (...args) {
|
|
176
176
|
return require('./actions/keypair').apply(this, args)
|
|
177
177
|
})
|
|
@@ -197,13 +197,22 @@ program.command('login')
|
|
|
197
197
|
|
|
198
198
|
// dotenvx logout
|
|
199
199
|
program.command('logout', { hidden: true })
|
|
200
|
-
.description('
|
|
200
|
+
.description('log out of your dotenvx account')
|
|
201
201
|
.allowUnknownOption()
|
|
202
202
|
.action(() => {
|
|
203
203
|
const rawArgs = ['ops', 'logout', ...process.argv.slice(3)]
|
|
204
204
|
executeDynamic(program, 'ops', rawArgs)
|
|
205
205
|
})
|
|
206
206
|
|
|
207
|
+
// dotenvx armor
|
|
208
|
+
program.command('armor', { hidden: true })
|
|
209
|
+
.description('ARMORED KEYS ⛨')
|
|
210
|
+
.allowUnknownOption()
|
|
211
|
+
.action((args) => {
|
|
212
|
+
const rawArgs = ['ops', 'armor', ...process.argv.slice(3)]
|
|
213
|
+
executeDynamic(program, 'ops', rawArgs)
|
|
214
|
+
})
|
|
215
|
+
|
|
207
216
|
// dotenvx help
|
|
208
217
|
program.command('help [command]')
|
|
209
218
|
.description('display help for command')
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const childProcess = require('child_process')
|
|
3
3
|
const util = require('util')
|
|
4
|
+
const { logger } = require('../../shared/logger')
|
|
4
5
|
|
|
5
6
|
const execFile = util.promisify(childProcess.execFile)
|
|
6
7
|
|
|
@@ -98,6 +99,8 @@ class Ops {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
_execSync (binary, args) {
|
|
102
|
+
logger.debug(binary)
|
|
103
|
+
logger.debug(args)
|
|
101
104
|
return childProcess.execFileSync(binary, args).toString().trim()
|
|
102
105
|
}
|
|
103
106
|
|
|
@@ -130,13 +133,17 @@ class Ops {
|
|
|
130
133
|
this._execSync(npmBin, ['--version'])
|
|
131
134
|
this._binarySync = npmBin
|
|
132
135
|
return this._binarySync
|
|
133
|
-
} catch (
|
|
136
|
+
} catch (err) {
|
|
137
|
+
logger.debug(err.message)
|
|
138
|
+
}
|
|
134
139
|
|
|
135
140
|
try {
|
|
136
141
|
this._execSync('dotenvx-ops', ['--version'])
|
|
137
142
|
this._binarySync = 'dotenvx-ops'
|
|
138
143
|
return this._binarySync
|
|
139
|
-
} catch (
|
|
144
|
+
} catch (err) {
|
|
145
|
+
logger.debug(err.message)
|
|
146
|
+
}
|
|
140
147
|
|
|
141
148
|
this._binarySync = null
|
|
142
149
|
return null
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
function canonicalEnvFilename (filepath) {
|
|
4
|
+
let filename = path.basename(filepath).toLowerCase()
|
|
5
|
+
|
|
6
|
+
if (filename.startsWith('.env') && filename.endsWith('.txt')) {
|
|
7
|
+
filename = filename.slice(0, -4)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return filename
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = canonicalEnvFilename
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const canonicalEnvFilename = require('./../canonicalEnvFilename')
|
|
2
2
|
|
|
3
3
|
function environment (filepath) {
|
|
4
|
-
const filename =
|
|
4
|
+
const filename = canonicalEnvFilename(filepath)
|
|
5
5
|
|
|
6
6
|
const parts = filename.split('.')
|
|
7
7
|
const possibleEnvironmentList = [...parts.slice(2)]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const canonicalEnvFilename = require('./../canonicalEnvFilename')
|
|
2
2
|
const environment = require('./../envResolution/environment')
|
|
3
3
|
|
|
4
4
|
function keyNames (filepath) {
|
|
5
|
-
const filename =
|
|
5
|
+
const filename = canonicalEnvFilename(filepath)
|
|
6
6
|
|
|
7
7
|
// .env
|
|
8
8
|
if (filename === '.env') {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
const dotenvParse = require('./../dotenvParse')
|
|
4
|
+
const readFileKeySync = require('./readFileKeySync')
|
|
5
|
+
const opsKeypairSync = require('../cryptography/opsKeypairSync')
|
|
6
|
+
|
|
7
|
+
const PUBLIC_KEY_SCHEMA = 'DOTENV_PUBLIC_KEY'
|
|
8
|
+
const PRIVATE_KEY_SCHEMA = 'DOTENV_PRIVATE_KEY'
|
|
9
|
+
|
|
10
|
+
function readProcessKey (processEnv, keyName) {
|
|
11
|
+
if (processEnv[keyName] && processEnv[keyName].length > 0) {
|
|
12
|
+
return processEnv[keyName]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function publicKeyNameFromEnvSrc (envParsed) {
|
|
17
|
+
for (const keyName of Object.keys(envParsed)) {
|
|
18
|
+
if (keyName === PUBLIC_KEY_SCHEMA || keyName.startsWith(PUBLIC_KEY_SCHEMA)) {
|
|
19
|
+
return keyName
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function keyValuesFromEnvSrc (src, privateKeyName = null, opts = {}) {
|
|
27
|
+
let keysFilepath = opts.keysFilepath || null
|
|
28
|
+
const noOps = opts.noOps === true
|
|
29
|
+
const processEnv = opts.processEnv || process.env
|
|
30
|
+
const envParsed = dotenvParse(src)
|
|
31
|
+
|
|
32
|
+
const publicKeyName = publicKeyNameFromEnvSrc(envParsed)
|
|
33
|
+
const publicKeyValue = publicKeyName ? readProcessKey(processEnv, publicKeyName) || envParsed[publicKeyName] || null : null
|
|
34
|
+
|
|
35
|
+
if (!privateKeyName && publicKeyName) {
|
|
36
|
+
privateKeyName = publicKeyName.replace(PUBLIC_KEY_SCHEMA, PRIVATE_KEY_SCHEMA)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let privateKeyValue = null
|
|
40
|
+
if (privateKeyName) {
|
|
41
|
+
privateKeyValue = readProcessKey(processEnv, privateKeyName)
|
|
42
|
+
|
|
43
|
+
if (!privateKeyValue) {
|
|
44
|
+
if (keysFilepath) {
|
|
45
|
+
keysFilepath = path.resolve(keysFilepath)
|
|
46
|
+
} else {
|
|
47
|
+
keysFilepath = path.resolve('.env.keys')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
privateKeyValue = readFileKeySync(privateKeyName, keysFilepath)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!noOps && !privateKeyValue && publicKeyValue && publicKeyValue.length > 0) {
|
|
55
|
+
const kp = opsKeypairSync(publicKeyValue)
|
|
56
|
+
privateKeyValue = kp.privateKey
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
publicKeyValue: publicKeyValue || null,
|
|
61
|
+
privateKeyValue: privateKeyValue || null,
|
|
62
|
+
privateKeyName: privateKeyName || null
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = keyValuesFromEnvSrc
|
package/src/lib/main.js
CHANGED
|
@@ -276,6 +276,14 @@ const get = function (key, options = {}) {
|
|
|
276
276
|
}
|
|
277
277
|
inline = inline.trim()
|
|
278
278
|
|
|
279
|
+
return inline
|
|
280
|
+
} else if (options.format === 'colon') {
|
|
281
|
+
let inline = ''
|
|
282
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
283
|
+
inline += `${key}:${value} `
|
|
284
|
+
}
|
|
285
|
+
inline = inline.trim()
|
|
286
|
+
|
|
279
287
|
return inline
|
|
280
288
|
} else {
|
|
281
289
|
return parsed
|
package/src/lib/services/run.js
CHANGED
|
@@ -12,7 +12,8 @@ const detectEncodingSync = require('./../helpers/detectEncodingSync')
|
|
|
12
12
|
const {
|
|
13
13
|
keyNames,
|
|
14
14
|
keyValues,
|
|
15
|
-
keyValuesSync
|
|
15
|
+
keyValuesSync,
|
|
16
|
+
keyValuesFromEnvSrc
|
|
16
17
|
} = require('./../helpers/keyResolution')
|
|
17
18
|
|
|
18
19
|
class Run {
|
|
@@ -88,17 +89,20 @@ class Run {
|
|
|
88
89
|
row.string = env
|
|
89
90
|
|
|
90
91
|
try {
|
|
91
|
-
const
|
|
92
|
+
const {
|
|
93
|
+
privateKeyName: resolvedPrivateKeyName,
|
|
94
|
+
privateKeyValue
|
|
95
|
+
} = keyValuesFromEnvSrc(env, privateKeyName, { keysFilepath: this.envKeysFilepath, noOps: this.noOps, processEnv: this.processEnv })
|
|
92
96
|
|
|
93
97
|
const {
|
|
94
98
|
parsed,
|
|
95
99
|
errors,
|
|
96
100
|
injected,
|
|
97
101
|
preExisted
|
|
98
|
-
} = new Parse(env,
|
|
102
|
+
} = new Parse(env, privateKeyValue, this.processEnv, this.overload, resolvedPrivateKeyName).run()
|
|
99
103
|
|
|
100
|
-
row.privateKeyName =
|
|
101
|
-
row.privateKey =
|
|
104
|
+
row.privateKeyName = resolvedPrivateKeyName
|
|
105
|
+
row.privateKey = privateKeyValue
|
|
102
106
|
row.parsed = parsed
|
|
103
107
|
row.errors = errors
|
|
104
108
|
row.injected = injected
|