2025-07-25 00:11:30 +03:00
|
|
|
import concatMd, { concatMdSync } from "concat-md";
|
|
|
|
|
import path from "path";
|
|
|
|
|
import fs from "fs";
|
|
|
|
|
|
2026-01-29 16:00:19 +03:00
|
|
|
const resultMd = concatMdSync("./parts", {
|
2025-07-25 00:11:30 +03:00
|
|
|
toc: false,
|
|
|
|
|
sorter: (a, b) => {
|
|
|
|
|
// Извлекаем номер из начала имени файла (например, "1" из "1-assistent.md")
|
|
|
|
|
const getNumber = (filename) => {
|
|
|
|
|
const match = filename.match(/^(\d+)/);
|
|
|
|
|
return match ? parseInt(match[1], 10) : 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Сортировка по возрастанию (1, 2, 3...)
|
|
|
|
|
return getNumber(a) - getNumber(b);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-30 02:02:32 +03:00
|
|
|
// Записываем результат в файл RULES.md в корне проекта
|
|
|
|
|
const outputPath = path.join("./", "RULES.md");
|
2025-07-25 00:11:30 +03:00
|
|
|
fs.writeFileSync(outputPath, resultMd, "utf8");
|
|
|
|
|
|
2026-01-30 02:02:32 +03:00
|
|
|
console.log(`Файл RULES.md успешно создан: ${outputPath}`);
|