upskill-event-manager/fix-css-properly.js
bengizmo 993a820a84 feat: Add comprehensive development artifacts to repository
- Add 26 documentation files including test reports, deployment guides, and troubleshooting documentation
- Include 3 CSV data files for trainer imports and user registration tracking
- Add 43 JavaScript test files covering mobile optimization, Safari compatibility, and E2E testing
- Include 18 PHP utility files for debugging, geocoding, and data analysis
- Add 12 shell scripts for deployment verification, user management, and database operations
- Update .gitignore with whitelist patterns for development files, documentation, and CSV data

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 12:26:11 -03:00

105 lines
No EOL
3.1 KiB
JavaScript

const fs = require('fs');
const path = require('path');
function fixCSSProperly(filePath) {
console.log(`Fixing CSS in ${filePath}...`);
let css = fs.readFileSync(filePath, 'utf8');
// First, remove all the excessive closing braces that are on their own lines
css = css.replace(/^\s*}\s*$/gm, '');
// Now rebuild the CSS with proper structure
let lines = css.split('\n');
let output = [];
let inRule = false;
let inComment = false;
let currentRule = [];
let braceDepth = 0;
for (let i = 0; i < lines.length; i++) {
let line = lines[i];
let trimmed = line.trim();
// Track comments
if (trimmed.includes('/*') && !trimmed.includes('*/')) {
inComment = true;
}
if (trimmed.includes('*/')) {
inComment = false;
}
// Skip empty lines
if (trimmed === '') {
if (!inRule) {
output.push(line);
}
continue;
}
// Count braces
if (!inComment) {
for (let char of line) {
if (char === '{') {
braceDepth++;
inRule = true;
} else if (char === '}') {
braceDepth--;
if (braceDepth === 0) {
inRule = false;
}
}
}
}
// Handle CSS rules
if (inRule) {
currentRule.push(line);
// If we're back at depth 0, output the complete rule
if (braceDepth === 0) {
output.push(...currentRule);
output.push('}'); // Add closing brace
output.push(''); // Add blank line after rule
currentRule = [];
}
} else if (trimmed.startsWith('/*') || trimmed.startsWith('*') || trimmed.startsWith('*/')) {
// Comments outside rules
output.push(line);
} else if (trimmed.includes('{')) {
// Start of a new rule
currentRule = [line];
inRule = true;
} else if (trimmed.startsWith('@')) {
// At-rules like @media, @keyframes
output.push(line);
} else if (trimmed !== '') {
// Other content
output.push(line);
}
}
// Clean up the output
let finalCSS = output.join('\n');
// Remove multiple consecutive empty lines
finalCSS = finalCSS.replace(/\n{3,}/g, '\n\n');
// Ensure closing braces are properly formatted
finalCSS = finalCSS.replace(/}\s*}/g, '}\n}');
// Save the fixed file
fs.writeFileSync(filePath, finalCSS);
console.log(`Fixed ${filePath}`);
}
// Fix the dashboard CSS files
const dashboardCSS = path.join(__dirname, 'assets/css/hvac-dashboard.css');
fixCSSProperly(dashboardCSS);
const enhancedCSS = path.join(__dirname, 'assets/css/hvac-dashboard-enhanced.css');
if (fs.existsSync(enhancedCSS)) {
fixCSSProperly(enhancedCSS);
}
console.log('CSS fixing complete!');