@@ -3,6 +3,7 @@ import * as NodeCrypto from "node:crypto";
33import * as NodePath from "node:path" ;
44
55import * as NodeServices from "@effect/platform-node/NodeServices" ;
6+ import { extractFile } from "@electron/asar" ;
67import { assert , it } from "@effect/vitest" ;
78import * as ConfigProvider from "effect/ConfigProvider" ;
89import * as FileSystem from "effect/FileSystem" ;
@@ -197,7 +198,7 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu
197198 yield * fs . makeDirectory ( path . dirname ( serverEntryPath ) , { recursive : true } ) ;
198199 yield * fs . makeDirectory ( path . dirname ( nativePath ) , { recursive : true } ) ;
199200 yield * fs . writeFileString ( serverEntryPath , input . serverEntrySource ?? "console.log('server');\n" ) ;
200- yield * fs . writeFileString ( nativePath , "native-binary" ) ;
201+ yield * fs . writeFileString ( nativePath , "MZ native-binary" ) ;
201202
202203 const generatedAsarPath = path . join ( tempDir , WINDOWS_SERVER_ASAR_RESOURCE ) ;
203204 yield * packWindowsServerAsar ( { sourceDir, asarPath : generatedAsarPath , arch : "x64" } ) ;
@@ -888,7 +889,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
888889 ] ) ;
889890 } ) ;
890891
891- it . effect ( "keeps target native files while excluding the other Windows architecture" , ( ) =>
892+ it . effect ( "unpacks target Windows natives while excluding the other architecture" , ( ) =>
892893 Effect . scoped (
893894 Effect . gen ( function * ( ) {
894895 const fs = yield * FileSystem . FileSystem ;
@@ -902,12 +903,14 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
902903 "node_modules/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe" ,
903904 "node_modules/node-pty/third_party/conpty/1.0.0/win10-x64/OpenConsole.exe" ,
904905 "node_modules/node-pty/third_party/conpty/1.0.0/win10-arm64/OpenConsole.exe" ,
906+ "node_modules/node-pty/prebuilds/win32-x64/pty.node" ,
907+ "node_modules/node-pty/prebuilds/linux-x64/pty.node" ,
905908 ] ;
906909
907910 for ( const nativeFile of nativeFiles ) {
908911 const nativePath = path . join ( sourceDir , nativeFile ) ;
909912 yield * fs . makeDirectory ( path . dirname ( nativePath ) , { recursive : true } ) ;
910- yield * fs . writeFileString ( nativePath , "native ") ;
913+ yield * fs . writeFileString ( nativePath , nativeFile . includes ( "linux" ) ? "\x7fELF" : "MZ ") ;
911914 }
912915
913916 const asarPath = path . join ( tempDir , "server.asar" ) ;
@@ -922,6 +925,22 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
922925 ) ,
923926 ) ,
924927 ) ;
928+ assert . isTrue (
929+ yield * fs . exists (
930+ path . join ( unpackedRoot , "node_modules/node-pty/prebuilds/win32-x64/pty.node" ) ,
931+ ) ,
932+ ) ;
933+ // Signed builds sign every unpacked .node, so the ELF prebuild stays packed.
934+ assert . isFalse (
935+ yield * fs . exists ( path . join ( unpackedRoot , "node_modules/node-pty/prebuilds/linux-x64" ) ) ,
936+ ) ;
937+ assert . equal (
938+ extractFile (
939+ asarPath ,
940+ path . join ( "node_modules" , "node-pty" , "prebuilds" , "linux-x64" , "pty.node" ) ,
941+ ) . toString ( ) ,
942+ "\x7fELF" ,
943+ ) ;
925944 assert . isFalse (
926945 yield * fs . exists ( path . join ( unpackedRoot , "node_modules/node-pty/prebuilds/win32-arm64" ) ) ,
927946 ) ;
@@ -2126,7 +2145,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
21262145 } ) . pipe ( Effect . provide ( ConfigProvider . layer ( ConfigProvider . fromEnv ( { env : { } } ) ) ) ) ,
21272146 ) ;
21282147
2129- it . effect ( "keeps executable resource editing enabled for unsigned Windows builds " , ( ) =>
2148+ it . effect ( "configures Windows executable metadata and native signing extensions " , ( ) =>
21302149 Effect . gen ( function * ( ) {
21312150 const config = yield * createBuildConfig (
21322151 "win" ,
@@ -2140,6 +2159,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
21402159
21412160 const win = config . win as Record < string , unknown > ;
21422161 assert . equal ( win . icon , "icon.ico" ) ;
2162+ assert . deepStrictEqual ( win . signExts , [ ".node" , ".dll" ] ) ;
21432163 assert . equal ( win . signAndEditExecutable , true ) ;
21442164 assert . notProperty ( win , "azureSignOptions" ) ;
21452165 } ) . pipe ( Effect . provide ( ConfigProvider . layer ( ConfigProvider . fromEnv ( { env : { } } ) ) ) ) ,
0 commit comments