smoonb 0.0.42 → 0.0.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smoonb",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "description": "Complete Supabase backup and migration tool - EXPERIMENTAL VERSION - USE AT YOUR OWN RISK",
5
5
  "preferGlobal": false,
6
6
  "preventGlobalInstall": true,
@@ -89,7 +89,7 @@ module.exports = async (options) => {
89
89
  }
90
90
  };
91
91
 
92
- // Listar backups válidos (apenas com .backup.gz)
92
+ // Listar backups válidos (aceita .backup.gz e .backup)
93
93
  async function listValidBackups(backupsDir) {
94
94
  if (!fs.existsSync(backupsDir)) {
95
95
  return [];
@@ -102,7 +102,10 @@ async function listValidBackups(backupsDir) {
102
102
  if (item.isDirectory() && item.name.startsWith('backup-')) {
103
103
  const backupPath = path.join(backupsDir, item.name);
104
104
  const files = fs.readdirSync(backupPath);
105
- const backupFile = files.find(file => file.endsWith('.backup.gz'));
105
+ // Aceitar tanto .backup.gz quanto .backup
106
+ const backupFile = files.find(file =>
107
+ file.endsWith('.backup.gz') || file.endsWith('.backup')
108
+ );
106
109
 
107
110
  if (backupFile) {
108
111
  const manifestPath = path.join(backupPath, 'backup-manifest.json');
@@ -313,9 +316,9 @@ async function confirmExecution() {
313
316
  }
314
317
 
315
318
  // Restaurar Database via psql (conforme documentação oficial Supabase: https://supabase.com/docs/guides/platform/migrating-within-supabase/dashboard-restore)
319
+ // Aceita tanto arquivos .backup.gz quanto .backup já descompactados
316
320
  async function restoreDatabaseGz(backupFilePath, targetDatabaseUrl) {
317
321
  console.log(chalk.blue('📊 Restaurando Database...'));
318
- console.log(chalk.gray(' - Descompactando backup (se necessário)...'));
319
322
 
320
323
  try {
321
324
  const { execSync } = require('child_process');
@@ -324,9 +327,11 @@ async function restoreDatabaseGz(backupFilePath, targetDatabaseUrl) {
324
327
  const fileName = path.basename(backupFilePath);
325
328
  let uncompressedFile = fileName;
326
329
 
327
- // Descompactar .gz se necessário
328
- if (fileName.endsWith('.gz')) {
330
+ // Verificar se é arquivo .backup.gz (compactado) ou .backup (descompactado)
331
+ if (fileName.endsWith('.backup.gz')) {
332
+ console.log(chalk.gray(' - Arquivo .backup.gz detectado'));
329
333
  console.log(chalk.gray(' - Extraindo arquivo .gz...'));
334
+
330
335
  const unzipCmd = [
331
336
  'docker run --rm',
332
337
  `-v "${backupDirAbs}:/host"`,
@@ -336,6 +341,11 @@ async function restoreDatabaseGz(backupFilePath, targetDatabaseUrl) {
336
341
  execSync(unzipCmd, { stdio: 'pipe' });
337
342
  uncompressedFile = fileName.replace('.gz', '');
338
343
  console.log(chalk.gray(' - Arquivo descompactado: ' + uncompressedFile));
344
+ } else if (fileName.endsWith('.backup')) {
345
+ console.log(chalk.gray(' - Arquivo .backup detectado (já descompactado)'));
346
+ console.log(chalk.gray(' - Prosseguindo com restauração direta'));
347
+ } else {
348
+ throw new Error(`Formato de arquivo inválido. Esperado .backup.gz ou .backup, recebido: ${fileName}`);
339
349
  }
340
350
 
341
351
  // Extrair credenciais da URL de conexão