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

Improving client setup #1

Merged
merged 33 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3f69532
Added debugging
Nils-Kolvenbach Feb 2, 2024
6661951
Enhanced description
Nils-Kolvenbach Feb 2, 2024
fb0588a
Added window display logic and chrome react devtools extension
Nils-Kolvenbach Feb 2, 2024
091eda3
Changed CI to use yarn too
Nils-Kolvenbach Feb 2, 2024
fda73a2
Making the linter happy
Nils-Kolvenbach Feb 2, 2024
cf541b2
Changed filestructure of src
Nils-Kolvenbach Feb 2, 2024
132c511
Added @elek-io/core with test button and IPC communication
Nils-Kolvenbach Feb 2, 2024
cd7e89b
Making the linter happy
Nils-Kolvenbach Feb 2, 2024
12de510
Lets see the build
Nils-Kolvenbach Feb 3, 2024
dc0819c
Inspect CI not CD ...
Nils-Kolvenbach Feb 3, 2024
e5a39dc
Set NODE_ENV to production for build and release scripts
Nils-Kolvenbach Feb 3, 2024
aa51e60
Added sentry for error monitoring
Nils-Kolvenbach Feb 4, 2024
b187589
Added sentry sourcemap support through @sentry/wizard
Nils-Kolvenbach Feb 4, 2024
10f6b98
Fixing actions versions to current "-latest" and added M1 (arm) runner
Nils-Kolvenbach Feb 5, 2024
5f39f99
Changing CI test name
Nils-Kolvenbach Feb 5, 2024
3d70cbb
Added M1 release to pipeline
Nils-Kolvenbach Feb 5, 2024
b20b9e0
Removed cross-env since we're going to use an argument for setting th…
Nils-Kolvenbach Feb 5, 2024
24903b1
Updated core
Nils-Kolvenbach Feb 6, 2024
af32b66
Setting core environment based on if client is packaged or not
Nils-Kolvenbach Feb 8, 2024
9cabcfd
Added local file protocol handler
Nils-Kolvenbach Feb 8, 2024
7e8923d
Added react and tanstack router for very basic project listing via IP…
Nils-Kolvenbach Feb 9, 2024
15594f8
Small fixes to make global types and dugite work with dev and build s…
Nils-Kolvenbach Feb 11, 2024
5b9052d
Added logic to load projects data on visiting routes. User guard not …
Nils-Kolvenbach Feb 11, 2024
5d08e94
Added sentry.io tracing, profiling and session replay
Nils-Kolvenbach Feb 12, 2024
07c2d70
Added auto-updater and ZIP maker
Nils-Kolvenbach Feb 14, 2024
b80e926
Focussing on squirrel (Windows) maker and ZIP (MacOS) maker, since up…
Nils-Kolvenbach Feb 14, 2024
d7ec3b6
Testing Electronegativity
Nils-Kolvenbach Feb 15, 2024
03029e8
Fixes for first Electronegativity audit
Nils-Kolvenbach Feb 16, 2024
5009a5c
Prevent "https://elek.io.attacker.com" to pass trusted domain check
Nils-Kolvenbach Feb 16, 2024
5577a41
Optimized internal and external navigation handling and prevent loadi…
Nils-Kolvenbach Feb 16, 2024
277a1e6
Added some icons with configuration for now. But they do not look goo…
Nils-Kolvenbach Feb 21, 2024
3e3c945
Modified window to be borderless without chrome. Added default dragab…
Nils-Kolvenbach Feb 21, 2024
a9adf5d
Added changeset
Nils-Kolvenbach Feb 21, 2024
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
23 changes: 23 additions & 0 deletions .changeset/four-years-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@elek-io/client': minor
---

Initial setup - pre GUI

- [x] Debugging main & renderer in VSCode. See https://www.electronforge.io/advanced/debugging
- [x] CI/CD with lint, test & build
- [x] Custom file protocol handler to access Assets on disk
- [x] Working IPC calls
- [x] Working IPC call to Core with git command execution with included dugite binary
- [x] Using react inside renderer
- [x] Typesafe routing working with data loading. See https://tanstack.com/router/latest
- [x] Sentry.io
- [x] Error monitoring in renderer, main & preload
- [x] Replays on error
- [x] Performance monitoring
- [x] Profiling
- [x] Creating releases incl. sourcemap upload
- [x] First security & best practice audit. See https://github.com/doyensec/electronegativity & https://www.electronjs.org/docs/latest/tutorial/security
- [x] Automatic updates working. See https://www.electronforge.io/advanced/auto-update (Should work but needs certificates I do not have for not - need to test later)
- [x] Using an custom app icon
- [x] Custom borderless window with draggable area
9 changes: 6 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
name: Releasing on ${{ matrix.platform }} with Node.js ${{ matrix.node-version }}
timeout-minutes: 15
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
# @see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
# macos-12 = intel
# macos-14 = M1 (arm)
platform: [ubuntu-22.04, macos-12, macos-14, windows-2022]
node-version: [18]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -27,7 +30,7 @@ jobs:
run: yarn install
- name: Run linter
run: yarn run lint
- name: Create pull request or publish to GitHub
- name: Build and create pull request or publish to GitHub
uses: changesets/action@v1
with:
title: 'WIP: Release x.x.x'
Expand Down
27 changes: 22 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ on:

jobs:
test:
name: Test
name: Testing on ${{ matrix.platform }} with Node.js ${{ matrix.node-version }}
timeout-minutes: 15
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
# @see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
# macos-12 = intel
# macos-14 = M1 (arm)
platform: [ubuntu-22.04, macos-12, macos-14, windows-2022]
node-version: [18]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -22,8 +25,22 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ic
run: yarn install
- name: Run linter
run: npm run lint
run: yarn run lint
- name: Identify misconfigurations and security anti-patterns
uses: doyensec/electronegativity-action@v2
- name: Upload report
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ../electronegativity_results
- name: Build
run: npm run build
run: yarn run build
# Uncomment if necessary
# For example to inspect the build applications
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: artifact_${{ matrix.platform }}
path: out/make
if-no-files-found: error
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,6 @@ typings/

# Electron-Forge
out/

# Sentry Config File
.env.sentry-build-plugin
25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"configurations": [
{
"name": "Dev (Electron Main)",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceFolder}/node_modules/@electron-forge/cli/script/vscode.sh",
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/@electron-forge/cli/script/vscode.cmd"
},
// runtimeArgs will be passed directly to your Electron application
"runtimeArgs": [],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal"
},
{
"name": "Build process",
"request": "launch",
"runtimeExecutable": "yarn",
"runtimeArgs": ["run", "build"],
"skipFiles": ["<node_internals>/**"],
"type": "node"
}
]
}
44 changes: 25 additions & 19 deletions forge.config.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
import { MakerDeb } from '@electron-forge/maker-deb';
import { MakerDMG } from '@electron-forge/maker-dmg';
import { MakerRpm } from '@electron-forge/maker-rpm';
// import { MakerDeb } from '@electron-forge/maker-deb';
// import { MakerDMG } from '@electron-forge/maker-dmg';
// import { MakerRpm } from '@electron-forge/maker-rpm';
import { MakerSquirrel } from '@electron-forge/maker-squirrel';
import { MakerZIP } from '@electron-forge/maker-zip';
import { VitePlugin } from '@electron-forge/plugin-vite';
import type { ForgeConfig } from '@electron-forge/shared-types';

const config: ForgeConfig = {
packagerConfig: {},
packagerConfig: {
icon: 'icons/icon',
},
rebuildConfig: {},
makers: [
new MakerSquirrel({
title: 'elek.io Client',
setupExe: 'elek.io Client',
name: 'client',
// The ICO file to use as the icon for the generated Setup.exe
setupIcon: 'icons/icon.ico',
}),
new MakerDMG({}),
new MakerRpm({
options: {
productName: 'elek.io Client',
bin: 'elek.io Client',
},
}),
new MakerDeb({
options: {
productName: 'elek.io Client',
bin: 'elek.io Client',
},
}),
new MakerZIP(),
// new MakerDMG(),
// new MakerRpm({
// options: {
// productName: 'elek.io Client',
// bin: 'elek.io Client',
// },
// }),
// new MakerDeb({
// options: {
// productName: 'elek.io Client',
// bin: 'elek.io Client',
// },
// }),
],
publishers: [
{
Expand All @@ -48,11 +54,11 @@ const config: ForgeConfig = {
build: [
{
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
entry: 'src/main.ts',
entry: 'src/main/index.ts',
config: 'vite.main.config.ts',
},
{
entry: 'src/preload.ts',
entry: 'src/renderer/preload.ts',
config: 'vite.preload.config.ts',
},
],
Expand Down
3 changes: 3 additions & 0 deletions icons/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Application icons

Please refer to the [Electron Forge documentation](https://www.electronforge.io/guides/create-and-add-icons).
Binary file added icons/icon.icns
Binary file not shown.
Binary file added icons/icon.ico
Binary file not shown.
Binary file added icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/[email protected]
Binary file not shown.
30 changes: 28 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,35 @@
<meta charset="UTF-8" />
<title>Hello World!</title>
</head>
<body>
<body style="margin: 0; padding: 0">
<div
style="
display: flex;
background-color: grey;
-webkit-app-region: drag;
height: 28px;
"
></div>
<h1>💖 Hello World!</h1>
<p>Welcome to your Electron application.</p>
<script type="module" src="/src/renderer.ts"></script>
<p>
Internal navigation to any
<a href="https://google.com">origin</a> is currently not allowed.
</p>
<p>
Navigation to an URL with the intent to
<a href="https://google.com" target="_blank">open a new window</a> should
open given URL in the OS's default browser (external) instead -
<a href="https://elek.io" target="_blank"
>if the origin is on the whitelist</a
>.
</p>
<button
onclick="window.ipc.core.user.get().then((result) => console.log('Result:', result)).catch((err) => console.log('Error:', err))"
>
Test IPC
</button>
<div id="app"></div>
<script type="module" src="/src/renderer/index.ts"></script>
</body>
</html>
19 changes: 17 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"url": "https://elek.io"
},
"license": "todo",
"main": ".vite/build/main.js",
"main": ".vite/build/index.js",
"scripts": {
"lint": "eslint --ext .ts,.tsx .",
"dev": "electron-forge start",
Expand All @@ -23,7 +23,17 @@
"release": "electron-forge publish"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
"@elek-io/core": "^0.1.1",
"@sentry/electron": "^4.17.0",
"@sentry/react": "7.92.0",
"@sentry/vite-plugin": "^2.13.0",
"@tanstack/react-router": "^1.15.23",
"@tanstack/router-devtools": "^1.15.23",
"dugite": "^2.5.2",
"electron-squirrel-startup": "^1.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"update-electron-app": "^3.0.0"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
Expand All @@ -32,12 +42,17 @@
"@electron-forge/maker-dmg": "^7.2.0",
"@electron-forge/maker-rpm": "^7.2.0",
"@electron-forge/maker-squirrel": "^7.2.0",
"@electron-forge/maker-zip": "^7.2.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.2.0",
"@electron-forge/plugin-vite": "^7.2.0",
"@electron-forge/publisher-github": "^7.2.0",
"@tanstack/router-vite-plugin": "^1.15.22",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"electron": "^28.2.1",
"electron-devtools-installer": "^3.2.0",
"eslint": "^8.0.1",
"eslint-plugin-import": "^2.25.0",
"ts-node": "^10.0.0",
Expand Down
7 changes: 0 additions & 7 deletions src/index.css

This file was deleted.

53 changes: 0 additions & 53 deletions src/main.ts

This file was deleted.

Loading
Loading