Skip to content
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
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ RUN apt-get update \
build-essential \
libudev-dev \
python3 \
python3-setuptools \
ca-certificates \
curl \
xz-utils \
Expand All @@ -28,6 +27,7 @@ RUN apt-get update \
&& rm -f /tmp/SHASUMS256.txt \
&& tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1 --no-same-owner \
&& rm -f /tmp/node.tar.xz \
&& (command -v corepack >/dev/null || npm install -g corepack) \
&& corepack enable \
&& node --version \
&& npm --version \
Expand Down
40 changes: 16 additions & 24 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Install
Expand All @@ -32,10 +32,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Install
Expand All @@ -51,10 +51,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Install
Expand All @@ -77,10 +77,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Install
Expand All @@ -98,10 +98,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Install
Expand Down Expand Up @@ -130,20 +130,12 @@ jobs:
os: [macos-latest, ubuntu-22.04, windows-latest]
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Setup Python 3.9
uses: actions/setup-python@v7
with:
python-version: "3.9"

- name: Install required python deps
run: python3 -m pip install setuptools

- name: Install
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
Expand Down Expand Up @@ -178,10 +170,10 @@ jobs:
needs: compile
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Install
Expand Down Expand Up @@ -261,10 +253,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ e2e-recordings/
locales/**/*_old.json
token
.devcontainer/devcontainer-lock.json
.claude/settings.local.json
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.23.5
24.22.3
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,28 @@ Linux
$ sudo apt-get install build-essential libudev-dev
```

This software is designed to run on `node@22` which can be installed with [`Fast Node Manager`](https://github.com/Schniz/fnm)
This software is designed to run on `node@24` (see [`.node-version`](./.node-version)) which can be installed with [`Fast Node Manager`](https://github.com/Schniz/fnm)

### Devcontainer

This repository includes a devcontainer configuration that is intended to work from scratch.

- Node.js version is sourced from [`.node-version`](./.node-version)
- Container base image targets Ubuntu 22.04 to align with CI environments
- Linux build prerequisites are installed in the container image (`build-essential`, `libudev-dev`, `python3`, `python3-setuptools`)
- Linux build prerequisites are installed in the container image (`build-essential`, `libudev-dev`, `python3`)
- Corepack is enabled in the image build, and `yarn install` runs automatically on first container create
- Husky pre-commit hooks are installed during dependency install and checked on container start

Default devcontainer setup is intentionally focused on lint/test/compile/commit workflows. e2e runtime dependencies (for example xvfb/playwright browsers) are not preinstalled by default.

### Commands

Enable or install yarn package manager
Enable the yarn package manager via Corepack. The Yarn release itself is committed in `.yarn/releases`, so the version always matches the project.

```bash
# For Node.js <16.10
$ npm i -g corepack
# Corepack ships with Node.js 24; on Node.js 25+ install it first
$ npm install -g corepack

# For Node.js >=16.10
$ corepack enable
```

Expand Down
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edgetx-buddy",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"license": "MIT",
"main": "./build/main/main.js",
Expand Down Expand Up @@ -66,10 +66,8 @@
"apollo-link-logger": "^2.0.1",
"base64-arraybuffer": "^1.0.2",
"copy-text-to-clipboard": "^3.2.0",
"date-fns": "^2.30.0",
"debounce": "^1.2.1",
"debounce": "^2",
"detect-browser": "^5.3.0",
"electron-window-controls": "^1.0.28",
"fflate": "^0.8.2",
"get-stream": "^6.0.1",
"got": "^11.8.6",
Expand All @@ -84,22 +82,22 @@
"ky": "^1.2.3",
"markdown-to-jsx": "7.4.6",
"md5": "^2.3.0",
"nanoevents": "^6.0.2",
"nanoevents": "^9",
"native-file-system-adapter": "^2.0.4",
"p-limit": "^3.1.0",
"p-map": "^5.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.15.4",
"react-router-dom": "^6.0.2",
"semver": "^7.3.5",
"semver": "^7.7",
"source-map-support": "^0.5.21",
"styled-components": "^5.3.3",
"type-guards": "^0.15.0",
"unzipit": "^1.4.3",
"usb": "2.12.1",
"use-media": "^1.5.0",
"uuid": "^9.0.1",
"uuid": "^11",
"web-streams-polyfill": "^3.3.3",
"yaml": "^2.7.0"
},
Expand Down Expand Up @@ -144,7 +142,7 @@
},
"devDependencies": {
"@babel/core": "^7.16.0",
"@electron/rebuild": "^3.6.0",
"@electron/rebuild": "^4.2.1",
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/gql-tag-operations": "^4.0.6",
"@graphql-codegen/gql-tag-operations-preset": "^2.1.0",
Expand All @@ -161,17 +159,17 @@
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"@types/debounce": "^1.2.1",
"@types/debounce": "^3",
"@types/is-ci": "^3.0.4",
"@types/md5": "^2.3.5",
"@types/node": "^20.12.5",
"@types/node": "^24.9.0",
"@types/range-parser": "^1.2.7",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/semver": "^7.5.8",
"@types/styled-components": "^5.1.17",
"@types/testing-library__jest-dom": "5.14.9",
"@types/uuid": "^8.3.4",
"@types/uuid": "^10",
"@types/w3c-web-usb": "^1.0.10",
"@types/wicg-file-system-access": "^2020.9.8",
"@typescript-eslint/eslint-plugin": "^5.6.0",
Expand All @@ -187,9 +185,9 @@
"css-loader": "^6.5.1",
"directory-tree": "^3.0.1",
"dotenv": "^10.0.0",
"electron": "^29.3.0",
"electron-builder": "^24.13.3",
"electron-devtools-installer": "^3.2.0",
"electron": "^45.3.3",
"electron-builder": "^26.18.0",
"electron-devtools-installer": "^4",
"esbuild-loader": "^2.21.0",
"eslint": "^8.4.1",
"eslint-config-airbnb": "^19.0.2",
Expand Down
17 changes: 10 additions & 7 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
session,
} from "electron";
import path from "path";
import WindowControls from "electron-window-controls";

import {
createBusLinkBackend,
Expand All @@ -25,6 +24,7 @@
import config from "shared/config";
import backendConfig from "shared/backend/config";
import { createGithubClient } from "shared/api/github";
import { WINDOW_CLOSE, WINDOW_MINIMIZE } from "./windowControls";

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
Expand All @@ -50,6 +50,7 @@

await app.whenReady();

registerWindowControls();
await startBackend();
createWindow();
};
Expand Down Expand Up @@ -82,7 +83,7 @@
if (allowedPermissions.includes(permission)) {
callback(true);
} else {
console.error(

Check warning on line 86 in src/main/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
`The application tried to request permission for '${permission}'. This permission was not whitelisted and has been blocked.`
);

Expand All @@ -92,10 +93,10 @@
}

if (!config.isProduction) {
console.log("loading renderer in development");

Check warning on line 96 in src/main/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
void mainWindow.loadURL(`http://localhost:8081/index.html`);
} else {
console.log("loading renderer");

Check warning on line 99 in src/main/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
void mainWindow.loadFile(path.join(__dirname, "../renderer/index.html"));
}

Expand Down Expand Up @@ -129,28 +130,30 @@
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
APOLLO_DEVELOPER_TOOLS,
// eslint-disable-next-line import/no-extraneous-dependencies
} = await import("electron-devtools-installer");
installExtension(REACT_DEVELOPER_TOOLS).catch((err) =>
// eslint-disable-next-line no-console
console.log("Error loading React DevTools: ", err)
);
installExtension(APOLLO_DEVELOPER_TOOLS).catch((err) =>
// eslint-disable-next-line no-console
console.log("Error loading Apollo DevTools: ", err)
);
mainWindow?.webContents.openDevTools({ mode: "detach" });
}
});
};

WindowControls.initMain();
const registerWindowControls = (): void => {
ipcMain.on(WINDOW_MINIMIZE, (event) => {
BrowserWindow.fromWebContents(event.sender)?.minimize();
});
ipcMain.on(WINDOW_CLOSE, (event) => {
BrowserWindow.fromWebContents(event.sender)?.close();
});
};

const startBackend = async (): Promise<void> => {
const mocked = config.startParams.isMocked || config.startParams.isE2e;
if (mocked) {
console.log("Creating backend in mocked mode");

Check warning on line 156 in src/main/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
}

const busLink = createBusLinkBackend({
Expand Down
6 changes: 3 additions & 3 deletions src/main/preload.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { ipcRenderer } from "electron";
import { BrowserWindow } from "electron-window-controls";
import { WINDOW_CLOSE, WINDOW_MINIMIZE } from "./windowControls";

window.ipcRenderer = ipcRenderer;
window.electronMinimize = () => BrowserWindow.minimize();
window.electronClose = () => BrowserWindow.close();
window.electronMinimize = () => ipcRenderer.send(WINDOW_MINIMIZE);
window.electronClose = () => ipcRenderer.send(WINDOW_CLOSE);
5 changes: 5 additions & 0 deletions src/main/windowControls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// IPC channels used by the custom title bar (see WindowsNav) to control the
// window it is rendered in. The renderer sends via the preload; the main
// process handles them in registerWindowControls.
export const WINDOW_MINIMIZE = "WINDOW_MINIMIZE";
export const WINDOW_CLOSE = "WINDOW_CLOSE";
11 changes: 9 additions & 2 deletions src/renderer/components/flashing/FlashBuildStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { InfoCircleOutlined } from "@ant-design/icons";
import React, { useEffect, useState } from "react";
import { JobStatus } from "shared/backend/types";
import { format } from "date-fns";
import { TFunction, useTranslation } from "react-i18next";
import type { FlashingBuildStageStatus } from "./FlashJobTimeline";

const pad2 = (n: number): string => n.toString().padStart(2, "0");

/** Formats an elapsed duration in seconds as mm:ss (minutes keep counting past 59). */
export const formatElapsed = (seconds: number): string => {
const total = Math.max(0, Math.floor(seconds));
return `${pad2(Math.floor(total / 60))}:${pad2(total % 60)}`;
};

function jobStatusText(
status: JobStatus,
t: TFunction<"flashing", undefined>
Expand Down Expand Up @@ -50,7 +57,7 @@ const FlashBuildStatus: React.FC<Props> = ({ status }) => {
/>{" "}
<p style={{ color: "gray", border: "black" }}>
{jobStatusText(status.jobStatus as JobStatus, t)} -{" "}
{format(sinceTime * 1000, "mm:ss")}
{formatElapsed(sinceTime)}
</p>
</div>
);
Expand Down
18 changes: 18 additions & 0 deletions src/renderer/components/flashing/__tests__/formatElapsed.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { formatElapsed } from "renderer/components/flashing/FlashBuildStatus";

describe("formatElapsed", () => {
it("formats seconds as mm:ss", () => {
expect(formatElapsed(0)).toBe("00:00");
expect(formatElapsed(5)).toBe("00:05");
expect(formatElapsed(65)).toBe("01:05");
expect(formatElapsed(59 * 60 + 59)).toBe("59:59");
});

it("keeps counting minutes past an hour", () => {
expect(formatElapsed(61 * 60 + 2)).toBe("61:02");
});

it("clamps negative values (clock skew) to zero", () => {
expect(formatElapsed(-3)).toBe("00:00");
});
});
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2022",
"lib": ["dom", "dom.iterable", "es2021"],
"lib": ["dom", "dom.iterable", "es2022"],
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
Expand Down
Loading
Loading