smoonb 1.0.0 → 1.0.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.

Potentially problematic release.


This version of smoonb might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
+ ## [1.0.2] - 2025-01-29
8
+
9
+ ### Fixed
10
+
11
+ - **Backup report** – When Realtime settings are reused from a previous backup file, the final summary now correctly shows "Settings imported from backup {name}" (or the pt-BR equivalent) instead of "Configurations captured interactively"
12
+
13
+ ---
14
+
15
+ ## [1.0.1] - 2025-01-29
16
+
17
+ ### Removed
18
+
19
+ - **`check` command** – Post-restore integrity verification command removed from CLI, help and documentation
20
+ - **`--skip-realtime`** – Backup option removed; Realtime settings are always captured interactively
21
+ - **`--file` and `--storage` on restore** – Restore no longer accepts direct file paths; use `import` then `restore` to select from the list
22
+ - **`--lang`** – CLI language option removed; language is determined by `SMOONB_LANG` (env or `.env.local`) and system locale only
23
+
24
+ ### Changed
25
+
26
+ - README and README.pt-BR: all `#` comment lines removed from code blocks (replaced with normal text) to avoid light-gray rendering issues
27
+ - Restore flow: backup selection is always interactive (no skip via `--file`)
28
+ - i18n: `detectLocale` no longer reads `--lang` from argv; precedence is SMOONB_LANG → system locale → en
29
+
30
+ ---
31
+
7
32
  ## [1.0.0] - 2025-01-29
8
33
 
9
34
  ### Added
@@ -27,4 +52,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
27
52
 
28
53
  ---
29
54
 
55
+ [1.0.2]: https://github.com/almmello/smoonb/releases/tag/v1.0.2
56
+ [1.0.1]: https://github.com/almmello/smoonb/releases/tag/v1.0.1
30
57
  [1.0.0]: https://github.com/almmello/smoonb/releases/tag/v1.0.0
package/README.md CHANGED
@@ -40,23 +40,26 @@ By continuing, you acknowledge and agree that Supa Moonbase (smoonb) is provided
40
40
 
41
41
  **⚠️ IMPORTANT: Install ONLY locally in the project!**
42
42
 
43
+ **Install locally in the project:**
43
44
  ```bash
44
- # ✅ CORRECT - Install locally in the project
45
45
  npm install smoonb
46
+ ```
46
47
 
47
- # ✅ CORRECT - Use with npx
48
+ **Use with npx:**
49
+ ```bash
48
50
  npx smoonb --help
51
+ ```
49
52
 
50
- # WRONG - DO NOT install globally
51
- npm install -g smoonb # ← This will be blocked!
53
+ **Do not install globally** (blocked):
54
+ ```bash
55
+ npm install -g smoonb
52
56
  ```
53
57
 
54
58
  ### 🔄 Update to Latest Version
55
59
 
56
- To update smoonb to the latest available version:
60
+ To update smoonb to the latest available version, run in the current project:
57
61
 
58
62
  ```bash
59
- # Update in current project
60
63
  npm install smoonb@latest
61
64
  ```
62
65
 
@@ -71,12 +74,10 @@ npm install smoonb@latest
71
74
  ## 📋 Prerequisites
72
75
 
73
76
  ### 1. Docker Desktop (REQUIRED)
74
- ```bash
75
- # Install Docker Desktop
76
- # Windows/macOS: https://docs.docker.com/desktop/install/
77
- # Linux: https://docs.docker.com/engine/install/
78
77
 
79
- # Verify if it's running
78
+ Install from [Docker Desktop](https://docs.docker.com/desktop/install/) (Windows/macOS) or [Docker Engine](https://docs.docker.com/engine/install/) (Linux). Then verify it is running:
79
+
80
+ ```bash
80
81
  docker --version
81
82
  docker ps
82
83
  ```
@@ -117,39 +118,26 @@ You need to obtain a Supabase personal access token to use the Management API:
117
118
  #### 1. Create or edit `.env.local` in the project root
118
119
 
119
120
  ```bash
120
- # Create .env.local file
121
121
  touch .env.local
122
122
  ```
123
123
 
124
124
  #### 2. Add required environment variables
125
125
 
126
126
  ```env
127
- # License (REQUIRED – from https://www.smoonb.com desktop app)
128
127
  SMOONB_LICENSE_KEY=[your-license-key]
129
-
130
- # Supabase URLs and Keys
131
128
  NEXT_PUBLIC_SUPABASE_URL=[your-supabase-url]
132
129
  NEXT_PUBLIC_SUPABASE_ANON_KEY=[your-anon-key]
133
130
  SUPABASE_SERVICE_ROLE_KEY=[your-service-role]
134
-
135
- # Database Connection
136
131
  SUPABASE_DB_URL=postgresql://postgres:[your-database-password]@db.[your-project-id].supabase.co:5432/postgres
137
-
138
- # Project Identification
139
132
  SUPABASE_PROJECT_ID=[your-project-id]
140
-
141
- # Personal Access Token (REQUIRED for Management API)
142
133
  SUPABASE_ACCESS_TOKEN=[your-access-token]
143
-
144
- # Postgres major version (REQUIRED for backup and restore). Check in Dashboard: Project Settings -> Infrastructure -> Service Versions (Postgres line).
145
134
  SUPABASE_POSTGRES_MAJOR=17
146
-
147
- # Optional
148
135
  SMOONB_TELEMETRY_ENABLED=true
149
- # Backup Directory (optional, default: ./backups)
150
136
  SMOONB_OUTPUT_DIR=./backups
151
137
  ```
152
138
 
139
+ Required: `SMOONB_LICENSE_KEY` (from [smoonb.com](https://www.smoonb.com) desktop app), `SUPABASE_POSTGRES_MAJOR` (e.g. 17; see Dashboard → Project Settings → Infrastructure → Service Versions). Optional: `SMOONB_TELEMETRY_ENABLED`, `SMOONB_OUTPUT_DIR` (default `./backups`).
140
+
153
141
  #### 3. Interactive Mapping
154
142
 
155
143
  When running `backup` or `restore` for the first time, **smoonb** will:
@@ -179,69 +167,15 @@ Is this the correct value for the target project? (Y/n): Y
179
167
 
180
168
  Language is detected automatically in the following order of precedence:
181
169
 
182
- 1. **CLI flag `--lang`** (highest priority)
183
- ```bash
184
- npx smoonb --lang pt-BR backup
185
- npx smoonb --lang en restore
186
- ```
187
-
188
- 2. **Environment variable `SMOONB_LANG`**
189
- ```bash
190
- # Windows PowerShell
191
- $env:SMOONB_LANG="pt-BR"
192
- npx smoonb backup
193
-
194
- # Linux/macOS
195
- export SMOONB_LANG=pt-BR
196
- npx smoonb backup
197
- ```
198
-
199
- 3. **System locale** (LANG, LC_ALL, LC_MESSAGES)
200
- ```bash
201
- # smoonb automatically detects system locale
202
- # Example: LANG=pt_BR.UTF-8 → pt-BR
203
- # Example: LANG=en_US.UTF-8 → en
204
- ```
205
-
206
- 4. **Fallback to English (en)** if none of the above are detected
170
+ 1. **Environment variable `SMOONB_LANG`** (in `.env.local` or in the environment)
171
+ 2. **System locale** (LANG, LC_ALL, LC_MESSAGES). Example: `LANG=pt_BR.UTF-8` → pt-BR
172
+ 3. **Fallback to English (en)** if none of the above are detected
207
173
 
208
174
  ### Supported Languages and Aliases
209
175
 
210
- smoonb accepts the following language codes:
211
-
212
176
  - `en` or `en-US` → English
213
177
  - `pt-BR`, `pt_BR` or `pt` → Portuguese (Brazil)
214
178
 
215
- ### Usage Examples
216
-
217
- **Force Portuguese:**
218
- ```bash
219
- npx smoonb --lang pt-BR backup
220
- ```
221
-
222
- **Force English:**
223
- ```bash
224
- npx smoonb --lang en restore
225
- ```
226
-
227
- **Use environment variable:**
228
- ```bash
229
- # Windows PowerShell
230
- $env:SMOONB_LANG="pt-BR"
231
- npx smoonb check
232
-
233
- # Linux/macOS
234
- export SMOONB_LANG=en
235
- npx smoonb check
236
- ```
237
-
238
- **Automatic system detection:**
239
- ```bash
240
- # If system is configured with LANG=pt_BR.UTF-8
241
- # smoonb will automatically use Portuguese
242
- npx smoonb backup
243
- ```
244
-
245
179
  ### Important Notes
246
180
 
247
181
  - **Machine outputs** (e.g., `--json` if implemented) are **not** translated; fields and keys remain in English
@@ -284,30 +218,31 @@ npx smoonb backup
284
218
  - 📁 9/10 - Supabase .temp Backup (if selected)
285
219
  - 📋 10/10 - Migrations Backup (if selected)
286
220
 
287
- **Result:**
221
+ **Result:** A folder `backups/backup-YYYY-MM-DD-HH-MM-SS/` containing for example:
222
+
288
223
  ```
289
224
  backups/backup-2025-10-31-09-37-54/
290
- ├── backup-manifest.json # Manifest with metadata
291
- ├── db_cluster-31-10-2025@09-38-57.backup.gz # Full backup (Dashboard compatible)
292
- ├── schema.sql # Database schema
293
- ├── data.sql # Data
294
- ├── roles.sql # PostgreSQL roles
295
- ├── database-settings-*.json # Extensions and settings
296
- ├── auth-settings.json # Auth configurations
297
- ├── realtime-settings.json # Realtime configurations
298
- ├── storage/ # Storage metadata
299
- │ └── [bucket-name].json # Metadata for each bucket
300
- ├── [project-id].storage.zip # Full Storage backup (Dashboard format)
301
- ├── storage_temp/ # Temporary structure (optional, can be removed)
302
- │ └── [project-id]/ # Downloaded files structure
303
- │ └── [bucket-name]/ # Files for each bucket
304
- ├── edge-functions/ # Downloaded Edge Functions
225
+ ├── backup-manifest.json
226
+ ├── db_cluster-31-10-2025@09-38-57.backup.gz
227
+ ├── schema.sql
228
+ ├── data.sql
229
+ ├── roles.sql
230
+ ├── database-settings-*.json
231
+ ├── auth-settings.json
232
+ ├── realtime-settings.json
233
+ ├── storage/
234
+ │ └── [bucket-name].json
235
+ ├── [project-id].storage.zip
236
+ ├── storage_temp/
237
+ │ └── [project-id]/
238
+ │ └── [bucket-name]/
239
+ ├── edge-functions/
305
240
  │ └── [function-name]/
306
- ├── supabase-temp/ # Supabase CLI .temp files
307
- ├── migrations/ # All migrations
241
+ ├── supabase-temp/
242
+ ├── migrations/
308
243
  └── env/
309
- ├── .env.local # .env.local backup
310
- └── env-map.json # Variable mapping
244
+ ├── .env.local
245
+ └── env-map.json
311
246
  ```
312
247
 
313
248
  ### Interactive Restoration
@@ -317,15 +252,6 @@ backups/backup-2025-10-31-09-37-54/
317
252
  npx smoonb restore
318
253
  ```
319
254
 
320
- **Import and restore directly from Dashboard:**
321
- ```bash
322
- # Database only
323
- npx smoonb restore --file "C:\Downloads\db_cluster-04-03-2024@14-16-59.backup.gz"
324
-
325
- # Database and storage together
326
- npx smoonb restore --file "backup.backup.gz" --storage "my-project.storage.zip"
327
- ```
328
-
329
255
  **Interactive restore flow:**
330
256
 
331
257
  1. **Terms of use** - Displays and requests acceptance of terms
@@ -334,9 +260,7 @@ npx smoonb restore --file "backup.backup.gz" --storage "my-project.storage.zip"
334
260
  4. **Consent** - Asks permission to read/write `.env.local`
335
261
  5. **Variable mapping** - Maps variables to target project (includes `SUPABASE_POSTGRES_MAJOR`)
336
262
  6. **.env.local backup** - Creates automatic backup
337
- 7. **Backup selection** - Lists and allows choosing which backup to restore (skips if `--file` provided)
338
- - If `--file` is provided: automatically imports and auto-selects the backup
339
- - If `--storage` is provided along with `--file`: also imports the storage file
263
+ 7. **Backup selection** - Lists and allows choosing which backup to restore
340
264
  8. **Component selection** - Asks which components to restore:
341
265
  - 📊 Database (always available)
342
266
  - ⚡ Edge Functions (if available in backup)
@@ -359,12 +283,6 @@ npx smoonb restore --file "backup.backup.gz" --storage "my-project.storage.zip"
359
283
  - ✅ `.backup.gz` (compressed) - Automatically decompresses before restoring
360
284
  - ✅ `.backup` (uncompressed) - Restores directly
361
285
 
362
- **When to use `--file`:**
363
- - Automatically imports backup file before restoring
364
- - Eliminates backup selection step
365
- - If `--storage` provided, also imports storage file
366
- - Useful for restoring backups downloaded directly from Supabase Dashboard
367
-
368
286
  ### Import Backup from Supabase Dashboard
369
287
 
370
288
  If you downloaded a backup directly from the Supabase Dashboard (`.backup.gz` format), you can import it to the format expected by smoonb. The command also supports optionally importing storage files (`.storage.zip`).
@@ -389,52 +307,28 @@ npx smoonb import --file "backup.backup.gz" --storage "my-project.storage.zip"
389
307
  7. Makes backup ready to be found by `restore` command
390
308
 
391
309
  **Complete example - Database only (using import + restore):**
392
- ```bash
393
- # 1. Download backup from Supabase Dashboard
394
- # File: db_cluster-04-03-2024@14-16-59.backup.gz
395
310
 
396
- # 2. Import the file
397
- npx smoonb import --file "C:\Downloads\db_cluster-04-03-2024@14-16-59.backup.gz"
311
+ 1. Download backup from Supabase Dashboard (e.g. `db_cluster-04-03-2024@14-16-59.backup.gz`).
312
+ 2. Import the file, then restore:
398
313
 
399
- # 3. Restore the imported backup
314
+ ```bash
315
+ npx smoonb import --file "C:\Downloads\db_cluster-04-03-2024@14-16-59.backup.gz"
400
316
  npx smoonb restore
401
- # The imported backup will appear in the list of available backups
402
317
  ```
403
318
 
404
- **Complete example - Database only (using restore directly):**
405
- ```bash
406
- # 1. Download backup from Supabase Dashboard
407
- # File: db_cluster-04-03-2024@14-16-59.backup.gz
408
-
409
- # 2. Import and restore directly (skips backup selection)
410
- npx smoonb restore --file "C:\Downloads\db_cluster-04-03-2024@14-16-59.backup.gz"
411
- ```
319
+ The imported backup will appear in the list of available backups.
412
320
 
413
321
  **Complete example - Database and Storage (using import + restore):**
414
- ```bash
415
- # 1. Download backup and storage from Supabase Dashboard
416
- # Files:
417
- # - db_cluster-04-03-2024@14-16-59.backup.gz
418
- # - my-project.storage.zip
419
322
 
420
- # 2. Import both files
421
- npx smoonb import --file "C:\Downloads\db_cluster-04-03-2024@14-16-59.backup.gz" --storage "C:\Downloads\my-project.storage.zip"
323
+ 1. Download backup and storage from Supabase Dashboard (e.g. `db_cluster-04-03-2024@14-16-59.backup.gz` and `my-project.storage.zip`).
324
+ 2. Import both files, then restore:
422
325
 
423
- # 3. Restore the imported backup
326
+ ```bash
327
+ npx smoonb import --file "C:\Downloads\db_cluster-04-03-2024@14-16-59.backup.gz" --storage "C:\Downloads\my-project.storage.zip"
424
328
  npx smoonb restore
425
- # The imported backup will appear in the list of available backups
426
329
  ```
427
330
 
428
- **Complete example - Database and Storage (using restore directly):**
429
- ```bash
430
- # 1. Download backup and storage from Supabase Dashboard
431
- # Files:
432
- # - db_cluster-04-03-2024@14-16-59.backup.gz
433
- # - my-project.storage.zip
434
-
435
- # 2. Import and restore directly (skips backup selection)
436
- npx smoonb restore --file "C:\Downloads\db_cluster-04-03-2024@14-16-59.backup.gz" --storage "C:\Downloads\my-project.storage.zip"
437
- ```
331
+ The imported backup will appear in the list of available backups.
438
332
 
439
333
  **Important:**
440
334
  - Backup file is **required** and must be in Dashboard format: `db_cluster-DD-MM-YYYY@HH-MM-SS.backup.gz`
@@ -444,24 +338,7 @@ npx smoonb restore --file "C:\Downloads\db_cluster-04-03-2024@14-16-59.backup.gz
444
338
  - Path can be absolute or relative
445
339
  - Command will automatically create necessary folder structure
446
340
 
447
- **Difference between `import` and `restore --file`:**
448
- - `import`: Only imports the file and creates backup structure. You need to run `restore` afterwards.
449
- - `restore --file`: Automatically imports the file and starts the restoration process, skipping the backup selection step.
450
-
451
- ### Post-Restore Verification
452
-
453
- ```bash
454
- npx smoonb check
455
- ```
456
-
457
- **Verifies:**
458
- - ✅ Database connection
459
- - ✅ Installed extensions
460
- - ✅ Created tables
461
- - ✅ RLS policies
462
- - ✅ Realtime publications
463
- - ✅ Storage buckets
464
-
341
+ After running `import`, run `restore` to choose the imported backup from the list and restore it.
465
342
 
466
343
  ## 🔧 Available Commands
467
344
 
@@ -469,9 +346,7 @@ npx smoonb check
469
346
  |---------|-------------|
470
347
  | `npx smoonb backup` | Full interactive backup using Docker |
471
348
  | `npx smoonb restore` | Interactive restoration using psql (Docker) |
472
- | `npx smoonb restore --file <path> [--storage <path>]` | Import and restore directly .backup.gz file and optionally .storage.zip from Dashboard |
473
349
  | `npx smoonb import --file <path> [--storage <path>]` | Import .backup.gz file and optionally .storage.zip from Supabase Dashboard |
474
- | `npx smoonb check` | Post-restore integrity verification |
475
350
 
476
351
  ## 🏗️ Technical Architecture
477
352
 
@@ -482,39 +357,39 @@ The code has been refactored to a **modular architecture** with independent step
482
357
  #### Backup (`src/commands/backup/`)
483
358
  ```
484
359
  backup/
485
- ├── index.js # Orquestrador principal
486
- ├── utils.js # Utilitários específicos
360
+ ├── index.js
361
+ ├── utils.js
487
362
  └── steps/
488
- ├── 00-license.js # Validação de licença (SMOONB_LICENSE_KEY)
489
- ├── 01-docker-validation.js # Validação Docker
490
- ├── 02-database.js # Backup via pg_dumpall
491
- ├── 03-database-separated.js # SQL separado
492
- ├── 04-database-settings.js # Extensões e settings
493
- ├── 05-auth-settings.js # Auth via API
494
- ├── 06-realtime-settings.js # Realtime interativo
495
- ├── 07-storage.js # Storage via API
496
- ├── 08-custom-roles.js # Custom roles
497
- ├── 09-edge-functions.js # Edge Functions
498
- ├── 10-supabase-temp.js # Supabase .temp
499
- └── 11-migrations.js # Migrations
363
+ ├── 00-license.js
364
+ ├── 01-docker-validation.js
365
+ ├── 02-database.js
366
+ ├── 03-database-separated.js
367
+ ├── 04-database-settings.js
368
+ ├── 05-auth-settings.js
369
+ ├── 06-realtime-settings.js
370
+ ├── 07-storage.js
371
+ ├── 08-custom-roles.js
372
+ ├── 09-edge-functions.js
373
+ ├── 10-supabase-temp.js
374
+ └── 11-migrations.js
500
375
  ```
501
376
 
502
377
  #### Restore (`src/commands/restore/`)
503
378
  License validation (same as backup, `00-license.js` from backup steps) runs at start. Then:
504
379
  ```
505
380
  restore/
506
- ├── index.js # Orquestrador principal
507
- ├── utils.js # Utilitários específicos
381
+ ├── index.js
382
+ ├── utils.js
508
383
  └── steps/
509
- ├── 00-backup-selection.js # Seleção de backup
510
- ├── 01-components-selection.js # Seleção de componentes
511
- ├── 02-confirmation.js # Confirmação (legacy)
512
- ├── 03-database.js # Restauração database
513
- ├── 04-edge-functions.js # Deploy Edge Functions
514
- ├── 05-auth-settings.js # Exibe Auth settings
515
- ├── 06-storage.js # Exibe Storage info
516
- ├── 07-database-settings.js # Restaura settings
517
- └── 08-realtime-settings.js # Exibe Realtime settings
384
+ ├── 00-backup-selection.js
385
+ ├── 01-components-selection.js
386
+ ├── 02-confirmation.js
387
+ ├── 03-database.js
388
+ ├── 04-edge-functions.js
389
+ ├── 05-auth-settings.js
390
+ ├── 06-storage.js
391
+ ├── 07-database-settings.js
392
+ └── 08-realtime-settings.js
518
393
  ```
519
394
 
520
395
  ### Backup Strategy
@@ -587,42 +462,26 @@ restore/
587
462
 
588
463
  ## 📊 Recommended Flow
589
464
 
590
- ```bash
591
- # 1. Configure .env.local (first time)
592
- # Edit .env.local with your source project credentials
593
-
594
- # 2. Backup source project
595
- npx smoonb backup
596
- # - Maps variables interactively (first time)
597
- # - Selects components for backup
598
- # - Executes full backup
599
-
600
- # 3. Create new Supabase project
601
- # (via Dashboard or Supabase CLI)
602
-
603
- # 4. Edit .env.local with new project credentials
604
- # Update variables to point to target project
605
-
606
- # 5. Restore backup (interactive mode)
607
- npx smoonb restore
608
- # - Selects desired backup
609
- # - Selects components to restore
610
- # - Executes restoration
611
-
612
- # 6. Verify integrity
613
- npx smoonb check
614
-
615
- # 7. Apply manual configurations (if necessary)
616
- # - Auth Settings: Dashboard → Authentication → Settings
617
- # - Realtime: Dashboard → Database → Replication
618
- # Note: Storage is automatically restored from ZIP if available
619
- ```
465
+ 1. **Configure `.env.local`** (first time) with your source project credentials.
466
+ 2. **Backup source project:**
467
+ ```bash
468
+ npx smoonb backup
469
+ ```
470
+ (Maps variables interactively on first run, selects components, executes full backup.)
471
+ 3. **Create new Supabase project** (via Dashboard or Supabase CLI).
472
+ 4. **Edit `.env.local`** with new project credentials (point variables to target project).
473
+ 5. **Restore backup** (interactive mode):
474
+ ```bash
475
+ npx smoonb restore
476
+ ```
477
+ (Select desired backup, select components, execute restoration.)
478
+ 6. **Apply manual configurations** if necessary: Auth Settings (Dashboard → Authentication → Settings), Realtime (Dashboard → Database → Replication). Storage is restored automatically from ZIP when available.
620
479
 
621
480
  ## 🎨 User Experience
622
481
 
623
482
  ### Multi-Language Interface
624
483
 
625
- All interactions are **automatically translated** based on system locale or `--lang` flag:
484
+ All interactions are **automatically translated** based on system locale or `SMOONB_LANG`:
626
485
  - Clear and direct questions
627
486
  - Explanations before each process
628
487
  - Detailed summaries before confirming
@@ -645,18 +504,16 @@ All interactions are **automatically translated** based on system locale or `--l
645
504
  ## 🐛 Troubleshooting
646
505
 
647
506
  ### Docker not found or not running
507
+
508
+ Verify Docker is installed and running:
509
+
648
510
  ```bash
649
- # Verify if Docker is installed
650
511
  docker --version
651
-
652
- # Verify if Docker Desktop is running
653
512
  docker ps
654
-
655
- # If not, start Docker Desktop
656
- # Windows/macOS: Open Docker Desktop application
657
- # Linux: sudo systemctl start docker
658
513
  ```
659
514
 
515
+ If not, start Docker Desktop (Windows/macOS) or run `sudo systemctl start docker` (Linux).
516
+
660
517
  ### Supabase CLI not found
661
518
  ```bash
662
519
  npm install -g supabase