@dotenvx/dotenvx 0.8.3 → 0.9.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/README.md +11 -1
- package/package.json +1 -1
- package/src/cli/actions/hub/login.js +1 -1
- package/src/cli/actions/hub/push.js +1 -1
- package/src/cli/actions/run.js +18 -4
- package/src/cli/dotenvx.js +1 -1
- package/src/cli/helpers.js +15 -15
- package/src/cli/ignores.js +1 -1
- package/src/shared/axios.js +7 -0
- package/src/shared/logger.js +3 -0
package/README.md
CHANGED
|
@@ -347,10 +347,20 @@ More examples
|
|
|
347
347
|
|
|
348
348
|
* <details><summary>Heroku</summary><br>
|
|
349
349
|
|
|
350
|
+
> Add the buildpack, installing the `dotenvx` binary to your heroku deployment.
|
|
351
|
+
|
|
350
352
|
```sh
|
|
351
|
-
|
|
353
|
+
heroku buildpacks:add https://github.com/dotenvx/heroku-buildpack-dotenvx
|
|
352
354
|
```
|
|
353
355
|
|
|
356
|
+
> Use it in your Procfile.
|
|
357
|
+
|
|
358
|
+
```sh
|
|
359
|
+
web: dotenvx run -- node index.js
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
<sub><a href="https://github.com/dotenvx/heroku-buildpack-dotenvx">buildpack docs</a></sub>
|
|
363
|
+
|
|
354
364
|
</details>
|
|
355
365
|
|
|
356
366
|
* <details><summary>Laravel Forge</summary><br>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const { execSync } = require('child_process')
|
|
3
|
-
const axios = require('
|
|
3
|
+
const axios = require('./../../../shared/axios')
|
|
4
4
|
|
|
5
5
|
const store = require('./../../../shared/store')
|
|
6
6
|
const logger = require('./../../../shared/logger')
|
package/src/cli/actions/run.js
CHANGED
|
@@ -6,6 +6,9 @@ const main = require('./../../lib/main')
|
|
|
6
6
|
const ENCODING = 'utf8'
|
|
7
7
|
|
|
8
8
|
async function run () {
|
|
9
|
+
const commandArgs = this.args
|
|
10
|
+
logger.debug(`process command [${commandArgs.join(' ')}]`)
|
|
11
|
+
|
|
9
12
|
const options = this.opts()
|
|
10
13
|
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
11
14
|
|
|
@@ -81,7 +84,19 @@ async function run () {
|
|
|
81
84
|
readableFilepaths.add(envFilepath)
|
|
82
85
|
result.injected.forEach(key => injected.add(key))
|
|
83
86
|
} catch (e) {
|
|
84
|
-
|
|
87
|
+
switch (e.code) {
|
|
88
|
+
// missing .env
|
|
89
|
+
case 'ENOENT':
|
|
90
|
+
logger.warnv(`missing .env file (${filepath})`)
|
|
91
|
+
logger.help(`? in development: add one with [echo "HELLO=World" > .env] and re-run [dotenvx run -- ${commandArgs.join(' ')}]`)
|
|
92
|
+
logger.help('? for production: set [DOTENV_KEY] on your server and re-deploy')
|
|
93
|
+
break
|
|
94
|
+
|
|
95
|
+
// unhandled error
|
|
96
|
+
default:
|
|
97
|
+
logger.warn(e)
|
|
98
|
+
break
|
|
99
|
+
}
|
|
85
100
|
}
|
|
86
101
|
}
|
|
87
102
|
|
|
@@ -99,9 +114,8 @@ async function run () {
|
|
|
99
114
|
logger.error(' or try: [dotenvx run -- npm run dev]')
|
|
100
115
|
process.exit(1)
|
|
101
116
|
} else {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
await helpers.executeCommand(subCommand, process.env)
|
|
117
|
+
// const commandArgs = process.argv.slice(commandIndex + 1)
|
|
118
|
+
await helpers.executeCommand(commandArgs, process.env)
|
|
105
119
|
}
|
|
106
120
|
}
|
|
107
121
|
|
package/src/cli/dotenvx.js
CHANGED
|
@@ -56,7 +56,7 @@ program
|
|
|
56
56
|
|
|
57
57
|
// dotenvx run -- node index.js
|
|
58
58
|
program.command('run')
|
|
59
|
-
.description('inject env at runtime [dotenvx run --
|
|
59
|
+
.description('inject env at runtime [dotenvx run -- yourcommand]')
|
|
60
60
|
.addHelpText('after', examples.run)
|
|
61
61
|
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)', '.env')
|
|
62
62
|
.option('-o, --overload', 'override existing env variables')
|
package/src/cli/helpers.js
CHANGED
|
@@ -23,26 +23,26 @@ const resolvePath = function (filepath) {
|
|
|
23
23
|
return path.resolve(process.cwd(), filepath)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const executeCommand = async function (
|
|
26
|
+
const executeCommand = async function (commandArgs, env) {
|
|
27
27
|
const signals = [
|
|
28
28
|
'SIGHUP', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT',
|
|
29
29
|
'SIGBUS', 'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGTERM'
|
|
30
30
|
]
|
|
31
31
|
|
|
32
|
-
logger.debug(`executing
|
|
32
|
+
logger.debug(`executing process command [${commandArgs.join(' ')}]`)
|
|
33
33
|
|
|
34
34
|
// handler for SIGINT
|
|
35
|
-
let
|
|
35
|
+
let commandProcess
|
|
36
36
|
const sigintHandler = () => {
|
|
37
37
|
logger.debug('received SIGINT')
|
|
38
|
-
logger.debug('checking
|
|
39
|
-
logger.debug(
|
|
38
|
+
logger.debug('checking command process')
|
|
39
|
+
logger.debug(commandProcess)
|
|
40
40
|
|
|
41
|
-
if (
|
|
42
|
-
logger.debug('sending SIGINT to
|
|
43
|
-
|
|
41
|
+
if (commandProcess) {
|
|
42
|
+
logger.debug('sending SIGINT to command process')
|
|
43
|
+
commandProcess.kill('SIGINT') // Send SIGINT to the command process
|
|
44
44
|
} else {
|
|
45
|
-
logger.debug('no
|
|
45
|
+
logger.debug('no command process to send SIGINT to')
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -51,7 +51,7 @@ const executeCommand = async function (subCommand, env) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
try {
|
|
54
|
-
|
|
54
|
+
commandProcess = execa(commandArgs[0], commandArgs.slice(1), {
|
|
55
55
|
stdio: 'inherit',
|
|
56
56
|
env: { ...process.env, ...env }
|
|
57
57
|
})
|
|
@@ -62,8 +62,8 @@ const executeCommand = async function (subCommand, env) {
|
|
|
62
62
|
process.on(signal, () => handleOtherSignal(signal))
|
|
63
63
|
})
|
|
64
64
|
|
|
65
|
-
// Wait for the
|
|
66
|
-
const { exitCode } = await
|
|
65
|
+
// Wait for the command process to finish
|
|
66
|
+
const { exitCode } = await commandProcess
|
|
67
67
|
|
|
68
68
|
if (exitCode !== 0) {
|
|
69
69
|
logger.debug(`received exitCode ${exitCode}`)
|
|
@@ -72,15 +72,15 @@ const executeCommand = async function (subCommand, env) {
|
|
|
72
72
|
} catch (error) {
|
|
73
73
|
if (error.signal !== 'SIGINT') {
|
|
74
74
|
logger.error(error.message)
|
|
75
|
-
logger.error(`command [${
|
|
75
|
+
logger.error(`command [${commandArgs.join(' ')}] failed`)
|
|
76
76
|
logger.error('')
|
|
77
|
-
logger.error(` try without dotenvx: [${
|
|
77
|
+
logger.error(` try without dotenvx: [${commandArgs.join(' ')}]`)
|
|
78
78
|
logger.error('')
|
|
79
79
|
logger.error('if that succeeds, then dotenvx is the culprit. report issue:')
|
|
80
80
|
logger.error(`<${REPORT_ISSUE_LINK}>`)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
// Exit with the error code from the
|
|
83
|
+
// Exit with the error code from the command process, or 1 if unavailable
|
|
84
84
|
process.exit(error.exitCode || 1)
|
|
85
85
|
} finally {
|
|
86
86
|
// Clean up: Remove the SIGINT handler
|
package/src/cli/ignores.js
CHANGED
package/src/shared/logger.js
CHANGED
|
@@ -11,6 +11,7 @@ const packageJson = require('./packageJson')
|
|
|
11
11
|
const levels = {
|
|
12
12
|
error: 0,
|
|
13
13
|
warn: 1,
|
|
14
|
+
warnv: 1,
|
|
14
15
|
success: 2,
|
|
15
16
|
successv: 2,
|
|
16
17
|
info: 2,
|
|
@@ -41,6 +42,8 @@ const dotenvxFormat = printf(({ level, message, label, timestamp }) => {
|
|
|
41
42
|
return error(formattedMessage)
|
|
42
43
|
case 'warn':
|
|
43
44
|
return warn(formattedMessage)
|
|
45
|
+
case 'warnv':
|
|
46
|
+
return warn(`[dotenvx@${packageJson.version}] ${formattedMessage}`)
|
|
44
47
|
case 'success':
|
|
45
48
|
return success(formattedMessage)
|
|
46
49
|
case 'successv': // success with 'version'
|