vaultsy-cli 0.1.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.
Files changed (3) hide show
  1. package/README.md +338 -0
  2. package/dist/index.js +1351 -0
  3. package/package.json +53 -0
package/README.md ADDED
@@ -0,0 +1,338 @@
1
+ # vaultsy-cli
2
+
3
+ Official CLI for [Vaultsy](https://vaultsy.app) — pull, push, and inject secrets from your terminal without secrets ever living outside your encrypted store.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install -g vaultsy-cli
11
+ # or
12
+ bun add -g vaultsy-cli
13
+ ```
14
+
15
+ ---
16
+
17
+ ## Quick Start
18
+
19
+ ```sh
20
+ # 1. Authenticate
21
+ vaultsy login
22
+
23
+ # 2. Pin a project to the current directory (optional but recommended)
24
+ vaultsy init
25
+
26
+ # 3. Pull secrets to a local .env file
27
+ vaultsy pull
28
+
29
+ # 4. Push local changes back up
30
+ vaultsy push
31
+
32
+ # 5. Run a command with secrets injected — nothing ever touches disk
33
+ vaultsy run -- node server.js
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Authentication
39
+
40
+ Vaultsy uses API tokens. Tokens are created in the web dashboard under **Settings → API Tokens**.
41
+
42
+ ```sh
43
+ vaultsy login
44
+ ```
45
+
46
+ You will be prompted for:
47
+ - Your Vaultsy base URL (default: `https://vaultsy.app`)
48
+ - Your API token (paste it from the dashboard)
49
+
50
+ The token is verified against the server and saved to `~/.vaultsy/config.json` with `600` permissions (owner read/write only).
51
+
52
+ ### Options
53
+
54
+ | Flag | Description |
55
+ |---|---|
56
+ | `-t, --token <token>` | Provide the token directly (skips the interactive prompt) |
57
+ | `-u, --base-url <url>` | Base URL of your Vaultsy instance |
58
+
59
+ ### Non-interactive / CI usage
60
+
61
+ ```sh
62
+ vaultsy login --token "$VAULTSY_TOKEN" --base-url https://vaultsy.app
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Commands
68
+
69
+ ### `vaultsy login`
70
+
71
+ Authenticate and save credentials to `~/.vaultsy/config.json`.
72
+
73
+ ```sh
74
+ vaultsy login
75
+ vaultsy login --token <token> --base-url https://vaultsy.app
76
+ ```
77
+
78
+ ---
79
+
80
+ ### `vaultsy logout`
81
+
82
+ Remove locally stored credentials.
83
+
84
+ ```sh
85
+ vaultsy logout
86
+ ```
87
+
88
+ ---
89
+
90
+ ### `vaultsy whoami`
91
+
92
+ Show the currently authenticated user.
93
+
94
+ ```sh
95
+ vaultsy whoami
96
+ # → Logged in as John Doe <john@example.com>
97
+ ```
98
+
99
+ ---
100
+
101
+ ### `vaultsy init`
102
+
103
+ Create a `vaultsy.json` in the current directory. This pins a project ID and a default environment so you can run `vaultsy pull` / `vaultsy push` with no arguments.
104
+
105
+ ```sh
106
+ vaultsy init
107
+ ```
108
+
109
+ Creates `vaultsy.json`:
110
+
111
+ ```json
112
+ {
113
+ "project": "abc123",
114
+ "defaultEnv": "development"
115
+ }
116
+ ```
117
+
118
+ Commit this file — it contains only a project ID, never any secret values.
119
+
120
+ ---
121
+
122
+ ### `vaultsy pull [project] [env]`
123
+
124
+ Pull all secrets for an environment and write them to a local `.env` file.
125
+
126
+ ```sh
127
+ # Interactive — picks project and env from a list
128
+ vaultsy pull
129
+
130
+ # With vaultsy.json in the current directory
131
+ vaultsy pull
132
+
133
+ # Explicit
134
+ vaultsy pull <project-id> production
135
+
136
+ # Write to a custom file
137
+ vaultsy pull <project-id> production --output .env.local
138
+ ```
139
+
140
+ **Default output file:**
141
+ - `development` → `.env`
142
+ - `staging` → `.env.staging`
143
+ - `preview` → `.env.preview`
144
+ - `production` → `.env.production`
145
+
146
+ The CLI warns you if the output file is not in `.gitignore`.
147
+
148
+ #### Options
149
+
150
+ | Flag | Description |
151
+ |---|---|
152
+ | `-o, --output <file>` | Override the output file path |
153
+ | `-y, --yes` | Skip the gitignore warning prompt |
154
+
155
+ ---
156
+
157
+ ### `vaultsy push [project] [env]`
158
+
159
+ Read a local `.env` file and push its contents to Vaultsy. Shows a diff before applying.
160
+
161
+ ```sh
162
+ # Interactive
163
+ vaultsy push
164
+
165
+ # Explicit
166
+ vaultsy push <project-id> production
167
+
168
+ # Push from a custom file
169
+ vaultsy push <project-id> production --input .env.local
170
+
171
+ # Skip the confirmation prompt
172
+ vaultsy push <project-id> production --yes
173
+ ```
174
+
175
+ The push is a **full replace** — keys present in Vaultsy but absent from your local file will be deleted. Always review the diff before confirming.
176
+
177
+ Output example:
178
+
179
+ ```
180
+ + NEW_KEY
181
+ ~ MODIFIED_KEY
182
+ - REMOVED_KEY
183
+ · UNCHANGED_KEY
184
+
185
+ +1 to add, ~1 to modify, -1 to remove, 1 unchanged
186
+ ```
187
+
188
+ A new version snapshot is created automatically on every successful push, so you can always roll back.
189
+
190
+ #### Options
191
+
192
+ | Flag | Description |
193
+ |---|---|
194
+ | `-i, --input <file>` | Override the input file path |
195
+ | `-y, --yes` | Skip the diff confirmation prompt |
196
+
197
+ ---
198
+
199
+ ### `vaultsy history [project] [env]`
200
+
201
+ List version snapshots for an environment, newest first.
202
+
203
+ ```sh
204
+ vaultsy history
205
+ vaultsy history <project-id> production
206
+ ```
207
+
208
+ Output example:
209
+
210
+ ```
211
+ # │ VERSION ID │ KEYS │ CREATED BY │ DATE
212
+ ─────────┼──────────────────────────────┼─────────┼──────────────────────┼──────────────────────
213
+ v4 │ abc-123... │ 12 │ John Doe │ 01 Jul 2025, 14:32 ← latest
214
+ v3 │ def-456... │ 11 │ John Doe │ 30 Jun 2025, 09:15
215
+ v2 │ ghi-789... │ 11 │ Jane Smith │ 28 Jun 2025, 17:44
216
+ v1 │ jkl-012... │ 8 │ John Doe │ 25 Jun 2025, 11:03
217
+ ```
218
+
219
+ Copy a version ID to use with `vaultsy rollback`.
220
+
221
+ ---
222
+
223
+ ### `vaultsy rollback [project] [env] [versionId]`
224
+
225
+ Roll an environment back to a previous version snapshot. A new snapshot is created automatically after the rollback, so you can always undo it.
226
+
227
+ ```sh
228
+ # Interactive — pick project, env, and version from lists
229
+ vaultsy rollback
230
+
231
+ # Explicit
232
+ vaultsy rollback <project-id> production <version-id>
233
+
234
+ # Skip the confirmation prompt
235
+ vaultsy rollback <project-id> production <version-id> --yes
236
+ ```
237
+
238
+ #### Options
239
+
240
+ | Flag | Description |
241
+ |---|---|
242
+ | `-y, --yes` | Skip the confirmation prompt |
243
+
244
+ ---
245
+
246
+ ### `vaultsy run [project] [env] -- <command>`
247
+
248
+ Pull secrets, inject them into the subprocess environment, and run the command. **Secrets never touch disk.**
249
+
250
+ ```sh
251
+ vaultsy run <project-id> production -- node server.js
252
+ vaultsy run <project-id> production -- npm run start
253
+ vaultsy run <project-id> staging -- python manage.py runserver
254
+
255
+ # With vaultsy.json in the current directory
256
+ vaultsy run -- node server.js
257
+ ```
258
+
259
+ **Precedence:** variables already set in your shell take priority over secrets from Vaultsy. This lets you override a single variable locally without editing the remote store:
260
+
261
+ ```sh
262
+ PORT=4000 vaultsy run -- node server.js # PORT=4000 wins; all other secrets come from Vaultsy
263
+ ```
264
+
265
+ The child process shares `stdin`, `stdout`, and `stderr` with the CLI. Signals (`SIGINT`, `SIGTERM`, `SIGHUP`) are forwarded to the child, so `Ctrl+C` works as expected.
266
+
267
+ ---
268
+
269
+ ## Project Config (`vaultsy.json`)
270
+
271
+ Placing a `vaultsy.json` in your project root lets you run all commands without specifying a project ID or environment every time.
272
+
273
+ ```json
274
+ {
275
+ "project": "<project-id>",
276
+ "defaultEnv": "development"
277
+ }
278
+ ```
279
+
280
+ | Field | Required | Description |
281
+ |---|---|---|
282
+ | `project` | Yes | The project ID from your Vaultsy dashboard |
283
+ | `defaultEnv` | No | Default environment used when no `[env]` argument is given |
284
+
285
+ The CLI walks up the directory tree to find `vaultsy.json`, the same way `git` finds `.git`. You can commit this file safely — it contains no secrets.
286
+
287
+ ---
288
+
289
+ ## CI/CD Usage
290
+
291
+ ### GitHub Actions
292
+
293
+ ```yaml
294
+ - name: Pull secrets
295
+ env:
296
+ VAULTSY_TOKEN: ${{ secrets.VAULTSY_TOKEN }}
297
+ run: |
298
+ npx vaultsy-cli login --token "$VAULTSY_TOKEN" --base-url https://vaultsy.app
299
+ npx vaultsy-cli pull my-project production --output .env --yes
300
+ ```
301
+
302
+ ### Inject secrets directly into a step
303
+
304
+ ```yaml
305
+ - name: Start server with secrets injected
306
+ env:
307
+ VAULTSY_TOKEN: ${{ secrets.VAULTSY_TOKEN }}
308
+ run: |
309
+ npx vaultsy-cli login --token "$VAULTSY_TOKEN"
310
+ npx vaultsy-cli run my-project production -- node server.js
311
+ ```
312
+
313
+ ---
314
+
315
+ ## Security
316
+
317
+ - The API token is stored in `~/.vaultsy/config.json` with `0600` permissions — never readable by other users.
318
+ - Secret **values** are never printed to stdout unless the web dashboard is used directly.
319
+ - The `run` command uses `shell: false` when spawning the child process to prevent secrets from appearing in `ps` output.
320
+ - The `pull` command warns if the output `.env` file is not in `.gitignore`.
321
+ - HTTPS is enforced by default. Use `--base-url http://...` only for local development.
322
+
323
+ ---
324
+
325
+ ## Environments
326
+
327
+ | Name | Description |
328
+ |---|---|
329
+ | `development` | Local development (default, maps to `.env`) |
330
+ | `staging` | Staging / QA environment |
331
+ | `preview` | Preview / PR deployments |
332
+ | `production` | Production environment |
333
+
334
+ ---
335
+
336
+ ## License
337
+
338
+ MIT