Repository: opossum-tool/OpossumUI
Pull request #2499 (2024-01-14 18:58:47)

fix(deps): update dependency electron-is-dev to v3
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [electron-is-dev](https://togithub.com/sindresorhus/electron-is-dev) | [`^2.0.0` -> `^3.0.1`](https://renovatebot.com/diffs/npm/electron-is-dev/2.0.0/3.0.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/electron-is-dev/3.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/electron-is-dev/3.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/electron-is-dev/2.0.0/3.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/electron-is-dev/2.0.0/3.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>sindresorhus/electron-is-dev (electron-is-dev)</summary>

### [`v3.0.1`](https://togithub.com/sindresorhus/electron-is-dev/releases/tag/v3.0.1)

[Compare Source](https://togithub.com/sindresorhus/electron-is-dev/compare/v3.0.0...v3.0.1)

-   Fix missing field in package.json  [`8a7f7df`](https://togithub.com/sindresorhus/electron-is-dev/commit/8a7f7df)

### [`v3.0.0`](https://togithub.com/sindresorhus/electron-is-dev/releases/tag/v3.0.0)

[Compare Source](https://togithub.com/sindresorhus/electron-is-dev/compare/v2.0.0...v3.0.0)

##### Breaking

-   Require Electron 28  [`8e0dbe5`](https://togithub.com/sindresorhus/electron-is-dev/commit/8e0dbe5)
-   This package is now pure ESM. **Please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) and [this](https://www.electronjs.org/docs/latest/tutorial/esm).**

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/opossum-tool/OpossumUI).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->


mstykow: This upgrade requires electron 28 which we cannot use until #2391 is merged.
leslielazzarino: I'll wait until we update to Electron 28.
renovate[bot]: ### Edited/Blocked Notification

Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.

You can manually request rebase by checking the rebase/retry box above.

 ⚠ **Warning**: custom changes will be lost.

Patch:
diff --git a/package.json b/package.json
index a37713d2..f9813df3 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,6 @@
     "compare-versions": "^6.1.0",
     "dayjs": "^1.11.10",
     "electron-devtools-installer": "^3.2.0",
-    "electron-is-dev": "^2.0.0",
     "electron-log": "^5.0.4",
     "electron-settings": "^4.0.2",
     "fast-csv": "^5.0.0",
diff --git a/renovate.json5 b/renovate.json5
index ff392688..389b2e32 100644
--- a/renovate.json5
+++ b/renovate.json5
@@ -28,7 +28,6 @@
         'cross-env',
         'dayjs',
         'electron-devtools-installer',
-        'electron-is-dev',
         'electron-log',
         'electron-playwright-helpers',
         'electron-settings',
diff --git a/src/ElectronBackend/app.ts b/src/ElectronBackend/app.ts
index cf3f209a..8dc95d96 100644
--- a/src/ElectronBackend/app.ts
+++ b/src/ElectronBackend/app.ts
@@ -7,7 +7,6 @@ import installExtension, {
   REACT_DEVELOPER_TOOLS,
   REDUX_DEVTOOLS,
 } from 'electron-devtools-installer';
-import isDev from 'electron-is-dev';
 
 import { main } from './main/main';
 
@@ -18,7 +17,7 @@ app.on('window-all-closed', () => {
 });
 
 app.on('ready', () => {
-  if (isDev) {
+  if (!app.isPackaged) {
     [REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS].forEach((extension) => {
       installExtension(extension)
         .then((name) => console.log(`Added Extension: ${name}`))
diff --git a/src/ElectronBackend/main/createWindow.ts b/src/ElectronBackend/main/createWindow.ts
index 5ff9b1a6..16eee841 100644
--- a/src/ElectronBackend/main/createWindow.ts
+++ b/src/ElectronBackend/main/createWindow.ts
@@ -3,8 +3,7 @@
 // SPDX-FileCopyrightText: Nico Carl <nicocarl@protonmail.com>
 //
 // SPDX-License-Identifier: Apache-2.0
-import { BrowserWindow } from 'electron';
-import isDev from 'electron-is-dev';
+import { app, BrowserWindow } from 'electron';
 import path from 'path';
 import upath from 'upath';
 
@@ -23,7 +22,7 @@ export async function createWindow(): Promise<BrowserWindow> {
     icon: getIconPath(),
   });
 
-  if (isDev) {
+  if (!app.isPackaged) {
     await mainWindow.loadURL('http://localhost:5173/');
 
     mainWindow.webContents.openDevTools();
diff --git a/src/ElectronBackend/main/getPath.ts b/src/ElectronBackend/main/getPath.ts
index 460b6eb3..f4c6ecd1 100644
--- a/src/ElectronBackend/main/getPath.ts
+++ b/src/ElectronBackend/main/getPath.ts
@@ -1,13 +1,13 @@
 // SPDX-FileCopyrightText: Tarun Samanta <tarunsamanta77@gmail.com>
 //
 // SPDX-License-Identifier: Apache-2.0
-import isDev from 'electron-is-dev';
+import { app } from 'electron';
 import path from 'path';
 import upath from 'upath';
 
 export function getBasePathOfAssets(): string {
-  const basePath = isDev
-    ? path.join(upath.toUnix(__dirname), '../../../public/assets')
-    : path.join(upath.toUnix(__dirname), '../../assets');
+  const basePath = app.isPackaged
+    ? path.join(upath.toUnix(__dirname), '../../assets')
+    : path.join(upath.toUnix(__dirname), '../../../public/assets');
   return basePath;
 }
diff --git a/src/ElectronBackend/main/iconHelpers.ts b/src/ElectronBackend/main/iconHelpers.ts
index ba05c188..6005a818 100644
--- a/src/ElectronBackend/main/iconHelpers.ts
+++ b/src/ElectronBackend/main/iconHelpers.ts
@@ -2,17 +2,16 @@
 // SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
 //
 // SPDX-License-Identifier: Apache-2.0
-import electron, { Menu } from 'electron';
-import isDev from 'electron-is-dev';
+import electron, { app, Menu } from 'electron';
 import path from 'path';
 import upath from 'upath';
 
 import { getBasePathOfAssets } from './getPath';
 
 export function getIconPath(): string {
-  const basePath = isDev
-    ? path.join(upath.toUnix(__dirname), '../../../public')
-    : path.join(upath.toUnix(__dirname), '../..');
+  const basePath = app.isPackaged
+    ? path.join(upath.toUnix(__dirname), '../..')
+    : path.join(upath.toUnix(__dirname), '../../../public');
   return path.join(basePath, 'icons/icon_512x512.png');
 }
 
diff --git a/src/ElectronBackend/main/notice-document-helpers.ts b/src/ElectronBackend/main/notice-document-helpers.ts
index 2fb35f52..0a11706b 100644
--- a/src/ElectronBackend/main/notice-document-helpers.ts
+++ b/src/ElectronBackend/main/notice-document-helpers.ts
@@ -2,11 +2,11 @@
 // SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
 //
 // SPDX-License-Identifier: Apache-2.0
-import isDev from 'electron-is-dev';
+import { app } from 'electron';
 import path from 'path';
 
 function getNoticesDirectory(): string {
-  if (isDev) {
+  if (!app.isPackaged) {
     return path.join(__dirname, '..', '..', '..', 'notices');
   }
 
diff --git a/yarn.lock b/yarn.lock
index 43c58e24..e03a60cf 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5933,13 +5933,6 @@ __metadata:
   languageName: node
   linkType: hard
 
-"electron-is-dev@npm:^2.0.0":
-  version: 2.0.0
-  resolution: "electron-is-dev@npm:2.0.0"
-  checksum: 7393f46f06153d70a427ea904c60a092e50fbf1015c26c342cebb8324ada8c9e0c0f1f02867af56d9cc76f47be17da8cb311ea6bdc83343e7ebd2323ec4014c8
-  languageName: node
-  linkType: hard
-
 "electron-log@npm:^5.0.4":
   version: 5.1.0
   resolution: "electron-log@npm:5.1.0"
@@ -9918,7 +9911,6 @@ __metadata:
     electron: "npm:28.1.4"
     electron-builder: "npm:^24.9.1"
     electron-devtools-installer: "npm:^3.2.0"
-    electron-is-dev: "npm:^2.0.0"
     electron-log: "npm:^5.0.4"
     electron-playwright-helpers: "npm:^1.7.0"
     electron-settings: "npm:^4.0.2"


Test patch:
diff --git a/src/ElectronBackend/main/__tests__/createWindowDev.test.ts b/src/ElectronBackend/main/__tests__/createWindowDev.test.ts
index e7a3d547..59e519e7 100644
--- a/src/ElectronBackend/main/__tests__/createWindowDev.test.ts
+++ b/src/ElectronBackend/main/__tests__/createWindowDev.test.ts
@@ -11,6 +11,7 @@ jest.mock('electron', () => ({
     getName: jest.fn(),
     getVersion: jest.fn(),
     whenReady: async (): Promise<unknown> => Promise.resolve(true),
+    isPackaged: false,
   },
   BrowserWindow: class BrowserWindowMock {
     constructor() {
@@ -34,8 +35,6 @@ jest.mock('electron', () => ({
   },
 }));
 
-jest.mock('electron-is-dev', () => true);
-
 describe('createWindow', () => {
   it('returns correct BrowserWindow in devMode', async () => {
     const browserWindow = await createWindow();
diff --git a/src/ElectronBackend/main/__tests__/createWindowProd.test.ts b/src/ElectronBackend/main/__tests__/createWindowProd.test.ts
index e48abf4a..6dc2655e 100644
--- a/src/ElectronBackend/main/__tests__/createWindowProd.test.ts
+++ b/src/ElectronBackend/main/__tests__/createWindowProd.test.ts
@@ -11,6 +11,7 @@ jest.mock('electron', () => ({
     getName: jest.fn(),
     getVersion: jest.fn(),
     whenReady: async (): Promise<unknown> => Promise.resolve(true),
+    isPackaged: true,
   },
   BrowserWindow: class BrowserWindowMock {
     constructor() {
@@ -34,7 +35,6 @@ jest.mock('electron', () => ({
   },
 }));
 
-jest.mock('electron-is-dev', () => false);
 jest.mock('../iconHelpers', () => ({
   getIconPath: (): string => {
     return 'icon/path.png';
diff --git a/src/ElectronBackend/main/__tests__/iconHelpers.test.ts b/src/ElectronBackend/main/__tests__/iconHelpers.test.ts
index dd89c838..5eb52d0d 100644
--- a/src/ElectronBackend/main/__tests__/iconHelpers.test.ts
+++ b/src/ElectronBackend/main/__tests__/iconHelpers.test.ts
@@ -7,13 +7,15 @@ import { Menu, MenuItem } from 'electron';
 import { makeFirstIconVisibleAndSecondHidden } from '../iconHelpers';
 
 jest.mock('electron', () => ({
+  app: {
+    isPackaged: true,
+  },
   Menu: {
     setApplicationMenu: jest.fn(),
     buildFromTemplate: jest.fn(),
     getApplicationMenu: jest.fn(),
   },
 }));
-jest.mock('electron-is-dev', () => false);
 
 describe('makeFirstIconVisibleAndSecondHidden', () => {
   let toBeVisibleMenuItem: Partial<MenuItem>;
diff --git a/src/ElectronBackend/main/__tests__/mainErrorCase.test.ts b/src/ElectronBackend/main/__tests__/mainErrorCase.test.ts
index e949e1dc..1c63031c 100644
--- a/src/ElectronBackend/main/__tests__/mainErrorCase.test.ts
+++ b/src/ElectronBackend/main/__tests__/mainErrorCase.test.ts
@@ -16,6 +16,7 @@ jest.mock('electron', () => ({
     getName: jest.fn(),
     getVersion: jest.fn(),
     whenReady: (): Promise<boolean> => Promise.resolve(true),
+    isPackaged: true,
   },
   BrowserWindow: class BrowserWindowMock {
     constructor() {