smoonb 0.0.29 → 0.0.31

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.29",
3
+ "version": "0.0.31",
4
4
  "description": "Complete Supabase backup and migration tool - EXPERIMENTAL VERSION - USE AT YOUR OWN RISK",
5
5
  "preferGlobal": false,
6
6
  "preventGlobalInstall": true,
@@ -1,6 +1,6 @@
1
1
  const chalk = require('chalk');
2
2
  const path = require('path');
3
- const fs = require('fs');
3
+ const fs = require('fs').promises;
4
4
  const { exec } = require('child_process');
5
5
  const { promisify } = require('util');
6
6
  const { ensureDir, writeJson, copyDir } = require('../utils/fsx');
@@ -285,7 +285,7 @@ async function backupDatabase(projectId, backupDir) {
285
285
  execSync(gzipCmd, { stdio: 'pipe' });
286
286
 
287
287
  const finalFileName = `${fileName}.gz`;
288
- const stats = fs.statSync(path.join(backupDir, finalFileName));
288
+ const stats = await fs.stat(path.join(backupDir, finalFileName));
289
289
  const sizeKB = (stats.size / 1024).toFixed(1);
290
290
 
291
291
  console.log(chalk.green(` ✅ Database backup: ${finalFileName} (${sizeKB} KB)`));
@@ -349,7 +349,7 @@ async function backupEdgeFunctionsWithDocker(projectId, accessToken, backupDir)
349
349
  const sourceDir = path.join(process.cwd(), 'supabase', 'functions', func.name);
350
350
  const targetDir = path.join(functionsDir, func.name);
351
351
 
352
- if (fs.existsSync(sourceDir)) {
352
+ if (await fs.access(sourceDir).then(() => true).catch(() => false)) {
353
353
  await copyDir(sourceDir, targetDir);
354
354
  console.log(chalk.green(` ✅ ${func.name} baixada com sucesso`));
355
355
  successCount++;
@@ -358,7 +358,7 @@ async function backupEdgeFunctionsWithDocker(projectId, accessToken, backupDir)
358
358
  name: func.name,
359
359
  slug: func.name,
360
360
  version: func.version || 'unknown',
361
- files: fs.existsSync(targetDir) ? fs.readdirSync(targetDir) : []
361
+ files: await fs.access(targetDir).then(() => fs.readdir(targetDir)).catch(() => [])
362
362
  });
363
363
  } else {
364
364
  throw new Error('Diretório não encontrado após download');
@@ -523,7 +523,7 @@ async function backupCustomRoles(databaseUrl, backupDir) {
523
523
  // ✅ Usar Supabase CLI via Docker para roles
524
524
  await execAsync(`supabase db dump --db-url "${databaseUrl}" --role-only -f "${customRolesFile}"`);
525
525
 
526
- const stats = fs.statSync(customRolesFile);
526
+ const stats = await fs.stat(customRolesFile);
527
527
  const sizeKB = (stats.size / 1024).toFixed(1);
528
528
 
529
529
  console.log(chalk.green(` ✅ Custom Roles exportados via Docker: ${sizeKB} KB`));
@@ -706,9 +706,9 @@ ORDER BY rolname;
706
706
  await fs.writeFile(jsonFile, JSON.stringify(result, null, 2));
707
707
 
708
708
  // Limpar arquivo temporário
709
- await fs.promises.unlink(sqlFile);
709
+ await fs.unlink(sqlFile);
710
710
 
711
- const stats = fs.statSync(jsonFile);
711
+ const stats = await fs.stat(jsonFile);
712
712
  const sizeKB = (stats.size / 1024).toFixed(1);
713
713
 
714
714
  console.log(chalk.green(` ✅ Database Settings: ${fileName} (${sizeKB} KB)`));
@@ -727,7 +727,7 @@ async function backupRealtimeSettings(projectId, backupDir, skipInteractive = fa
727
727
 
728
728
  const result = await captureRealtimeSettings(projectId, backupDir, skipInteractive);
729
729
 
730
- const stats = fs.statSync(path.join(backupDir, 'realtime-settings.json'));
730
+ const stats = await fs.stat(path.join(backupDir, 'realtime-settings.json'));
731
731
  const sizeKB = (stats.size / 1024).toFixed(1);
732
732
 
733
733
  console.log(chalk.green(` ✅ Realtime Settings capturadas: ${sizeKB} KB`));