herdux-cli 0.3.0 → 0.4.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 +126 -35
- package/README.pt-BR.md +94 -33
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +3 -5
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +3 -5
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +11 -5
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +3 -5
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +2 -4
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/drop.d.ts.map +1 -1
- package/dist/commands/drop.js +3 -5
- package/dist/commands/drop.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +3 -5
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/restore.d.ts.map +1 -1
- package/dist/commands/restore.js +9 -6
- package/dist/commands/restore.js.map +1 -1
- package/dist/commands/version.js +3 -3
- package/dist/commands/version.js.map +1 -1
- package/dist/core/interfaces/database-engine.interface.d.ts +9 -1
- package/dist/core/interfaces/database-engine.interface.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/infra/command-runner.d.ts +2 -0
- package/dist/infra/command-runner.d.ts.map +1 -1
- package/dist/infra/command-runner.js +1 -0
- package/dist/infra/command-runner.js.map +1 -1
- package/dist/infra/config/config.service.d.ts +8 -5
- package/dist/infra/config/config.service.d.ts.map +1 -1
- package/dist/infra/config/config.service.js.map +1 -1
- package/dist/infra/engines/engine-factory.d.ts +3 -0
- package/dist/infra/engines/engine-factory.d.ts.map +1 -0
- package/dist/infra/engines/engine-factory.js +12 -0
- package/dist/infra/engines/engine-factory.js.map +1 -0
- package/dist/infra/engines/mysql/mysql-env.d.ts +11 -0
- package/dist/infra/engines/mysql/mysql-env.d.ts.map +1 -0
- package/dist/infra/engines/mysql/mysql-env.js +30 -0
- package/dist/infra/engines/mysql/mysql-env.js.map +1 -0
- package/dist/infra/engines/mysql/mysql.engine.d.ts +21 -0
- package/dist/infra/engines/mysql/mysql.engine.d.ts.map +1 -0
- package/dist/infra/engines/mysql/mysql.engine.js +311 -0
- package/dist/infra/engines/mysql/mysql.engine.js.map +1 -0
- package/dist/infra/engines/postgres/postgres.engine.d.ts +5 -1
- package/dist/infra/engines/postgres/postgres.engine.d.ts.map +1 -1
- package/dist/infra/engines/postgres/postgres.engine.js +8 -6
- package/dist/infra/engines/postgres/postgres.engine.js.map +1 -1
- package/dist/infra/engines/resolve-connection.d.ts +26 -0
- package/dist/infra/engines/resolve-connection.d.ts.map +1 -0
- package/dist/infra/engines/resolve-connection.js +156 -0
- package/dist/infra/engines/resolve-connection.js.map +1 -0
- package/package.json +14 -4
package/README.md
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
🇺🇸 English | 🇧🇷 [Português](./README.pt-BR.md)
|
|
2
2
|
|
|
3
|
-
# Herdux — Database Workflow CLI
|
|
4
|
-
|
|
5
3
|
<p align="center">
|
|
6
4
|
<strong>Infrastructure-grade power. Developer-grade experience.</strong>
|
|
7
5
|
</p>
|
|
8
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src=".github/assets/logo.svg" alt="Herdux banner" style="max-width: 100%; width: 600px;" />
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
## ⏭️ Herdux — Database Workflow CLI
|
|
12
|
+
|
|
9
13
|
A fast, interactive CLI that removes friction from daily local database workflows, especially when juggling multiple instances and large datasets.
|
|
10
14
|
|
|
11
|
-

|
|
12
16
|

|
|
13
17
|

|
|
18
|
+

|
|
19
|
+

|
|
14
20
|
[](https://github.com/sponsors/eduardozaniboni)
|
|
15
21
|
[](https://www.buymeacoffee.com/eduardozaniboni)
|
|
16
22
|
|
|
@@ -36,6 +42,55 @@ That's it. You're managing databases.
|
|
|
36
42
|
|
|
37
43
|
---
|
|
38
44
|
|
|
45
|
+
## 🔌 Supported Engines
|
|
46
|
+
|
|
47
|
+
| Engine | Status | Client Tools Required |
|
|
48
|
+
| ---------- | ------ | ------------------------------- |
|
|
49
|
+
| PostgreSQL | ✅ | `psql`, `pg_dump`, `pg_restore` |
|
|
50
|
+
| MySQL | ✅ | `mysql`, `mysqldump` |
|
|
51
|
+
|
|
52
|
+
Herdux resolves the engine explicitly using a strict priority order (CLI flags → profiles → saved defaults → fallback).
|
|
53
|
+
|
|
54
|
+
Internally, no command ever runs without a fully resolved engine.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# PostgreSQL (default)
|
|
58
|
+
herdux list
|
|
59
|
+
herdux create mydb
|
|
60
|
+
|
|
61
|
+
# MySQL
|
|
62
|
+
herdux --engine mysql list
|
|
63
|
+
herdux --engine mysql create mydb
|
|
64
|
+
|
|
65
|
+
# Or save it in a profile and forget about it
|
|
66
|
+
herdux config add mysql-local --port 3306 --user root --password secret --engine mysql
|
|
67
|
+
herdux list -s mysql-local
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 🧠 How Herdux Thinks
|
|
73
|
+
|
|
74
|
+
Herdux is designed around **strict separation of concerns**:
|
|
75
|
+
|
|
76
|
+
- **Commands decide _what_ to do**
|
|
77
|
+
- **Engines decide _how_ to do it**
|
|
78
|
+
- **Binaries are never called directly by commands**
|
|
79
|
+
- **All external behavior is isolated behind engine contracts**
|
|
80
|
+
|
|
81
|
+
This architecture guarantees:
|
|
82
|
+
|
|
83
|
+
- predictable behavior
|
|
84
|
+
- engine-agnostic commands
|
|
85
|
+
- safer destructive operations
|
|
86
|
+
- easier extension to new databases
|
|
87
|
+
|
|
88
|
+
If something feels “magical”, it’s probably wrong.
|
|
89
|
+
|
|
90
|
+
Any change that breaks these boundaries is considered a bug.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
39
94
|
## Why Herdux?
|
|
40
95
|
|
|
41
96
|
Managing local databases through raw bash scripts or binaries is repetitive, error-prone, and painful at scale.
|
|
@@ -43,17 +98,14 @@ Managing local databases through raw bash scripts or binaries is repetitive, err
|
|
|
43
98
|
### ❌ Without Herdux
|
|
44
99
|
|
|
45
100
|
```bash
|
|
46
|
-
#
|
|
47
|
-
pg_dump -U postgres -h localhost -p 5416 -Fc -f ./backups/
|
|
101
|
+
# PostgreSQL backup
|
|
102
|
+
pg_dump -U postgres -h localhost -p 5416 -Fc -f ./backups/mydb.dump mydb
|
|
48
103
|
|
|
49
|
-
#
|
|
50
|
-
|
|
104
|
+
# MySQL backup
|
|
105
|
+
mysqldump -u root -h localhost -P 3306 -p mydb > ./backups/mydb.sql
|
|
51
106
|
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
# Check if tools are installed
|
|
56
|
-
psql --version && pg_dump --version && pg_restore --version
|
|
107
|
+
# Manually drop, restore, check tools...
|
|
108
|
+
# Different flags, different tools, different muscle memory for each engine.
|
|
57
109
|
```
|
|
58
110
|
|
|
59
111
|
### ✅ With Herdux
|
|
@@ -65,7 +117,7 @@ herdux clean # Multi-select and batch-drop databases
|
|
|
65
117
|
herdux doctor # Full system health check
|
|
66
118
|
```
|
|
67
119
|
|
|
68
|
-
Fewer flags. Fewer mistakes. Zero terminal fatigue.
|
|
120
|
+
Same commands. Any engine. Fewer flags. Fewer mistakes. Zero terminal fatigue.
|
|
69
121
|
|
|
70
122
|
---
|
|
71
123
|
|
|
@@ -82,6 +134,7 @@ It is specifically designed for developers who:
|
|
|
82
134
|
- Need safe backup & restore workflows that don't rely on fragile bash scripts.
|
|
83
135
|
- Prefer terminal-first tooling.
|
|
84
136
|
- Want predictable connection resolution without hidden magic.
|
|
137
|
+
- Work with **multiple database engines** (PostgreSQL, MySQL) and want a unified interface.
|
|
85
138
|
|
|
86
139
|
If you manage databases locally, Herdux was created to solve your pain.
|
|
87
140
|
|
|
@@ -89,12 +142,13 @@ If you manage databases locally, Herdux was created to solve your pain.
|
|
|
89
142
|
|
|
90
143
|
## 🚀 Key Features
|
|
91
144
|
|
|
145
|
+
- **🔌 Multi-Engine Support** — First-class support for PostgreSQL and MySQL. Same commands, same workflow, any engine.
|
|
92
146
|
- **📋 Smart Listing** — Optimized listing strategy for massive clusters. Optional `--size` flag for disk usage analysis, sorted largest-first.
|
|
93
147
|
- **💾 Intelligent Backup & Restore** — Supports Custom (`.dump`) and Plain (`.sql`) formats. Auto-detects the right tool for restores.
|
|
94
148
|
- **🧹 Bulk Cleanup** — Multi-select databases, optionally backup, and batch-drop them. Reclaim disk space instantly.
|
|
95
149
|
- **🩺 System Diagnostics** — One-command health check verifying binaries, authentication, and connectivity.
|
|
96
|
-
- **⚙️ Persistent Profiles** — Save named server configurations. Switch between environments with `-s pg16`.
|
|
97
|
-
- **🎯 Smart Connection Resolution** — Explicit CLI flags → profiles → saved defaults → auto-discovery. Always predictable.
|
|
150
|
+
- **⚙️ Persistent Profiles** — Save named server configurations with engine type. Switch between environments with `-s pg16`.
|
|
151
|
+
- **🎯 Smart Connection & Engine Resolution** — Explicit CLI flags → profiles → saved defaults → auto-discovery. Always predictable.
|
|
98
152
|
|
|
99
153
|
---
|
|
100
154
|
|
|
@@ -105,7 +159,7 @@ If you manage databases locally, Herdux was created to solve your pain.
|
|
|
105
159
|
**Herdux** follows three principles:
|
|
106
160
|
|
|
107
161
|
- **Safety first** — Never drops data without explicit confirmation or a verified backup.
|
|
108
|
-
- **Explicit over implicit** — Connection resolution follows a strict, documented priority. No magic.
|
|
162
|
+
- **Explicit over implicit** — Connection and engine resolution follows a strict, documented priority. No magic.
|
|
109
163
|
- **Developer workflow optimization** — Every command is designed to save you from repetitive terminal work.
|
|
110
164
|
|
|
111
165
|
---
|
|
@@ -116,7 +170,7 @@ If you manage databases locally, Herdux was created to solve your pain.
|
|
|
116
170
|
|
|
117
171
|
- **Never drops a database** unless explicit confirmation is given
|
|
118
172
|
- **Aborts the entire operation** if a safety backup fails during `herdux clean`
|
|
119
|
-
- **Validates
|
|
173
|
+
- **Validates backup tool exit codes** before considering a backup successful
|
|
120
174
|
- **Requires `--drop` flag** intentionally — dropping is never the default
|
|
121
175
|
- **`--yes` must be combined with `--drop`** — cannot skip confirmation alone
|
|
122
176
|
|
|
@@ -127,10 +181,11 @@ If you manage databases locally, Herdux was created to solve your pain.
|
|
|
127
181
|
## 🧩 Requirements
|
|
128
182
|
|
|
129
183
|
- **Node.js** 18 or higher
|
|
130
|
-
- **PostgreSQL
|
|
184
|
+
- **For PostgreSQL:** `psql`, `pg_dump`, `pg_restore` installed and available in your `PATH`
|
|
185
|
+
- **For MySQL:** `mysql`, `mysqldump` installed and available in your `PATH`
|
|
131
186
|
|
|
132
187
|
> [!TIP]
|
|
133
|
-
> Run `herdux doctor` after installation to verify everything is set up correctly.
|
|
188
|
+
> Run `herdux doctor` after installation to verify everything is set up correctly. The doctor command checks the tools for the active engine.
|
|
134
189
|
|
|
135
190
|
---
|
|
136
191
|
|
|
@@ -158,24 +213,28 @@ npm link
|
|
|
158
213
|
|
|
159
214
|
## 🛠️ Commands
|
|
160
215
|
|
|
216
|
+
All commands work with both PostgreSQL and MySQL. Use `--engine mysql` or configure engine in your server profile.
|
|
217
|
+
|
|
161
218
|
### `herdux version`
|
|
162
219
|
|
|
163
|
-
Shows the CLI version and the connected
|
|
220
|
+
Shows the CLI version and the connected database server version.
|
|
164
221
|
|
|
165
222
|
```bash
|
|
166
223
|
herdux version
|
|
224
|
+
herdux --engine mysql version
|
|
167
225
|
```
|
|
168
226
|
|
|
169
227
|
### `herdux doctor`
|
|
170
228
|
|
|
171
229
|
Runs a full system health check:
|
|
172
230
|
|
|
173
|
-
- Verifies
|
|
231
|
+
- Verifies the required client tools are installed and reachable (engine-specific)
|
|
174
232
|
- Attempts a live connection using the resolved configuration
|
|
175
233
|
- Tests authentication against the target server
|
|
176
234
|
|
|
177
235
|
```bash
|
|
178
236
|
herdux doctor
|
|
237
|
+
herdux --engine mysql doctor
|
|
179
238
|
```
|
|
180
239
|
|
|
181
240
|
---
|
|
@@ -190,7 +249,7 @@ herdux ls --size # Includes disk size, sorted largest → smallest
|
|
|
190
249
|
```
|
|
191
250
|
|
|
192
251
|
> [!NOTE]
|
|
193
|
-
> The `--size` flag calculates physical disk usage
|
|
252
|
+
> The `--size` flag calculates physical disk usage. On servers with dozens of multi-GB databases, this may take a few minutes depending on disk speed.
|
|
194
253
|
|
|
195
254
|
---
|
|
196
255
|
|
|
@@ -200,6 +259,7 @@ Creates a new database.
|
|
|
200
259
|
|
|
201
260
|
```bash
|
|
202
261
|
herdux create my_new_db
|
|
262
|
+
herdux --engine mysql create my_new_db
|
|
203
263
|
```
|
|
204
264
|
|
|
205
265
|
### `herdux drop <name>`
|
|
@@ -236,7 +296,7 @@ This is designed for the real-world dev workflow: clone databases, experiment, t
|
|
|
236
296
|
Generates a timestamped backup in `./backups/`.
|
|
237
297
|
|
|
238
298
|
```bash
|
|
239
|
-
herdux backup mydb # Custom format (.dump)
|
|
299
|
+
herdux backup mydb # Custom format (.dump for PG, .sql for MySQL)
|
|
240
300
|
herdux backup mydb --format plain # Plain SQL (.sql)
|
|
241
301
|
herdux backup mydb --drop # Backup, then ask to drop
|
|
242
302
|
herdux backup mydb --drop --yes # Backup + drop, no questions
|
|
@@ -256,8 +316,8 @@ herdux backup mydb -o ./my-backups # Custom output directory
|
|
|
256
316
|
|
|
257
317
|
Restores a database from a backup file. Automatically detects the format:
|
|
258
318
|
|
|
259
|
-
- `.sql` → uses
|
|
260
|
-
- `.dump` or any other extension → uses
|
|
319
|
+
- `.sql` → uses the appropriate SQL import tool
|
|
320
|
+
- `.dump` or any other extension → uses the appropriate restore tool
|
|
261
321
|
|
|
262
322
|
```bash
|
|
263
323
|
herdux restore ./backups/mydb_2026-02-23.dump --db mydb
|
|
@@ -271,6 +331,9 @@ herdux restore archive.bkp --db mydb --format custom
|
|
|
271
331
|
herdux restore script.txt --db mydb --format plain
|
|
272
332
|
```
|
|
273
333
|
|
|
334
|
+
> [!NOTE]
|
|
335
|
+
> When restoring dumps from managed environments (e.g., AWS RDS), Herdux automatically configures the underlying engine to ignore ownership and role assignments. This prevents errors caused by production roles that do not exist locally. If the restore engine completes with non-fatal warnings (such as missing roles), Herdux will inform you and proceed normally rather than failing.
|
|
336
|
+
|
|
274
337
|
---
|
|
275
338
|
|
|
276
339
|
## ⚙️ Configuration & Server Profiles
|
|
@@ -280,6 +343,7 @@ herdux restore script.txt --db mydb --format plain
|
|
|
280
343
|
### Set Global Defaults
|
|
281
344
|
|
|
282
345
|
```bash
|
|
346
|
+
herdux config set engine postgres # Default engine
|
|
283
347
|
herdux config set user postgres
|
|
284
348
|
herdux config set password my_secret
|
|
285
349
|
herdux config set port 5432
|
|
@@ -290,8 +354,14 @@ herdux config set port 5432
|
|
|
290
354
|
Manage multiple database instances effortlessly:
|
|
291
355
|
|
|
292
356
|
```bash
|
|
357
|
+
# PostgreSQL profiles
|
|
293
358
|
herdux config add pg16 --port 5416
|
|
294
359
|
herdux config add pg17 --port 5417 --user admin
|
|
360
|
+
|
|
361
|
+
# MySQL profiles (engine is saved in the profile)
|
|
362
|
+
herdux config add mysql-dev --port 3306 --user root --password secret --engine mysql
|
|
363
|
+
|
|
364
|
+
# Remote servers
|
|
295
365
|
herdux config add staging --host 192.168.0.10 --port 5432
|
|
296
366
|
```
|
|
297
367
|
|
|
@@ -299,9 +369,11 @@ Then connect using the `-s` flag:
|
|
|
299
369
|
|
|
300
370
|
```bash
|
|
301
371
|
herdux list -s pg16
|
|
302
|
-
herdux backup mydb -s
|
|
372
|
+
herdux backup mydb -s mysql-dev
|
|
303
373
|
```
|
|
304
374
|
|
|
375
|
+
Or just run a command without flags — if you have saved profiles, Herdux will show an interactive selection menu displaying the engine for each profile.
|
|
376
|
+
|
|
305
377
|
### View & Manage Config
|
|
306
378
|
|
|
307
379
|
```bash
|
|
@@ -313,9 +385,20 @@ herdux config reset # Clear all configuration
|
|
|
313
385
|
|
|
314
386
|
---
|
|
315
387
|
|
|
316
|
-
## 🔌 Connection
|
|
388
|
+
## 🔌 Connection & Engine Resolution
|
|
317
389
|
|
|
318
|
-
When resolving how to connect, **Herdux** follows a strict, predictable priority order:
|
|
390
|
+
When resolving how to connect and which engine to use, **Herdux** follows a strict, predictable priority order:
|
|
391
|
+
|
|
392
|
+
### Engine Priority
|
|
393
|
+
|
|
394
|
+
| Priority | Source | Example |
|
|
395
|
+
| -------- | ------------------ | -------------------------------- |
|
|
396
|
+
| 1️⃣ | **CLI flag** | `herdux --engine mysql list` |
|
|
397
|
+
| 2️⃣ | **Server profile** | Profile's `engine` field |
|
|
398
|
+
| 3️⃣ | **Saved default** | `herdux config set engine mysql` |
|
|
399
|
+
| 4️⃣ | **Fallback** | `postgres` |
|
|
400
|
+
|
|
401
|
+
### Connection Priority
|
|
319
402
|
|
|
320
403
|
| Priority | Source | Example |
|
|
321
404
|
| -------- | ------------------ | --------------------------------------------- |
|
|
@@ -328,10 +411,10 @@ This means explicit input always wins. No surprises.
|
|
|
328
411
|
|
|
329
412
|
---
|
|
330
413
|
|
|
331
|
-
## 🤔 Why not pgAdmin?
|
|
414
|
+
## 🤔 Why not pgAdmin / phpMyAdmin?
|
|
332
415
|
|
|
333
416
|
**Herdux** is not a GUI replacement.
|
|
334
|
-
It
|
|
417
|
+
It's a workflow accelerator for developers who live in the terminal.
|
|
335
418
|
|
|
336
419
|
No GUI. No overhead. Just speed.
|
|
337
420
|
|
|
@@ -341,14 +424,17 @@ No GUI. No overhead. Just speed.
|
|
|
341
424
|
|
|
342
425
|
- No hidden defaults.
|
|
343
426
|
- No destructive magic.
|
|
344
|
-
- Deterministic connection resolution.
|
|
427
|
+
- Deterministic connection and engine resolution.
|
|
345
428
|
- Explicit and composable commands.
|
|
429
|
+
- Engine-agnostic: same interface, any database.
|
|
346
430
|
|
|
347
431
|
---
|
|
348
432
|
|
|
349
|
-
## 🐳 Docker Support
|
|
433
|
+
## 🐳 Docker Support
|
|
350
434
|
|
|
351
|
-
|
|
435
|
+
> Docker MUST NOT be required for normal CLI usage.
|
|
436
|
+
> Docker is currently used internally for end-to-end testing to validate real database workflows.
|
|
437
|
+
> Runtime Docker integration (detecting and managing live containers) is planned.
|
|
352
438
|
|
|
353
439
|
---
|
|
354
440
|
|
|
@@ -370,10 +456,15 @@ npm run dev
|
|
|
370
456
|
|
|
371
457
|
# Run the unit test suite
|
|
372
458
|
npm run test:unit
|
|
373
|
-
# Run the test
|
|
374
|
-
npm run test:e2e
|
|
459
|
+
# Run the E2E test suites (requires Docker)
|
|
460
|
+
npm run test:e2e:pgsql
|
|
461
|
+
npm run test:e2e:mysql
|
|
375
462
|
```
|
|
376
463
|
|
|
464
|
+
> Herdux follows strict architectural boundaries.
|
|
465
|
+
> Commands are engine-agnostic, engines encapsulate all database-specific behavior, and all binaries are isolated behind adapters.
|
|
466
|
+
> Please keep these boundaries intact when contributing.
|
|
467
|
+
|
|
377
468
|
---
|
|
378
469
|
|
|
379
470
|
## ☕ Support the Project
|
package/README.pt-BR.md
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
🇧🇷 Português | 🇺🇸 [English](./README.md)
|
|
2
2
|
|
|
3
|
-
# Herdux — Database Workflow CLI
|
|
4
|
-
|
|
5
3
|
<p align="center">
|
|
6
4
|
<strong>Infrastructure-grade power. Developer-grade experience.</strong>
|
|
7
5
|
</p>
|
|
8
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src=".github/assets/logo.svg" alt="Herdux banner" style="max-width: 100%; width: 600px;" />
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
## ⏭️ Herdux — Database Workflow CLI
|
|
12
|
+
|
|
9
13
|
Uma CLI rápida e interativa que remove a fricção dos workflows diários com bancos de dados locais, especialmente ao lidar com múltiplas instâncias e grandes datasets.
|
|
10
14
|
|
|
11
|
-

|
|
12
16
|

|
|
13
17
|

|
|
18
|
+

|
|
19
|
+

|
|
14
20
|
[](https://github.com/sponsors/eduardozaniboni)
|
|
15
21
|
[](https://www.buymeacoffee.com/eduardozaniboni)
|
|
16
22
|
|
|
@@ -36,6 +42,31 @@ herdux list
|
|
|
36
42
|
|
|
37
43
|
---
|
|
38
44
|
|
|
45
|
+
## 🔌 Engines Suportadas
|
|
46
|
+
|
|
47
|
+
| Engine | Status | Ferramentas Cliente Necessárias |
|
|
48
|
+
| ---------- | ------ | ------------------------------- |
|
|
49
|
+
| PostgreSQL | ✅ | `psql`, `pg_dump`, `pg_restore` |
|
|
50
|
+
| MySQL | ✅ | `mysql`, `mysqldump` |
|
|
51
|
+
|
|
52
|
+
O Herdux detecta automaticamente a engine a partir do seu perfil de servidor ou da flag `--engine`. PostgreSQL é o padrão quando nenhuma engine é especificada.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# PostgreSQL (padrão)
|
|
56
|
+
herdux list
|
|
57
|
+
herdux create mydb
|
|
58
|
+
|
|
59
|
+
# MySQL
|
|
60
|
+
herdux --engine mysql list
|
|
61
|
+
herdux --engine mysql create mydb
|
|
62
|
+
|
|
63
|
+
# Ou salve no perfil e esqueça
|
|
64
|
+
herdux config add mysql-local --port 3306 --user root --password secret --engine mysql
|
|
65
|
+
herdux list -s mysql-local
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
39
70
|
## Por que Herdux?
|
|
40
71
|
|
|
41
72
|
Gerenciar bancos de dados locais através de scripts bash ou binários crus é repetitivo, propenso a erros e doloroso em escala.
|
|
@@ -43,17 +74,14 @@ Gerenciar bancos de dados locais através de scripts bash ou binários crus é r
|
|
|
43
74
|
### ❌ Sem Herdux
|
|
44
75
|
|
|
45
76
|
```bash
|
|
46
|
-
#
|
|
47
|
-
pg_dump -U postgres -h localhost -p 5416 -Fc -f ./backups/
|
|
48
|
-
|
|
49
|
-
# Depois dropar manualmente
|
|
50
|
-
psql -U postgres -h localhost -p 5416 -c "DROP DATABASE mydb;"
|
|
77
|
+
# Backup PostgreSQL
|
|
78
|
+
pg_dump -U postgres -h localhost -p 5416 -Fc -f ./backups/mydb.dump mydb
|
|
51
79
|
|
|
52
|
-
#
|
|
53
|
-
|
|
80
|
+
# Backup MySQL
|
|
81
|
+
mysqldump -u root -h localhost -P 3306 -p mydb > ./backups/mydb.sql
|
|
54
82
|
|
|
55
|
-
#
|
|
56
|
-
|
|
83
|
+
# Dropar manualmente, restaurar, verificar ferramentas...
|
|
84
|
+
# Flags diferentes, ferramentas diferentes, memória muscular diferente para cada engine.
|
|
57
85
|
```
|
|
58
86
|
|
|
59
87
|
### ✅ Com Herdux
|
|
@@ -65,7 +93,7 @@ herdux clean # Multi-seleção e batch-drop de bancos
|
|
|
65
93
|
herdux doctor # Verificação completa do sistema
|
|
66
94
|
```
|
|
67
95
|
|
|
68
|
-
Menos flags. Menos erros. Zero fadiga de terminal.
|
|
96
|
+
Mesmos comandos. Qualquer engine. Menos flags. Menos erros. Zero fadiga de terminal.
|
|
69
97
|
|
|
70
98
|
---
|
|
71
99
|
|
|
@@ -82,6 +110,7 @@ Ele é especificamente projetado para desenvolvedores que:
|
|
|
82
110
|
- Precisam de fluxos seguros de backup & restore que não dependam de scripts bash frágeis.
|
|
83
111
|
- Preferem ferramentas focadas no terminal (terminal-first).
|
|
84
112
|
- Querem resolução previsível de conexões sem mágicas ocultas.
|
|
113
|
+
- Trabalham com **múltiplas engines de banco de dados** (PostgreSQL, MySQL) e querem uma interface unificada.
|
|
85
114
|
|
|
86
115
|
Se você gerencia bancos de dados localmente e compartilha dessa dor, o Herdux foi criado para você.
|
|
87
116
|
|
|
@@ -89,12 +118,13 @@ Se você gerencia bancos de dados localmente e compartilha dessa dor, o Herdux f
|
|
|
89
118
|
|
|
90
119
|
## 🚀 Funcionalidades Principais
|
|
91
120
|
|
|
121
|
+
- **🔌 Suporte Multi-Engine** — Suporte de primeira classe para PostgreSQL e MySQL. Mesmos comandos, mesmo workflow, qualquer engine.
|
|
92
122
|
- **📋 Listagem Inteligente** — Estratégia otimizada para clusters massivos. Flag opcional `--size` para análise de uso de disco, ordenado do maior para o menor.
|
|
93
123
|
- **💾 Backup & Restore Inteligente** — Suporta formatos Custom (`.dump`) e Plain (`.sql`). Detecta automaticamente a ferramenta correta para restauração.
|
|
94
124
|
- **🧹 Limpeza em Massa** — Multi-seleção de bancos, backup opcional e batch-drop. Recupere espaço em disco instantaneamente.
|
|
95
125
|
- **🩺 Diagnóstico do Sistema** — Verificação completa de saúde com um único comando: binários, autenticação e conectividade.
|
|
96
|
-
- **⚙️ Perfis Persistentes** — Salve configurações de servidor nomeadas. Alterne entre ambientes com `-s pg16`.
|
|
97
|
-
- **🎯 Resolução Inteligente de Conexão** — Flags CLI explícitas → perfis → padrões salvos → auto-descoberta. Sempre previsível.
|
|
126
|
+
- **⚙️ Perfis Persistentes** — Salve configurações de servidor nomeadas com tipo de engine. Alterne entre ambientes com `-s pg16`.
|
|
127
|
+
- **🎯 Resolução Inteligente de Conexão e Engine** — Flags CLI explícitas → perfis → padrões salvos → auto-descoberta. Sempre previsível.
|
|
98
128
|
|
|
99
129
|
---
|
|
100
130
|
|
|
@@ -105,7 +135,7 @@ Se você gerencia bancos de dados localmente e compartilha dessa dor, o Herdux f
|
|
|
105
135
|
O **Herdux** segue três princípios:
|
|
106
136
|
|
|
107
137
|
- **Segurança primeiro** — Nunca apaga dados sem confirmação explícita ou um backup verificado.
|
|
108
|
-
- **Explícito sobre implícito** — A resolução de conexão segue uma prioridade estrita e documentada. Sem mágica.
|
|
138
|
+
- **Explícito sobre implícito** — A resolução de conexão e engine segue uma prioridade estrita e documentada. Sem mágica.
|
|
109
139
|
- **Otimização de workflow** — Cada comando é projetado para te salvar de tarefas repetitivas no terminal.
|
|
110
140
|
|
|
111
141
|
---
|
|
@@ -116,7 +146,7 @@ O **Herdux** trata operações destrutivas com cuidado:
|
|
|
116
146
|
|
|
117
147
|
- **Nunca dropa um banco** sem confirmação explícita
|
|
118
148
|
- **Aborta toda a operação** se um backup de segurança falhar durante o `herdux clean`
|
|
119
|
-
- **Valida códigos de saída
|
|
149
|
+
- **Valida códigos de saída das ferramentas de backup** antes de considerar um backup bem-sucedido
|
|
120
150
|
- **Requer a flag `--drop`** intencionalmente — dropar nunca é o padrão
|
|
121
151
|
- **`--yes` deve ser combinado com `--drop`** — não é possível pular confirmação sozinho
|
|
122
152
|
|
|
@@ -127,10 +157,11 @@ O **Herdux** trata operações destrutivas com cuidado:
|
|
|
127
157
|
## 🧩 Requisitos
|
|
128
158
|
|
|
129
159
|
- **Node.js** 18 ou superior
|
|
130
|
-
- **
|
|
160
|
+
- **Para PostgreSQL:** `psql`, `pg_dump`, `pg_restore` instalados e disponíveis no `PATH`
|
|
161
|
+
- **Para MySQL:** `mysql`, `mysqldump` instalados e disponíveis no `PATH`
|
|
131
162
|
|
|
132
163
|
> [!TIP]
|
|
133
|
-
> Execute `herdux doctor` após a instalação para verificar se tudo está configurado corretamente.
|
|
164
|
+
> Execute `herdux doctor` após a instalação para verificar se tudo está configurado corretamente. O comando doctor verifica as ferramentas da engine ativa.
|
|
134
165
|
|
|
135
166
|
---
|
|
136
167
|
|
|
@@ -158,24 +189,28 @@ npm link
|
|
|
158
189
|
|
|
159
190
|
## 🛠️ Comandos
|
|
160
191
|
|
|
192
|
+
Todos os comandos funcionam tanto com PostgreSQL quanto com MySQL. Use `--engine mysql` ou configure a engine no seu perfil de servidor.
|
|
193
|
+
|
|
161
194
|
### `herdux version`
|
|
162
195
|
|
|
163
|
-
Mostra a versão da CLI e a versão do servidor
|
|
196
|
+
Mostra a versão da CLI e a versão do servidor de banco de dados conectado.
|
|
164
197
|
|
|
165
198
|
```bash
|
|
166
199
|
herdux version
|
|
200
|
+
herdux --engine mysql version
|
|
167
201
|
```
|
|
168
202
|
|
|
169
203
|
### `herdux doctor`
|
|
170
204
|
|
|
171
205
|
Executa uma verificação completa de saúde do sistema:
|
|
172
206
|
|
|
173
|
-
- Verifica se
|
|
207
|
+
- Verifica se as ferramentas cliente necessárias estão instaladas e acessíveis (específicas por engine)
|
|
174
208
|
- Tenta uma conexão real usando a configuração resolvida
|
|
175
209
|
- Testa autenticação contra o servidor alvo
|
|
176
210
|
|
|
177
211
|
```bash
|
|
178
212
|
herdux doctor
|
|
213
|
+
herdux --engine mysql doctor
|
|
179
214
|
```
|
|
180
215
|
|
|
181
216
|
---
|
|
@@ -190,7 +225,7 @@ herdux ls --size # Inclui tamanho em disco, ordenado do maior → menor
|
|
|
190
225
|
```
|
|
191
226
|
|
|
192
227
|
> [!NOTE]
|
|
193
|
-
> A flag `--size` calcula o uso físico de disco
|
|
228
|
+
> A flag `--size` calcula o uso físico de disco. Em servidores com dezenas de bancos multi-GB, isso pode levar alguns minutos dependendo da velocidade do disco.
|
|
194
229
|
|
|
195
230
|
---
|
|
196
231
|
|
|
@@ -200,6 +235,7 @@ Cria um novo banco de dados.
|
|
|
200
235
|
|
|
201
236
|
```bash
|
|
202
237
|
herdux create meu_novo_db
|
|
238
|
+
herdux --engine mysql create meu_novo_db
|
|
203
239
|
```
|
|
204
240
|
|
|
205
241
|
### `herdux drop <nome>`
|
|
@@ -236,7 +272,7 @@ Projetado para o workflow real do desenvolvedor: clonar bancos, experimentar, de
|
|
|
236
272
|
Gera um backup com timestamp em `./backups/`.
|
|
237
273
|
|
|
238
274
|
```bash
|
|
239
|
-
herdux backup mydb # Formato custom (.dump)
|
|
275
|
+
herdux backup mydb # Formato custom (.dump para PG, .sql para MySQL)
|
|
240
276
|
herdux backup mydb --format plain # SQL puro (.sql)
|
|
241
277
|
herdux backup mydb --drop # Backup, depois pergunta se quer dropar
|
|
242
278
|
herdux backup mydb --drop --yes # Backup + drop, sem perguntas
|
|
@@ -256,8 +292,8 @@ herdux backup mydb -o ./meus-backups # Diretório de saída personalizado
|
|
|
256
292
|
|
|
257
293
|
Restaura um banco de dados a partir de um arquivo de backup. Detecta automaticamente o formato:
|
|
258
294
|
|
|
259
|
-
- `.sql` → usa
|
|
260
|
-
- `.dump` ou qualquer outra extensão → usa
|
|
295
|
+
- `.sql` → usa a ferramenta de importação SQL apropriada
|
|
296
|
+
- `.dump` ou qualquer outra extensão → usa a ferramenta de restore apropriada
|
|
261
297
|
|
|
262
298
|
```bash
|
|
263
299
|
herdux restore ./backups/mydb_2026-02-23.dump --db mydb
|
|
@@ -271,6 +307,9 @@ herdux restore arquivo.bkp --db mydb --format custom
|
|
|
271
307
|
herdux restore script.txt --db mydb --format plain
|
|
272
308
|
```
|
|
273
309
|
|
|
310
|
+
> [!NOTE]
|
|
311
|
+
> Ao restaurar backups vindos de ambientes gerenciados (ex: AWS RDS), o Herdux configura automaticamente a engine subjacente para ignorar atribuições de permissões e roles. Isso evita erros com roles que existem em produção mas não no seu ambiente local. Se a engine de restauração concluir a operação com avisos não-fatais (como roles ausentes), o Herdux irá te informar no terminal e prosseguir normalmente sem interromper o fluxo.
|
|
312
|
+
|
|
274
313
|
---
|
|
275
314
|
|
|
276
315
|
## ⚙️ Configuração & Perfis de Servidor
|
|
@@ -280,6 +319,7 @@ O `herdux` armazena configurações localmente em `~/.herdux/config.json`.
|
|
|
280
319
|
### Definir Padrões Globais
|
|
281
320
|
|
|
282
321
|
```bash
|
|
322
|
+
herdux config set engine postgres # Engine padrão
|
|
283
323
|
herdux config set user postgres
|
|
284
324
|
herdux config set password minha_senha
|
|
285
325
|
herdux config set port 5432
|
|
@@ -290,8 +330,14 @@ herdux config set port 5432
|
|
|
290
330
|
Gerencie múltiplas instâncias de banco de dados sem esforço:
|
|
291
331
|
|
|
292
332
|
```bash
|
|
333
|
+
# Perfis PostgreSQL
|
|
293
334
|
herdux config add pg16 --port 5416
|
|
294
335
|
herdux config add pg17 --port 5417 --user admin
|
|
336
|
+
|
|
337
|
+
# Perfis MySQL (a engine é salva no perfil)
|
|
338
|
+
herdux config add mysql-dev --port 3306 --user root --password secret --engine mysql
|
|
339
|
+
|
|
340
|
+
# Servidores remotos
|
|
295
341
|
herdux config add staging --host 192.168.0.10 --port 5432
|
|
296
342
|
```
|
|
297
343
|
|
|
@@ -299,9 +345,11 @@ Depois conecte usando a flag `-s`:
|
|
|
299
345
|
|
|
300
346
|
```bash
|
|
301
347
|
herdux list -s pg16
|
|
302
|
-
herdux backup mydb -s
|
|
348
|
+
herdux backup mydb -s mysql-dev
|
|
303
349
|
```
|
|
304
350
|
|
|
351
|
+
Ou simplesmente execute um comando sem flags — se você tiver perfis salvos, o Herdux mostrará um menu de seleção interativo exibindo a engine de cada perfil.
|
|
352
|
+
|
|
305
353
|
### Visualizar & Gerenciar Config
|
|
306
354
|
|
|
307
355
|
```bash
|
|
@@ -313,9 +361,20 @@ herdux config reset # Limpa toda a configuração
|
|
|
313
361
|
|
|
314
362
|
---
|
|
315
363
|
|
|
316
|
-
## 🔌
|
|
364
|
+
## 🔌 Resolução de Conexão e Engine
|
|
365
|
+
|
|
366
|
+
Ao resolver como se conectar e qual engine usar, o **Herdux** segue uma ordem de prioridade estrita e previsível:
|
|
367
|
+
|
|
368
|
+
### Prioridade da Engine
|
|
369
|
+
|
|
370
|
+
| Prioridade | Fonte | Exemplo |
|
|
371
|
+
| ---------- | ---------------- | -------------------------------- |
|
|
372
|
+
| 1️⃣ | **Flag CLI** | `herdux --engine mysql list` |
|
|
373
|
+
| 2️⃣ | **Perfil** | Campo `engine` do perfil |
|
|
374
|
+
| 3️⃣ | **Padrão salvo** | `herdux config set engine mysql` |
|
|
375
|
+
| 4️⃣ | **Fallback** | `postgres` |
|
|
317
376
|
|
|
318
|
-
|
|
377
|
+
### Prioridade da Conexão
|
|
319
378
|
|
|
320
379
|
| Prioridade | Fonte | Exemplo |
|
|
321
380
|
| ---------- | ---------------------- | ------------------------------------------------------- |
|
|
@@ -328,7 +387,7 @@ Isso significa que a entrada explícita sempre vence. Sem surpresas.
|
|
|
328
387
|
|
|
329
388
|
---
|
|
330
389
|
|
|
331
|
-
## 🤔 Por que não pgAdmin?
|
|
390
|
+
## 🤔 Por que não pgAdmin / phpMyAdmin?
|
|
332
391
|
|
|
333
392
|
O **Herdux** não é um substituto de GUI.
|
|
334
393
|
É um acelerador de workflow para desenvolvedores que vivem no terminal.
|
|
@@ -341,14 +400,15 @@ Sem GUI. Sem overhead. Só velocidade.
|
|
|
341
400
|
|
|
342
401
|
- Sem padrões ocultos (hidden defaults).
|
|
343
402
|
- Sem mágicas destrutivas.
|
|
344
|
-
- Resolução de conexão
|
|
403
|
+
- Resolução determinística de conexão e engine.
|
|
345
404
|
- Comandos explícitos e combináveis.
|
|
405
|
+
- Engine-agnostic: mesma interface, qualquer banco de dados.
|
|
346
406
|
|
|
347
407
|
---
|
|
348
408
|
|
|
349
409
|
## 🐳 Suporte Docker (Em Breve)
|
|
350
410
|
|
|
351
|
-
O **Herdux** poderá detectar e interagir com instâncias
|
|
411
|
+
O **Herdux** poderá detectar e interagir com instâncias de banco de dados rodando dentro de containers Docker — listando, conectando e gerenciando-as tão naturalmente quanto instâncias locais.
|
|
352
412
|
|
|
353
413
|
---
|
|
354
414
|
|
|
@@ -370,8 +430,9 @@ npm run dev
|
|
|
370
430
|
|
|
371
431
|
# Executar testes unitários
|
|
372
432
|
npm run test:unit
|
|
373
|
-
# Executar testes
|
|
374
|
-
npm run test:e2e
|
|
433
|
+
# Executar testes E2E (requer Docker)
|
|
434
|
+
npm run test:e2e:pgsql
|
|
435
|
+
npm run test:e2e:mysql
|
|
375
436
|
```
|
|
376
437
|
|
|
377
438
|
---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../src/commands/backup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../src/commands/backup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4F5D"}
|