smoonb 0.0.5 → 0.0.7
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/.smoonbrc +21 -0
- package/.smoonbrc.example +2 -1
- package/README.md +30 -25
- package/backups/backup-2025-10-17T19-18-58-539Z/auth-config.json +7 -0
- package/backups/backup-2025-10-17T19-18-58-539Z/backup-manifest.json +19 -0
- package/backups/backup-2025-10-17T19-18-58-539Z/functions/README.md +4 -0
- package/backups/backup-2025-10-17T19-18-58-539Z/realtime-config.json +7 -0
- package/backups/backup-2025-10-17T19-18-58-539Z/storage/storage-config.json +6 -0
- package/backups/backup-2025-10-17T19-52-20-211Z/auth-config.json +7 -0
- package/backups/backup-2025-10-17T19-52-20-211Z/backup-manifest.json +19 -0
- package/backups/backup-2025-10-17T19-52-20-211Z/database-2025-10-17T19-52-20-215Z.dump +0 -0
- package/backups/backup-2025-10-17T19-52-20-211Z/functions/README.md +4 -0
- package/backups/backup-2025-10-17T19-52-20-211Z/realtime-config.json +7 -0
- package/backups/backup-2025-10-17T19-52-20-211Z/storage/storage-config.json +6 -0
- package/backups/backup-2025-10-17T20-38-13-188Z/auth-config.json +7 -0
- package/backups/backup-2025-10-17T20-38-13-188Z/backup-manifest.json +19 -0
- package/backups/backup-2025-10-17T20-38-13-188Z/database-2025-10-17T20-38-13-194Z.dump +0 -0
- package/backups/backup-2025-10-17T20-38-13-188Z/functions/README.md +4 -0
- package/backups/backup-2025-10-17T20-38-13-188Z/realtime-config.json +7 -0
- package/backups/backup-2025-10-17T20-38-13-188Z/storage/storage-config.json +6 -0
- package/bin/smoonb.js +9 -9
- package/package.json +1 -1
- package/src/commands/backup.js +31 -8
- package/src/commands/check.js +1 -0
- package/src/commands/config.js +78 -77
- package/src/commands/restore.js +1 -0
- package/src/utils/supabase.js +447 -387
package/.smoonbrc
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"supabase": {
|
|
3
|
+
"projectId": "xvfgdgdfgdfgdfgdfg",
|
|
4
|
+
"url": "https://dfgdfgdfgdfgdfgdfg.supabase.co",
|
|
5
|
+
"serviceKey": "sdfsdfsdfsdfsdfgyjyuiuyjyujuyjyujuyjyujuy",
|
|
6
|
+
"anonKey": "uyjyujyujyhmnbmbghjghjghghjghjghjghj",
|
|
7
|
+
"databaseUrl": "postgresql://postgres:ghjghjghjghjghjghjghj@db.sdfsdfsdfsdfsdfsdfsdfsdf.supabase.co:5432/postgres"
|
|
8
|
+
},
|
|
9
|
+
"backup": {
|
|
10
|
+
"includeFunctions": true,
|
|
11
|
+
"includeStorage": true,
|
|
12
|
+
"includeAuth": true,
|
|
13
|
+
"includeRealtime": true,
|
|
14
|
+
"outputDir": "./backups",
|
|
15
|
+
"pgDumpPath": "C:\\Program Files\\PostgreSQL\\17\\bin\\pg_dump.exe"
|
|
16
|
+
},
|
|
17
|
+
"restore": {
|
|
18
|
+
"cleanRestore": false,
|
|
19
|
+
"verifyAfterRestore": true
|
|
20
|
+
}
|
|
21
|
+
}
|
package/.smoonbrc.example
CHANGED
package/README.md
CHANGED
|
@@ -40,20 +40,20 @@ smoonb é a **primeira ferramenta** que faz backup **COMPLETO** do Supabase:
|
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
# Backup completo do projeto
|
|
43
|
-
smoonb backup
|
|
43
|
+
npx smoonb backup
|
|
44
44
|
|
|
45
45
|
# Restauração completa
|
|
46
|
-
smoonb restore
|
|
46
|
+
npx smoonb restore
|
|
47
47
|
|
|
48
48
|
# Gerenciamento de secrets
|
|
49
|
-
smoonb secrets export
|
|
50
|
-
smoonb secrets import
|
|
49
|
+
npx smoonb secrets export
|
|
50
|
+
npx smoonb secrets import
|
|
51
51
|
|
|
52
52
|
# Deploy de Edge Functions
|
|
53
|
-
smoonb functions push
|
|
53
|
+
npx smoonb functions push
|
|
54
54
|
|
|
55
55
|
# Checklist pós-restore
|
|
56
|
-
smoonb check
|
|
56
|
+
npx smoonb check
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
## 📊 Comparação: smoonb vs Outras Ferramentas
|
|
@@ -72,34 +72,39 @@ smoonb check
|
|
|
72
72
|
## 🛠️ Instalação
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
#
|
|
76
|
-
npm install
|
|
75
|
+
# Instalar localmente no projeto
|
|
76
|
+
npm install smoonb
|
|
77
77
|
|
|
78
|
-
#
|
|
79
|
-
npx smoonb --
|
|
78
|
+
# Usar com npx
|
|
79
|
+
npx smoonb --version
|
|
80
|
+
|
|
81
|
+
# Ou adicionar script no package.json
|
|
82
|
+
npm pkg set scripts.backup="npx smoonb backup"
|
|
83
|
+
npm run backup
|
|
80
84
|
```
|
|
81
85
|
|
|
82
86
|
## ⚡ Quick Start
|
|
83
87
|
|
|
84
88
|
```bash
|
|
85
|
-
# 1.
|
|
86
|
-
smoonb
|
|
89
|
+
# 1. Instale o smoonb no projeto
|
|
90
|
+
npm install smoonb
|
|
87
91
|
|
|
88
|
-
# 2.
|
|
89
|
-
smoonb
|
|
92
|
+
# 2. Configure suas credenciais Supabase
|
|
93
|
+
npx npx smoonb config --init
|
|
90
94
|
|
|
91
|
-
# 3.
|
|
92
|
-
|
|
95
|
+
# 3. Edite o arquivo .smoonbrc com suas credenciais
|
|
96
|
+
# 4. Execute o backup completo
|
|
97
|
+
npx npx smoonb backup
|
|
93
98
|
|
|
94
|
-
#
|
|
95
|
-
smoonb
|
|
99
|
+
# 5. Restaure em outro projeto
|
|
100
|
+
npx npx smoonb restore --backup-dir ./backups/backup-2024-01-15T10-30-00Z
|
|
96
101
|
```
|
|
97
102
|
|
|
98
103
|
## 📋 Exemplos de Uso
|
|
99
104
|
|
|
100
105
|
### Backup Completo
|
|
101
106
|
```bash
|
|
102
|
-
smoonb backup \
|
|
107
|
+
npx smoonb backup \
|
|
103
108
|
--project-id abc123def456 \
|
|
104
109
|
--output ./backup-$(date +%Y%m%d) \
|
|
105
110
|
--include-functions \
|
|
@@ -109,7 +114,7 @@ smoonb backup \
|
|
|
109
114
|
|
|
110
115
|
### Restauração com Verificação
|
|
111
116
|
```bash
|
|
112
|
-
smoonb restore \
|
|
117
|
+
npx smoonb restore \
|
|
113
118
|
--project-id xyz789uvw012 \
|
|
114
119
|
--backup-dir ./backup-20241201 \
|
|
115
120
|
--verify \
|
|
@@ -119,19 +124,19 @@ smoonb restore \
|
|
|
119
124
|
### Migração Entre Projetos
|
|
120
125
|
```bash
|
|
121
126
|
# 1. Backup do projeto origem
|
|
122
|
-
smoonb backup --project-id source-project
|
|
127
|
+
npx smoonb backup --project-id source-project
|
|
123
128
|
|
|
124
129
|
# 2. Export secrets (opcional)
|
|
125
|
-
smoonb secrets export --project-id source-project
|
|
130
|
+
npx smoonb secrets export --project-id source-project
|
|
126
131
|
|
|
127
132
|
# 3. Restore no projeto destino
|
|
128
|
-
smoonb restore --project-id target-project
|
|
133
|
+
npx smoonb restore --project-id target-project
|
|
129
134
|
|
|
130
135
|
# 4. Import secrets (opcional)
|
|
131
|
-
smoonb secrets import --project-id target-project
|
|
136
|
+
npx smoonb secrets import --project-id target-project
|
|
132
137
|
|
|
133
138
|
# 5. Verificação final
|
|
134
|
-
smoonb check --project-id target-project
|
|
139
|
+
npx smoonb check --project-id target-project
|
|
135
140
|
```
|
|
136
141
|
|
|
137
142
|
## 🔧 Configuração
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"timestamp": "2025-10-17T19:18:58.559Z",
|
|
3
|
+
"projectId": "itrnlqsdfsdfsdf",
|
|
4
|
+
"version": "0.1.0-beta",
|
|
5
|
+
"components": {
|
|
6
|
+
"database": false,
|
|
7
|
+
"functions": true,
|
|
8
|
+
"auth": true,
|
|
9
|
+
"storage": true,
|
|
10
|
+
"realtime": true
|
|
11
|
+
},
|
|
12
|
+
"files": {
|
|
13
|
+
"database": null,
|
|
14
|
+
"functions": "functions/",
|
|
15
|
+
"auth": "auth-config.json",
|
|
16
|
+
"storage": "storage/",
|
|
17
|
+
"realtime": "realtime-config.json"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"timestamp": "2025-10-17T19:52:20.452Z",
|
|
3
|
+
"projectId": "xvfgdgdfgdfgdfgdfg",
|
|
4
|
+
"version": "0.1.0-beta",
|
|
5
|
+
"components": {
|
|
6
|
+
"database": false,
|
|
7
|
+
"functions": true,
|
|
8
|
+
"auth": true,
|
|
9
|
+
"storage": true,
|
|
10
|
+
"realtime": true
|
|
11
|
+
},
|
|
12
|
+
"files": {
|
|
13
|
+
"database": null,
|
|
14
|
+
"functions": "functions/",
|
|
15
|
+
"auth": "auth-config.json",
|
|
16
|
+
"storage": "storage/",
|
|
17
|
+
"realtime": "realtime-config.json"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"timestamp": "2025-10-17T20:38:13.584Z",
|
|
3
|
+
"projectId": "xvfgdgdfgdfgdfgdfg",
|
|
4
|
+
"version": "0.1.0-beta",
|
|
5
|
+
"components": {
|
|
6
|
+
"database": false,
|
|
7
|
+
"functions": true,
|
|
8
|
+
"auth": true,
|
|
9
|
+
"storage": true,
|
|
10
|
+
"realtime": true
|
|
11
|
+
},
|
|
12
|
+
"files": {
|
|
13
|
+
"database": null,
|
|
14
|
+
"functions": "functions/",
|
|
15
|
+
"auth": "auth-config.json",
|
|
16
|
+
"storage": "storage/",
|
|
17
|
+
"realtime": "realtime-config.json"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
File without changes
|
package/bin/smoonb.js
CHANGED
|
@@ -31,10 +31,10 @@ program
|
|
|
31
31
|
})
|
|
32
32
|
.addHelpText('after', () => {
|
|
33
33
|
return chalk.cyan.bold(`
|
|
34
|
-
📋 CONFIGURAÇÃO AUTOMÁTICA:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
📋 CONFIGURAÇÃO AUTOMÁTICA:
|
|
35
|
+
npx smoonb config --init # Cria .smoonbrc com projectId, URLs, etc.
|
|
36
|
+
# Edite o arquivo com suas credenciais Supabase
|
|
37
|
+
npx smoonb backup # Funciona sem --project-id!
|
|
38
38
|
|
|
39
39
|
📝 EXEMPLO DE CONFIGURAÇÃO (.smoonbrc):
|
|
40
40
|
{
|
|
@@ -58,10 +58,10 @@ program
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
🔧 COMO CONFIGURAR:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
🔧 COMO CONFIGURAR:
|
|
62
|
+
1. npx smoonb config --init
|
|
63
|
+
2. Edite .smoonbrc com suas credenciais
|
|
64
|
+
3. npx smoonb backup (funciona automaticamente!)
|
|
65
65
|
`);
|
|
66
66
|
});
|
|
67
67
|
|
|
@@ -70,7 +70,7 @@ program
|
|
|
70
70
|
.command('backup')
|
|
71
71
|
.description('Fazer backup completo do projeto Supabase')
|
|
72
72
|
.option('-p, --project-id <id>', 'ID do projeto Supabase')
|
|
73
|
-
.option('-o, --output <dir>', 'Diretório de saída do backup', './
|
|
73
|
+
.option('-o, --output <dir>', 'Diretório de saída do backup', './backups')
|
|
74
74
|
.option('--include-functions', 'Incluir Edge Functions no backup', true)
|
|
75
75
|
.option('--include-storage', 'Incluir Storage Objects no backup', true)
|
|
76
76
|
.option('--include-auth', 'Incluir Auth Settings no backup', true)
|
package/package.json
CHANGED
package/src/commands/backup.js
CHANGED
|
@@ -8,7 +8,7 @@ const { execSync } = require('child_process');
|
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const { createClient } = require('@supabase/supabase-js');
|
|
11
|
-
const { getProjectId, getDatabaseUrl } = require('../utils/supabase');
|
|
11
|
+
const { getProjectId, getDatabaseUrl, findPgDumpPath, loadConfig } = require('../utils/supabase');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Backup completo do projeto Supabase
|
|
@@ -29,17 +29,23 @@ async function backupCommand(options) {
|
|
|
29
29
|
if (!projectId) {
|
|
30
30
|
console.error(chalk.red.bold('❌ Erro: Project ID não encontrado'));
|
|
31
31
|
console.log(chalk.yellow('💡 Opções:'));
|
|
32
|
-
console.log(chalk.gray(' 1. Use: smoonb backup --project-id <seu-project-id>'));
|
|
33
|
-
console.log(chalk.gray(' 2. Configure: smoonb config --init'));
|
|
32
|
+
console.log(chalk.gray(' 1. Use: npx smoonb backup --project-id <seu-project-id>'));
|
|
33
|
+
console.log(chalk.gray(' 2. Configure: npx smoonb config --init'));
|
|
34
34
|
console.log(chalk.gray(' 3. Ou defina SUPABASE_PROJECT_ID no ambiente'));
|
|
35
|
+
console.log(chalk.gray(' 4. Ou edite .smoonbrc e configure o projectId'));
|
|
36
|
+
console.log(chalk.gray(' 5. Substitua "your-project-id-here" por seu ID real'));
|
|
35
37
|
process.exit(1);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
console.log(chalk.blue('🆔 Project ID:'), projectId);
|
|
39
41
|
|
|
42
|
+
// Obter diretório de backup da configuração ou usar opção
|
|
43
|
+
const config = loadConfig();
|
|
44
|
+
const outputDir = config?.backup?.outputDir || options.output;
|
|
45
|
+
|
|
40
46
|
// Criar diretório de backup com timestamp
|
|
41
47
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
42
|
-
const backupDir = path.resolve(
|
|
48
|
+
const backupDir = path.resolve(outputDir, `backup-${timestamp}`);
|
|
43
49
|
await fs.promises.mkdir(backupDir, { recursive: true });
|
|
44
50
|
|
|
45
51
|
console.log(chalk.green('✅ Diretório de backup criado:'), backupDir);
|
|
@@ -130,10 +136,24 @@ async function backupDatabase(projectId, outputDir) {
|
|
|
130
136
|
|
|
131
137
|
if (!dbUrl) {
|
|
132
138
|
console.log(chalk.yellow('⚠️ Database URL não configurada'));
|
|
133
|
-
console.log(chalk.gray(' - Configure DATABASE_URL
|
|
139
|
+
console.log(chalk.gray(' - Configure DATABASE_URL no ambiente'));
|
|
140
|
+
console.log(chalk.gray(' - Ou edite ~/.smoonbrc e configure databaseUrl'));
|
|
141
|
+
console.log(chalk.gray(' - Ou use smoonb config --init'));
|
|
134
142
|
return null;
|
|
135
143
|
}
|
|
136
144
|
|
|
145
|
+
// Verificar se a URL contém placeholder de senha
|
|
146
|
+
if (dbUrl.includes('[password]')) {
|
|
147
|
+
console.log(chalk.yellow('⚠️ Database URL contém placeholder [password]'));
|
|
148
|
+
console.log(chalk.gray(' - Substitua [password] pela senha real da database'));
|
|
149
|
+
console.log(chalk.gray(' - Ou configure DATABASE_URL completa no ambiente'));
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Encontrar caminho do pg_dump (detecção automática no Windows)
|
|
154
|
+
const pgDumpPath = findPgDumpPath();
|
|
155
|
+
console.log(chalk.gray(` - Usando pg_dump: ${pgDumpPath}`));
|
|
156
|
+
|
|
137
157
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
138
158
|
const filename = `database-${timestamp}.dump`;
|
|
139
159
|
const filepath = path.join(outputDir, filename);
|
|
@@ -141,13 +161,16 @@ async function backupDatabase(projectId, outputDir) {
|
|
|
141
161
|
console.log(chalk.gray(' - Executando pg_dump com formato Custom (-Fc)...'));
|
|
142
162
|
|
|
143
163
|
// Usar formato Custom (-Fc) para restauração mais segura
|
|
144
|
-
const command = `
|
|
164
|
+
const command = `"${pgDumpPath}" "${dbUrl}" -Fc -f "${filepath}"`;
|
|
145
165
|
execSync(command, { stdio: 'pipe' });
|
|
146
166
|
|
|
147
167
|
return filepath;
|
|
148
168
|
} catch (error) {
|
|
149
|
-
console.log(chalk.yellow('⚠️ Backup da database falhou
|
|
150
|
-
console.log(chalk.gray(' -
|
|
169
|
+
console.log(chalk.yellow('⚠️ Backup da database falhou:'), error.message);
|
|
170
|
+
console.log(chalk.gray(' - Verifique se DATABASE_URL está correta'));
|
|
171
|
+
console.log(chalk.gray(' - Verifique se pg_dump está instalado'));
|
|
172
|
+
console.log(chalk.gray(' - Verifique se as credenciais estão corretas'));
|
|
173
|
+
console.log(chalk.gray(' - Configure pgDumpPath no .smoonbrc se necessário'));
|
|
151
174
|
return null;
|
|
152
175
|
}
|
|
153
176
|
}
|
package/src/commands/check.js
CHANGED
|
@@ -31,6 +31,7 @@ async function checkCommand(options) {
|
|
|
31
31
|
console.log(chalk.gray(' 1. Use: smoonb check --project-id <seu-project-id>'));
|
|
32
32
|
console.log(chalk.gray(' 2. Configure: smoonb config --init'));
|
|
33
33
|
console.log(chalk.gray(' 3. Ou defina SUPABASE_PROJECT_ID no ambiente'));
|
|
34
|
+
console.log(chalk.gray(' 4. Ou edite ~/.smoonbrc e configure o projectId'));
|
|
34
35
|
process.exit(1);
|
|
35
36
|
}
|
|
36
37
|
|
package/src/commands/config.js
CHANGED
|
@@ -1,77 +1,78 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comando de configuração do smoonb
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
const fs = require('fs').promises;
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const os = require('os');
|
|
9
|
-
|
|
10
|
-
async function configCommand(options) {
|
|
11
|
-
console.log(chalk.red.bold('🚀 smoonb - EXPERIMENTAL VERSION'));
|
|
12
|
-
console.log(chalk.red.bold('⚠️ VERSÃO EXPERIMENTAL - NUNCA TESTADA EM PRODUÇÃO!'));
|
|
13
|
-
console.log(chalk.red.bold('🚨 USE POR SUA CONTA E RISCO - Pode causar perda de dados!'));
|
|
14
|
-
console.log(chalk.red.bold('❌ NÃO NOS RESPONSABILIZAMOS por qualquer perda de dados!\n'));
|
|
15
|
-
|
|
16
|
-
console.log(chalk.cyan.bold('⚙️ Configuração do smoonb...\n'));
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
const configPath = path.join(
|
|
20
|
-
|
|
21
|
-
if (options.init) {
|
|
22
|
-
// Inicializar configuração
|
|
23
|
-
const defaultConfig = {
|
|
24
|
-
supabase: {
|
|
25
|
-
projectId: '',
|
|
26
|
-
url: '',
|
|
27
|
-
serviceKey: '',
|
|
28
|
-
anonKey: '',
|
|
29
|
-
databaseUrl: ''
|
|
30
|
-
},
|
|
31
|
-
backup: {
|
|
32
|
-
includeFunctions: true,
|
|
33
|
-
includeStorage: true,
|
|
34
|
-
includeAuth: true,
|
|
35
|
-
includeRealtime: true,
|
|
36
|
-
outputDir: './backups'
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
console.log(chalk.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.log(chalk.
|
|
56
|
-
console.log(chalk.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
console.log(chalk.yellow('
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
console.log(chalk.
|
|
67
|
-
console.log(chalk.cyan(' --
|
|
68
|
-
console.log(chalk.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Comando de configuração do smoonb
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
const fs = require('fs').promises;
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
|
|
10
|
+
async function configCommand(options) {
|
|
11
|
+
console.log(chalk.red.bold('🚀 smoonb - EXPERIMENTAL VERSION'));
|
|
12
|
+
console.log(chalk.red.bold('⚠️ VERSÃO EXPERIMENTAL - NUNCA TESTADA EM PRODUÇÃO!'));
|
|
13
|
+
console.log(chalk.red.bold('🚨 USE POR SUA CONTA E RISCO - Pode causar perda de dados!'));
|
|
14
|
+
console.log(chalk.red.bold('❌ NÃO NOS RESPONSABILIZAMOS por qualquer perda de dados!\n'));
|
|
15
|
+
|
|
16
|
+
console.log(chalk.cyan.bold('⚙️ Configuração do smoonb...\n'));
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const configPath = path.join(process.cwd(), '.smoonbrc');
|
|
20
|
+
|
|
21
|
+
if (options.init) {
|
|
22
|
+
// Inicializar configuração
|
|
23
|
+
const defaultConfig = {
|
|
24
|
+
supabase: {
|
|
25
|
+
projectId: '',
|
|
26
|
+
url: '',
|
|
27
|
+
serviceKey: '',
|
|
28
|
+
anonKey: '',
|
|
29
|
+
databaseUrl: ''
|
|
30
|
+
},
|
|
31
|
+
backup: {
|
|
32
|
+
includeFunctions: true,
|
|
33
|
+
includeStorage: true,
|
|
34
|
+
includeAuth: true,
|
|
35
|
+
includeRealtime: true,
|
|
36
|
+
outputDir: './backups',
|
|
37
|
+
pgDumpPath: 'C:\\Program Files\\PostgreSQL\\17\\bin\\pg_dump.exe'
|
|
38
|
+
},
|
|
39
|
+
restore: {
|
|
40
|
+
cleanRestore: false,
|
|
41
|
+
verifyAfterRestore: true
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
await fs.writeFile(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
46
|
+
console.log(chalk.green('✅ Arquivo de configuração criado:'), configPath);
|
|
47
|
+
console.log(chalk.yellow('💡 Edite o arquivo para configurar suas credenciais Supabase'));
|
|
48
|
+
|
|
49
|
+
} else if (options.show) {
|
|
50
|
+
// Mostrar configuração atual
|
|
51
|
+
try {
|
|
52
|
+
const configContent = await fs.readFile(configPath, 'utf8');
|
|
53
|
+
const config = JSON.parse(configContent);
|
|
54
|
+
|
|
55
|
+
console.log(chalk.green('📋 Configuração atual:'));
|
|
56
|
+
console.log(chalk.blue('📁 Arquivo:'), configPath);
|
|
57
|
+
console.log(chalk.gray(JSON.stringify(config, null, 2)));
|
|
58
|
+
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.log(chalk.yellow('⚠️ Arquivo de configuração não encontrado'));
|
|
61
|
+
console.log(chalk.yellow('💡 Use'), chalk.cyan('smoonb config --init'), chalk.yellow('para criar a configuração'));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
} else {
|
|
65
|
+
// Mostrar ajuda
|
|
66
|
+
console.log(chalk.yellow('💡 Opções disponíveis:'));
|
|
67
|
+
console.log(chalk.cyan(' --init'), chalk.gray(' Inicializar arquivo de configuração'));
|
|
68
|
+
console.log(chalk.cyan(' --show'), chalk.gray(' Mostrar configuração atual'));
|
|
69
|
+
console.log(chalk.blue('\n📁 Arquivo de configuração:'), configPath);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error(chalk.red.bold('❌ Erro durante a configuração:'), error.message);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = configCommand;
|
package/src/commands/restore.js
CHANGED
|
@@ -31,6 +31,7 @@ async function restoreCommand(options) {
|
|
|
31
31
|
console.log(chalk.gray(' 1. Use: smoonb restore --project-id <seu-project-id>'));
|
|
32
32
|
console.log(chalk.gray(' 2. Configure: smoonb config --init'));
|
|
33
33
|
console.log(chalk.gray(' 3. Ou defina SUPABASE_PROJECT_ID no ambiente'));
|
|
34
|
+
console.log(chalk.gray(' 4. Ou edite ~/.smoonbrc e configure o projectId'));
|
|
34
35
|
process.exit(1);
|
|
35
36
|
}
|
|
36
37
|
|