mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Fix levitate detailed report and improve error treatment (#91617)
This commit is contained in:
parent
875fdb18b4
commit
bf24454007
@ -30,6 +30,8 @@ if (data.changes.length > 0) {
|
|||||||
markdown += printSection('Changes', data.changes);
|
markdown += printSection('Changes', data.changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
markdown += printAffectedPluginsSection(data);
|
if (data.removals.length > 0 || data.changes.length > 0) {
|
||||||
|
markdown += printAffectedPluginsSection(data);
|
||||||
|
}
|
||||||
|
|
||||||
console.log(markdown);
|
console.log(markdown);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const { execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the package name from a given location string.
|
* Extracts the package name from a given location string.
|
||||||
@ -13,8 +14,18 @@ const { execSync } = require('child_process');
|
|||||||
* @returns {string} - The extracted package name, or an empty string if no match is found.
|
* @returns {string} - The extracted package name, or an empty string if no match is found.
|
||||||
*/
|
*/
|
||||||
function getPackage(location) {
|
function getPackage(location) {
|
||||||
const match = location.match(/\/(@[^@]+)@/);
|
const match = location.match(/(.+\/)dist\//);
|
||||||
return match ? match[1] : '';
|
if (match) {
|
||||||
|
const packageJsonPath = match[1] + 'package.json';
|
||||||
|
const data = fs.readFileSync(packageJsonPath, 'utf8');
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return JSON.parse(data)?.name || '';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const PANEL_URL = 'https://ops.grafana-ops.net/d/dmb2o0xnz/imported-property-details?orgId=1';
|
const PANEL_URL = 'https://ops.grafana-ops.net/d/dmb2o0xnz/imported-property-details?orgId=1';
|
||||||
@ -63,6 +74,10 @@ function makeQuery(section) {
|
|||||||
.filter((item) => item !== undefined)
|
.filter((item) => item !== undefined)
|
||||||
.join(' OR ');
|
.join(' OR ');
|
||||||
|
|
||||||
|
if (!whereClause) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
return `
|
return `
|
||||||
SELECT
|
SELECT
|
||||||
property_name,
|
property_name,
|
||||||
@ -113,6 +128,10 @@ function printAffectedPluginsSection(data) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const sqlQuery = makeQuery([...removals, ...changes]);
|
const sqlQuery = makeQuery([...removals, ...changes]);
|
||||||
|
if (!sqlQuery) {
|
||||||
|
throw new Error("Couldn't generate SQL query");
|
||||||
|
}
|
||||||
|
|
||||||
const cmd = `bq query --nouse_legacy_sql "${sqlQuery}"`;
|
const cmd = `bq query --nouse_legacy_sql "${sqlQuery}"`;
|
||||||
const stdout = execSync(cmd, { encoding: 'utf-8' });
|
const stdout = execSync(cmd, { encoding: 'utf-8' });
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user