Skip to content

Commit

Permalink
feat: add podman version when reporting an issue (#427)
Browse files Browse the repository at this point in the history
also format data from json

---------

Co-authored-by: jgresham <johnsgresham@gmail.com>
  • Loading branch information
Gathin23 and jgresham committed May 9, 2024
1 parent 2dcad94 commit 6f20303
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { app } from 'electron';

import { getArch } from './arch';
import { getPlatform } from './platform';
import { getInstalledPodmanVersion } from './podman/install/install';
import { getOperatingSystemInfo } from './systemInfo.js';

export default async function getDebugInfo() {
let niceNodeVersion = app.getVersion();
const podmanVersion = await getInstalledPodmanVersion();

if (process.env.NODE_ENV === 'development') {
niceNodeVersion = `Dev-${niceNodeVersion}`;
Expand All @@ -23,12 +25,14 @@ export default async function getDebugInfo() {
arch: getArch(),
freeMemory: os.freemem(),
totalMemory: os.totalmem(),
podmanVersion,
niceNodeVersion,
};
}

const getDebugInfoShort = async () => {
let niceNodeVersion = app.getVersion();
const podmanVersion = await getInstalledPodmanVersion();

if (process.env.NODE_ENV === 'development') {
niceNodeVersion = `Dev-${niceNodeVersion}`;
Expand All @@ -43,8 +47,8 @@ const getDebugInfoShort = async () => {
release: release,
arch: getArch(),
totalMemory: os.totalmem(),
podmanVersion,
niceNodeVersion,
// ethereumNodeVersion: gethBuildNameForPlatformAndArch(),
};
};

Expand All @@ -58,18 +62,24 @@ export const getDebugInfoString = async () => {

export const getDebugInfoShortString = async () => {
try {
return JSON.stringify(await getDebugInfoShort(), null, 2);
const formattedString = JSON.stringify(await getDebugInfoShort(), null, 2)
.replace(/[{}"]/g, '')
.replace(/:/g, ': ')
.replace(/,\n/g, '\n')
.replace(/(^|\n)\s*\w/g, (s) => s.toUpperCase());

return formattedString;
} catch (err) {
return 'No system details.';
}
};

export const getGithubIssueProblemURL = async () => {
const url = new URL('https://github.com/NiceNode/nice-node/issues/new');
const debugInfo = await getDebugInfoShortString();
url.searchParams.set(
'body',
`Problem description\n-\n<!-- Describe your problem on the next line! Thank you -->\n\n\nFor NiceNode developers\n-\n${await getDebugInfoShortString()}`,
`Problem description\n-\n<!-- Describe your problem on the next line! Thank you -->\n\n\nFor NiceNode developers\n-\n${debugInfo}`,
);

return url.toString();
};

0 comments on commit 6f20303

Please sign in to comment.