Skip to content

Commit

Permalink
build: forge cannot make a build without signing. Also playwright fir…
Browse files Browse the repository at this point in the history
…st working test
  • Loading branch information
javierguzman committed Jul 12, 2023
1 parent 464e014 commit c9d0d8a
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 31 deletions.
8 changes: 0 additions & 8 deletions e2e_tests/example.spec.ts

This file was deleted.

37 changes: 37 additions & 0 deletions e2e_tests/flashing.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { _electron as electron, ElectronApplication, test, Page } from "@playwright/test";
import { findLatestBuild, parseElectronApp, clickMenuItemById } from "electron-playwright-helpers";

let electronApp: ElectronApplication;
let page: Page;

test.beforeAll(async () => {
const latestBuild = findLatestBuild();
const appInfo = parseElectronApp(latestBuild);

electronApp = await electron.launch({
args: [appInfo.main],
executablePath: appInfo.executable,
});

electronApp.on("window", async initialPage => {
const filename = initialPage.url()?.split("/").pop();
console.log(`Window opened: ${filename}`);

initialPage.on("pageerror", error => {
console.error(error);
});

initialPage.on("console", msg => {
console.log(msg.text());
});
});
});

test("renders landing page", async () => {
page = await electronApp.firstWindow();
await page.screenshot({ path: "landing.png" });
});

test.afterAll(async () => {
await electronApp.close();
});
47 changes: 26 additions & 21 deletions forge.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ForgeConfig } from "@electron-forge/shared-types";
import type { ForgeConfig, ForgePackagerOptions } from "@electron-forge/shared-types";
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
import { WebpackPlugin } from "@electron-forge/plugin-webpack";
import fs from "fs";
Expand All @@ -8,27 +8,32 @@ import { spawnSync } from "child_process";
import rendererConfig from "./webpack.renderer.config";
import mainConfig from "./webpack.main.config";

const packagerConfig: ForgePackagerOptions = {
appBundleId: "com.dygmalab.bazecor",
darwinDarkModeSupport: true,
icon: "./build/logo.png",
name: "Bazecor",
extraResource: ["NEWS.md"],
appCopyright: "Copyright © 2018, 2023 Keyboardio Inc.; Copyright © 2018, 2023 DygmaLab SE; distributed under the GPLv3",
};

if (process.env.NODE_ENV !== "development") {
packagerConfig.osxNotarize = {
tool: "notarytool",
appleId: process.env.APPLE_ID || "",
appleIdPassword: process.env.APPLE_ID_PASSWORD || "",
teamId: process.env.APPLE_TEAM_ID || "",
};
packagerConfig.osxSign = {
optionsForFile: () => ({
entitlements: "./build/entitlements.plist",
hardenedRuntime: true,
}),
};
}

const config: ForgeConfig = {
packagerConfig: {
appBundleId: "com.dygmalab.bazecor",
darwinDarkModeSupport: true,
icon: "./build/logo.png",
name: "Bazecor",
extraResource: ["NEWS.md"],
appCopyright: "Copyright © 2018, 2023 Keyboardio Inc.; Copyright © 2018, 2023 DygmaLab SE; distributed under the GPLv3",
osxNotarize: {
tool: "notarytool",
appleId: process.env.APPLE_ID || "",
appleIdPassword: process.env.APPLE_ID_PASSWORD || "",
teamId: process.env.APPLE_TEAM_ID || "",
},
osxSign: {
optionsForFile: () => ({
entitlements: "./build/entitlements.plist",
hardenedRuntime: true,
}),
},
},
packagerConfig,
rebuildConfig: {},
makers: [
new MakerSquirrel({
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"main": ".webpack/main",
"scripts": {
"clean": "rm -rf dist && rm -rf out && rm -rf node_modules",
"start": "electron-forge start",
"start": "NODE_ENV=development electron-forge start",
"make-dev": "NODE_ENV=development electron-forge make",
"package": "electron-forge package",
"make": "electron-forge make",
"make-win": "electron-forge make --platform win32",
Expand All @@ -21,6 +22,7 @@
"lint": "eslint --ext .ts,.tsx,.js,.jsx .",
"prettier": "prettier --write \"./**/*.{js,json,css,scss,md}\"",
"test": "vitest run src/renderer/tests src/main/tests",
"e2e": "yarn playwright test",
"commit": "cz",
"prepare": "husky install"
},
Expand Down Expand Up @@ -76,6 +78,7 @@
"electron": "^25.2.0",
"electron-devtools-installer": "^3.2.0",
"electron-forge-maker-appimage": "^24.5.2",
"electron-playwright-helpers": "^1.6.0",
"eslint": "^8.0.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@
xterm-addon-fit "^0.5.0"
xterm-addon-search "^0.8.0"

"@electron/asar@^3.2.1":
"@electron/asar@^3.2.1", "@electron/asar@^3.2.4":
version "3.2.4"
resolved "https://registry.yarnpkg.com/@electron/asar/-/asar-3.2.4.tgz#7e8635a3c4f6d8b3f8ae6efaf5ecb9fbf3bd9864"
integrity sha512-lykfY3TJRRWFeTxccEKdf1I6BLl2Plw81H0bbp4Fc5iEc67foDCa5pjJQULVgo0wF+Dli75f3xVcdb/67FFZ/g==
Expand Down Expand Up @@ -5070,6 +5070,13 @@ electron-packager@^17.1.1:
semver "^7.1.3"
yargs-parser "^21.1.1"

electron-playwright-helpers@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/electron-playwright-helpers/-/electron-playwright-helpers-1.6.0.tgz#74d17d3e1a4f738afc51e93c0912d2e1e16d496a"
integrity sha512-0csyp77xRAi8m5g1ApcYdTMJ8n0+Geyb4huyMAsIYTInk4wsuUTHmIy2gMfgF3I130ogfpX6ZfEGeffS93FaUA==
dependencies:
"@electron/asar" "^3.2.4"

[email protected]:
version "24.5.0"
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-24.5.0.tgz#492a4d7caa232e88ee3c18f5c3b4dc637e5e1b3a"
Expand Down

0 comments on commit c9d0d8a

Please sign in to comment.