Update llmdumper.php

This commit is contained in:
2025-11-12 22:33:12 +02:00
parent 29992b7f83
commit 7c0a354464

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* LLM Dumper for PrestaShop Modules * LLM Dumper for PrestaShop Modules
* *
@@ -33,6 +34,7 @@ define('OUTPUT_FILE', '.llmdump');
// The directory to exclude. Typically for Composer packages. // The directory to exclude. Typically for Composer packages.
define('VENDOR_DIR', 'vendor'); define('VENDOR_DIR', 'vendor');
define('GIT_DIR', '.git');
// A list of image file extensions to exclude. Case-insensitive. // A list of image file extensions to exclude. Case-insensitive.
const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'ico', 'bmp']; const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'ico', 'bmp'];
@@ -81,7 +83,9 @@ foreach ($fileIterator as $file) {
if (strpos($filePath, DIRECTORY_SEPARATOR . VENDOR_DIR . DIRECTORY_SEPARATOR) !== false) { if (strpos($filePath, DIRECTORY_SEPARATOR . VENDOR_DIR . DIRECTORY_SEPARATOR) !== false) {
continue; continue;
} }
if (strpos($filePath, DIRECTORY_SEPARATOR . GIT_DIR . DIRECTORY_SEPARATOR) !== false) {
continue;
}
// We only care about files, not directories. // We only care about files, not directories.
if ($file->isDir()) { if ($file->isDir()) {
continue; continue;
@@ -100,14 +104,14 @@ foreach ($fileIterator as $file) {
// Prepend the module directory name to the relative path as requested. // Prepend the module directory name to the relative path as requested.
$finalPath = $moduleDirName . DIRECTORY_SEPARATOR . $relativePath; $finalPath = $moduleDirName . DIRECTORY_SEPARATOR . $relativePath;
// Read the file content. // Read the file content.
$content = file_get_contents($filePath); $content = file_get_contents($filePath);
if ($content === false) { if ($content === false) {
echo "WARNING: Could not read file: {$finalPath}\n"; echo "WARNING: Could not read file: {$finalPath}\n";
continue; continue;
} }
// Create a header for this file's content to identify it in the dump. // Create a header for this file's content to identify it in the dump.
$fileHeader = " $fileHeader = "
//- - - - - - - - - - START: {$finalPath} - - - - - - - - - -// //- - - - - - - - - - START: {$finalPath} - - - - - - - - - -//
@@ -135,5 +139,3 @@ echo "Dump complete!\n";
echo "- Files processed: {$fileCount}\n"; echo "- Files processed: {$fileCount}\n";
echo "- Total size: " . round($totalBytes / 1024, 2) . " KB\n"; echo "- Total size: " . round($totalBytes / 1024, 2) . " KB\n";
echo "- Output file: {$outputFilePath}\n"; echo "- Output file: {$outputFilePath}\n";
?>