Refactor SVG processing scripts and add new functionality

- Updated `svg-cleanup.js` to improve SVG file processing and validation.
- Refactored `update-data.js` to streamline the data update process and integrate new scripts for generating image variants and syncing data files.
- Introduced `generate-variants.js` to handle the conversion of SVG files to PNG and JPG formats.
- Created `sync-data.js` to synchronize logo data with the filesystem, ensuring accurate representation of available images.
- Enhanced error handling and logging throughout the scripts for better debugging and user feedback.
- Added support for processing all collections or a specific collection based on command-line arguments or environment variables.
This commit is contained in:
sHa
2025-06-19 17:09:45 +03:00
parent 1db0f1cbe9
commit 374ece5142
11 changed files with 424 additions and 386 deletions

View File

@@ -106,24 +106,24 @@ function processSvgFiles(collectionName) {
}
const imagesDir = path.join(__dirname, '..', 'public', collection.baseDir);
if (!fs.existsSync(imagesDir)) {
console.error(`Directory does not exist: ${imagesDir}`);
return;
}
console.log(`Processing SVG files in collection: ${collection.label}`);
const files = fs.readdirSync(imagesDir);
const svgFiles = files.filter(file => /\.svg$/i.test(file));
console.log(`Found ${svgFiles.length} SVG files`);
for (const file of svgFiles) {
const svgPath = path.join(imagesDir, file);
validateAndFixSvg(svgPath);
}
console.log(`Completed processing SVG files for ${collection.label}`);
}