mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 03:38:32 +02:00
* feat(desktop): brand dev build as Multica Canary with bundled icon pnpm dev:desktop ran under the stock Electron name and default icon, making it indistinguishable from any other Electron dev app in the dock. Set a Canary app name + userData path and point the macOS dock icon and BrowserWindow icon at the bundled resources/icon.png so the dev build is visually branded. * feat(desktop): allow overriding renderer port via DESKTOP_RENDERER_PORT Lets a second worktree run `pnpm dev:desktop` while a primary checkout already holds the default Vite dev port 5173 — required to actually exercise the "Multica Canary" branding in isolation. * feat(desktop): rebrand Electron.app Info.plist so dev shows Multica Canary app.setName() can't override the macOS menu bar title or Cmd+Tab label — those come from CFBundleName baked into the running bundle's Info.plist. Patch the bundled Electron.app's plist during `pnpm dev:desktop` so dev launches read "Multica Canary" everywhere, not "Electron". Idempotent; unlinks before rewriting so we don't mutate a pnpm-store inode shared with other projects.
74 lines
2.3 KiB
JavaScript
74 lines
2.3 KiB
JavaScript
#!/usr/bin/env node
|
|
// Rebrand the bundled Electron.app's Info.plist so `pnpm dev:desktop`
|
|
// shows "Multica Canary" in the menu bar, Cmd+Tab switcher, and
|
|
// Activity Monitor. On macOS these titles come from CFBundleName at
|
|
// launch time — `app.setName()` cannot override them at runtime, so
|
|
// patching the plist in node_modules is the only working fix.
|
|
//
|
|
// Idempotent: runs on every dev launch and no-ops once the plist already
|
|
// matches. The patch is isolated to this worktree's node_modules — we
|
|
// unlink the file before rewriting so we never mutate a pnpm-store inode
|
|
// shared with another project.
|
|
|
|
import { createRequire } from "node:module";
|
|
import { execFileSync } from "node:child_process";
|
|
import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
|
|
if (process.platform !== "darwin") process.exit(0);
|
|
|
|
const DESIRED_NAME = "Multica Canary";
|
|
|
|
const require = createRequire(import.meta.url);
|
|
// `require('electron')` returns the path to the executable
|
|
// (.../Electron.app/Contents/MacOS/Electron). Walk up to Contents/Info.plist.
|
|
const electronBin = require("electron");
|
|
const plistPath = resolve(electronBin, "../../Info.plist");
|
|
|
|
function plistGet(key) {
|
|
try {
|
|
return execFileSync(
|
|
"/usr/libexec/PlistBuddy",
|
|
["-c", `Print :${key}`, plistPath],
|
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] },
|
|
).trim();
|
|
} catch {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
function plistSet(key, value) {
|
|
try {
|
|
execFileSync("/usr/libexec/PlistBuddy", [
|
|
"-c",
|
|
`Set :${key} ${value}`,
|
|
plistPath,
|
|
]);
|
|
} catch {
|
|
execFileSync("/usr/libexec/PlistBuddy", [
|
|
"-c",
|
|
`Add :${key} string ${value}`,
|
|
plistPath,
|
|
]);
|
|
}
|
|
}
|
|
|
|
if (
|
|
plistGet("CFBundleName") === DESIRED_NAME &&
|
|
plistGet("CFBundleDisplayName") === DESIRED_NAME
|
|
) {
|
|
process.exit(0);
|
|
}
|
|
|
|
// Break any pnpm hardlink to the global store: read, unlink, rewrite.
|
|
// PlistBuddy would otherwise write through the hardlink and mutate the
|
|
// shared store file (and every other project's Electron.app with it).
|
|
const original = readFileSync(plistPath);
|
|
unlinkSync(plistPath);
|
|
writeFileSync(plistPath, original);
|
|
|
|
plistSet("CFBundleName", DESIRED_NAME);
|
|
plistSet("CFBundleDisplayName", DESIRED_NAME);
|
|
|
|
console.log(`[brand-dev-electron] ${plistPath} → CFBundleName="${DESIRED_NAME}"`);
|