diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e220f4c63..1f70af23c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,6 +14,7 @@ jobs: name: Tests uses: ./.github/workflows/test.yml needs: lint + secrets: inherit publish: name: Publish diff --git a/package.json b/package.json index 414e536a5..82488b9cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitify", - "version": "5.18.0", + "version": "6.0.0", "description": "GitHub notifications on your menu bar.", "main": "build/main.js", "scripts": { @@ -129,7 +129,7 @@ "repo": "gitify" }, "afterSign": "scripts/notarize.js", - "afterPack": "scripts/remove-unused-locales.js" + "afterPack": "scripts/afterPack.js" }, "dependencies": { "@electron/remote": "2.1.2", diff --git a/scripts/remove-unused-locales.js b/scripts/afterPack.js similarity index 63% rename from scripts/remove-unused-locales.js rename to scripts/afterPack.js index fadaa9bbc..20b77d826 100644 --- a/scripts/remove-unused-locales.js +++ b/scripts/afterPack.js @@ -8,15 +8,31 @@ const electronLanguages = packageJson.build.electronLanguages; /** * @param {AfterPackContext} context */ -const removeLocales = async (context) => { +const afterPack = async (context) => { + // biome-ignore lint/suspicious/noConsoleLog: disabled + console.log('[afterPack]: Starting...'); + const appName = context.packager.appInfo.productFilename; const appOutDir = context.appOutDir; const platform = context.electronPlatformName; - if (platform !== 'darwin') { - return; + if (platform === 'darwin') { + removeUnusedLocales(appOutDir, appName); } + // biome-ignore lint/suspicious/noConsoleLog: disabled + console.log('[afterPack]: Completed'); +}; + +/** + * Removes unused locales for macOS builds. + * @param {string} appOutDir + * @param {string} appName + */ +const removeUnusedLocales = (appOutDir, appName) => { + // biome-ignore lint/suspicious/noConsoleLog: disabled + console.log('[afterPack]: removing unused locales'); + const resourcesPath = path.join( appOutDir, `${appName}.app`, @@ -44,4 +60,4 @@ const removeLocales = async (context) => { } }; -exports.default = removeLocales; +exports.default = afterPack; diff --git a/src/main/main.ts b/src/main/main.ts index 2c7a15a67..67ddc93b6 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -4,7 +4,8 @@ import { menubar } from 'menubar'; import { APPLICATION } from '../shared/constants'; import { namespacedEvent } from '../shared/events'; -import { isMacOS, isWindows } from '../shared/platform'; +import { logInfo, logWarn } from '../shared/logger'; +import { isLinux, isMacOS, isWindows } from '../shared/platform'; import { onFirstRunMaybe } from './first-run'; import { TrayIcons } from './icons'; import MenuBuilder from './menu'; @@ -90,6 +91,31 @@ app.whenReady().then(async () => { }); }); + /** Prevent second instances */ + if (isWindows() || isLinux()) { + const gotTheLock = app.requestSingleInstanceLock(); + + if (!gotTheLock) { + logWarn('main:gotTheLock', 'Second instance detected, quitting'); + app.quit(); // Quit the second instance + return; + } + + app.on('second-instance', (_event, commandLine, _workingDirectory) => { + logInfo( + 'main:second-instance', + 'Second instance was launched. extracting command to forward', + ); + + // Get the URL from the command line arguments + const url = commandLine.find((arg) => arg.startsWith(`${protocol}://`)); + + if (url) { + handleURL(url); + } + }); + } + /** * Gitify custom IPC events */ @@ -183,5 +209,13 @@ ipc.handle(namespacedEvent('safe-storage-decrypt'), (_, settings) => { // Handle gitify:// custom protocol URL events for OAuth 2.0 callback app.on('open-url', (event, url) => { event.preventDefault(); - mb.window.webContents.send(namespacedEvent('auth-callback'), url); + logInfo('main:open-url', `URL received ${url}`); + handleURL(url); }); + +const handleURL = (url: string) => { + if (url.startsWith(`${protocol}://`)) { + logInfo('main:handleUrl', `forwarding URL ${url} to renderer process`); + mb.window.webContents.send(namespacedEvent('auth-callback'), url); + } +}; diff --git a/src/renderer/routes/Accounts.tsx b/src/renderer/routes/Accounts.tsx index 125f362d1..b8caa70b0 100644 --- a/src/renderer/routes/Accounts.tsx +++ b/src/renderer/routes/Accounts.tsx @@ -121,7 +121,7 @@ export const AccountsRoute: FC = () => { return ( diff --git a/src/renderer/routes/__snapshots__/Accounts.test.tsx.snap b/src/renderer/routes/__snapshots__/Accounts.test.tsx.snap index d5694394c..927322e10 100644 --- a/src/renderer/routes/__snapshots__/Accounts.test.tsx.snap +++ b/src/renderer/routes/__snapshots__/Accounts.test.tsx.snap @@ -89,7 +89,7 @@ exports[`renderer/routes/Accounts.tsx Account interactions should render with PA class="Box-sc-g0xbh4-0 grow overflow-x-auto px-8 pb-2 mb-12 " >
{ + logInfo( + 'renderer:auth-callback', + `received authentication callback URL ${callbackUrl}`, + ); handleCallback(callbackUrl); }, );