@dotenvx/dotenvx 2.29.0 → 2.31.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 +24 -1
- package/README.md +81 -749
- package/package.json +5 -5
- package/src/cli/actions/armor/down.js +1 -1
- package/src/cli/actions/armor/move.js +1 -1
- package/src/cli/actions/armor/open.js +1 -1
- package/src/cli/actions/armor/pull.js +1 -1
- package/src/cli/actions/armor/push.js +1 -1
- package/src/cli/actions/armor/up.js +1 -1
- package/src/cli/actions/{validate.js → check.js} +5 -5
- package/src/cli/actions/curl.js +2 -2
- package/src/cli/actions/decrypt.js +4 -10
- package/src/cli/actions/del.js +3 -5
- package/src/cli/actions/encrypt.js +4 -10
- package/src/cli/actions/ext/genexample.js +1 -1
- package/src/cli/actions/ext/prebuild.js +1 -1
- package/src/cli/actions/ext/scan.js +2 -3
- package/src/cli/actions/feedback.js +42 -0
- package/src/cli/actions/get.js +4 -7
- package/src/cli/actions/init.js +56 -2
- package/src/cli/actions/keychain/down.js +1 -1
- package/src/cli/actions/keychain/pull.js +1 -1
- package/src/cli/actions/keychain/push.js +1 -1
- package/src/cli/actions/keychain/up.js +1 -1
- package/src/cli/actions/keypair.js +3 -3
- package/src/cli/actions/lock/down.js +2 -3
- package/src/cli/actions/lock/up.js +2 -3
- package/src/cli/actions/login.js +2 -2
- package/src/cli/actions/logout.js +1 -1
- package/src/cli/actions/ls.js +1 -1
- package/src/cli/actions/protect.js +4 -1
- package/src/cli/actions/protectDocker.js +2 -2
- package/src/cli/actions/protectProcess.js +4 -1
- package/src/cli/actions/protectStdin.js +1 -0
- package/src/cli/actions/run.js +5 -6
- package/src/cli/actions/set.js +5 -9
- package/src/cli/actions/settings/device.js +2 -2
- package/src/cli/actions/settings/hostname.js +2 -2
- package/src/cli/actions/settings/off.js +1 -1
- package/src/cli/actions/settings/on.js +1 -1
- package/src/cli/actions/settings/path.js +2 -2
- package/src/cli/actions/settings/token.js +2 -2
- package/src/cli/actions/settings/username.js +2 -2
- package/src/cli/commandAction.js +16 -0
- package/src/cli/commands/armor.js +10 -9
- package/src/cli/commands/custody.js +6 -4
- package/src/cli/commands/ext.js +4 -3
- package/src/cli/commands/lock.js +3 -2
- package/src/cli/commands/native.js +5 -4
- package/src/cli/commands/primitives.js +46 -0
- package/src/cli/commands/settings.js +8 -7
- package/src/cli/dotenvx.js +45 -24
- package/src/lib/api/postFeedback.js +31 -0
- package/src/lib/envfile/discovery/discoverEnvFiles.js +29 -0
- package/src/lib/envfile/discovery/extractEnvKeys.js +173 -0
- package/src/lib/envfile/discovery/scanSource.js +79 -0
- package/src/lib/{helpers → envfile/parsing}/readEnvfile.js +3 -3
- package/src/lib/envfile/rendering/normalizeEnvfile.js +56 -0
- package/src/lib/envfile/rendering/renderEnvfile.js +26 -0
- package/src/lib/{helpers → envfile/validation}/validate.js +2 -2
- package/src/lib/{helpers → envfile/validation}/validateEnvfile.js +1 -1
- package/src/lib/events/backends/armor.js +31 -0
- package/src/lib/events/background.js +59 -0
- package/src/lib/events/catalog.js +14 -0
- package/src/lib/events/cli.js +40 -0
- package/src/lib/events/delivery.js +89 -0
- package/src/lib/events/index.js +73 -0
- package/src/lib/events/metadata.js +25 -0
- package/src/lib/events/sdk.js +44 -0
- package/src/lib/events/worker.js +29 -0
- package/src/lib/events/workerEnvironment.js +14 -0
- package/src/lib/helpers/checklist.js +9 -4
- package/src/lib/helpers/errors.js +1 -1
- package/src/lib/helpers/executeCommand.js +12 -1
- package/src/lib/helpers/hasPlaintextSecrets.js +2 -6
- package/src/lib/helpers/prompts.js +17 -0
- package/src/lib/main.d.ts +14 -0
- package/src/lib/main.js +15 -3
- package/src/lib/services/init.js +34 -12
- package/src/lib/services/validate.js +2 -2
- package/src/cli/actions/define.js +0 -17
- /package/src/lib/{grammars → envfile/parsing}/envfile.peggy +0 -0
- /package/src/lib/{helpers → envfile/parsing}/envfileParser.js +0 -0
- /package/src/lib/{helpers → envfile/parsing}/formatEnvfileSyntaxError.js +0 -0
- /package/src/lib/{helpers → envfile/validation}/encryptedSources.js +0 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.31.0",
|
|
3
3
|
"name": "@dotenvx/dotenvx",
|
|
4
4
|
"description": "a secure dotenv–from the creator of `dotenv`",
|
|
5
5
|
"author": "@motdotla",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"scripts": {
|
|
46
46
|
"standard": "standard",
|
|
47
47
|
"standard:fix": "standard --fix",
|
|
48
|
-
"test": "tap run --test-env=DOTENVX_NO_ARMOR=true --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
48
|
+
"test": "tap run --test-env=DOTENVX_NO_ARMOR=true --allow-empty-coverage --allow-incomplete-coverage --disable-coverage --timeout=60000",
|
|
49
49
|
"testshell": "shellspec --shell /bin/bash",
|
|
50
50
|
"release:check": "npm test && npm run testshell",
|
|
51
51
|
"prerelease": "npm run release:check",
|
|
52
52
|
"release": "npm run release:check && standard-version",
|
|
53
|
-
"build:envfile": "peggy --format commonjs -o src/lib/
|
|
53
|
+
"build:envfile": "peggy --format commonjs -o src/lib/envfile/parsing/envfileParser.js src/lib/envfile/parsing/envfile.peggy"
|
|
54
54
|
},
|
|
55
55
|
"funding": "https://dotenvx.com",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@dotenvx/primitives": "^3.0.
|
|
57
|
+
"@dotenvx/primitives": "^3.0.3",
|
|
58
58
|
"@dotenvx/tooling": "^1.0.3",
|
|
59
59
|
"global-agent": "^3.0.0",
|
|
60
60
|
"node-forge": "^1.4.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"standard": {
|
|
84
84
|
"ignore": [
|
|
85
|
-
"src/lib/
|
|
85
|
+
"src/lib/envfile/parsing/envfileParser.js"
|
|
86
86
|
]
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -7,10 +7,10 @@ const normalizeDotenvConfigQuiet = require('../../lib/helpers/normalizeDotenvCon
|
|
|
7
7
|
const normalizeDotenvConfigConvention = require('../../lib/helpers/normalizeDotenvConfigConvention')
|
|
8
8
|
const normalizeDotenvConfigIgnore = require('../../lib/helpers/normalizeDotenvConfigIgnore')
|
|
9
9
|
|
|
10
|
-
async function
|
|
10
|
+
async function check () {
|
|
11
11
|
const options = normalizeDotenvConfigIgnore(normalizeDotenvConfigConvention(normalizeDotenvConfigQuiet(this.opts())))
|
|
12
12
|
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
13
|
-
const spinner = await createSpinner({ ...spinnerOptions, ...options, text: '
|
|
13
|
+
const spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'checking' })
|
|
14
14
|
const ignore = options.ignore || []
|
|
15
15
|
let errorCount = 0
|
|
16
16
|
|
|
@@ -61,15 +61,15 @@ async function validate () {
|
|
|
61
61
|
if (spinner) spinner.stop()
|
|
62
62
|
|
|
63
63
|
if (errorCount > 0) {
|
|
64
|
-
|
|
64
|
+
return { exitCode: 1 }
|
|
65
65
|
} else {
|
|
66
66
|
logger.success(`▣ valid ${sourceSummary}`)
|
|
67
67
|
}
|
|
68
68
|
} catch (error) {
|
|
69
69
|
if (spinner) spinner.stop()
|
|
70
70
|
catchAndLog(error)
|
|
71
|
-
|
|
71
|
+
return { exitCode: 1, error }
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
module.exports =
|
|
75
|
+
module.exports = check
|
package/src/cli/actions/curl.js
CHANGED
|
@@ -58,10 +58,10 @@ async function curl () {
|
|
|
58
58
|
const text = await response.body.text()
|
|
59
59
|
console.log(outputBody(text))
|
|
60
60
|
|
|
61
|
-
if (response.statusCode >= 400)
|
|
61
|
+
if (response.statusCode >= 400) return { exitCode: 1 }
|
|
62
62
|
} catch (error) {
|
|
63
63
|
catchAndLog(error)
|
|
64
|
-
|
|
64
|
+
return { exitCode: 1, error }
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -59,11 +59,7 @@ async function decrypt () {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
process.exit(1)
|
|
64
|
-
} else {
|
|
65
|
-
process.exit(0) // exit early
|
|
66
|
-
}
|
|
62
|
+
return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
|
|
67
63
|
} else {
|
|
68
64
|
try {
|
|
69
65
|
const {
|
|
@@ -110,15 +106,13 @@ async function decrypt () {
|
|
|
110
106
|
// do nothing - scenario when no .env files found
|
|
111
107
|
}
|
|
112
108
|
|
|
113
|
-
|
|
114
|
-
process.exit(1)
|
|
115
|
-
}
|
|
109
|
+
return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
|
|
116
110
|
} catch (error) {
|
|
117
111
|
if (spinner) spinner.stop()
|
|
118
112
|
catchAndLog(error)
|
|
119
|
-
|
|
113
|
+
return { exitCode: 1, error }
|
|
120
114
|
}
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
117
|
|
|
124
|
-
module.exports = decrypt
|
|
118
|
+
module.exports = require('../../lib/events/cli')('decrypt', decrypt)
|
package/src/cli/actions/del.js
CHANGED
|
@@ -43,14 +43,12 @@ async function del (key) {
|
|
|
43
43
|
// do nothing - scenario when no .env files found
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
process.exit(1)
|
|
48
|
-
}
|
|
46
|
+
return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
|
|
49
47
|
} catch (error) {
|
|
50
48
|
if (spinner) spinner.stop()
|
|
51
49
|
catchAndLog(error)
|
|
52
|
-
|
|
50
|
+
return { exitCode: 1, error }
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
module.exports = del
|
|
54
|
+
module.exports = require('../../lib/events/cli')('del', del)
|
|
@@ -43,11 +43,7 @@ async function encryptAction () {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
process.exit(1)
|
|
48
|
-
} else {
|
|
49
|
-
process.exit(0) // exit early
|
|
50
|
-
}
|
|
46
|
+
return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
try {
|
|
@@ -84,14 +80,12 @@ async function encryptAction () {
|
|
|
84
80
|
// do nothing - scenario when no .env files found
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
process.exit(1)
|
|
89
|
-
}
|
|
83
|
+
return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
|
|
90
84
|
} catch (error) {
|
|
91
85
|
if (spinner) spinner.stop()
|
|
92
86
|
catchAndLog(error)
|
|
93
|
-
|
|
87
|
+
return { exitCode: 1, error }
|
|
94
88
|
}
|
|
95
89
|
}
|
|
96
90
|
|
|
97
|
-
module.exports = encryptAction
|
|
91
|
+
module.exports = require('../../lib/events/cli')('encrypt', encryptAction)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('../../../shared/logger')
|
|
2
|
-
const protectDocker = require('../protectDocker')
|
|
2
|
+
const protectDocker = require('../../../lib/events/cli')('protect', require('../protectDocker'))
|
|
3
3
|
|
|
4
4
|
module.exports = function prebuild (directory) {
|
|
5
5
|
logger.warn('[DEPRECATED] dotenvx prebuild. fix: run [dotenvx protect --docker]')
|
|
@@ -14,8 +14,7 @@ function scan () {
|
|
|
14
14
|
logger.error('gitleaks: command not found')
|
|
15
15
|
logger.help('fix: install gitleaks: [brew install gitleaks]')
|
|
16
16
|
logger.help('fix: other install options: [https://github.com/gitleaks/gitleaks]')
|
|
17
|
-
|
|
18
|
-
return
|
|
17
|
+
return { exitCode: 1, error }
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
let output = ''
|
|
@@ -27,7 +26,7 @@ function scan () {
|
|
|
27
26
|
logger.error(chomp(error.stdout.toString()))
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
return { exitCode: 1, error }
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { logger } = require('../../shared/logger')
|
|
2
|
+
const Session = require('../../db/session')
|
|
3
|
+
const PostFeedback = require('../../lib/api/postFeedback')
|
|
4
|
+
const prompts = require('../../lib/helpers/prompts')
|
|
5
|
+
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
6
|
+
|
|
7
|
+
async function feedback (body) {
|
|
8
|
+
let spinner
|
|
9
|
+
try {
|
|
10
|
+
if (body === undefined) {
|
|
11
|
+
if (!process.stdin.isTTY) {
|
|
12
|
+
throw new Error('provide a message: dotenvx feedback "Your feedback"')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
body = await prompts.input({
|
|
16
|
+
message: 'Send feedback'
|
|
17
|
+
}, { input: process.stdin, output: process.stderr })
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!body.trim()) {
|
|
21
|
+
throw new Error('feedback cannot be empty')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const options = this.opts()
|
|
25
|
+
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
26
|
+
const hostname = options.hostname || new Session().hostname()
|
|
27
|
+
spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'sending' })
|
|
28
|
+
await new PostFeedback(hostname, body).run()
|
|
29
|
+
if (spinner) spinner.stop()
|
|
30
|
+
logger.success('✔ Feedback sent, thanks!')
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (spinner) spinner.stop()
|
|
33
|
+
if (error.code === 'PROMPT_CANCELLED') {
|
|
34
|
+
return { exitCode: 130, error }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
logger.error(error.message || error)
|
|
38
|
+
return { exitCode: 1, error }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = feedback
|
package/src/cli/actions/get.js
CHANGED
|
@@ -118,18 +118,15 @@ async function get (key) {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
process.exit(1)
|
|
123
|
-
}
|
|
121
|
+
return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
|
|
124
122
|
} catch (error) {
|
|
125
123
|
if (spinner) spinner.stop()
|
|
126
124
|
if (error.code === 'PROMPT_CANCELLED') {
|
|
127
|
-
|
|
128
|
-
return
|
|
125
|
+
return { exitCode: 130, error }
|
|
129
126
|
}
|
|
130
127
|
catchAndLog(error)
|
|
131
|
-
|
|
128
|
+
return { exitCode: 1, error }
|
|
132
129
|
}
|
|
133
130
|
}
|
|
134
131
|
|
|
135
|
-
module.exports = get
|
|
132
|
+
module.exports = require('../../lib/events/cli')('get', get)
|
package/src/cli/actions/init.js
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const fs = require('node:fs')
|
|
2
|
+
const process = require('node:process')
|
|
3
|
+
const prompts = require('../../lib/helpers/prompts')
|
|
4
|
+
const initEnvfile = require('../../lib/services/init')
|
|
5
|
+
const scanSource = require('../../lib/envfile/discovery/scanSource')
|
|
6
|
+
const discoverEnvFiles = require('../../lib/envfile/discovery/discoverEnvFiles')
|
|
7
|
+
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
8
|
+
const { logger } = require('../../shared/logger')
|
|
9
|
+
const catchAndLog = require('../../lib/helpers/catchAndLog')
|
|
10
|
+
|
|
11
|
+
module.exports = async function init () {
|
|
12
|
+
const envFile = this.opts().envFile
|
|
13
|
+
const interactive = !process.env.CI && process.stdin.isTTY && process.stderr.isTTY
|
|
14
|
+
let spinner
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
if (fs.lstatSync('Envfile', { throwIfNoEntry: false })) {
|
|
18
|
+
logger.info('○ Envfile already exists (unchanged)')
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let envFiles
|
|
23
|
+
let sourceKeys = []
|
|
24
|
+
let scanCode = false
|
|
25
|
+
const onFile = filename => {
|
|
26
|
+
if (spinner) spinner.text = `scanning ${filename}`
|
|
27
|
+
}
|
|
28
|
+
if (interactive && !envFile) {
|
|
29
|
+
const candidates = discoverEnvFiles()
|
|
30
|
+
const selected = await prompts.multiselect({
|
|
31
|
+
message: 'Create Envfile from .env files and code',
|
|
32
|
+
submitLabel: 'Create Envfile',
|
|
33
|
+
choices: [...candidates, { name: 'code ./**/* (env references)', value: '__scan_source' }],
|
|
34
|
+
initial: [...candidates, '__scan_source']
|
|
35
|
+
})
|
|
36
|
+
envFiles = selected.filter(value => value !== '__scan_source')
|
|
37
|
+
scanCode = selected.includes('__scan_source')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const options = this.opts()
|
|
41
|
+
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
42
|
+
spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'scanning' })
|
|
43
|
+
if (scanCode) {
|
|
44
|
+
const { keys } = await scanSource({ onFile })
|
|
45
|
+
sourceKeys = keys
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { created } = initEnvfile({ envFile, envFiles, sourceKeys, onFile })
|
|
49
|
+
if (spinner) spinner.stop()
|
|
50
|
+
if (created) logger.success('◈ created (Envfile)')
|
|
51
|
+
else logger.info('○ Envfile already exists (unchanged)')
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (spinner) spinner.stop()
|
|
54
|
+
catchAndLog(error)
|
|
55
|
+
return { exitCode: 1, error }
|
|
56
|
+
}
|
|
3
57
|
}
|
|
@@ -65,7 +65,7 @@ async function keypair (key) {
|
|
|
65
65
|
} else {
|
|
66
66
|
if (results === undefined) {
|
|
67
67
|
console.log('')
|
|
68
|
-
|
|
68
|
+
return { exitCode: 1 }
|
|
69
69
|
} else if (options.format === 'colon' && key) {
|
|
70
70
|
console.log(`${key}:${results}`)
|
|
71
71
|
} else {
|
|
@@ -75,8 +75,8 @@ async function keypair (key) {
|
|
|
75
75
|
} catch (error) {
|
|
76
76
|
if (spinner) spinner.stop()
|
|
77
77
|
catchAndLog(error)
|
|
78
|
-
|
|
78
|
+
return { exitCode: 1, error }
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
module.exports = keypair
|
|
82
|
+
module.exports = require('../../lib/events/cli')('keypair', keypair)
|
|
@@ -42,12 +42,11 @@ async function down () {
|
|
|
42
42
|
}
|
|
43
43
|
} catch (error) {
|
|
44
44
|
if (error.code === 'PROMPT_CANCELLED') {
|
|
45
|
-
|
|
46
|
-
return
|
|
45
|
+
return { exitCode: 130, error }
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
logger.error(error.message)
|
|
50
|
-
|
|
49
|
+
return { exitCode: 1, error }
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -50,12 +50,11 @@ async function up () {
|
|
|
50
50
|
}
|
|
51
51
|
} catch (error) {
|
|
52
52
|
if (error.code === 'PROMPT_CANCELLED') {
|
|
53
|
-
|
|
54
|
-
return
|
|
53
|
+
return { exitCode: 130, error }
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
logger.error(error.message)
|
|
58
|
-
|
|
57
|
+
return { exitCode: 1, error }
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
|
package/src/cli/actions/login.js
CHANGED
|
@@ -45,7 +45,7 @@ async function login () {
|
|
|
45
45
|
cleanupOpenKeyListener()
|
|
46
46
|
if (spinner) spinner.stop()
|
|
47
47
|
logger.success(`◉ logged in (${data.username})`)
|
|
48
|
-
|
|
48
|
+
return { exitCode: 0 }
|
|
49
49
|
} catch (error) {
|
|
50
50
|
cleanupOpenKeyListener()
|
|
51
51
|
if (spinner) spinner.stop()
|
|
@@ -57,7 +57,7 @@ async function login () {
|
|
|
57
57
|
if (error.stack) {
|
|
58
58
|
logger.debug(error.stack)
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
return { exitCode: 1, error }
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
package/src/cli/actions/ls.js
CHANGED
|
@@ -6,7 +6,7 @@ const catchAndLog = require('../../lib/helpers/catchAndLog')
|
|
|
6
6
|
const settings = require('../../lib/helpers/protectSettings')
|
|
7
7
|
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
async function protect (directory) {
|
|
10
10
|
if (this.opts().docker) return require('./protectDocker').call(this, directory)
|
|
11
11
|
const filterOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : this.opts()
|
|
12
12
|
if (this.opts().gitProcess) return require('./protectProcess')(filterOptions)
|
|
@@ -68,5 +68,8 @@ module.exports = async function protect (directory) {
|
|
|
68
68
|
if (spinner) spinner.stop()
|
|
69
69
|
catchAndLog(error)
|
|
70
70
|
process.exitCode = 1
|
|
71
|
+
return { error }
|
|
71
72
|
}
|
|
72
73
|
}
|
|
74
|
+
|
|
75
|
+
module.exports = require('../../lib/events/cli')('protect', protect)
|
|
@@ -3,7 +3,7 @@ const { logger } = require('../../shared/logger')
|
|
|
3
3
|
const Prebuild = require('../../lib/services/prebuild')
|
|
4
4
|
const catchAndLog = require('../../lib/helpers/catchAndLog')
|
|
5
5
|
|
|
6
|
-
function protectDocker (directory) {
|
|
6
|
+
async function protectDocker (directory) {
|
|
7
7
|
// debug args
|
|
8
8
|
logger.debug(`directory: ${directory}`)
|
|
9
9
|
|
|
@@ -23,7 +23,7 @@ function protectDocker (directory) {
|
|
|
23
23
|
logger.success(successMessage)
|
|
24
24
|
} catch (error) {
|
|
25
25
|
catchAndLog(error)
|
|
26
|
-
|
|
26
|
+
return { exitCode: 1, error }
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -27,6 +27,7 @@ module.exports = async function protectProcess (options = {}) {
|
|
|
27
27
|
let spinner
|
|
28
28
|
let started = false
|
|
29
29
|
let failed = false
|
|
30
|
+
let errorCount = 0
|
|
30
31
|
let activeRequest = false
|
|
31
32
|
let reported = false
|
|
32
33
|
const checkedFiles = new Set()
|
|
@@ -78,7 +79,7 @@ module.exports = async function protectProcess (options = {}) {
|
|
|
78
79
|
await packet(null)
|
|
79
80
|
while (true) {
|
|
80
81
|
const headers = await list(true)
|
|
81
|
-
if (headers === null) return
|
|
82
|
+
if (headers === null) return { errorCount }
|
|
82
83
|
activeRequest = true
|
|
83
84
|
const fields = new Map(lines(headers).map(line => {
|
|
84
85
|
const index = line.indexOf('=')
|
|
@@ -94,6 +95,7 @@ module.exports = async function protectProcess (options = {}) {
|
|
|
94
95
|
// Checkout must remain a byte-for-byte passthrough, even for existing plaintext history.
|
|
95
96
|
if (command === 'clean' && !check(fields.get('pathname'), content, stop)) {
|
|
96
97
|
failed = true
|
|
98
|
+
errorCount++
|
|
97
99
|
await packet('status=error\n')
|
|
98
100
|
await packet(null)
|
|
99
101
|
activeRequest = false
|
|
@@ -116,6 +118,7 @@ module.exports = async function protectProcess (options = {}) {
|
|
|
116
118
|
logger.error('Git protection filter protocol failed')
|
|
117
119
|
process.exitCode = 1
|
|
118
120
|
process.stdin.destroy()
|
|
121
|
+
return { error: { code: 'GIT_FILTER_PROTOCOL_FAILED' } }
|
|
119
122
|
} finally {
|
|
120
123
|
finish()
|
|
121
124
|
process.removeListener('exit', onExit)
|
package/src/cli/actions/run.js
CHANGED
|
@@ -95,7 +95,7 @@ async function run () {
|
|
|
95
95
|
logger.error(`ambiguous command due to missing '--' separator. try [dotenvx run -f ${realExample} -- yourcommand]`)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
return { exitCode: 1 }
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
try {
|
|
@@ -214,18 +214,17 @@ async function run () {
|
|
|
214
214
|
if (closeProxy) await closeProxy()
|
|
215
215
|
if (spinner) spinner.stop()
|
|
216
216
|
if (error.code === 'PROMPT_CANCELLED') {
|
|
217
|
-
|
|
218
|
-
return
|
|
217
|
+
return { exitCode: 130, error }
|
|
219
218
|
}
|
|
220
219
|
catchAndLog(error)
|
|
221
|
-
|
|
220
|
+
return { exitCode: 1, error }
|
|
222
221
|
}
|
|
223
222
|
|
|
224
223
|
try {
|
|
225
|
-
await executeCommand(commandArgs, commandEnv, sensitiveValues, closeProxy)
|
|
224
|
+
return await executeCommand(commandArgs, commandEnv, sensitiveValues, closeProxy)
|
|
226
225
|
} finally {
|
|
227
226
|
if (closeProxy) await closeProxy()
|
|
228
227
|
}
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
module.exports = run
|
|
230
|
+
module.exports = require('../../lib/events/cli')('run', run)
|