From 098c9e30fd2e4859505e640dc5185adb9ffa3f74 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Thu, 29 Jan 2026 13:50:37 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Improve=20code=20formatting=20and?= =?UTF-8?q?=20readability=20in=20build=20verification=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pokedex.online/scripts/verify-build.js | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/code/websites/pokedex.online/scripts/verify-build.js b/code/websites/pokedex.online/scripts/verify-build.js index ec23735..2b28903 100644 --- a/code/websites/pokedex.online/scripts/verify-build.js +++ b/code/websites/pokedex.online/scripts/verify-build.js @@ -1,6 +1,6 @@ /** * Build Verification Script - * + * * Verifies that the production build was successful and contains * all necessary files for deployment. */ @@ -37,11 +37,13 @@ console.log('\nšŸ“‹ Checking required files:'); for (const file of REQUIRED_FILES) { const filePath = path.join(DIST_DIR, file); const exists = fs.existsSync(filePath); - + if (exists) { const stats = fs.statSync(filePath); const isDir = stats.isDirectory(); - console.log(` āœ… ${file} ${isDir ? '(directory)' : `(${(stats.size / 1024).toFixed(2)} KB)`}`); + console.log( + ` āœ… ${file} ${isDir ? '(directory)' : `(${(stats.size / 1024).toFixed(2)} KB)`}` + ); } else { errors.push(`Required file missing: ${file}`); console.log(` āŒ ${file} - MISSING`); @@ -55,30 +57,34 @@ if (fs.existsSync(assetsDir)) { const files = fs.readdirSync(assetsDir); const jsFiles = files.filter(f => f.endsWith('.js')); const cssFiles = files.filter(f => f.endsWith('.css')); - + if (jsFiles.length === 0) { errors.push('No JavaScript bundles found in assets/'); console.log(' āŒ No JavaScript bundles found'); } else { console.log(` āœ… Found ${jsFiles.length} JavaScript bundles`); - + // Show bundle sizes const totalJsSize = jsFiles.reduce((total, file) => { const stats = fs.statSync(path.join(assetsDir, file)); return total + stats.size; }, 0); - console.log(` Total JS size: ${(totalJsSize / 1024 / 1024).toFixed(2)} MB`); - + console.log( + ` Total JS size: ${(totalJsSize / 1024 / 1024).toFixed(2)} MB` + ); + // Warn if bundles are too large jsFiles.forEach(file => { const stats = fs.statSync(path.join(assetsDir, file)); const sizeMB = stats.size / 1024 / 1024; if (sizeMB > 1) { - warnings.push(`Large bundle detected: ${file} (${sizeMB.toFixed(2)} MB)`); + warnings.push( + `Large bundle detected: ${file} (${sizeMB.toFixed(2)} MB)` + ); } }); } - + if (cssFiles.length === 0) { warnings.push('No CSS files found in assets/'); console.log(' āš ļø No CSS files found'); @@ -95,7 +101,7 @@ console.log('\nšŸ“„ Checking index.html:'); const indexPath = path.join(DIST_DIR, 'index.html'); if (fs.existsSync(indexPath)) { const content = fs.readFileSync(indexPath, 'utf8'); - + // Check for script tags const scriptTags = content.match(/]*src="[^"]*"[^>]*>/g); if (scriptTags && scriptTags.length > 0) { @@ -104,7 +110,7 @@ if (fs.existsSync(indexPath)) { errors.push('No script tags found in index.html'); console.log(' āŒ No script tags found'); } - + // Check for stylesheet links const linkTags = content.match(/]*rel="stylesheet"[^>]*>/g); if (linkTags && linkTags.length > 0) { @@ -123,18 +129,18 @@ console.log('\nšŸ“Š Build Statistics:'); function getDirSize(dirPath) { let size = 0; const files = fs.readdirSync(dirPath); - + for (const file of files) { const filePath = path.join(dirPath, file); const stats = fs.statSync(filePath); - + if (stats.isDirectory()) { size += getDirSize(filePath); } else { size += stats.size; } } - + return size; }