@dotenc/cli 0.3.0 → 0.3.2

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.
Files changed (2) hide show
  1. package/README.md +120 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # ![dotenc](./assets/logo.png "dotenc logo")
2
+ 🔐 Secure, encrypted environment variables that live in your codebase
3
+
4
+ ## Features
5
+
6
+ - 🔒 Uses the battle-tested AES-256-GCM encryption algorithm
7
+ - 🔑 Keys can be exported anytime - no vendor lock-in
8
+ - 🚀 Secure command running with on-the-fly decryption
9
+ - ✍️ Easy and secure environment variable editing
10
+ - 🌍 Supports multiple and extensible environments
11
+ - 🔄 Offers a simplified key rotation process
12
+
13
+ ## How It Works
14
+
15
+ 1. Environment variables are encrypted using a secure key
16
+ 2. Encrypted files (`.env.*.enc`) are committed to your repository
17
+ 3. Keys are stored securely and not committed to the repository
18
+ 4. The local, git-ignored `.env` file can be used for development
19
+ 5. When running commands, variables are decrypted on-the-fly
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install -g @dotenc/cli
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Initialize a New Environment
30
+
31
+ ```bash
32
+ dotenc init [environment]
33
+ ```
34
+
35
+ This will:
36
+ 1. Create a new encrypted environment file (`.env.[environment].enc`)
37
+ 2. Set up a local `.env` file for development
38
+ 3. Create a `dotenc.json` configuration file
39
+
40
+ ### Edit an Environment
41
+
42
+ ```bash
43
+ dotenc edit [environment]
44
+ ```
45
+
46
+ Opens your system's default editor to modify the specified environment. To set a custom editor, use the `dotenc config editor` command. It will take precedence over your system's default editor.
47
+
48
+ Example:
49
+ ```bash
50
+ dotenc config editor vim
51
+ ```
52
+
53
+ ### Run Commands on an Environment
54
+
55
+ ```bash
56
+ dotenc run --env <environment> <command> [...args]
57
+ # or
58
+ dotenc run -e <environment> <command> [...args]
59
+ ```
60
+
61
+ Example:
62
+ ```bash
63
+ dotenc run -e production node app.js
64
+ ```
65
+
66
+ You can also specify multiple environments:
67
+ ```bash
68
+ dotenc run -e base,production node app.js
69
+ ```
70
+
71
+ In the example above, `production` will override any variables also present in `global`.
72
+
73
+ ### Key management
74
+
75
+ To import a key into your machine, use the `key import` command:
76
+ ```bash
77
+ dotenc key import <environment> <key>
78
+ ```
79
+
80
+ To export a key from your machine, use the `key export` command:
81
+ ```bash
82
+ dotenc key export <environment>
83
+ ```
84
+
85
+ ## Use Cases
86
+
87
+ For convenience, you can setup your `package.json` file like this:
88
+ ```json
89
+ // ...
90
+ "scripts": {
91
+ "dev": "dotenc run -e development tsx src/app.ts",
92
+ "start": "dotenc run -e production node dist/app.js",
93
+ "test": "dotenc run -e test vitest"
94
+ }
95
+ ```
96
+
97
+ Alternatively, the `DOTENC_ENV` variable can be used to set the environment, so the `-e` option can be omitted. For example:
98
+
99
+ ```bash
100
+ export DOTENC_ENV="production"
101
+ dotenc run node app.js
102
+ ```
103
+
104
+ Also, if a key is not present in your machine, you can use the `DOTENC_KEY` variable to decrypt an environment:
105
+
106
+ ```bash
107
+ DOTENC_KEY=<prod_key> dotenc run -e production node app.js
108
+ ```
109
+
110
+ This can be useful for CI and automated platforms like Netlify and Vercel. Just export your keys and set the `DOTENC_KEY` variable in each environment.
111
+
112
+ The `DOTENC_KEY` variable also works with multiple environments:
113
+
114
+ ```bash
115
+ DOTENC_KEY=<base_key>,<prod_key> dotenc run -e base,production node app.js
116
+ ```
117
+
118
+ ## License
119
+
120
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotenc/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "🔐 Secure, encrypted environment variables that live in your codebase",
5
5
  "author": "Ivan Filho <i@ivanfilho.com>",
6
6
  "license": "MIT",