smoonb 0.0.69 → 0.0.70

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.69",
3
+ "version": "0.0.70",
4
4
  "description": "Complete Supabase backup and migration tool - EXPERIMENTAL VERSION - USE AT YOUR OWN RISK",
5
5
  "preferGlobal": false,
6
6
  "preventGlobalInstall": true,
@@ -100,6 +100,7 @@ module.exports = async ({ backupPath, targetProject }) => {
100
100
 
101
101
  // 3. Selecionar o primeiro arquivo .storage.zip encontrado
102
102
  const storageZipFile = path.join(backupPath, storageZipFiles[0]);
103
+ const storageZipBaseName = path.basename(storageZipFiles[0], '.storage.zip');
103
104
  console.log(chalk.white(` - Arquivo de storage encontrado: ${storageZipFiles[0]}`));
104
105
 
105
106
  // 4. Validar credenciais do projeto destino
@@ -155,17 +156,30 @@ module.exports = async ({ backupPath, targetProject }) => {
155
156
  const firstItem = extractedContents[0];
156
157
  const firstItemPath = path.join(extractDir, firstItem);
157
158
  const firstItemStats = await fs.stat(firstItemPath);
158
-
159
+
159
160
  if (firstItemStats.isDirectory()) {
160
161
  // Verificar se o nome da pasta raiz corresponde ao Project ID antigo OU novo
161
- const isProjectId =
162
- (sourceProjectId && firstItem === sourceProjectId) ||
163
- (firstItem === targetProject.targetProjectId);
164
-
162
+ const matchesSourceProjectId = sourceProjectId && firstItem === sourceProjectId;
163
+ const matchesTargetProjectId = firstItem === targetProject.targetProjectId;
164
+ const matchesZipFileName = firstItem === storageZipBaseName;
165
+ const matchesProjectIdPattern = isLikelyProjectId(firstItem);
166
+
167
+ const isProjectId =
168
+ matchesSourceProjectId ||
169
+ matchesTargetProjectId ||
170
+ matchesZipFileName ||
171
+ matchesProjectIdPattern;
172
+
165
173
  if (isProjectId) {
166
174
  // A pasta raiz é um wrapper do Project ID - SEMPRE buscar buckets nas subpastas
167
175
  rootDir = firstItem;
168
- console.log(chalk.white(` - Detectada pasta raiz com Project ID: ${firstItem}`));
176
+ const reasons = [];
177
+ if (matchesSourceProjectId) reasons.push('manifest');
178
+ if (matchesTargetProjectId) reasons.push('projeto destino');
179
+ if (matchesZipFileName) reasons.push('nome do arquivo ZIP');
180
+ if (matchesProjectIdPattern) reasons.push('formato de Project ID');
181
+ const reasonText = reasons.length ? ` (${reasons.join(', ')})` : '';
182
+ console.log(chalk.white(` - Detectada pasta raiz com Project ID: ${firstItem}${reasonText}`));
169
183
  console.log(chalk.white(` - Buscando buckets nas subpastas...`));
170
184
  }
171
185
  }
@@ -551,3 +565,12 @@ function getContentType(fileName) {
551
565
 
552
566
  return contentTypes[ext] || 'application/octet-stream';
553
567
  }
568
+
569
+ function isLikelyProjectId(name) {
570
+ if (!name || typeof name !== 'string') {
571
+ return false;
572
+ }
573
+
574
+ // Project IDs do Supabase são normalmente strings de 20 caracteres alfanuméricos minúsculos
575
+ return /^[a-z0-9]{20}$/.test(name);
576
+ }