Files
s41r4j-pixie/scripts/finalize-app.mjs
T
s41r4jandClaude Opus 5.5 d7e973731c
Build / macOS (universal .dmg) (push) Canceled after 0s
Build / Windows (x64 .exe) (push) Canceled after 0s
Build / Linux (x64 .AppImage + .deb) (push) Canceled after 0s
Build / Publish release (push) Canceled after 0s
Pixie 0.8.1: own speech to text, canvas layouts, 3D explanations, battery
- Pixie's own streaming speech to text (sherpa-onnx, on device, Mac, Windows
  and Linux) that types as you speak; Apple's stays as the fallback
- Canvas lays out trees, mind maps, timelines, layers, cycles, comparisons,
  quadrants, charts, tables, notes, code and wireframes, and edits by shape
- 3D: new shapes, nested parts, copies, materials, shadows, motion, explode
  and cut, frames only on change
- New app ID pixie.s41r4j.in and program name pixie; settings move across
- Idle cost down from about 7% to under 0.5% CPU

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 17:35:09 +05:30

65 lines
3.6 KiB
JavaScript

#!/usr/bin/env node
// Re-sign the built app so its identity is stable across rebuilds, then make the DMG.
//
// Why: an ad-hoc signature's designated requirement defaults to `cdhash H"…"`, which changes on
// every build. macOS stores Screen Recording / Accessibility grants against that requirement, so
// a rebuilt app shows as "Not allowed" even though its switch is on. We pin the requirement to
// the bundle identifier instead (`identifier "pixie.s41r4j.in"`), which every build satisfies.
// With a real certificate (APPLE_SIGNING_IDENTITY) the default requirement is already stable.
import { execFileSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const repo = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const target = process.argv[2] ?? "target/release/bundle";
const bundleDir = path.join(repo, target);
const app = path.join(bundleDir, "macos/Pixie.app");
const entitlements = path.join(repo, "apps/desktop/src-tauri/entitlements.plist");
const identity = process.env.APPLE_SIGNING_IDENTITY || "-";
const version = JSON.parse(fs.readFileSync(path.join(repo, "apps/desktop/src-tauri/tauri.conf.json"), "utf8")).version;
const sign = (file, ident) => {
const args = ["--force", "--sign", identity, "--options", "runtime", "--entitlements", entitlements, "--identifier", ident];
if (identity === "-") args.push(`-r=designated => identifier "${ident}"`);
execFileSync("codesign", [...args, file], { stdio: "inherit" });
};
if (!fs.existsSync(app)) {
console.error(`no app at ${app}`);
process.exit(1);
}
// Inner executables first, then the bundle (which seals them). With a real Developer ID the
// Tauri bundler has already signed (and notarized) the app; re-signing would undo that.
if (identity === "-") {
sign(path.join(app, "Contents/MacOS/pixie-helper"), "pixie.s41r4j.in.helper");
sign(path.join(app, "Contents/MacOS/pixie-voice"), "pixie.s41r4j.in.voice");
sign(app, "pixie.s41r4j.in");
}
execFileSync("codesign", ["--verify", "--deep", "--strict", app], { stdio: "inherit" });
const req = execFileSync("codesign", ["-d", "-r-", app], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
console.log(req.trim().split("\n").pop());
const dmgDir = path.join(bundleDir, "dmg");
fs.mkdirSync(dmgDir, { recursive: true });
const arch = target.includes("universal") ? "universal" : process.arch === "arm64" ? "aarch64" : "x64";
const dmg = path.join(dmgDir, `Pixie_${version}_${arch}.dmg`);
fs.rmSync(dmg, { force: true });
const stage = fs.mkdtempSync(path.join(dmgDir, "stage-"));
execFileSync("ditto", [app, path.join(stage, "Pixie.app")]);
fs.symlinkSync("/Applications", path.join(stage, "Applications"));
execFileSync("hdiutil", ["create", "-volname", "Pixie", "-srcfolder", stage, "-ov", "-format", "UDZO", dmg], { stdio: "ignore" });
fs.rmSync(stage, { recursive: true, force: true });
console.log(`app: ${app}\ndmg: ${dmg}`);
// Auto-update package: the finished (re-signed) app as .app.tar.gz plus its updater signature.
// Only when the signing key is around (CI with TAURI_SIGNING_PRIVATE_KEY); local builds skip it.
if (process.env.TAURI_SIGNING_PRIVATE_KEY) {
const tgz = path.join(bundleDir, "macos/Pixie.app.tar.gz");
fs.rmSync(tgz, { force: true });
fs.rmSync(`${tgz}.sig`, { force: true });
execFileSync("tar", ["-czf", tgz, "-C", path.join(bundleDir, "macos"), "Pixie.app"], { stdio: "inherit" });
execFileSync("npx", ["--no-install", "tauri", "signer", "sign", tgz], { cwd: path.join(repo, "apps/desktop"), stdio: "inherit" });
console.log(`update: ${tgz}`);
}