smoonb 0.0.35 → 0.0.37
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 +1 -1
- package/src/commands/backup.js +29 -12
package/package.json
CHANGED
package/src/commands/backup.js
CHANGED
|
@@ -414,23 +414,40 @@ async function backupEdgeFunctionsWithDocker(projectId, accessToken, backupDir)
|
|
|
414
414
|
let successCount = 0;
|
|
415
415
|
let errorCount = 0;
|
|
416
416
|
|
|
417
|
-
// ✅ Baixar cada Edge Function
|
|
417
|
+
// ✅ Baixar cada Edge Function DIRETAMENTE para o backup (sem tocar em ./supabase/functions)
|
|
418
418
|
for (const func of functions) {
|
|
419
419
|
try {
|
|
420
420
|
console.log(chalk.gray(` - Baixando: ${func.name}...`));
|
|
421
421
|
|
|
422
|
-
//
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
422
|
+
// Criar diretório da função DIRETAMENTE no backup
|
|
423
|
+
const functionTargetDir = path.join(functionsDir, func.name);
|
|
424
|
+
await ensureDir(functionTargetDir);
|
|
425
|
+
|
|
426
|
+
// Baixar Edge Function via Supabase CLI DIRETAMENTE para o backup
|
|
427
|
+
const { execSync } = require('child_process');
|
|
428
|
+
const tempBackupDir = path.join(backupDir, 'temp-supabase-download');
|
|
429
|
+
|
|
430
|
+
// Criar estrutura temp para download sem contaminar ./supabase/
|
|
431
|
+
await ensureDir(tempBackupDir);
|
|
432
|
+
|
|
433
|
+
// Download para diretório temporário
|
|
434
|
+
execSync(`supabase functions download ${func.name}`, {
|
|
435
|
+
cwd: tempBackupDir,
|
|
436
|
+
timeout: 60000,
|
|
437
|
+
stdio: 'pipe'
|
|
426
438
|
});
|
|
427
439
|
|
|
428
|
-
// Mover
|
|
429
|
-
const
|
|
430
|
-
const targetDir = path.join(functionsDir, func.name);
|
|
440
|
+
// Mover de temp para o backup final
|
|
441
|
+
const tempFunctionDir = path.join(tempBackupDir, 'supabase', 'functions', func.name);
|
|
431
442
|
|
|
432
|
-
|
|
433
|
-
|
|
443
|
+
// Verificar se existe usando fs.promises.access
|
|
444
|
+
try {
|
|
445
|
+
await fs.access(tempFunctionDir);
|
|
446
|
+
await copyDir(tempFunctionDir, functionTargetDir);
|
|
447
|
+
|
|
448
|
+
// Limpar diretório temporário
|
|
449
|
+
await fs.rm(tempBackupDir, { recursive: true, force: true }).catch(() => {});
|
|
450
|
+
|
|
434
451
|
console.log(chalk.green(` ✅ ${func.name} baixada com sucesso`));
|
|
435
452
|
successCount++;
|
|
436
453
|
|
|
@@ -438,9 +455,9 @@ async function backupEdgeFunctionsWithDocker(projectId, accessToken, backupDir)
|
|
|
438
455
|
name: func.name,
|
|
439
456
|
slug: func.name,
|
|
440
457
|
version: func.version || 'unknown',
|
|
441
|
-
files: await fs.
|
|
458
|
+
files: await fs.readdir(functionTargetDir).catch(() => [])
|
|
442
459
|
});
|
|
443
|
-
}
|
|
460
|
+
} catch (innerError) {
|
|
444
461
|
throw new Error('Diretório não encontrado após download');
|
|
445
462
|
}
|
|
446
463
|
|