65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
import fs from "fs";
|
|
import path from "path";
|
|
|
|
const CONFIG = {
|
|
// Папки для сканирования
|
|
includeDirs: ["app", "components", "lib", "types"],
|
|
// Исключения
|
|
excludeDirs: ["node_modules", ".next", ".git", "public"],
|
|
// Только TypeScript файлы
|
|
extensions: [".ts", ".tsx"],
|
|
outputFile: "project_dump.txt",
|
|
};
|
|
|
|
let outputContent = "";
|
|
|
|
function readFilesRecursively(dir) {
|
|
const files = fs.readdirSync(dir);
|
|
|
|
files.forEach((file) => {
|
|
const filePath = path.join(dir, file);
|
|
const stat = fs.statSync(filePath);
|
|
|
|
if (stat.isDirectory()) {
|
|
if (!CONFIG.excludeDirs.includes(file)) {
|
|
readFilesRecursively(filePath);
|
|
}
|
|
} else {
|
|
const ext = path.extname(file);
|
|
if (CONFIG.extensions.includes(ext)) {
|
|
const content = fs.readFileSync(filePath, "utf8");
|
|
outputContent += `\n\n--- FILE: ${filePath} ---\n\n`;
|
|
outputContent += content;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
console.log("🚀 Сборка TypeScript кода началась...");
|
|
|
|
// Обрабатываем основные папки
|
|
CONFIG.includeDirs.forEach((dir) => {
|
|
if (fs.existsSync(dir)) {
|
|
readFilesRecursively(dir);
|
|
}
|
|
});
|
|
|
|
// Дополнительно проверяем только ts/tsx файлы в корне (если они есть)
|
|
const rootFiles = fs
|
|
.readdirSync(".")
|
|
.filter(
|
|
(f) =>
|
|
fs.statSync(f).isFile() && CONFIG.extensions.includes(path.extname(f)),
|
|
);
|
|
|
|
rootFiles.forEach((file) => {
|
|
const content = fs.readFileSync(file, "utf8");
|
|
outputContent += `\n\n--- FILE: ${file} ---\n\n`;
|
|
outputContent += content;
|
|
});
|
|
|
|
fs.writeFileSync(CONFIG.outputFile, outputContent);
|
|
console.log(`\n✅ Готово!`);
|
|
console.log(`📄 Файл: ${CONFIG.outputFile}`);
|
|
console.log(`💡 Теперь в дампе только чистый код .ts и .tsx`);
|