@dotenvx/dotenvx 1.5.0 → 1.6.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 +18 -1
- package/README.md +88 -2
- package/package.json +9 -9
- package/src/cli/actions/decrypt.js +71 -0
- package/src/cli/actions/encrypt.js +54 -42
- package/src/cli/actions/ext/genexample.js +4 -12
- package/src/cli/actions/ext/gitignore.js +5 -0
- package/src/cli/actions/ext/prebuild.js +1 -0
- package/src/cli/actions/ext/scan.js +9 -6
- package/src/cli/actions/ext/settings.js +5 -4
- package/src/cli/actions/ext/vault/decrypt.js +6 -13
- package/src/cli/actions/ext/vault/encrypt.js +5 -12
- package/src/cli/actions/ext/vault/migrate.js +22 -39
- package/src/cli/actions/get.js +6 -5
- package/src/cli/actions/run.js +3 -110
- package/src/cli/actions/set.js +2 -2
- package/src/cli/commands/ext.js +2 -32
- package/src/cli/dotenvx.js +12 -14
- package/src/lib/helpers/execute.js +9 -0
- package/src/lib/helpers/executeCommand.js +117 -0
- package/src/lib/helpers/executeExtension.js +38 -0
- package/src/lib/helpers/findOrCreatePublicKey.js +14 -8
- package/src/lib/helpers/isEncrypted.js +1 -2
- package/src/lib/helpers/isFullyEncrypted.js +2 -1
- package/src/lib/helpers/isIgnoringDotenvKeys.js +1 -1
- package/src/lib/helpers/isPublicKey.js +7 -0
- package/src/lib/helpers/keyPair.js +8 -2
- package/src/lib/helpers/smartDotenvPrivateKey.js +64 -6
- package/src/lib/main.js +16 -9
- package/src/lib/services/decrypt.js +79 -98
- package/src/lib/services/encrypt.js +12 -7
- package/src/lib/services/sets.js +9 -2
- package/src/lib/services/status.js +2 -2
- package/src/lib/services/vaultDecrypt.js +126 -0
- package/src/shared/logger.js +0 -3
- package/src/cli/commands/vault.js +0 -57
- package/src/lib/helpers/clipboardy/fallbacks/linux/xsel +0 -0
- package/src/lib/helpers/clipboardy/fallbacks/windows/clipboard_i686.exe +0 -0
- package/src/lib/helpers/clipboardy/fallbacks/windows/clipboard_x86_64.exe +0 -0
- package/src/lib/helpers/clipboardy/linux.js +0 -57
- package/src/lib/helpers/clipboardy/macos.js +0 -14
- package/src/lib/helpers/clipboardy/termux.js +0 -41
- package/src/lib/helpers/clipboardy/windows.js +0 -16
- package/src/lib/helpers/clipboardy.js +0 -51
- package/src/lib/helpers/extractUsernameName.js +0 -10
- package/src/lib/helpers/forgivingDirectory.js +0 -11
- package/src/lib/helpers/gitRoot.js +0 -14
- package/src/lib/helpers/gitUrl.js +0 -13
- package/src/lib/helpers/isGitRepo.js +0 -13
- package/src/lib/helpers/isGithub.js +0 -5
- package/src/lib/helpers/resolvePath.js +0 -8
- package/src/shared/confirm.js +0 -12
- package/src/shared/createSpinner.js +0 -97
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const execa = require('execa')
|
|
3
|
-
|
|
4
|
-
const handler = error => {
|
|
5
|
-
if (error.code === 'ENOENT') {
|
|
6
|
-
throw new Error('Couldn\'t find the termux-api scripts. You can install them with: apt install termux-api')
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
throw error
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = {
|
|
13
|
-
copy: async options => {
|
|
14
|
-
try {
|
|
15
|
-
await execa('termux-clipboard-set', options)
|
|
16
|
-
} catch (error) {
|
|
17
|
-
handler(error)
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
paste: async options => {
|
|
21
|
-
try {
|
|
22
|
-
return await execa.stdout('termux-clipboard-get', options)
|
|
23
|
-
} catch (error) {
|
|
24
|
-
handler(error)
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
copySync: options => {
|
|
28
|
-
try {
|
|
29
|
-
execa.sync('termux-clipboard-set', options)
|
|
30
|
-
} catch (error) {
|
|
31
|
-
handler(error)
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
pasteSync: options => {
|
|
35
|
-
try {
|
|
36
|
-
return execa.sync('termux-clipboard-get', options)
|
|
37
|
-
} catch (error) {
|
|
38
|
-
handler(error)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const execa = require('execa')
|
|
4
|
-
const arch = require('arch')
|
|
5
|
-
|
|
6
|
-
// Binaries from: https://github.com/sindresorhus/clipboardy/tree/v2.3.0
|
|
7
|
-
const windowBinaryPath = arch() === 'x64'
|
|
8
|
-
? path.join(__dirname, './fallbacks/windows/clipboard_x86_64.exe')
|
|
9
|
-
: path.join(__dirname, './fallbacks/windows/clipboard_i686.exe')
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
copy: async options => execa(windowBinaryPath, ['--copy'], options),
|
|
13
|
-
paste: async options => execa.stdout(windowBinaryPath, ['--paste'], options),
|
|
14
|
-
copySync: options => execa.sync(windowBinaryPath, ['--copy'], options),
|
|
15
|
-
pasteSync: options => execa.sync(windowBinaryPath, ['--paste'], options)
|
|
16
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// based on "clipboardy" by Sindre Sorhus (https://github.com/sindresorhus/clipboardy)
|
|
2
|
-
// licensed under the MIT License (see [license](https://github.com/sindresorhus/clipboardy/blob/v2.3.0/license) file for details).
|
|
3
|
-
|
|
4
|
-
'use strict'
|
|
5
|
-
const isWSL = require('is-wsl')
|
|
6
|
-
const termux = require('./clipboardy/termux.js')
|
|
7
|
-
const linux = require('./clipboardy/linux.js')
|
|
8
|
-
const macos = require('./clipboardy/macos.js')
|
|
9
|
-
const windows = require('./clipboardy/windows.js')
|
|
10
|
-
|
|
11
|
-
const platformLib = (() => {
|
|
12
|
-
switch (process.platform) {
|
|
13
|
-
case 'darwin':
|
|
14
|
-
return macos
|
|
15
|
-
case 'win32':
|
|
16
|
-
return windows
|
|
17
|
-
case 'android':
|
|
18
|
-
if (process.env.PREFIX !== '/data/data/com.termux/files/usr') {
|
|
19
|
-
throw new Error('You need to install Termux for this module to work on Android: https://termux.com')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return termux
|
|
23
|
-
default:
|
|
24
|
-
// `process.platform === 'linux'` for WSL.
|
|
25
|
-
if (isWSL) {
|
|
26
|
-
return windows
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return linux
|
|
30
|
-
}
|
|
31
|
-
})()
|
|
32
|
-
|
|
33
|
-
exports.write = async text => {
|
|
34
|
-
if (typeof text !== 'string') {
|
|
35
|
-
throw new TypeError(`Expected a string, got ${typeof text}`)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
await platformLib.copy({ input: text })
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
exports.read = async () => platformLib.paste({ stripEof: false })
|
|
42
|
-
|
|
43
|
-
exports.writeSync = text => {
|
|
44
|
-
if (typeof text !== 'string') {
|
|
45
|
-
throw new TypeError(`Expected a string, got ${typeof text}`)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
platformLib.copySync({ input: text })
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
exports.readSync = () => platformLib.pasteSync({ stripEof: false }).stdout
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
function extractUsernameName (url) {
|
|
2
|
-
// Removing the protocol part and splitting by slashes and colons
|
|
3
|
-
// Removing the protocol part and .git suffix, then splitting by slashes and colons
|
|
4
|
-
const parts = url.replace(/(^\w+:|^)\/\//, '').replace(/\.git$/, '').split(/[/:]/)
|
|
5
|
-
|
|
6
|
-
// Extract the 'username/repository' part
|
|
7
|
-
return parts.slice(-2).join('/')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = extractUsernameName
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const execa = require('execa')
|
|
2
|
-
|
|
3
|
-
function gitRoot () {
|
|
4
|
-
try {
|
|
5
|
-
// Redirect standard error to null to suppress Git error messages
|
|
6
|
-
const raw = execa.sync('git', ['rev-parse', '--show-toplevel'], { stderr: 'ignore' })
|
|
7
|
-
const result = raw.stdout.toString().trim()
|
|
8
|
-
return result
|
|
9
|
-
} catch (_error) {
|
|
10
|
-
return null
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
module.exports = gitRoot
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const execa = require('execa')
|
|
2
|
-
|
|
3
|
-
function isGitRepo () {
|
|
4
|
-
try {
|
|
5
|
-
const raw = execa.sync('git', ['rev-parse', '--is-inside-work-tree'], { stderr: 'ignore' })
|
|
6
|
-
const result = raw.stdout.toString().trim()
|
|
7
|
-
return result === 'true'
|
|
8
|
-
} catch (_error) {
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
module.exports = isGitRepo
|
package/src/shared/confirm.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const { ConfirmPrompt } = require('@clack/core')
|
|
2
|
-
|
|
3
|
-
module.exports = (opts) => {
|
|
4
|
-
return new ConfirmPrompt({
|
|
5
|
-
active: 'Y',
|
|
6
|
-
inactive: 'N',
|
|
7
|
-
initialValue: true,
|
|
8
|
-
render () {
|
|
9
|
-
return `${opts.message} (${this.value ? 'Y/n' : 'y/N'})`
|
|
10
|
-
}
|
|
11
|
-
}).prompt()
|
|
12
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk')
|
|
2
|
-
|
|
3
|
-
const FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
|
4
|
-
const HIDE_CURSOR = '\u001B[?25l'
|
|
5
|
-
const SHOW_CURSOR = '\u001B[?25h'
|
|
6
|
-
const CLEAR_LINE = '\r\x1b[K'
|
|
7
|
-
const SYMBOL_INFO = 'ℹ'
|
|
8
|
-
const SYMBOL_WARN = '⚠'
|
|
9
|
-
const SYMBOL_ERROR = '✖'
|
|
10
|
-
const SYMBOL_SUCCESS = '✔'
|
|
11
|
-
|
|
12
|
-
class Spinner {
|
|
13
|
-
text
|
|
14
|
-
interval
|
|
15
|
-
frameIndex = 0
|
|
16
|
-
symbol = chalk.blue(FRAMES[0])
|
|
17
|
-
|
|
18
|
-
constructor (text) {
|
|
19
|
-
this.text = text
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
start (text) {
|
|
23
|
-
if (text) {
|
|
24
|
-
this.text = text
|
|
25
|
-
}
|
|
26
|
-
this.render()
|
|
27
|
-
this.interval = setInterval(() => this.tick(), 50)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
tick () {
|
|
31
|
-
this.symbol = chalk.blue(FRAMES[this.frameIndex++])
|
|
32
|
-
if (this.frameIndex === FRAMES.length - 1) this.frameIndex = 0
|
|
33
|
-
this.render()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
render () {
|
|
37
|
-
process.stdout.write(CLEAR_LINE + HIDE_CURSOR + (this.symbol ? this.symbol + ' ' : '') + this.text)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
succeed (text) {
|
|
41
|
-
if (text) {
|
|
42
|
-
this.text = text
|
|
43
|
-
}
|
|
44
|
-
this.symbol = chalk.green(SYMBOL_SUCCESS)
|
|
45
|
-
this.end()
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
info (text) {
|
|
49
|
-
if (text) {
|
|
50
|
-
this.text = text
|
|
51
|
-
}
|
|
52
|
-
this.symbol = chalk.blue(SYMBOL_INFO)
|
|
53
|
-
this.end()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
warn (text) {
|
|
57
|
-
if (text) {
|
|
58
|
-
this.text = text
|
|
59
|
-
}
|
|
60
|
-
this.symbol = chalk.yellow(SYMBOL_WARN)
|
|
61
|
-
this.end()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
fail (text) {
|
|
65
|
-
if (text) {
|
|
66
|
-
this.text = text
|
|
67
|
-
}
|
|
68
|
-
this.symbol = chalk.red(SYMBOL_ERROR)
|
|
69
|
-
this.end()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
stop () {
|
|
73
|
-
this.symbol = ''
|
|
74
|
-
this.end()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
end () {
|
|
78
|
-
this.render()
|
|
79
|
-
clearInterval(this.interval)
|
|
80
|
-
process.stdout.write(SHOW_CURSOR + '\n')
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const createSpinner = (initialMessage = '') => {
|
|
85
|
-
const spinner = new Spinner(initialMessage)
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
start: (message) => spinner.start(message),
|
|
89
|
-
succeed: (message) => spinner.succeed(chalk.keyword('green')(message)),
|
|
90
|
-
warn: (message) => spinner.warn(chalk.keyword('orangered')(message)),
|
|
91
|
-
info: (message) => spinner.info(chalk.keyword('blue')(message)),
|
|
92
|
-
done: (message) => spinner.succeed(message),
|
|
93
|
-
fail: (message) => spinner.fail(chalk.bold.red(message))
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
module.exports = { createSpinner, Spinner }
|