@@ -17,6 +17,8 @@ import {
17
17
mkdirSync ,
18
18
cpSync ,
19
19
rmSync ,
20
+ lstatSync ,
21
+ readlinkSync ,
20
22
} from "node:fs" ;
21
23
import { join , normalize } from "node:path" ;
22
24
// Use flora-colossus for finding all dependencies of EXTERNAL_DEPENDENCIES
@@ -38,6 +40,7 @@ export const EXTERNAL_DEPENDENCIES = [
38
40
"libsql" ,
39
41
"onnxruntime-node" ,
40
42
"workerpool" ,
43
+ "@amical/smart-whisper" ,
41
44
// Add any other native modules you need here
42
45
] ;
43
46
@@ -153,6 +156,42 @@ const config: ForgeConfig = {
153
156
}
154
157
}
155
158
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
+
156
195
// Prune onnxruntime-node to keep only the required binary
157
196
const targetPlatform = platform ;
158
197
const targetArch = arch ;
@@ -199,6 +238,7 @@ const config: ForgeConfig = {
199
238
}
200
239
} ,
201
240
packageAfterPrune : async ( _forgeConfig , buildPath ) => {
241
+ console . error ( "PRE PACKAGE" ) ;
202
242
try {
203
243
function getItemsFromFolder (
204
244
path : string ,
@@ -267,14 +307,13 @@ const config: ForgeConfig = {
267
307
packagerConfig : {
268
308
asar : {
269
309
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/**}" ,
271
311
} ,
272
312
name : "Amical" ,
273
313
executableName : "Amical" ,
274
314
icon : "./assets/logo" , // Path to your icon file
275
315
appBundleId : "com.amical.desktop" , // Proper bundle ID
276
316
extraResource : [
277
- `${ process . platform === "win32" ? "../../packages/native-helpers/windows-helper/bin" : "../../packages/native-helpers/swift-helper/bin" } ` ,
278
317
"./src/db/migrations" ,
279
318
// Only include the platform-specific node binary
280
319
`./node-binaries/${ process . platform } -${ process . arch } /node${
@@ -361,6 +400,14 @@ const config: ForgeConfig = {
361
400
// Handle scoped packages: if dep is @scope /package, also keep @scope/ directory
362
401
if ( dep . includes ( "/" ) && dep . startsWith ( "@" ) ) {
363
402
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
+ }
364
411
if (
365
412
filePath === `/node_modules/${ scopeDir } /` ||
366
413
filePath === `/node_modules/${ scopeDir } ` ||
0 commit comments