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

BREAKING CHANGE: Switch to vite with electron-forge #469

Merged
merged 77 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
26d1dcc
wip: Install deps
RobertGemmaJr May 13, 2024
653e1c2
wip: Add boilerplate for vite configurations
RobertGemmaJr May 13, 2024
7fe39ad
ref: Move vite config files outside of seperate config folder
RobertGemmaJr May 13, 2024
cb99c62
wip: Add configs from the vite template
RobertGemmaJr May 13, 2024
842b0ab
wip: Add env.d.ts file
RobertGemmaJr May 13, 2024
26d3d0f
wip: Update index.html and other files
RobertGemmaJr May 13, 2024
ba92d9d
wip: Update config file extensions and gitignore
RobertGemmaJr May 13, 2024
bacb205
wip: Get the app running
RobertGemmaJr May 13, 2024
237d998
wip: Remove uneeded public files
RobertGemmaJr May 13, 2024
d09c0fb
wip: Clean up vite main process
RobertGemmaJr May 13, 2024
c9c8da4
wip: Clean up global variables from electron forge
RobertGemmaJr May 13, 2024
cb71b38
wip: remove old electron code form public folder
RobertGemmaJr May 13, 2024
5e274c3
wip: Use VITE_ for environment variables
RobertGemmaJr May 13, 2024
2ad6a37
wip: Clean up trigger export
RobertGemmaJr May 13, 2024
57ece84
chore: cleanup renderer
RobertGemmaJr May 13, 2024
134f2c5
chore: index.html cleanup
RobertGemmaJr May 13, 2024
d12f5d1
fix: USE_PROLIFIC checks against null instead of undefined
RobertGemmaJr May 13, 2024
d74c74a
BREAKING_CHANGE: Update scripts
RobertGemmaJr May 13, 2024
2185667
ref: Clean up workflows with the new commands
RobertGemmaJr May 13, 2024
e4ba93b
BREAKING CHANGE: Remove the github pages deployment workflow
RobertGemmaJr May 13, 2024
be72c15
chore: Update firebase scripts
RobertGemmaJr May 13, 2024
7680b9e
chore: Update firebase.json
RobertGemmaJr May 13, 2024
c4364e1
ci: Test Firebase preview link without pre-configured script
RobertGemmaJr May 13, 2024
06a35c4
chore: Ci
RobertGemmaJr May 13, 2024
d310a3e
ci: Remove Firebase
RobertGemmaJr May 13, 2024
4369ff4
ci: Add back Firebase actions
RobertGemmaJr May 13, 2024
75418f5
ci: Add build step back to firebase acitons
RobertGemmaJr May 13, 2024
b9ee57a
ci: Test firebase predwploy script with firebase.json
RobertGemmaJr May 13, 2024
d8d57dc
chore: Update predeploy script
RobertGemmaJr May 13, 2024
684fb90
Merge pull request #470 from brown-ccv/feat-vite
RobertGemmaJr May 13, 2024
6f84705
chore: lock
RobertGemmaJr May 13, 2024
15fcc12
wip: Set type as module
RobertGemmaJr May 14, 2024
14a579c
ref: Rename vite configs with js extension
RobertGemmaJr May 14, 2024
cde924e
ref: Rename extension for version
RobertGemmaJr May 14, 2024
4f106f2
ref: Use forge config as a type module
RobertGemmaJr May 14, 2024
81ea139
wip: Build .vite dev server as cjs
RobertGemmaJr May 14, 2024
d6de43e
ref: Use Electron code as CJS
RobertGemmaJr May 14, 2024
4cd465d
chore: cleanup
RobertGemmaJr May 14, 2024
de17e26
chore: Remove console log
RobertGemmaJr May 14, 2024
1a984b6
chore: comments
RobertGemmaJr May 14, 2024
f735da8
ref: Separate window logic between dev and prod
RobertGemmaJr May 14, 2024
431e9aa
ref: Use app.isPackaged for the window size
RobertGemmaJr May 14, 2024
52ba7fe
chore: comments
RobertGemmaJr May 14, 2024
d236e45
chore: Remove installer
RobertGemmaJr May 14, 2024
8e20317
build: Uninstall uneeded dependencies
RobertGemmaJr May 14, 2024
119e0bc
ci: Update actions
RobertGemmaJr May 14, 2024
1bf10c1
chore: update make scripts
RobertGemmaJr May 14, 2024
d933dae
wip: Move the serialport code into its own file
RobertGemmaJr May 14, 2024
f92177c
chore: UPdate forge config
RobertGemmaJr May 14, 2024
c1262cc
ref: Remove react strict mode
RobertGemmaJr May 15, 2024
e98d14b
chore: COnfig cleanup
RobertGemmaJr May 15, 2024
eb4c396
chore: comments
RobertGemmaJr May 15, 2024
efb6a63
ref: Update file saving paths in Honeycomb desktop
RobertGemmaJr May 15, 2024
4712a4a
ref: Update data paths
RobertGemmaJr May 15, 2024
6153a98
chore: TODO
RobertGemmaJr May 15, 2024
6163b67
wip: Add utility functions for getting the data and output paths
RobertGemmaJr May 15, 2024
ce07550
wip: Fix path functions
RobertGemmaJr May 15, 2024
4dd06f9
chore: Reorder constants
RobertGemmaJr May 15, 2024
47dd09e
chore: TODOs
RobertGemmaJr May 15, 2024
2ac1ce3
chore: Comments
RobertGemmaJr May 15, 2024
f70713d
Merge pull request #474 from brown-ccv/feat-developer-tools
RobertGemmaJr May 16, 2024
5acf003
Merge branch 'type-module' into fix-window
RobertGemmaJr May 16, 2024
4aeb7bd
Merge pull request #473 from brown-ccv/fix-window
RobertGemmaJr May 16, 2024
35360c9
Merge branch 'type-module' into fix-serialport
RobertGemmaJr May 16, 2024
5befd11
Merge branch 'type-module' into ref-paths
RobertGemmaJr May 16, 2024
420a8fc
Merge pull request #475 from brown-ccv/fix-serialport
RobertGemmaJr May 16, 2024
09d8e07
Merge branch 'feat-v4' into feat-forge-vite
RobertGemmaJr May 16, 2024
481687f
Merge branch 'feat-forge-vite' into type-module
RobertGemmaJr May 16, 2024
d2e26ff
Merge branch 'type-module' of https://github.com/brown-ccv/honeycomb …
RobertGemmaJr May 16, 2024
a382c55
Merge branch 'type-module' into ref-paths
RobertGemmaJr May 16, 2024
227c48d
chore: lock
RobertGemmaJr May 16, 2024
bf2c5e1
Update src/Electron/main.js
RobertGemmaJr May 16, 2024
ecaaa68
Update src/Electron/main.js
RobertGemmaJr May 16, 2024
5caa0b7
Update src/Electron/main.js
RobertGemmaJr May 16, 2024
48a7c04
Merge pull request #476 from brown-ccv/ref-paths
RobertGemmaJr May 16, 2024
0ec443c
Merge pull request #471 from brown-ccv/type-module
RobertGemmaJr May 16, 2024
65fba7c
ref: Cleanup forge config
RobertGemmaJr May 17, 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
11 changes: 3 additions & 8 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
"eslint:recommended",
"plugin:react/recommended",
"plugin:import/recommended",
"plugin:import/electron",
"prettier",
],
parserOptions: {
Expand All @@ -22,14 +23,8 @@ module.exports = {
"import/order": "warn",
},
settings: {
react: {
version: "detect",
},
"import/resolver": {
node: {
extensions: [".js", ".jsx"],
},
},
react: { version: "detect" },
"import/resolver": { node: { extensions: [".js", ".jsx"] } },
},
overrides: [{ files: ["*.jsx", "*.js"] }],
};
7 changes: 3 additions & 4 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
"on":
on:
push:
branches:
- main
Expand All @@ -11,10 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build:firebase
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_CCV_HONEYCOMB }}"
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CCV_HONEYCOMB }}
channelId: live
projectId: ccv-honeycomb
9 changes: 4 additions & 5 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on PR
"on": pull_request
on: pull_request
permissions:
checks: write
contents: read
pull-requests: write
jobs:
build_and_preview:
if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build:firebase
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_CCV_HONEYCOMB }}"
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CCV_HONEYCOMB }}
projectId: ccv-honeycomb
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
Expand Down
49 changes: 9 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
Expand All @@ -52,16 +52,16 @@ jobs:
path: ./env
mode: ${{matrix.setting}}

# Package the app installers
- name: 📦 Package app installer - Windows
# Package the app and make the installers
- name: 📦 Make app installer - Windows
if: startsWith(matrix.os, 'windows')
run: npm run package:windows
- name: 📦 Package app installer - Mac
run: npm run make:windows
- name: 📦 Make app installer - Mac
if: startsWith(matrix.os, 'mac')
run: npm run package:mac
- name: 📦 Package app installer - Linux
run: npm run make:mac
- name: 📦 Make app installer - Linux
if: startsWith(matrix.os, 'ubuntu')
run: npm run package:linux
run: npm run make:linux

# Get package info
- name: Get package name and version
Expand All @@ -72,6 +72,7 @@ jobs:
shell: bash

# Upload installers to GitHub release
# TODO @brown-ccv #247: Use the Publish command: https://www.electronforge.io/cli#publish
- name: ⬆ Upload installer to release - Windows
if: startsWith(matrix.os, 'windows')
uses: svenstaro/upload-release-action@v2
Expand All @@ -96,35 +97,3 @@ jobs:
asset_name: ${{ steps.package_info.outputs.name }}-${{ steps.package_info.outputs.version }}-${{ matrix.setting }}-amd64.deb
tag: ${{ github.ref }}
repo_token: ${{ secrets.GITHUB_TOKEN }}

deploy-gh-pages:
name: Deploy to GH Pages
runs-on: ubuntu-latest
steps:
# Set up runner
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: npm
- name: 🐍 Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

# Install dependencies
- name: 📥 Install Dependencies
run: npm ci

# Build the app
- name: ⚒ Build
run: npm run build

# Deploy the app to GitHub Pages
- name: 🚀 Deploy to GH Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
17 changes: 9 additions & 8 deletions .github/workflows/workflow-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
Expand All @@ -66,16 +66,16 @@ jobs:
path: ./env
mode: ${{github.event.inputs.setting}}

# Package the app installers
- name: 📦 Package app installer - Windows
# Package the app and make the installers
- name: 📦 Make app installer - Windows
if: startsWith(matrix.os, 'windows')
run: npm run package:windows
- name: 📦 Package app installer - Mac
run: npm run make:windows
- name: 📦 Make app installer - Mac
if: startsWith(matrix.os, 'mac')
run: npm run package:mac
- name: 📦 Package app installer - Linux
run: npm run make:mac
- name: 📦 Make app installer - Linux
if: startsWith(matrix.os, 'ubuntu')
run: npm run package:linux
run: npm run make:linux

# Get package info
- name: Get package name and version
Expand All @@ -86,6 +86,7 @@ jobs:
shell: bash

# Upload installers to github action
# TODO @brown-ccv #247: Can we use the publish command here?
- name: ⬆ Upload installer - Windows
uses: actions/upload-artifact@v3
if: startsWith(matrix.os, 'windows')
Expand Down
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

# Dependencies
/node_modules
Brewfile.lock.json
/.pnp
.pnp.js
.vite

# Cache
.npm
.eslintcache

# Testing
/coverage

# Production
.vite
/build
/dist
/out
Expand All @@ -19,6 +23,7 @@ Brewfile.lock.json
/.vscode

# Logs
logs
*.log
*.log*

Expand All @@ -27,10 +32,10 @@ public/config/version.json
public/version.json
Brewfile.lock.json

# Firebase private key
# Secrets
**/firebase-service-account.json

# Live data
# Data
**/participant_responses

# Misc
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file defines specific rules for Prettier. It adjusts their default settings.
* We recommend these settings if your lab does not have specific style standards.
*/
module.exports = {
export default {
printWidth: 100, // Sets the maximum line size to 100 (default is 80)
quoteProps: "as-needed", // Add quotes around props as needed
trailingComma: "es5", // Add a trailing comma to all es5 modules
Expand Down
6 changes: 3 additions & 3 deletions env/.env.clinic
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REACT_APP_USE_EEG="true"
REACT_APP_USE_PHOTODIODE="true"
REACT_APP_VOLUME="true"
VITE_USE_EEG="true"
VITE_USE_PHOTODIODE="true"
VITE_VOLUME="true"
Comment on lines +1 to +3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you need to change those?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, they're only used for the build

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, these are the "equipment" that users can turn on or off with environment variables

14 changes: 7 additions & 7 deletions env/.env.firebase
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REACT_APP_FIREBASE="true"
REACT_APP_API_KEY="AIzaSyB6C2nVXk__dqxdyyROFEC-ue50O_OsjTE"
REACT_APP_AUTH_DOMAIN="ccv-honeycomb.firebaseapp.com"
REACT_APP_PROJECT_ID="ccv-honeycomb"
REACT_APP_STORAGE_BUCKET="ccv-honeycomb.appspot.com"
REACT_APP_MESSAGING_SENDER_ID="449496296276"
REACT_APP_APP_ID="1:449496296276:web:0479c82b8b068ca9e6b6c1"
VITE_FIREBASE="true"
VITE_API_KEY="AIzaSyB6C2nVXk__dqxdyyROFEC-ue50O_OsjTE"
VITE_AUTH_DOMAIN="ccv-honeycomb.firebaseapp.com"
VITE_PROJECT_ID="ccv-honeycomb"
VITE_STORAGE_BUCKET="ccv-honeycomb.appspot.com"
VITE_MESSAGING_SENDER_ID="449496296276"
VITE_APP_ID="1:449496296276:web:0479c82b8b068ca9e6b6c1"
2 changes: 1 addition & 1 deletion env/.env.video
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_VIDEO="true"
VITE_VIDEO="true"
7 changes: 4 additions & 3 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "build",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"public": "dist",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
],
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"predeploy": ["npm ci", "npm run build:firebase"]
},
"emulators": {
"firestore": {
Expand Down
58 changes: 43 additions & 15 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
/**
* Configuration file for Electron Forge
*/
module.exports = {
import { FuseV1Options, FuseVersion } from "@electron/fuses";

/** Configuration file for Electron Forge */
export default {
packagerConfig: {
asar: true,
icon: "assets/icons/icon",
},
makers: [
{
// zip files
name: "@electron-forge/maker-zip",
// Windows Distribution
name: "@electron-forge/maker-squirrel",
config: {
iconUrl: "https://raw.githubusercontent.com/brown-ccv/honeycomb/main/assets/icons/icon.ico",
setupIcon: "assets/icons/icon.ico",
},
},
{
// Mac Distribution
name: "@electron-forge/maker-dmg",
config: {
icon: "assets/icons/icon.icns",
overwrite: true,
},
},
{
// Linux Distribution
Expand All @@ -21,21 +33,37 @@ module.exports = {
},
},
{
// Mac Distribution
name: "@electron-forge/maker-dmg",
// zip files
name: "@electron-forge/maker-zip",
},
],
plugins: [
{ name: "@electron-forge/plugin-auto-unpack-natives", config: {} },
{
name: "@electron-forge/plugin-vite",
config: {
icon: "assets/icons/icon.icns",
overwrite: true,
build: [
// Build files that use the main config
{ entry: "src/electron/main.js", config: "vite.main.config.js" },
// Build files that use the preload config
{ entry: "src/Electron/preload.js", config: "vite.preload.config.js" },
],
renderer: [{ name: "main_window", config: "vite.renderer.config.js" }],
},
},
{
// Windows Distribution
name: "@electron-forge/maker-squirrel",
name: "@electron-forge/plugin-fuses",
config: {
iconUrl: "https://raw.githubusercontent.com/brown-ccv/honeycomb/main/assets/icons/icon.ico",
setupIcon: "assets/icons/icon.ico",
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false, // Disables ELECTRON_RUN_AS_NODE
[FuseV1Options.GrantFileProtocolExtraPrivileges]: true, // Grants the file protocol extra privileges (for the built application)
[FuseV1Options.EnableCookieEncryption]: false, // Disables cookie encryption
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false, // Disables the NODE_OPTIONS environment variable
[FuseV1Options.EnableNodeCliInspectArguments]: false, // Disables the --inspect and --inspect-brk family of CLI options
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true, // Enforces validation of the app.asar archive on macOS
[FuseV1Options.OnlyLoadAppFromAsar]: true, // Enforces that Electron will only load your app from "app.asar" instead of its normal search paths
[FuseV1Options.LoadBrowserProcessSpecificV8Snapshot]: true, // Loads V8 Snapshot from `browser_v8_context_snapshot.bin` for the browser process
},
},
],
plugins: [{ name: "@electron-forge/plugin-auto-unpack-natives", config: {} }],
};
Loading
Loading