2023-12-20 03:09:58 -06:00
|
|
|
const fs = require('fs');
|
|
|
|
|
2024-07-11 04:38:43 -05:00
|
|
|
const printAffectedPluginsSection = require('./levitate-show-affected-plugins');
|
|
|
|
|
2023-12-20 03:09:58 -06:00
|
|
|
const data = JSON.parse(fs.readFileSync('data.json', 'utf8'));
|
|
|
|
|
2024-02-02 02:19:30 -06:00
|
|
|
function stripAnsi(str) {
|
|
|
|
return str.replace(/\x1b\[[0-9;]*m/g, '');
|
|
|
|
}
|
2023-12-20 03:09:58 -06:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2024-02-02 02:19:30 -06:00
|
|
|
output += `<b>${item.name}</b><br>\n`;
|
|
|
|
output += `<sub>${item.location}</sub><br>\n`;
|
|
|
|
output += `<pre lang="${language}">\n${code}\n</pre><br>\n`;
|
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);
|
|
|
|
}
|
|
|
|
|
2024-08-08 04:20:58 -05:00
|
|
|
if (data.removals.length > 0 || data.changes.length > 0) {
|
|
|
|
markdown += printAffectedPluginsSection(data);
|
|
|
|
}
|
2024-07-11 04:38:43 -05:00
|
|
|
|
2023-12-20 03:09:58 -06:00
|
|
|
console.log(markdown);
|