chore: sync repo with deployed state — clean up old specs/plans, desktop tweaks

This commit is contained in:
Jannis Braun
2026-03-24 04:33:23 +01:00
parent 46c3838193
commit cc30080ba8
6 changed files with 111 additions and 16 deletions
+11 -1
View File
@@ -6,8 +6,18 @@ directories:
files:
- dist/**/*
- resources/**/*
# Exclude host-compiled native module artifacts from the asar.
# electron-rebuild (postinstall) compiles uiohook-napi for the build machine,
# creating build/Release/*.node. node-gyp-build checks build/ BEFORE prebuilds/,
# so if these directories enter the asar, the app crashes on every platform
# (including the build platform after afterPack removes the unpacked file).
- "!**/node_modules/uiohook-napi/build/**"
- "!**/node_modules/uiohook-napi/build.bak/**"
- "!**/node_modules/uiohook-napi/bin/**"
asarUnpack:
- "**/*.node"
npmRebuild: false
afterPack: ./scripts/afterPack.js
publish:
- provider: github
owner: TheZwiss
@@ -25,7 +35,7 @@ mac:
- dmg
- zip
win:
icon: ./build/icon.ico
icon: ./build/icon.png
target:
- nsis
linux:
+1
View File
@@ -14,6 +14,7 @@
"dev": "mkdir -p build && cp ../../icon.png build/icon.png && bash scripts/gen-icns.sh && cp build/icon.icns $(find ../../node_modules -path '*/electron/dist/Electron.app/Contents/Resources/electron.icns' 2>/dev/null | head -1) 2>/dev/null; tsc && electron .",
"prebuild": "mkdir -p build && cp ../../icon.png build/icon.png",
"build": "tsc && electron-builder",
"build:all": "tsc && electron-builder --mac --win --linux --arm64 --x64",
"clean": "rm -rf dist dist-electron",
"postinstall": "electron-rebuild -f -w uiohook-napi"
},
+58
View File
@@ -0,0 +1,58 @@
// afterPack hook for electron-builder
// Removes host-compiled native module artifacts so cross-platform builds
// use the correct prebuilt binaries from the `prebuilds/` directory.
//
// Why this is needed:
// `electron-rebuild` (postinstall) compiles uiohook-napi for the BUILD
// machine (e.g. macOS arm64), placing the binary in `build/Release/`.
// `node-gyp-build` checks `build/Release/` BEFORE `prebuilds/{platform}/`,
// so Windows/Linux packages would load the macOS binary and crash.
//
// What this does:
// 1. Removes `build/`, `build.bak/`, `bin/` dirs (host-compiled artifacts)
// 2. Strips prebuilts for platforms other than the target
const fs = require('fs');
const path = require('path');
exports.default = async function afterPack(context) {
const platform = context.electronPlatformName; // 'darwin', 'linux', 'win32'
const appDir = path.join(
context.appOutDir,
// macOS bundles resources inside the .app
platform === 'darwin'
? `${context.packager.appInfo.productFilename}.app/Contents/Resources`
: 'resources'
);
const asarUnpacked = path.join(appDir, 'app.asar.unpacked');
const uiohookDir = path.join(asarUnpacked, 'node_modules', 'uiohook-napi');
if (!fs.existsSync(uiohookDir)) {
console.log(`[afterPack] uiohook-napi not found in ${platform} build — skipping`);
return;
}
// 1. Remove host-compiled artifacts that shadow prebuilts
for (const dir of ['build', 'build.bak', 'bin']) {
const target = path.join(uiohookDir, dir);
if (fs.existsSync(target)) {
fs.rmSync(target, { recursive: true, force: true });
console.log(`[afterPack] Removed ${dir}/ from uiohook-napi (${platform})`);
}
}
// 2. Strip prebuilts for other platforms (saves ~1-2MB per build)
const prebuildsDir = path.join(uiohookDir, 'prebuilds');
if (fs.existsSync(prebuildsDir)) {
for (const entry of fs.readdirSync(prebuildsDir)) {
const entryPlatform = entry.split('-')[0]; // 'darwin', 'linux', 'win32'
if (entryPlatform !== platform) {
fs.rmSync(path.join(prebuildsDir, entry), { recursive: true, force: true });
console.log(`[afterPack] Stripped prebuilds/${entry} (not needed for ${platform})`);
}
}
}
console.log(`[afterPack] Native module cleanup done for ${platform}`);
};