11import type { ChildProcess } from "node:child_process" ;
22import { execSync } from "node:child_process" ;
3- import { cpSync , existsSync , mkdirSync , rmSync , statSync } from "node:fs" ;
3+ import { cpSync , existsSync , mkdirSync , rmSync } from "node:fs" ;
44import path from "node:path" ;
55import { MakerDMG } from "@electron-forge/maker-dmg" ;
6+ import { MakerSquirrel } from "@electron-forge/maker-squirrel" ;
67import { MakerZIP } from "@electron-forge/maker-zip" ;
78import { VitePlugin } from "@electron-forge/plugin-vite" ;
89import { PublisherGithub } from "@electron-forge/publisher-github" ;
@@ -181,28 +182,30 @@ const config: ForgeConfig = {
181182 }
182183 : { } ) ,
183184 } ) ,
184- new MakerZIP ( { } , [ "darwin" , "linux" , "win32" ] ) ,
185+ new MakerSquirrel ( {
186+ name : "PostHogCode" ,
187+ setupIcon : "./build/app-icon.ico" ,
188+ } ) ,
189+ new MakerZIP ( { } , [ "darwin" , "linux" ] ) ,
185190 ] ,
186191 hooks : {
187192 generateAssets : async ( ) => {
188- const isNewer = ( src : string , dest : string ) =>
189- ! existsSync ( dest ) || statSync ( src ) . mtimeMs > statSync ( dest ) . mtimeMs ;
193+ if ( process . platform !== "darwin" ) return ;
190194
191195 if (
192196 existsSync ( "build/app-icon.png" ) &&
193- isNewer ( "build/app-icon.png" , "build/app-icon.icns" )
197+ ! existsSync ( "build/app-icon.icns" )
194198 ) {
195199 execSync ( "bash scripts/generate-icns.sh" , { stdio : "inherit" } ) ;
196200 }
197201
198- if (
199- existsSync ( "build/icon.icon" ) &&
200- isNewer ( "build/icon.icon/icon.json" , "build/Assets.car" )
201- ) {
202+ if ( existsSync ( "build/icon.icon" ) && ! existsSync ( "build/Assets.car" ) ) {
202203 execSync ( "bash scripts/compile-glass-icon.sh" , { stdio : "inherit" } ) ;
203204 }
204205 } ,
205206 prePackage : async ( ) => {
207+ if ( process . platform !== "darwin" ) return ;
208+
206209 // Build native modules for DMG maker on Node.js 22
207210 const modules = [ "macos-alias" , "fs-xattr" ] ;
208211
@@ -221,9 +224,20 @@ const config: ForgeConfig = {
221224 copyNativeDependency ( "node-pty" , buildPath ) ;
222225 copyNativeDependency ( "node-addon-api" , buildPath ) ;
223226 copyNativeDependency ( "@parcel/watcher" , buildPath ) ;
224- copyNativeDependency ( "@parcel/watcher-darwin-arm64" , buildPath ) ;
225- copyNativeDependency ( "file-icon" , buildPath ) ;
226- copyNativeDependency ( "p-map" , buildPath ) ;
227+
228+ // Platform-specific native dependencies
229+ if ( process . platform === "darwin" ) {
230+ copyNativeDependency ( "@parcel/watcher-darwin-arm64" , buildPath ) ;
231+ copyNativeDependency ( "file-icon" , buildPath ) ;
232+ copyNativeDependency ( "p-map" , buildPath ) ;
233+ } else if ( process . platform === "win32" ) {
234+ const watcherPkg =
235+ process . arch === "arm64"
236+ ? "@parcel/watcher-win32-arm64"
237+ : "@parcel/watcher-win32-x64" ;
238+ copyNativeDependency ( watcherPkg , buildPath ) ;
239+ }
240+
227241 // Copy @parcel /watcher's hoisted dependencies
228242 copyNativeDependency ( "micromatch" , buildPath ) ;
229243 copyNativeDependency ( "is-glob" , buildPath ) ;
0 commit comments