smoonb 1.0.7 → 1.0.8
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/CHANGELOG.md +26 -0
- package/README.md +23 -7
- package/README.pt-BR.md +23 -7
- package/package.json +4 -3
- package/src/commands/backup/steps/06-realtime-settings.js +19 -33
- package/src/commands/backup/steps/07-storage.js +7 -12
- package/src/commands/backup/steps/09-edge-functions.js +76 -202
- package/src/commands/restore/auth-fields.json +237 -0
- package/src/commands/restore/dump.js +284 -0
- package/src/commands/restore/index.js +4 -126
- package/src/commands/restore/management.js +74 -0
- package/src/commands/restore/pg.js +83 -0
- package/src/commands/restore/runner.js +117 -0
- package/src/commands/restore/steps/03-database.js +18 -84
- package/src/commands/restore/steps/04-edge-functions.js +95 -122
- package/src/commands/restore/steps/05-auth-settings.js +26 -54
- package/src/commands/restore/steps/06-storage.js +203 -584
- package/src/commands/restore/steps/07-database-settings.js +87 -69
- package/src/commands/restore/steps/08-realtime-settings.js +61 -53
- package/src/i18n/locales/en.json +797 -797
- package/src/i18n/locales/pt-BR.json +796 -796
- package/src/utils/supabaseCli.js +32 -0
|
@@ -1,54 +1,26 @@
|
|
|
1
|
-
const
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (authSettings.settings?.auth_url_config) {
|
|
29
|
-
Object.entries(authSettings.settings.auth_url_config).forEach(([key, value]) => {
|
|
30
|
-
console.log(chalk.white(` - ${key}: ${value}`));
|
|
31
|
-
});
|
|
32
|
-
} else if (authSettings.auth_url_config) {
|
|
33
|
-
Object.entries(authSettings.auth_url_config).forEach(([key, value]) => {
|
|
34
|
-
console.log(chalk.white(` - ${key}: ${value}`));
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.log(chalk.yellow(`\n ⚠️ ${getT('restore.steps.auth.pressEnter')}`));
|
|
39
|
-
|
|
40
|
-
await inquirer.prompt([{
|
|
41
|
-
type: 'input',
|
|
42
|
-
name: 'continue',
|
|
43
|
-
message: getT('restore.steps.auth.pressEnter'),
|
|
44
|
-
prefix: ''
|
|
45
|
-
}]);
|
|
46
|
-
|
|
47
|
-
console.log(chalk.green(` ✅ ${getT('restore.steps.auth.success')}`));
|
|
48
|
-
|
|
49
|
-
} catch (error) {
|
|
50
|
-
const getT = global.smoonbI18n?.t || t;
|
|
51
|
-
console.error(chalk.red(` ❌ ${getT('restore.steps.auth.error', { message: error.message })}`));
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { applyConfig } = require('../management');
|
|
4
|
+
const { remapServiceUrls } = require('../dump');
|
|
5
|
+
const allowed = require('../auth-fields.json');
|
|
6
|
+
module.exports = async ({ backupPath, targetProject, remapUrls = true }) => {
|
|
7
|
+
const backup = JSON.parse(
|
|
8
|
+
fs.readFileSync(path.join(backupPath, 'auth-settings.json'), 'utf8'),
|
|
9
|
+
);
|
|
10
|
+
const settings =
|
|
11
|
+
backup.settings?.auth_url_config ||
|
|
12
|
+
backup.settings ||
|
|
13
|
+
backup.auth_url_config;
|
|
14
|
+
if (!settings || !Object.keys(settings).length)
|
|
15
|
+
throw new Error('Auth configuration missing from backup');
|
|
16
|
+
const desired = remapUrls
|
|
17
|
+
? JSON.parse(
|
|
18
|
+
remapServiceUrls(
|
|
19
|
+
JSON.stringify(settings),
|
|
20
|
+
backup.project_id,
|
|
21
|
+
targetProject.targetProjectId,
|
|
22
|
+
),
|
|
23
|
+
)
|
|
24
|
+
: settings;
|
|
25
|
+
return applyConfig(targetProject, 'config/auth', desired, allowed);
|
|
26
|
+
};
|