refactor(core): move app para src e padroniza estrutura

This commit is contained in:
Felipe Coutinho
2026-03-12 19:22:50 +00:00
parent d92e70f1b9
commit b0fbb1062a
567 changed files with 8981 additions and 5014 deletions

View File

@@ -0,0 +1,72 @@
import fs from "node:fs";
import path from "node:path";
export type ChangelogSection = {
type: string;
items: string[];
};
export type ChangelogVersion = {
version: string;
date: string;
sections: ChangelogSection[];
/** Linha de contribuições/autor (pode conter markdown, ex: [Nome](url)) */
contributor?: string;
};
export function parseChangelog(): ChangelogVersion[] {
const filePath = path.join(process.cwd(), "CHANGELOG.md");
const content = fs.readFileSync(filePath, "utf-8");
const lines = content.split("\n");
const versions: ChangelogVersion[] = [];
let currentVersion: ChangelogVersion | null = null;
let currentSection: ChangelogSection | null = null;
for (const line of lines) {
const versionMatch = line.match(/^## \[(.+?)\] - (.+)$/);
if (versionMatch) {
if (currentSection && currentVersion) {
currentVersion.sections.push(currentSection);
}
const [y, m, d] = versionMatch[2].split("-");
currentVersion = {
version: versionMatch[1],
date: d && m && y ? `${d}/${m}/${y}` : versionMatch[2],
sections: [],
};
versions.push(currentVersion);
currentSection = null;
continue;
}
const sectionMatch = line.match(/^### (.+)$/);
if (sectionMatch && currentVersion) {
if (currentSection) {
currentVersion.sections.push(currentSection);
}
currentSection = { type: sectionMatch[1], items: [] };
continue;
}
const itemMatch = line.match(/^- (.+)$/);
if (itemMatch && currentSection) {
currentSection.items.push(itemMatch[1]);
continue;
}
// **Contribuições:** ou **Autor:** com texto/link opcional
const contributorMatch = line.match(
/^\*\*(?:Contribuições|Autor):\*\*\s*(.+)$/,
);
if (contributorMatch && currentVersion) {
currentVersion.contributor = contributorMatch[1].trim() || undefined;
}
}
if (currentSection && currentVersion) {
currentVersion.sections.push(currentSection);
}
return versions;
}