Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: prepare v6.0.0 release #1806

Merged
merged 12 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
name: Tests
uses: ./.github/workflows/test.yml
needs: lint
secrets: inherit

publish:
name: Publish
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
24 changes: 20 additions & 4 deletions scripts/remove-unused-locales.js → scripts/afterPack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down Expand Up @@ -44,4 +60,4 @@ const removeLocales = async (context) => {
}
};

exports.default = removeLocales;
exports.default = afterPack;
38 changes: 36 additions & 2 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
}
};
2 changes: 1 addition & 1 deletion src/renderer/routes/Accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const AccountsRoute: FC = () => {
return (
<Box
key={accountUUID}
className="rounded-md p-2 bg-gitify-accounts"
className="rounded-md p-2 mb-4 bg-gitify-accounts"
>
<Stack direction="vertical" align="stretch">
<Stack direction="horizontal" align="start">
Expand Down
18 changes: 9 additions & 9 deletions src/renderer/routes/__snapshots__/Accounts.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/renderer/utils/auth/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import semver from 'semver';
import { ipcRenderer } from 'electron';
import { APPLICATION } from '../../../shared/constants';
import { namespacedEvent } from '../../../shared/events';
import { logError, logWarn } from '../../../shared/logger';
import { logError, logInfo, logWarn } from '../../../shared/logger';
import type {
Account,
AuthCode,
Expand Down Expand Up @@ -62,6 +62,10 @@ export function authGitHub(
ipcRenderer.on(
namespacedEvent('auth-callback'),
(_, callbackUrl: string) => {
logInfo(
'renderer:auth-callback',
`received authentication callback URL ${callbackUrl}`,
);
handleCallback(callbackUrl);
},
);
Expand Down