@dotenvx/dotenvx 0.6.5 โ†’ 0.6.6

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 CHANGED
@@ -21,7 +21,8 @@ brew install dotenvx/brew/dotenvx
21
21
  ## Run Anywhere
22
22
 
23
23
  ```sh
24
- $ echo "HELLO=World" > .env && echo "console.log('Hello ' + process.env.HELLO)" > index.js
24
+ $ echo "HELLO=World" > .env
25
+ $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
25
26
 
26
27
  $ node index.js
27
28
  Hello undefined
@@ -36,7 +37,8 @@ More examples
36
37
  * <details><summary>Python ๐Ÿ</summary><br>
37
38
 
38
39
  ```sh
39
- $ echo "HELLO=World" > .env && echo 'import os;print("Hello " + os.getenv("HELLO", ""))' > index.py
40
+ $ echo "HELLO=World" > .env
41
+ $ echo 'import os;print("Hello " + os.getenv("HELLO", ""))' > index.py
40
42
 
41
43
  $ dotenvx run -- python3 index.py
42
44
  Hello World
@@ -46,7 +48,8 @@ More examples
46
48
  * <details><summary>PHP ๐Ÿ˜</summary><br>
47
49
 
48
50
  ```sh
49
- $ echo "HELLO=World" > .env && echo '<?php echo "Hello {$_SERVER["HELLO"]}\n";' > index.php
51
+ $ echo "HELLO=World" > .env
52
+ $ echo '<?php echo "Hello {$_SERVER["HELLO"]}\n";' > index.php
50
53
 
51
54
  $ dotenvx run -- php index.php
52
55
  Hello World
@@ -56,7 +59,8 @@ More examples
56
59
  * <details><summary>Ruby ๐Ÿ’Ž</summary><br>
57
60
 
58
61
  ```sh
59
- $ echo "HELLO=World" > .env && echo 'puts "Hello #{ENV["HELLO"]}"' > index.rb
62
+ $ echo "HELLO=World" > .env
63
+ $ echo 'puts "Hello #{ENV["HELLO"]}"' > index.rb
60
64
 
61
65
  $ dotenvx run -- ruby index.rb
62
66
  Hello World
@@ -66,7 +70,8 @@ More examples
66
70
  * <details><summary>Go ๐Ÿน</summary><br>
67
71
 
68
72
  ```sh
69
- $ echo "HELLO=World" > .env && echo 'package main; import ("fmt"; "os"); func main() { fmt.Printf("Hello %s\n", os.Getenv("HELLO")) }' > main.go
73
+ $ echo "HELLO=World" > .env
74
+ $ echo 'package main; import ("fmt"; "os"); func main() { fmt.Printf("Hello %s\n", os.Getenv("HELLO")) }' > main.go
70
75
 
71
76
  $ dotenvx run -- go run main.go
72
77
  Hello World
@@ -76,7 +81,8 @@ More examples
76
81
  * <details><summary>Rust ๐Ÿฆ€</summary><br>
77
82
 
78
83
  ```sh
79
- $ echo "HELLO=World" > .env && echo 'fn main() {let hello = std::env::var("HELLO").unwrap_or("".to_string());println!("Hello {hello}");}' > src/main.rs
84
+ $ echo "HELLO=World" > .env
85
+ $ echo 'fn main() {let hello = std::env::var("HELLO").unwrap_or("".to_string());println!("Hello {hello}");}' > src/main.rs
80
86
 
81
87
  $ dotenvx run -- cargo run
82
88
  Hello World
@@ -86,7 +92,8 @@ More examples
86
92
  * <details><summary>Java โ˜•๏ธ</summary><br>
87
93
 
88
94
  ```sh
89
- $ echo "HELLO=World" > .env && echo 'public class Index { public static void main(String[] args) { System.out.println("Hello " + System.getenv("HELLO")); } }' > index.java
95
+ $ echo "HELLO=World" > .env
96
+ $ echo 'public class Index { public static void main(String[] args) { System.out.println("Hello " + System.getenv("HELLO")); } }' > index.java
90
97
 
91
98
  $ dotenvx run -- java index.java
92
99
  Hello World
@@ -98,7 +105,8 @@ More examples
98
105
  ```sh
99
106
  $ dotnet new console -n HelloWorld -o HelloWorld
100
107
  $ cd HelloWorld
101
- $ echo "HELLO=World" > .env && echo 'Console.WriteLine($"Hello {Environment.GetEnvironmentVariable("HELLO")}");' > Program.cs && echo "HELLO=World" > .env
108
+ $ echo "HELLO=World" > .env
109
+ $ echo 'Console.WriteLine($"Hello {Environment.GetEnvironmentVariable("HELLO")}");' > Program.cs
102
110
 
103
111
  $ dotenvx run -- dotnet run
104
112
  Hello World
@@ -276,22 +284,16 @@ More examples
276
284
 
277
285
  ## Encryption
278
286
 
279
- > Encrypt your secrets to a `.env.vault` file.
280
- ```
281
- $ echo "HELLO=World" > .env && echo "console.log('Hello ' + process.env.HELLO)" > index.js
282
-
287
+ > Encrypt your secrets to a `.env.vault` file and load from it (recommended for production and ci).
288
+ ```sh
289
+ $ echo "HELLO=World" > .env
283
290
  $ echo "HELLO=production" > .env.production
291
+ $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
284
292
 
285
293
  $ dotenvx encrypt
286
294
  [dotenvx][info] encrypted to .env.vault (.env,.env.production)
287
- [dotenvx][info] key added to .env.keys (DOTENV_KEY_PRODUCTION)
288
- ```
295
+ [dotenvx][info] keys added to .env.keys (DOTENV_KEY_PRODUCTION,DOTENV_KEY_PRODUCTION)
289
296
 
290
- &nbsp;
291
-
292
- > Then load env from encrypted `.env.vault` file
293
-
294
- ```sh
295
297
  $ DOTENV_KEY='<dotenv_key_production>' dotenvx run -- node index.js
296
298
  [dotenvx][info] loading env (1) from encrypted .env.vault
297
299
  Hello production
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.6.5",
2
+ "version": "0.6.6",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenvโ€“from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -9,6 +9,7 @@ const ENCODING = 'utf8'
9
9
 
10
10
  const logger = require('./../shared/logger')
11
11
  const helpers = require('./helpers')
12
+ const examples = require('./examples')
12
13
  const { AppendToIgnores } = require('./ignores')
13
14
  const packageJson = require('./../shared/packageJson')
14
15
  const main = require('./../lib/main')
@@ -53,7 +54,8 @@ program
53
54
 
54
55
  // dotenvx run -- node index.js
55
56
  program.command('run')
56
- .description('load env into your application process')
57
+ .description('inject env at runtime (example: `dotenvx run -- your-cmd`)')
58
+ .addHelpText('after', examples.run)
57
59
  .option('-f, --env-file <paths...>', 'path(s) to your env file(s)', '.env')
58
60
  .option('-o, --overload', 'override existing env variables')
59
61
  .action(function () {
@@ -169,6 +171,7 @@ program.command('run')
169
171
  // dotenvx encrypt
170
172
  program.command('encrypt')
171
173
  .description('encrypt .env.* to .env.vault')
174
+ .addHelpText('after', examples.encrypt)
172
175
  .option('-f, --env-file <paths...>', 'path(s) to your env file(s)', helpers.findEnvFiles('./'))
173
176
  .action(function () {
174
177
  const options = this.opts()
@@ -0,0 +1,51 @@
1
+ const run = function () {
2
+ return `
3
+ Example:
4
+
5
+ \`\`\`sh
6
+ $ dotenvx run -- your-cmd
7
+ \`\`\`
8
+
9
+ Try it:
10
+
11
+ \`\`\`sh
12
+ $ echo "HELLO=World" > .env
13
+ $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
14
+
15
+ $ dotenvx run -- node index.js
16
+ [dotenvx][info] loading env (1) from .env
17
+ Hello World
18
+ \`\`\`
19
+ `
20
+ }
21
+
22
+ const encrypt = function () {
23
+ return `
24
+ Example:
25
+
26
+ \`\`\`sh
27
+ $ dotenvx encrypt
28
+ \`\`\`
29
+
30
+ Try it:
31
+
32
+ \`\`\`sh
33
+ $ echo "HELLO=World" > .env
34
+ $ echo "HELLO=production" > .env.production
35
+ $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
36
+
37
+ $ dotenvx encrypt
38
+ [dotenvx][info] encrypted to .env.vault (.env,.env.production)
39
+ [dotenvx][info] keys added to .env.keys (DOTENV_KEY_PRODUCTION,DOTENV_KEY_PRODUCTION)
40
+
41
+ $ DOTENV_KEY='<dotenv_key_production>' dotenvx run -- node index.js
42
+ [dotenvx][info] loading env (1) from encrypted .env.vault
43
+ Hello production
44
+ \`\`\`
45
+ `
46
+ }
47
+
48
+ module.exports = {
49
+ run,
50
+ encrypt
51
+ }