smoonb 0.0.74 → 0.0.76

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.
Files changed (29) hide show
  1. package/package.json +1 -1
  2. package/src/commands/backup/index.js +62 -65
  3. package/src/commands/backup/steps/00-docker-validation.js +6 -4
  4. package/src/commands/backup/steps/01-database.js +8 -4
  5. package/src/commands/backup/steps/02-database-separated.js +11 -8
  6. package/src/commands/backup/steps/03-database-settings.js +8 -4
  7. package/src/commands/backup/steps/04-auth-settings.js +6 -3
  8. package/src/commands/backup/steps/05-realtime-settings.js +5 -2
  9. package/src/commands/backup/steps/06-storage.js +29 -26
  10. package/src/commands/backup/steps/07-custom-roles.js +6 -3
  11. package/src/commands/backup/steps/08-edge-functions.js +15 -11
  12. package/src/commands/backup/steps/09-supabase-temp.js +9 -6
  13. package/src/commands/backup/steps/10-migrations.js +14 -10
  14. package/src/commands/check.js +5 -3
  15. package/src/commands/restore/index.js +51 -46
  16. package/src/commands/restore/steps/00-backup-selection.js +6 -4
  17. package/src/commands/restore/steps/01-components-selection.js +30 -28
  18. package/src/commands/restore/steps/03-database.js +21 -17
  19. package/src/commands/restore/steps/04-edge-functions.js +16 -13
  20. package/src/commands/restore/steps/05-auth-settings.js +10 -7
  21. package/src/commands/restore/steps/06-storage.js +50 -42
  22. package/src/commands/restore/steps/07-database-settings.js +10 -7
  23. package/src/commands/restore/steps/08-realtime-settings.js +10 -7
  24. package/src/commands/restore/utils.js +15 -13
  25. package/src/i18n/locales/en.json +427 -1
  26. package/src/i18n/locales/pt-BR.json +426 -1
  27. package/src/interactive/envMapper.js +30 -25
  28. package/src/utils/realtime-settings.js +15 -9
  29. package/src/utils/supabaseLink.js +11 -10
@@ -1,6 +1,7 @@
1
1
  const readline = require('readline');
2
2
  const fs = require('fs').promises;
3
3
  const path = require('path');
4
+ const { t } = require('../i18n');
4
5
 
5
6
  /**
6
7
  * Captura configurações de Realtime Settings interativamente
@@ -16,8 +17,10 @@ async function captureRealtimeSettings(projectId, backupDir, skipInteractive = f
16
17
  // Tentar ler configurações de backup anterior
17
18
  const previousSettings = await getPreviousRealtimeSettings(backupDir);
18
19
 
20
+ const getT = global.smoonbI18n?.t || t;
21
+
19
22
  if (skipInteractive && previousSettings) {
20
- console.log('📋 Copiando Realtime Settings do backup anterior...');
23
+ console.log(`📋 ${getT('utils.realtime.copying')}`);
21
24
  await fs.writeFile(settingsFile, JSON.stringify(previousSettings, null, 2));
22
25
  return previousSettings;
23
26
  }
@@ -25,23 +28,23 @@ async function captureRealtimeSettings(projectId, backupDir, skipInteractive = f
25
28
  if (previousSettings && !skipInteractive) {
26
29
  const shouldReuse = await askToReusePreviousSettings();
27
30
  if (shouldReuse) {
28
- console.log('📋 Reutilizando configurações de Realtime Settings do backup anterior...');
31
+ console.log(`📋 ${getT('utils.realtime.reusing')}`);
29
32
  await fs.writeFile(settingsFile, JSON.stringify(previousSettings, null, 2));
30
33
  return previousSettings;
31
34
  }
32
35
  }
33
36
 
34
37
  // Capturar configurações interativamente
35
- console.log('\n🔧 Configurações de Realtime Settings');
36
- console.log(''.repeat(50));
37
- console.log(`📱 Acesse: ${dashboardUrl}`);
38
- console.log('📝 Anote os valores dos 7 parâmetros abaixo:\n');
38
+ console.log(`\n🔧 ${getT('utils.realtime.configTitle')}`);
39
+ console.log(getT('utils.realtime.separator'));
40
+ console.log(`📱 ${getT('utils.realtime.access', { url: dashboardUrl })}`);
41
+ console.log(`📝 ${getT('utils.realtime.note')}\n`);
39
42
 
40
43
  const settings = await captureSettingsInteractively(projectId, previousSettings);
41
44
 
42
45
  // Salvar configurações
43
46
  await fs.writeFile(settingsFile, JSON.stringify(settings, null, 2));
44
- console.log('\n✅ Configurações de Realtime Settings salvas!');
47
+ console.log(`\n✅ ${getT('utils.realtime.saved')}`);
45
48
 
46
49
  return settings;
47
50
  }
@@ -87,13 +90,14 @@ async function getPreviousRealtimeSettings(backupDir) {
87
90
  * @returns {Promise<boolean>} true se deve reutilizar
88
91
  */
89
92
  async function askToReusePreviousSettings() {
93
+ const getT = global.smoonbI18n?.t || t;
90
94
  const rl = readline.createInterface({
91
95
  input: process.stdin,
92
96
  output: process.stdout
93
97
  });
94
98
 
95
99
  return new Promise((resolve) => {
96
- rl.question('🔄 Foi identificada uma gravação anterior de Realtime Settings.\n Deseja reutilizar as configurações anteriores? (S/n): ', (answer) => {
100
+ rl.question(`🔄 ${getT('utils.realtime.previousFound')}\n ${getT('utils.realtime.reuse')} (S/n): `, (answer) => {
97
101
  rl.close();
98
102
  const shouldReuse = !answer.toLowerCase().startsWith('n');
99
103
  resolve(shouldReuse);
@@ -121,8 +125,10 @@ async function captureSettingsInteractively(projectId, previousSettings) {
121
125
  });
122
126
  };
123
127
 
128
+ const getT = global.smoonbI18n?.t || t;
129
+
124
130
  try {
125
- console.log('📋 Responda as perguntas abaixo (pressione Enter para usar o valor padrão):\n');
131
+ console.log(`📋 ${getT('utils.realtime.questions')}\n`);
126
132
 
127
133
  // Valores padrão baseados na imagem ou configurações anteriores
128
134
  const defaults = previousSettings?.realtime_settings?.settings || {
@@ -2,6 +2,7 @@ const chalk = require('chalk');
2
2
  const path = require('path');
3
3
  const fs = require('fs').promises;
4
4
  const { execSync } = require('child_process');
5
+ const { t } = require('../i18n');
5
6
 
6
7
  /**
7
8
  * Extrai a senha da URL de conexão PostgreSQL
@@ -9,9 +10,11 @@ const { execSync } = require('child_process');
9
10
  * @returns {string} - Senha extraída
10
11
  */
11
12
  function extractPasswordFromDbUrl(dbUrl) {
13
+ const { t } = require('../i18n');
14
+ const getT = global.smoonbI18n?.t || t;
12
15
  const urlMatch = dbUrl.match(/postgresql:\/\/([^:]+):([^@]+)@([^:]+):(\d+)\/(.+)/);
13
16
  if (!urlMatch) {
14
- throw new Error('Database URL inválida');
17
+ throw new Error(getT('error.databaseUrlInvalidSimple'));
15
18
  }
16
19
  const [, , password] = urlMatch;
17
20
  return password;
@@ -25,10 +28,11 @@ function extractPasswordFromDbUrl(dbUrl) {
25
28
  * @returns {Promise<void>}
26
29
  */
27
30
  async function ensureCleanLink(projectRef, accessToken, dbPassword) {
31
+ const getT = global.smoonbI18n?.t || t;
28
32
  const tempDir = path.join(process.cwd(), 'supabase', '.temp');
29
33
 
30
34
  // Remover supabase/.temp completamente
31
- console.log(chalk.white(` - Zerando vínculo e linkando projeto: ${projectRef}...`));
35
+ console.log(chalk.white(` - ${getT('utils.supabaseLink.linking', { projectId: projectRef })}`));
32
36
 
33
37
  try {
34
38
  await fs.rm(tempDir, { recursive: true, force: true });
@@ -50,7 +54,7 @@ async function ensureCleanLink(projectRef, accessToken, dbPassword) {
50
54
  env
51
55
  });
52
56
  } catch (error) {
53
- throw new Error(`Falha ao linkar projeto ${projectRef}: ${error.message}`);
57
+ throw new Error(getT('utils.supabaseLink.linkFailed', { projectId: projectRef, message: error.message }));
54
58
  }
55
59
 
56
60
  // Validar: ler supabase/.temp/project-ref e verificar se == projectRef
@@ -60,18 +64,15 @@ async function ensureCleanLink(projectRef, accessToken, dbPassword) {
60
64
  const linkedRefTrimmed = linkedRef.trim();
61
65
 
62
66
  if (linkedRefTrimmed !== projectRef) {
63
- throw new Error(
64
- `Validação falhou: linked-ref = ${linkedRefTrimmed} (esperado = ${projectRef}). ` +
65
- `O projeto linkado não corresponde ao projeto esperado.`
66
- );
67
+ throw new Error(getT('utils.supabaseLink.validationFailed', { linkedRef: linkedRefTrimmed, expected: projectRef }));
67
68
  }
68
69
 
69
- console.log(chalk.white(` - Validação: linked-ref = ${linkedRefTrimmed} (esperado = ${projectRef})`));
70
+ console.log(chalk.white(` - ${getT('utils.supabaseLink.validation', { linkedRef: linkedRefTrimmed, expected: projectRef })}`));
70
71
  } catch (error) {
71
- if (error.message.includes('Validação falhou')) {
72
+ if (error.message.includes('Validation failed') || error.message.includes('Validação falhou')) {
72
73
  throw error;
73
74
  }
74
- throw new Error(`Não foi possível validar o vínculo: ${error.message}`);
75
+ throw new Error(getT('utils.supabaseLink.cannotValidate', { message: error.message }));
75
76
  }
76
77
  }
77
78