The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/scripts/levitate-parse-json-report.js

37 lines
1009 B

const fs = require('fs');
const printAffectedPluginsSection = require('./levitate-show-affected-plugins');
const data = JSON.parse(fs.readFileSync('data.json', 'utf8'));
function stripAnsi(str) {
return str.replace(/\x1b\[[0-9;]*m/g, '');
}
const printSection = (title, items) => {
let output = `<h4>${title}</h4>`;
items.forEach((item) => {
const language = item.declaration ? 'typescript' : 'diff';
const code = item.declaration ? item.declaration : stripAnsi(item.diff);
output += `<b>${item.name}</b><br>\n`;
output += `<sub>${item.location}</sub><br>\n`;
output += `<pre lang="${language}">\n${code}\n</pre><br>\n`;
});
return output;
};
let markdown = '';
if (data.removals.length > 0) {
markdown += printSection('Removals', data.removals);
}
if (data.changes.length > 0) {
markdown += printSection('Changes', data.changes);
}
if (data.removals.length > 0 || data.changes.length > 0) {
markdown += printAffectedPluginsSection(data);
}
console.log(markdown);