@dotenvx/dotenvx 1.6.4 → 1.7.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 +13 -1
- package/README.md +10 -0
- package/package.json +1 -2
- package/src/cli/commands/ext.js +0 -7
- package/src/cli/dotenvx.js +21 -21
- package/src/lib/helpers/dotenvEval.js +1 -1
- package/src/lib/main.d.ts +0 -15
- package/src/lib/main.js +0 -9
- package/src/cli/actions/ext/settings.js +0 -25
- package/src/lib/services/settings.js +0 -28
- package/src/shared/store.js +0 -146
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.
|
|
5
|
+
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.7.0...main)
|
|
6
|
+
|
|
7
|
+
## 1.7.0
|
|
8
|
+
|
|
9
|
+
### Removed
|
|
10
|
+
|
|
11
|
+
* remove `ext settings` command (and [`conf`](https://www.npmjs.com/package/conf) along with it) ([#323](https://github.com/dotenvx/dotenvx/pull/323))
|
|
12
|
+
|
|
13
|
+
## 1.6.5
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
* 🐞 patch `chomp` for interpolation. strip ending newline (was stripping first found newline) ([#322](https://github.com/dotenvx/dotenvx/pull/322))
|
|
6
18
|
|
|
7
19
|
## 1.6.4
|
|
8
20
|
|
package/README.md
CHANGED
|
@@ -267,6 +267,16 @@ More examples
|
|
|
267
267
|
Hello World
|
|
268
268
|
```
|
|
269
269
|
|
|
270
|
+
</details>
|
|
271
|
+
* <details><summary>Fish 🐠</summary><br>
|
|
272
|
+
|
|
273
|
+
```sh
|
|
274
|
+
$ echo "HELLO=World" > .env
|
|
275
|
+
|
|
276
|
+
$ dotenvx run --quiet -- sh -c 'echo Hello $HELLO'
|
|
277
|
+
Hello World
|
|
278
|
+
```
|
|
279
|
+
|
|
270
280
|
</details>
|
|
271
281
|
* <details><summary>Cron ⏰</summary><br>
|
|
272
282
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.7.0",
|
|
3
3
|
"name": "@dotenvx/dotenvx",
|
|
4
4
|
"description": "a better dotenv–from the creator of `dotenv`",
|
|
5
5
|
"author": "@motdotla",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"chalk": "^4.1.2",
|
|
40
40
|
"commander": "^11.1.0",
|
|
41
|
-
"conf": "^10.2.0",
|
|
42
41
|
"diff": "^5.2.0",
|
|
43
42
|
"dotenv": "^16.4.5",
|
|
44
43
|
"eciesjs": "^0.4.6",
|
package/src/cli/commands/ext.js
CHANGED
|
@@ -57,13 +57,6 @@ ext.command('scan')
|
|
|
57
57
|
.description('scan for leaked secrets')
|
|
58
58
|
.action(require('./../actions/ext/scan'))
|
|
59
59
|
|
|
60
|
-
// dotenvx settings
|
|
61
|
-
ext.command('settings')
|
|
62
|
-
.description('print current dotenvx settings')
|
|
63
|
-
.argument('[key]', 'settings name')
|
|
64
|
-
.option('-pp, --pretty-print', 'pretty print output')
|
|
65
|
-
.action(require('./../actions/ext/settings'))
|
|
66
|
-
|
|
67
60
|
ext.addCommand(require('./../commands/ext/vault'))
|
|
68
61
|
|
|
69
62
|
module.exports = ext
|
package/src/cli/dotenvx.js
CHANGED
|
@@ -108,13 +108,32 @@ const decryptAction = require('./actions/decrypt')
|
|
|
108
108
|
program.command('decrypt')
|
|
109
109
|
.description('convert encrypted .env file(s) to plain .env file(s)')
|
|
110
110
|
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)')
|
|
111
|
-
.option('-k, --key <keys...>', 'keys(s) to
|
|
111
|
+
.option('-k, --key <keys...>', 'keys(s) to decrypt (default: all keys in file)')
|
|
112
112
|
.option('--stdout', 'send to stdout')
|
|
113
113
|
.action(decryptAction)
|
|
114
114
|
|
|
115
|
+
// dotenvx help
|
|
116
|
+
program.command('help [command]')
|
|
117
|
+
.description('display help for command')
|
|
118
|
+
.action((command) => {
|
|
119
|
+
if (command) {
|
|
120
|
+
const subCommand = program.commands.find(c => c.name() === command)
|
|
121
|
+
if (subCommand) {
|
|
122
|
+
subCommand.outputHelp()
|
|
123
|
+
} else {
|
|
124
|
+
program.outputHelp()
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
program.outputHelp()
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
|
|
115
131
|
// dotenvx ext
|
|
116
132
|
program.addCommand(require('./commands/ext'))
|
|
117
133
|
|
|
134
|
+
//
|
|
135
|
+
// DEPRECATED or MOVED
|
|
136
|
+
//
|
|
118
137
|
const lsAction = require('./actions/ext/ls')
|
|
119
138
|
program.command('ls')
|
|
120
139
|
.description('DEPRECATED: moved to [dotenvx ext ls]')
|
|
@@ -137,7 +156,6 @@ program.command('genexample')
|
|
|
137
156
|
genexampleAction.apply(this, args)
|
|
138
157
|
})
|
|
139
158
|
|
|
140
|
-
// dotenvx gitignore
|
|
141
159
|
const gitignoreAction = require('./actions/ext/gitignore')
|
|
142
160
|
program.command('gitignore')
|
|
143
161
|
.description('DEPRECATED: moved to [dotenvx ext gitignore]')
|
|
@@ -148,7 +166,6 @@ program.command('gitignore')
|
|
|
148
166
|
gitignoreAction.apply(this, args)
|
|
149
167
|
})
|
|
150
168
|
|
|
151
|
-
// dotenvx prebuild
|
|
152
169
|
const prebuildAction = require('./actions/ext/prebuild')
|
|
153
170
|
program.command('prebuild')
|
|
154
171
|
.description('DEPRECATED: moved to [dotenvx ext prebuild]')
|
|
@@ -159,7 +176,6 @@ program.command('prebuild')
|
|
|
159
176
|
prebuildAction.apply(this, args)
|
|
160
177
|
})
|
|
161
178
|
|
|
162
|
-
// dotenvx precommit
|
|
163
179
|
const precommitAction = require('./actions/ext/precommit')
|
|
164
180
|
program.command('precommit')
|
|
165
181
|
.description('DEPRECATED: moved to [dotenvx ext precommit]')
|
|
@@ -171,7 +187,6 @@ program.command('precommit')
|
|
|
171
187
|
precommitAction.apply(this, args)
|
|
172
188
|
})
|
|
173
189
|
|
|
174
|
-
// dotenvx scan
|
|
175
190
|
const scanAction = require('./actions/ext/scan')
|
|
176
191
|
program.command('scan')
|
|
177
192
|
.description('DEPRECATED: moved to [dotenvx ext scan]')
|
|
@@ -181,28 +196,13 @@ program.command('scan')
|
|
|
181
196
|
scanAction.apply(this, args)
|
|
182
197
|
})
|
|
183
198
|
|
|
184
|
-
program.command('help [command]')
|
|
185
|
-
.description('display help for command')
|
|
186
|
-
.action((command) => {
|
|
187
|
-
if (command) {
|
|
188
|
-
const subCommand = program.commands.find(c => c.name() === command)
|
|
189
|
-
if (subCommand) {
|
|
190
|
-
subCommand.outputHelp()
|
|
191
|
-
} else {
|
|
192
|
-
program.outputHelp()
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
program.outputHelp()
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
|
|
199
199
|
// overide helpInformation to hide DEPRECATED commands
|
|
200
200
|
program.helpInformation = function () {
|
|
201
201
|
const originalHelp = Command.prototype.helpInformation.call(this)
|
|
202
202
|
const lines = originalHelp.split('\n')
|
|
203
203
|
|
|
204
204
|
// Filter out the hidden command from the help output
|
|
205
|
-
const filteredLines = lines.filter(line => !line.includes('DEPRECATED'))
|
|
205
|
+
const filteredLines = lines.filter(line => !line.includes('DEPRECATED') && !line.includes('help [command]'))
|
|
206
206
|
|
|
207
207
|
return filteredLines.join('\n')
|
|
208
208
|
}
|
package/src/lib/main.d.ts
CHANGED
|
@@ -289,21 +289,6 @@ export function genexample(
|
|
|
289
289
|
envFile: string
|
|
290
290
|
): GenExampleOutput;
|
|
291
291
|
|
|
292
|
-
export type Settings = {
|
|
293
|
-
DOTENVX_SETTINGS_FILEPATH: string;
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
type KeyOfSettings = Extract<keyof Settings, string>;
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Get the dotenvx settings
|
|
300
|
-
*
|
|
301
|
-
* @param [key] - the key to get the value of
|
|
302
|
-
*/
|
|
303
|
-
export function settings(
|
|
304
|
-
key: KeyOfSettings | undefined | null = null
|
|
305
|
-
): Settings;
|
|
306
|
-
|
|
307
292
|
/**
|
|
308
293
|
* Decrypt ciphertext
|
|
309
294
|
* @param encrypted - the encrypted ciphertext string
|
package/src/lib/main.js
CHANGED
|
@@ -12,7 +12,6 @@ const Status = require('./services/status')
|
|
|
12
12
|
const Encrypt = require('./services/encrypt')
|
|
13
13
|
const Decrypt = require('./services/decrypt')
|
|
14
14
|
const Genexample = require('./services/genexample')
|
|
15
|
-
const Settings = require('./services/settings')
|
|
16
15
|
const VaultEncrypt = require('./services/vaultEncrypt')
|
|
17
16
|
|
|
18
17
|
// helpers
|
|
@@ -204,12 +203,6 @@ const status = function (directory) {
|
|
|
204
203
|
return new Status(directory).run()
|
|
205
204
|
}
|
|
206
205
|
|
|
207
|
-
/** @type {import('./main').settings} */
|
|
208
|
-
const settings = function (key = null) {
|
|
209
|
-
// @ts-ignore
|
|
210
|
-
return new Settings(key).run()
|
|
211
|
-
}
|
|
212
|
-
|
|
213
206
|
// misc/cleanup
|
|
214
207
|
|
|
215
208
|
/** @type {import('./main').vaultDecrypt} */
|
|
@@ -255,8 +248,6 @@ module.exports = {
|
|
|
255
248
|
set,
|
|
256
249
|
status,
|
|
257
250
|
genexample,
|
|
258
|
-
// settings
|
|
259
|
-
settings,
|
|
260
251
|
// misc/cleanup
|
|
261
252
|
vaultEncrypt,
|
|
262
253
|
vaultDecrypt
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const { logger } = require('./../../../shared/logger')
|
|
2
|
-
|
|
3
|
-
const main = require('./../../../lib/main')
|
|
4
|
-
|
|
5
|
-
function settings (key = null) {
|
|
6
|
-
logger.debug(`key: ${key}`)
|
|
7
|
-
|
|
8
|
-
const options = this.opts()
|
|
9
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
10
|
-
|
|
11
|
-
const value = main.settings(key)
|
|
12
|
-
|
|
13
|
-
if (typeof value === 'object' && value !== null) {
|
|
14
|
-
let space = 0
|
|
15
|
-
if (options.prettyPrint) {
|
|
16
|
-
space = 2
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
process.stdout.write(JSON.stringify(value, null, space))
|
|
20
|
-
} else {
|
|
21
|
-
process.stdout.write(value)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = settings
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const store = require('./../../shared/store')
|
|
2
|
-
|
|
3
|
-
class Settings {
|
|
4
|
-
constructor (key = null) {
|
|
5
|
-
this.key = key
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
run () {
|
|
9
|
-
const store = this._store()
|
|
10
|
-
|
|
11
|
-
if (this.key) {
|
|
12
|
-
return store[this.key]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// json of dotenvx.settings
|
|
16
|
-
return store
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
_store () {
|
|
20
|
-
const h = {
|
|
21
|
-
DOTENVX_SETTINGS_FILEPATH: store.configPath()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return { ...h, ...store.confStore.store }
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = Settings
|
package/src/shared/store.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
const Conf = require('conf')
|
|
2
|
-
const dotenv = require('dotenv')
|
|
3
|
-
const packageJson = require('./../lib/helpers/packageJson')
|
|
4
|
-
|
|
5
|
-
function jsonToEnv (json) {
|
|
6
|
-
return Object.entries(json).map(function ([key, value]) {
|
|
7
|
-
return key + '=' + `"${value}"`
|
|
8
|
-
}).join('\n')
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function convertFullUsernameToEnvFormat (fullUsername) {
|
|
12
|
-
// gh/motdotla => GH_MOTDOTLA_DOTENVX_TOKEN
|
|
13
|
-
return fullUsername
|
|
14
|
-
.toUpperCase()
|
|
15
|
-
.replace(/\//g, '_') // Replace all slashes with underscores
|
|
16
|
-
.concat('_DOTENVX_TOKEN') // Append '_DOTENVX_TOKEN' at the end
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function findFirstMatchingKey (data) {
|
|
20
|
-
const dotenvxTokenValue = data.DOTENVX_TOKEN
|
|
21
|
-
|
|
22
|
-
for (const [key, value] of Object.entries(data)) {
|
|
23
|
-
if (key !== 'DOTENVX_TOKEN' && value === dotenvxTokenValue) {
|
|
24
|
-
return key
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return null // Return null if no matching key is found
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function parseUsernameFromTokenKey (key) {
|
|
32
|
-
// Remove the leading GH_/GL_ and trailing '_DOTENVX_TOKEN'
|
|
33
|
-
const modifiedKey = key.replace(/^(GH_|GL_)/, '').replace(/_DOTENVX_TOKEN$/, '')
|
|
34
|
-
|
|
35
|
-
// Convert to lowercase
|
|
36
|
-
return modifiedKey.toLowerCase()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const confStore = new Conf({
|
|
40
|
-
projectName: 'dotenvx',
|
|
41
|
-
configName: '.env',
|
|
42
|
-
// looks better on user's machine
|
|
43
|
-
// https://github.com/sindresorhus/conf/tree/v10.2.0#projectsuffix.
|
|
44
|
-
projectSuffix: '',
|
|
45
|
-
fileExtension: '',
|
|
46
|
-
// in the spirit of dotenv and format inherently puts limits on config complexity
|
|
47
|
-
serialize: function (json) {
|
|
48
|
-
return jsonToEnv(json)
|
|
49
|
-
},
|
|
50
|
-
// Convert .env format to an object
|
|
51
|
-
deserialize: function (env) {
|
|
52
|
-
return dotenv.parse(env)
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const getHostname = function () {
|
|
57
|
-
return confStore.get('DOTENVX_HOSTNAME') || 'https://hub.dotenvx.com'
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const getUsername = function () {
|
|
61
|
-
const key = findFirstMatchingKey(confStore.store)
|
|
62
|
-
|
|
63
|
-
if (key) {
|
|
64
|
-
return parseUsernameFromTokenKey(key)
|
|
65
|
-
} else {
|
|
66
|
-
return null
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const getToken = function () {
|
|
71
|
-
return confStore.get('DOTENVX_TOKEN')
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const getLatestVersion = function () {
|
|
75
|
-
return confStore.get('DOTENVX_LATEST_VERSION') || packageJson.version
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const getLatestVersionLastChecked = function () {
|
|
79
|
-
return parseInt(confStore.get('DOTENVX_LATEST_VERSION_LAST_CHECKED') || 0)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const setToken = function (fullUsername, accessToken) {
|
|
83
|
-
// current logged in user
|
|
84
|
-
confStore.set('DOTENVX_TOKEN', accessToken)
|
|
85
|
-
|
|
86
|
-
// for future use to switch between accounts locally
|
|
87
|
-
const memory = convertFullUsernameToEnvFormat(fullUsername)
|
|
88
|
-
confStore.set(memory, accessToken)
|
|
89
|
-
|
|
90
|
-
return accessToken
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const setHostname = function (hostname) {
|
|
94
|
-
confStore.set('DOTENVX_HOSTNAME', hostname)
|
|
95
|
-
|
|
96
|
-
return hostname
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const setLatestVersion = function (version) {
|
|
100
|
-
confStore.set('DOTENVX_LATEST_VERSION', version)
|
|
101
|
-
|
|
102
|
-
return version
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const setLatestVersionLastChecked = function (dateNow) {
|
|
106
|
-
confStore.set('DOTENVX_LATEST_VERSION_LAST_CHECKED', dateNow)
|
|
107
|
-
|
|
108
|
-
return dateNow
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const deleteToken = function () {
|
|
112
|
-
// memory user
|
|
113
|
-
const key = findFirstMatchingKey(confStore.store) // GH_MOTDOTLA_DOTENVX_TOKEN
|
|
114
|
-
confStore.delete(key)
|
|
115
|
-
|
|
116
|
-
// current logged in user
|
|
117
|
-
confStore.delete('DOTENVX_TOKEN')
|
|
118
|
-
|
|
119
|
-
return true
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const deleteHostname = function () {
|
|
123
|
-
confStore.delete('DOTENVX_HOSTNAME')
|
|
124
|
-
|
|
125
|
-
return true
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const configPath = function () {
|
|
129
|
-
return confStore.path
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
module.exports = {
|
|
133
|
-
confStore,
|
|
134
|
-
getHostname,
|
|
135
|
-
getToken,
|
|
136
|
-
getUsername,
|
|
137
|
-
getLatestVersion,
|
|
138
|
-
getLatestVersionLastChecked,
|
|
139
|
-
setHostname,
|
|
140
|
-
setToken,
|
|
141
|
-
setLatestVersion,
|
|
142
|
-
setLatestVersionLastChecked,
|
|
143
|
-
deleteToken,
|
|
144
|
-
deleteHostname,
|
|
145
|
-
configPath
|
|
146
|
-
}
|