Add detailed debugging for metadata.json processing

- Add file size and content preview debugging
- Track foundMetadata flag state throughout processing
- Add final foundMetadata state logging
- Help identify why metadata.json detection is failing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
riz 2025-11-19 22:55:58 +00:00
parent 0a39249851
commit af7b4c3968
1 changed files with 24 additions and 14 deletions

View File

@ -274,17 +274,27 @@ export const deploy = {
if (entry.filename === 'metadata.json') { if (entry.filename === 'metadata.json') {
console.log(`[DEBUG] Found metadata.json, parsing content...`); console.log(`[DEBUG] Found metadata.json, parsing content...`);
console.log(`[DEBUG] metadata.json file size: ${fileContent.length} bytes`);
const metadataStr = new TextDecoder().decode(fileContent); const metadataStr = new TextDecoder().decode(fileContent);
console.log(`[DEBUG] metadata.json decoded to string, length: ${metadataStr.length}`);
console.log(`[DEBUG] metadata.json preview:`, metadataStr.substring(0, 100));
let metadata; let metadata;
try { try {
metadata = JSON.parse(metadataStr); metadata = JSON.parse(metadataStr);
console.log(`[DEBUG] Successfully parsed metadata.json`); console.log(`[DEBUG] Successfully parsed metadata.json`);
} catch (jsonError) { console.log(`[DEBUG] foundMetadata flag before setting: ${foundMetadata}`);
console.error(`[ERROR] Failed to parse metadata.json: ${jsonError.message}`);
console.error(`[ERROR] JSON content preview:`, metadataStr.substring(0, 200)); // Update deploy content with metadata
throw new Error(`Invalid JSON in metadata.json: ${jsonError.message}`); g.deploy.content.layouts = metadata.layouts || [];
} g.deploy.content.pages = metadata.pages || [];
g.deploy.content.comps = metadata.components || [];
g.deploy.content.site = metadata.site;
foundMetadata = true;
console.log(`[DEBUG] foundMetadata flag after setting: ${foundMetadata}`);
console.log(`[DEBUG] Parsed metadata:`, { console.log(`[DEBUG] Parsed metadata:`, {
layouts: metadata.layouts?.length || 0, layouts: metadata.layouts?.length || 0,
@ -293,12 +303,11 @@ export const deploy = {
hasSite: !!metadata.site hasSite: !!metadata.site
}); });
// Update deploy content with metadata } catch (jsonError) {
g.deploy.content.layouts = metadata.layouts || []; console.error(`[ERROR] Failed to parse metadata.json: ${jsonError.message}`);
g.deploy.content.pages = metadata.pages || []; console.error(`[ERROR] JSON content preview:`, metadataStr.substring(0, 200));
g.deploy.content.comps = metadata.components || []; throw new Error(`Invalid JSON in metadata.json: ${jsonError.message}`);
g.deploy.content.site = metadata.site; }
foundMetadata = true;
} else if (entry.filename.startsWith('public/')) { } else if (entry.filename.startsWith('public/')) {
const relativePath = entry.filename.slice(7); // Remove 'public/' prefix const relativePath = entry.filename.slice(7); // Remove 'public/' prefix
const binaryExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.ico', '.svg', '.woff', '.woff2', '.ttf', '.eot', '.js', '.css', '.map']; const binaryExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.ico', '.svg', '.woff', '.woff2', '.ttf', '.eot', '.js', '.css', '.map'];
@ -348,6 +357,7 @@ export const deploy = {
} }
console.log(`[DEBUG] ZIP processing completed: ${loadedFiles} files loaded`); console.log(`[DEBUG] ZIP processing completed: ${loadedFiles} files loaded`);
console.log(`[DEBUG] Final foundMetadata state: ${foundMetadata}`);
if (!foundMetadata) { if (!foundMetadata) {
console.log(`[DEBUG] Available files in ZIP (${zipEntries.length} total entries):`); console.log(`[DEBUG] Available files in ZIP (${zipEntries.length} total entries):`);