From e860fcfbaa02057a5002f39f27eb75691df8de77 Mon Sep 17 00:00:00 2001 From: Sonia Sandler <66797193+SoniaSandler@users.noreply.github.com> Date: Thu, 16 Apr 2026 20:03:27 -0400 Subject: [PATCH] chore: update electron app name to be from product.json and use correct logs files paths (#17107) * chore: update electron app name to be from product.json and use correct logs files paths Signed-off-by: Sonia Sandler * chore: update copyrights years Signed-off-by: Sonia Sandler --- packages/main/src/main.ts | 3 ++- .../main/src/plugin/troubleshooting.spec.ts | 22 ++++++++----------- packages/main/src/plugin/troubleshooting.ts | 9 ++++---- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/main/src/main.ts b/packages/main/src/main.ts index fdd3e1b4019..855783212c7 100644 --- a/packages/main/src/main.ts +++ b/packages/main/src/main.ts @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (C) 2022-2025 Red Hat, Inc. + * Copyright (C) 2022-2026 Red Hat, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ export class Main implements IDisposable { constructor(app: ElectronApp) { this.app = app; + this.app.name = product.name; this.mainWindowDeferred = Promise.withResolvers(); this.protocolLauncher = new ProtocolLauncher(this.mainWindowDeferred); this.#plugins = [new DefaultProtocolClient(this.app), new WindowPlugin(this.app, this.mainWindowDeferred.resolve)]; diff --git a/packages/main/src/plugin/troubleshooting.spec.ts b/packages/main/src/plugin/troubleshooting.spec.ts index 98de6ddb183..4c5435f37b3 100644 --- a/packages/main/src/plugin/troubleshooting.spec.ts +++ b/packages/main/src/plugin/troubleshooting.spec.ts @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (C) 2024 Red Hat, Inc. + * Copyright (C) 2024-2026 Red Hat, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import { beforeEach, describe, expect, test, vi } from 'vitest'; import type { DialogRegistry } from '/@/plugin/dialog-registry.js'; import { Uri } from '/@/plugin/types/uri.js'; +import product from '/@product.json' with { type: 'json' }; import type { TroubleshootingFileMap } from './troubleshooting.js'; import { Troubleshooting } from './troubleshooting.js'; @@ -52,8 +53,12 @@ vi.mock('adm-zip', () => { }; }); +vi.mock(import('/@product.json')); + beforeEach(() => { vi.resetAllMocks(); + vi.mocked(product).name = 'Test Id'; + vi.mocked(product).artifactName = 'test-id'; }); describe('saveLogs', () => { @@ -190,14 +195,8 @@ test('Should return getMacSystemLogs if the platform is darwin', async () => { expect(readFileMock).toHaveBeenCalledTimes(2); // Expect readFileMock to have been called with /Library/Logs/Podman Desktop/launchd-stdout.log but CONTAINED in the path - expect(readFileMock).toHaveBeenCalledWith( - expect.stringContaining('/Library/Logs/Podman Desktop/launchd-stdout'), - 'utf-8', - ); - expect(readFileMock).toHaveBeenCalledWith( - expect.stringContaining('/Library/Logs/Podman Desktop/launchd-stderr'), - 'utf-8', - ); + expect(readFileMock).toHaveBeenCalledWith(expect.stringContaining('/Library/Logs/Test Id/launchd-stdout'), 'utf-8'); + expect(readFileMock).toHaveBeenCalledWith(expect.stringContaining('/Library/Logs/Test Id/launchd-stderr'), 'utf-8'); }); // Should return getWindowsSystemLogs if the platform is win32 @@ -225,10 +224,7 @@ test('Should return getWindowsSystemLogs if the platform is win32', async () => expect(readFileMock).toHaveBeenCalledTimes(1); // Expect readFileMock to have been called with ~/AppData/Roaming/Podman Desktop/logs/podman-desktop.log but CONTAINED in the path - expect(readFileMock).toHaveBeenCalledWith( - expect.stringContaining('/AppData/Roaming/Podman Desktop/logs/podman-desktop'), - 'utf-8', - ); + expect(readFileMock).toHaveBeenCalledWith(expect.stringContaining('/AppData/Roaming/Test Id/logs/test-id'), 'utf-8'); }); // test generateLogFileName for different cases diff --git a/packages/main/src/plugin/troubleshooting.ts b/packages/main/src/plugin/troubleshooting.ts index 02aba2aba54..3c7380d3506 100644 --- a/packages/main/src/plugin/troubleshooting.ts +++ b/packages/main/src/plugin/troubleshooting.ts @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (C) 2024-2025 Red Hat, Inc. + * Copyright (C) 2024-2026 Red Hat, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import moment from 'moment'; import { DialogRegistry } from '/@/plugin/dialog-registry.js'; import { Uri } from '/@/plugin/types/uri.js'; +import product from '/@product.json' with { type: 'json' }; const SYSTEM_FILENAME = 'system'; @@ -45,7 +46,7 @@ export class Troubleshooting { // all the logs and save them to a zip file. // this also takes in the console logs and adds them to the zip file (see preload/src/index.ts) regarding memoryLogs async saveLogs(console: { logType: LogType; message: string }[]): Promise { - const defaultUri = this.generateLogFileName('podman-desktop', 'zip'); + const defaultUri = this.generateLogFileName(product.artifactName, 'zip'); const uri = await this.dialogRegistry.saveDialog({ title: 'Save Logs as .zip', defaultUri: Uri.file(defaultUri) }); if (!uri) { @@ -81,10 +82,10 @@ export class Troubleshooting { case 'darwin': return this.getLogsFromFiles( ['launchd-stdout.log', 'launchd-stderr.log'], - `${os.homedir()}/Library/Logs/Podman Desktop`, + `${os.homedir()}/Library/Logs/${product.name}`, ); case 'win32': - return this.getLogsFromFiles(['podman-desktop'], `${os.homedir()}/AppData/Roaming/Podman Desktop/logs`); + return this.getLogsFromFiles([product.artifactName], `${os.homedir()}/AppData/Roaming/${product.name}/logs`); default: // Unsupported platform, so do not return anything return [];