2023-12-20 03:09:58 -06:00
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const data = JSON.parse(fs.readFileSync('data.json', 'utf8'));
|
|
|
|
|
|
|
|
const stripAnsi = (string) => string.replace(/\u001b\[.*?m/g, '');
|
|
|
|
|
|
|
|
const printSection = (title, items) => {
|
2023-12-20 06:40:47 -06:00
|
|
|
let output = `<h4>${title}</h4>`;
|
2023-12-20 03:09:58 -06:00
|
|
|
items.forEach((item) => {
|
2023-12-20 06:40:47 -06:00
|
|
|
const language = item.declaration ? 'typescript' : 'diff';
|
|
|
|
const code = item.declaration ? item.declaration : stripAnsi(item.diff);
|
|
|
|
|
|
|
|
output += `<b>${item.name}</b><br>`;
|
|
|
|
output += `<sub>${item.location}</sub><br>`;
|
|
|
|
output += `<pre lang="${language}">${code}</pre><br>`;
|
2023-12-20 03:09:58 -06:00
|
|
|
});
|
|
|
|
return output;
|
|
|
|
};
|
|
|
|
|
|
|
|
let markdown = '';
|
|
|
|
|
|
|
|
if (data.removals.length > 0) {
|
|
|
|
markdown += printSection('Removals', data.removals);
|
|
|
|
}
|
|
|
|
if (data.changes.length > 0) {
|
|
|
|
markdown += printSection('Changes', data.changes);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(markdown);
|