Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

test(desktop): discover the actual signed macOS bundle name (#776)

tianma-if377c1daa856f
diff --git a/scripts/build-native-update-fixtures.mjs b/scripts/build-native-update-fixtures.mjs
index a201b630..60b85ace 100644
--- a/scripts/build-native-update-fixtures.mjs
+++ b/scripts/build-native-update-fixtures.mjs
@@ -1,3 +1,4 @@
+import { macAppBundle } from "./native-update-macos.mjs";
import { createRequire } from "node:module";
import { generateKeyPairSync, createHash } from "node:crypto";
import { readFileSync, writeFileSync, mkdirSync, copyFileSync, rmSync } from "node:fs";
@@ -57,7 +58,7 @@ try {
const target = process.platform === "darwin" ? ["--mac", "zip"] : process.platform === "win32" ? ["--win", "nsis"] : ["--linux", "AppImage"];
run(process.execPath, [builderCli, "--projectDir", desktop, "--config", configPath, "--publish", "never", ...target, `--${process.arch}`], desktop);
const payload = process.platform === "darwin"
- ? join(directory, process.arch === "arm64" ? "mac-arm64" : "mac", "EdgeEver Update Verification.app/Contents/Resources/app.asar")
+ ? join(macAppBundle(join(directory, process.arch === "arm64" ? "mac-arm64" : "mac")), "Contents/Resources/app.asar")
: process.platform === "win32" ? join(directory, "win-unpacked/resources/app.asar")
: join(directory, `EdgeEver-${version}-linux-x64.AppImage`);
writeFileSync(join(directory, "payload.sha256"), createHash("sha256").update(readFileSync(payload)).digest("hex"));
diff --git a/scripts/native-update-instrumentation.test.mjs b/scripts/native-update-instrumentation.test.mjs
index 2ff4c210..c13f771c 100644
--- a/scripts/native-update-instrumentation.test.mjs
+++ b/scripts/native-update-instrumentation.test.mjs
@@ -1,9 +1,10 @@
-import { readFileSync, mkdtempSync, writeFileSync, rmSync } from "node:fs";
+import { readFileSync, mkdtempSync, writeFileSync, rmSync, mkdirSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { spawnSync } from "node:child_process";
import { Script, runInNewContext } from "node:vm";
import { expect, test } from "bun:test";
+import { macAppBundle } from "./native-update-macos.mjs";
import { instrumentNativeUpdateMain } from "./native-update-instrumentation.mjs";
const main = readFileSync(new URL("../apps/desktop/src/main/index.mjs", import.meta.url), "utf8");
@@ -55,3 +56,14 @@ test("official bridge debugger bootstrap compiles for old/new and Windows paths"
expect(() => new Script(expression)).not.toThrow();
}
});
+
+test("macOS fixture bundle discovery honors executableName and rejects ambiguity", () => {
+ const directory = mkdtempSync(join(tmpdir(), "edgeever-bundle-name-"));
+ try {
+ mkdirSync(join(directory, "EdgeEverUpdateVerifier.app"));
+ writeFileSync(join(directory, "not-a-bundle.app"), "not a directory");
+ expect(macAppBundle(directory)).toBe(join(directory, "EdgeEverUpdateVerifier.app"));
+ mkdirSync(join(directory, "Another.app"));
+ expect(() => macAppBundle(directory)).toThrow("exactly one");
+ } finally { rmSync(directory, { recursive: true, force: true }); }
+});
diff --git a/scripts/native-update-macos.mjs b/scripts/native-update-macos.mjs
new file mode 100644
index 00000000..5bfc1030
--- /dev/null
+++ b/scripts/native-update-macos.mjs
@@ -0,0 +1,15 @@
+import { readdirSync, statSync } from "node:fs";
+import { join } from "node:path";
+import { spawnSync } from "node:child_process";
+
+export const macAppBundle = (directory) => {
+ const bundles = readdirSync(directory).filter((name) => name.endsWith(".app") && statSync(join(directory, name)).isDirectory());
+ if (bundles.length !== 1) throw new Error(`Expected exactly one macOS bundle in ${directory}, found ${bundles.length}`);
+ return join(directory, bundles[0]);
+};
+
+export const macAppExecutable = (bundle) => {
+ const metadata = spawnSync("/usr/libexec/PlistBuddy", ["-c", "Print :CFBundleExecutable", join(bundle, "Contents/Info.plist")], { encoding: "utf8" });
+ if (metadata.status !== 0) throw new Error("Cannot read the signed fixture's CFBundleExecutable");
+ return join(bundle, "Contents/MacOS", metadata.stdout.trim());
+};
diff --git a/scripts/verify-native-desktop-update.mjs b/scripts/verify-native-desktop-update.mjs
index dbc12ccc..e0fb4ed3 100644
--- a/scripts/verify-native-desktop-update.mjs
+++ b/scripts/verify-native-desktop-update.mjs
@@ -1,3 +1,4 @@
+import { macAppBundle, macAppExecutable } from "./native-update-macos.mjs";
import { windowsUpdateInstallerRunning, stopWindowsUpdateFixtures } from "./native-update-windows.mjs";
import { createServer } from "node:http";
import { createReadStream, existsSync, readFileSync, statSync, writeFileSync, mkdirSync, chmodSync, appendFileSync } from "node:fs";
@@ -73,10 +74,7 @@ const installBaseline = async (directory) => {
if (process.platform === "darwin") {
const unpack = spawnSync("ditto", ["-x", "-k", join(root, oldVersion, packageName(oldVersion)), installed], { encoding: "utf8" });
if (unpack.status !== 0) throw new Error(unpack.stderr);
- const bundle = join(installed, "EdgeEver Update Verification.app");
- const metadata = spawnSync("/usr/libexec/PlistBuddy", ["-c", "Print :CFBundleExecutable", join(bundle, "Contents/Info.plist")], { encoding: "utf8" });
- if (metadata.status !== 0) throw new Error("Cannot read the signed fixture's CFBundleExecutable");
- return join(bundle, "Contents/MacOS", metadata.stdout.trim());
+ return macAppExecutable(macAppBundle(installed));
}
if (process.platform === "win32") {
stopWindowsUpdateFixtures();
@@ -173,14 +171,14 @@ try {
return log.some((entry) => entry.event === "session.quit");
}, "normal application shutdown");
const digest = (path) => createHash("sha256").update(readFileSync(path)).digest("hex");
- const expected = process.platform === "darwin"
- ? join(root, latestVersion, process.arch === "arm64" ? "mac-arm64" : "mac", "EdgeEver Update Verification.app/Contents/Resources/app.asar")
+ const expectedPayload = () => process.platform === "darwin"
+ ? join(macAppBundle(join(root, latestVersion, process.arch === "arm64" ? "mac-arm64" : "mac")), "Contents/Resources/app.asar")
: process.platform === "win32" ? join(root, latestVersion, "win-unpacked/resources/app.asar")
: join(root, latestVersion, packageName(latestVersion));
const installedPayload = process.platform === "darwin" ? join(dirname(executable), "../Resources/app.asar")
: process.platform === "win32" ? join(dirname(executable), "resources/app.asar") : executable;
const recordedDigest = join(root, latestVersion, "payload.sha256");
- const expectedDigest = existsSync(recordedDigest) ? readFileSync(recordedDigest, "utf8").trim() : digest(expected);
+ const expectedDigest = existsSync(recordedDigest) ? readFileSync(recordedDigest, "utf8").trim() : digest(expectedPayload());
await until(() => {
try { return digest(installedPayload) === expectedDigest; } catch { return false; }
}, "native installation replaces the actual installed payload", 240_000);