Skip to content

Commit 8781981

Browse files
committed
fix: unpacking of smart-whisper
1 parent 81cec16 commit 8781981

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ jobs:
2020
strategy:
2121
matrix:
2222
include:
23+
- os: macos
24+
arch: arm64
25+
runner: macos-latest
26+
- os: macos
27+
arch: x64
28+
runner: macos-13
2329
- os: windows
2430
arch: x64
2531
runner: windows-2025

apps/desktop/forge.config.ts

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
mkdirSync,
1818
cpSync,
1919
rmSync,
20+
lstatSync,
21+
readlinkSync,
2022
} from "node:fs";
2123
import { join, normalize } from "node:path";
2224
// Use flora-colossus for finding all dependencies of EXTERNAL_DEPENDENCIES
@@ -38,6 +40,7 @@ export const EXTERNAL_DEPENDENCIES = [
3840
"libsql",
3941
"onnxruntime-node",
4042
"workerpool",
43+
"@amical/smart-whisper",
4144
// Add any other native modules you need here
4245
];
4346

@@ -153,6 +156,42 @@ const config: ForgeConfig = {
153156
}
154157
}
155158

159+
// Second pass: Replace any symlinks with dereferenced copies
160+
console.log("Checking for symlinks in copied dependencies...");
161+
for (const dep of nativeModuleDependenciesToPackage) {
162+
const localDepPath = join(localNodeModules, dep);
163+
164+
try {
165+
if (existsSync(localDepPath)) {
166+
const stats = lstatSync(localDepPath);
167+
if (stats.isSymbolicLink()) {
168+
console.log(`Found symlink for ${dep}, replacing with dereferenced copy...`);
169+
170+
// Read where the symlink points to
171+
const symlinkTarget = readlinkSync(localDepPath);
172+
const absoluteTarget = join(localNodeModules, dep, "..", symlinkTarget);
173+
const sourcePath = normalize(absoluteTarget);
174+
175+
console.log(` Symlink points to: ${sourcePath}`);
176+
177+
// Remove the symlink
178+
rmSync(localDepPath, { recursive: true, force: true });
179+
180+
// Copy with dereference to get actual content
181+
cpSync(sourcePath, localDepPath, {
182+
recursive: true,
183+
force: true,
184+
dereference: true // Follow symlinks and copy actual content
185+
});
186+
187+
console.log(`✓ Successfully replaced symlink for ${dep} with actual content`);
188+
}
189+
}
190+
} catch (error) {
191+
console.error(`Failed to check/replace symlink for ${dep}:`, error);
192+
}
193+
}
194+
156195
// Prune onnxruntime-node to keep only the required binary
157196
const targetPlatform = platform;
158197
const targetArch = arch;
@@ -199,6 +238,7 @@ const config: ForgeConfig = {
199238
}
200239
},
201240
packageAfterPrune: async (_forgeConfig, buildPath) => {
241+
console.error("PRE PACKAGE");
202242
try {
203243
function getItemsFromFolder(
204244
path: string,
@@ -267,14 +307,13 @@ const config: ForgeConfig = {
267307
packagerConfig: {
268308
asar: {
269309
unpack:
270-
"{*.node,*.dylib,*.so,*.dll,*.metal,**/whisper.cpp/**,**/.vite/build/whisper-worker-fork.js,**/node_modules/jest-worker/**,**/onnxruntime-node/bin/**}",
310+
"{*.node,*.dylib,*.so,*.dll,*.metal,**/node_modules/@amical/smart-whisper/**,**/whisper.cpp/**,**/.vite/build/whisper-worker-fork.js,**/node_modules/jest-worker/**,**/onnxruntime-node/bin/**}",
271311
},
272312
name: "Amical",
273313
executableName: "Amical",
274314
icon: "./assets/logo", // Path to your icon file
275315
appBundleId: "com.amical.desktop", // Proper bundle ID
276316
extraResource: [
277-
`${process.platform === "win32" ? "../../packages/native-helpers/windows-helper/bin" : "../../packages/native-helpers/swift-helper/bin"}`,
278317
"./src/db/migrations",
279318
// Only include the platform-specific node binary
280319
`./node-binaries/${process.platform}-${process.arch}/node${
@@ -361,6 +400,14 @@ const config: ForgeConfig = {
361400
// Handle scoped packages: if dep is @scope/package, also keep @scope/ directory
362401
if (dep.includes("/") && dep.startsWith("@")) {
363402
const scopeDir = dep.split("/")[0]; // @libsql/client -> @libsql
403+
// for workspace packages only keep the actual package
404+
if (scopeDir === "@amical") {
405+
if (filePath.startsWith(`/node_modules/${dep}/`)) {
406+
KEEP_FILE.keep = true;
407+
KEEP_FILE.log = true;
408+
}
409+
break;
410+
}
364411
if (
365412
filePath === `/node_modules/${scopeDir}/` ||
366413
filePath === `/node_modules/${scopeDir}` ||

0 commit comments

Comments
 (0)