Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version-file: '.nvmrc'
cache: 'pnpm'
- run: pnpm install
- run: pnpm prettier:check
- run: pnpm lint:check
- run: pnpm tsc --noEmit
- run: pnpm test -- --coverage --runInBand --verbose
- name: Coveralls
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,3 @@ temp/

dist/
build/
.vscode/settings.json
4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports.biome": "explicit",
"quickfix.biome": "explicit"
},
"editor.defaultFormatter": "biomejs.biome"
}
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ The release process is automated. Follow the steps below.

### Tests

There are 2 checks - one for prettier and one for the unit tests with `jest`.
There are 2 checks - one for biome (linter & formatter) and one for the unit tests with `jest`.

```
// Run prettier to check
pnpm prettier:check
```shell
# Run biome to check linting and formatting
pnpm lint:check

// Run linter & unit tests with coverage
pnpm test
# Run unit tests with coverage
pnpm test

// If you want to pass arguments to jest (or other `pnpm` commands)
// like `--watch`, you can prepend `--` to the command
pnpm test -- --watch
# If you want to pass arguments to jest (or other `pnpm` commands)
# like `--watch`, you can prepend `--` to the command
pnpm test -- --watch
```

### FAQ
Expand Down
30 changes: 30 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"useExhaustiveDependencies": "warn"
}
}
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"json": {
"parser": {
"allowComments": true
}
}
}
20 changes: 10 additions & 10 deletions first-run.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { app, dialog } = require('electron');
const { app, dialog } = require("electron");

const fs = require('fs');
const path = require('path');
const fs = require("fs");
const path = require("path");

async function onFirstRunMaybe() {
if (isFirstRun()) {
Expand All @@ -11,16 +11,16 @@ async function onFirstRunMaybe() {

// Ask user if the app should be moved to the applications folder.
async function promptMoveToApplicationsFolder() {
if (process.platform !== 'darwin') return;
if (process.platform !== "darwin") return;

const isDevMode = !!process.defaultApp;
if (isDevMode || app.isInApplicationsFolder()) return;

const { response } = await dialog.showMessageBox({
type: 'question',
buttons: ['Move to Applications Folder', 'Do Not Move'],
type: "question",
buttons: ["Move to Applications Folder", "Do Not Move"],
defaultId: 0,
message: 'Move to Applications Folder?',
message: "Move to Applications Folder?",
});

if (response === 0) {
Expand All @@ -29,8 +29,8 @@ async function promptMoveToApplicationsFolder() {
}

const getConfigPath = () => {
const userDataPath = app.getPath('userData');
return path.join(userDataPath, 'FirstRun', 'gitify-first-run');
const userDataPath = app.getPath("userData");
return path.join(userDataPath, "FirstRun", "gitify-first-run");
};

// Whether or not the app is being run for the first time.
Expand All @@ -47,7 +47,7 @@ function isFirstRun() {
fs.mkdirSync(firstRunFolder);
}

fs.writeFileSync(configPath, '');
fs.writeFileSync(configPath, "");
} catch (error) {
console.warn(`First run: Unable to write firstRun file`, error);
}
Expand Down
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
preset: 'ts-jest/presets/js-with-ts',
setupFiles: ['<rootDir>/src/__helpers__/setupEnvVars.js'],
testEnvironment: 'jsdom',
preset: "ts-jest/presets/js-with-ts",
setupFiles: ["<rootDir>/src/__helpers__/setupEnvVars.js"],
testEnvironment: "jsdom",
collectCoverage: true,
coverageThreshold: {
global: {
Expand All @@ -11,7 +11,7 @@ const config = {
moduleNameMapper: {
// Force CommonJS build for http adapter to be available.
// via https://github.com/axios/axios/issues/5101#issuecomment-1276572468
'^axios$': require.resolve('axios'),
"^axios$": require.resolve("axios"),
},
};

Expand Down
60 changes: 30 additions & 30 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const { ipcMain, app, nativeTheme } = require('electron');
const { menubar } = require('menubar');
const { autoUpdater } = require('electron-updater');
const { onFirstRunMaybe } = require('./first-run');
const path = require('path');
const { ipcMain, app, nativeTheme } = require("electron");
const { menubar } = require("menubar");
const { autoUpdater } = require("electron-updater");
const { onFirstRunMaybe } = require("./first-run");
const path = require("path");

require('@electron/remote/main').initialize();
require("@electron/remote/main").initialize();

app.setAppUserModelId('com.electron.gitify');
app.setAppUserModelId("com.electron.gitify");

const iconIdle = path.join(
__dirname,
'assets',
'images',
'tray-idleTemplate.png',
"assets",
"images",
"tray-idleTemplate.png",
);
const iconActive = path.join(__dirname, 'assets', 'images', 'tray-active.png');
const iconActive = path.join(__dirname, "assets", "images", "tray-active.png");

const browserWindowOpts = {
width: 500,
Expand All @@ -30,7 +30,7 @@ const browserWindowOpts = {
},
};

app.on('ready', async () => {
app.on("ready", async () => {
await onFirstRunMaybe();
});

Expand All @@ -42,66 +42,66 @@ const menubarApp = menubar({
showDockIcon: false,
});

menubarApp.on('ready', () => {
menubarApp.on("ready", () => {
menubarApp.tray.setIgnoreDoubleClickEvents(true);

autoUpdater.checkForUpdatesAndNotify();

nativeTheme.on('updated', () => {
nativeTheme.on("updated", () => {
if (nativeTheme.shouldUseDarkColors) {
menubarApp.window.webContents.send('update-native-theme', 'DARK');
menubarApp.window.webContents.send("update-native-theme", "DARK");
} else {
menubarApp.window.webContents.send('update-native-theme', 'LIGHT');
menubarApp.window.webContents.send("update-native-theme", "LIGHT");
}
});

ipcMain.handle('get-platform', async () => {
ipcMain.handle("get-platform", async () => {
return process.platform;
});
ipcMain.handle('get-app-version', async () => {
ipcMain.handle("get-app-version", async () => {
return app.getVersion();
});

ipcMain.on('reopen-window', () => menubarApp.showWindow());
ipcMain.on('hide-window', () => menubarApp.hideWindow());
ipcMain.on("reopen-window", () => menubarApp.showWindow());
ipcMain.on("hide-window", () => menubarApp.hideWindow());

ipcMain.on('app-quit', () => menubarApp.app.quit());
ipcMain.on('update-icon', (_, arg) => {
ipcMain.on("app-quit", () => menubarApp.app.quit());
ipcMain.on("update-icon", (_, arg) => {
if (!menubarApp.tray.isDestroyed()) {
if (arg === 'TrayActive') {
if (arg === "TrayActive") {
menubarApp.tray.setImage(iconActive);
} else {
menubarApp.tray.setImage(iconIdle);
}
}
});
ipcMain.on('update-title', (_, title) => {
ipcMain.on("update-title", (_, title) => {
if (!menubarApp.tray.isDestroyed()) {
menubarApp.tray.setTitle(title);
}
});
ipcMain.on('set-login-item-settings', (event, settings) => {
ipcMain.on("set-login-item-settings", (event, settings) => {
app.setLoginItemSettings(settings);
});

menubarApp.window.webContents.on('devtools-opened', () => {
menubarApp.window.webContents.on("devtools-opened", () => {
menubarApp.window.setSize(800, 600);
menubarApp.window.center();
menubarApp.window.resizable = true;
});

menubarApp.window.webContents.on('devtools-closed', () => {
menubarApp.window.webContents.on("devtools-closed", () => {
const trayBounds = menubarApp.tray.getBounds();
menubarApp.window.setSize(
browserWindowOpts.width,
browserWindowOpts.height,
);
menubarApp.positioner.move('trayCenter', trayBounds);
menubarApp.positioner.move("trayCenter", trayBounds);
menubarApp.window.resizable = false;
});

menubarApp.window.webContents.on('before-input-event', (event, input) => {
if (input.key === 'Escape') {
menubarApp.window.webContents.on("before-input-event", (event, input) => {
if (input.key === "Escape") {
menubarApp.window.hide();
event.preventDefault();
}
Expand Down
23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"make:linux": "electron-builder --linux",
"make:macos": "electron-builder --mac --universal",
"make:win": "electron-builder --win",
"prettier:check": "prettier --check '*.{html,js,json,md,ts,tsx}'",
"prettier:apply": "prettier --write '*.{html,js,json,md,ts,tsx}'",
"lint:check": "biome check *",
"lint": "biome check --apply *",
"test": "jest",
"start": "electron . --enable-logging",
"prepare": "husky"
Expand Down Expand Up @@ -50,6 +50,10 @@
{
"name": "Adam Setch",
"url": "https://github.com/setchy"
},
{
"name": "Afonso Ramos",
"url": "https://github.com/afonsojramos"
}
],
"license": "MIT",
Expand All @@ -76,9 +80,7 @@
"gatekeeperAssess": false,
"entitlements": "./entitlements/entitlements.mac.plist",
"entitlementsInherit": "./entitlements/entitlements.mac.plist",
"publish": [
"github"
],
"publish": ["github"],
"extendInfo": {
"NSBluetoothAlwaysUsageDescription": null,
"NSBluetoothPeripheralUsageDescription": null,
Expand All @@ -98,12 +100,7 @@
"oneClick": false
},
"linux": {
"target": [
"AppImage",
"deb",
"rpm",
"snap"
],
"target": ["AppImage", "deb", "rpm", "snap"],
"category": "Development",
"maintainer": "Emmanouil Konstantinidis"
},
Expand All @@ -127,6 +124,7 @@
"typescript": "5.4.4"
},
"devDependencies": {
"@biomejs/biome": "1.6.4",
"@electron/notarize": "2.3.0",
"@testing-library/react": "14.2.2",
"@types/jest": "29.5.12",
Expand All @@ -146,7 +144,6 @@
"nock": "13.5.4",
"postcss": "8.4.38",
"postcss-loader": "8.1.1",
"prettier": "3.2.5",
"react-test-renderer": "18.2.0",
"rimraf": "5.0.5",
"style-loader": "3.3.4",
Expand All @@ -158,6 +155,6 @@
},
"packageManager": "[email protected]",
"lint-staged": {
"*.{html,js,json,md,ts,tsx}": "prettier --write"
"*.{html,js,json,md,ts,tsx}": "biome format --write"
}
}
Loading