@@ -22,6 +22,7 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
2222
2323import {
2424 buildDesktopBundles ,
25+ copyDesktopBuildArtifacts ,
2526 DesktopBuildManifestRestoreError ,
2627 BundleNotSelfContainedError ,
2728 BuildCommandFailedError ,
@@ -1745,3 +1746,57 @@ it.effect.skipIf(!symlinksSupported)("rebases packaged links into the isolated t
17451746 ) ;
17461747 } ) . pipe ( Effect . provide ( NodeServices . layer ) ) ,
17471748) ;
1749+
1750+ it . effect ( "preserves packaged app directories from the dir target" , ( ) =>
1751+ Effect . gen ( function * ( ) {
1752+ const fs = yield * FileSystem . FileSystem ;
1753+ const path = yield * Path . Path ;
1754+ const root = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-dir-artifact-" } ) ;
1755+ const stage = path . join ( root , "stage" ) ;
1756+ const output = path . join ( root , "output" ) ;
1757+ const app = path . join ( "mac-arm64" , "T3 Code.app" , "Contents" ) ;
1758+ yield * fs . makeDirectory ( path . join ( stage , app ) , { recursive : true } ) ;
1759+ yield * fs . writeFileString ( path . join ( stage , app , "Info.plist" ) , "built-app" ) ;
1760+ yield * fs . writeFileString ( path . join ( stage , "builder-debug.yml" ) , "debug" ) ;
1761+ const copied = yield * copyDesktopBuildArtifacts ( stage , output , true ) ;
1762+ assert . include ( copied , path . join ( output , "mac-arm64" ) ) ;
1763+ assert . equal ( yield * fs . readFileString ( path . join ( output , app , "Info.plist" ) ) , "built-app" ) ;
1764+ assert . equal ( yield * fs . readFileString ( path . join ( stage , app , "Info.plist" ) ) , "built-app" ) ;
1765+ yield * fs . remove ( path . join ( stage , app , "Info.plist" ) ) ;
1766+ yield * fs . writeFileString ( path . join ( stage , app , "New.plist" ) , "rebuilt-app" ) ;
1767+ yield * copyDesktopBuildArtifacts ( stage , output , true ) ;
1768+ assert . isFalse ( yield * fs . exists ( path . join ( output , app , "Info.plist" ) ) ) ;
1769+ assert . equal ( yield * fs . readFileString ( path . join ( output , app , "New.plist" ) ) , "rebuilt-app" ) ;
1770+ const filesOnly = yield * copyDesktopBuildArtifacts ( stage , path . join ( root , "files-only" ) ) ;
1771+ assert . deepEqual ( filesOnly , [ path . join ( root , "files-only" , "builder-debug.yml" ) ] ) ;
1772+ assert . isFalse ( yield * fs . exists ( path . join ( root , "files-only" , "mac-arm64" ) ) ) ;
1773+ yield * fs . remove ( path . join ( stage , "mac-arm64" ) , { recursive : true } ) ;
1774+ yield * fs . writeFileString ( path . join ( stage , "mac-arm64" ) , "flattened" ) ;
1775+ yield * copyDesktopBuildArtifacts ( stage , output , true ) ;
1776+ assert . equal ( yield * fs . readFileString ( path . join ( output , "mac-arm64" ) ) , "flattened" ) ;
1777+ } ) . pipe ( Effect . provide ( NodeServices . layer ) , Effect . scoped ) ,
1778+ ) ;
1779+
1780+ it . effect . skipIf ( ! symlinksSupported ) ( "preserves relative links when replacing dir artifacts" , ( ) =>
1781+ Effect . gen ( function * ( ) {
1782+ const fs = yield * FileSystem . FileSystem ;
1783+ const path = yield * Path . Path ;
1784+ const root = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-dir-artifact-links-" } ) ;
1785+ const stage = path . join ( root , "stage" ) ;
1786+ const output = path . join ( root , "output" ) ;
1787+ const app = path . join ( "mac-arm64" , "T3 Code.app" , "Contents" ) ;
1788+ yield * fs . makeDirectory ( path . join ( stage , app ) , { recursive : true } ) ;
1789+ yield * fs . writeFileString ( path . join ( stage , app , "Info.plist" ) , "built-app" ) ;
1790+ yield * fs . symlink ( "Info.plist" , path . join ( stage , app , "Current" ) ) ;
1791+ yield * copyDesktopBuildArtifacts ( stage , output , true ) ;
1792+ assert . equal ( yield * fs . readLink ( path . join ( output , app , "Current" ) ) , "Info.plist" ) ;
1793+ assert . equal ( yield * fs . readFileString ( path . join ( output , app , "Current" ) ) , "built-app" ) ;
1794+
1795+ yield * fs . remove ( path . join ( stage , app , "Current" ) ) ;
1796+ yield * fs . writeFileString ( path . join ( stage , app , "New.plist" ) , "rebuilt-app" ) ;
1797+ yield * fs . symlink ( "New.plist" , path . join ( stage , app , "Current" ) ) ;
1798+ yield * copyDesktopBuildArtifacts ( stage , output , true ) ;
1799+ assert . equal ( yield * fs . readLink ( path . join ( output , app , "Current" ) ) , "New.plist" ) ;
1800+ assert . equal ( yield * fs . readFileString ( path . join ( output , app , "Current" ) ) , "rebuilt-app" ) ;
1801+ } ) . pipe ( Effect . provide ( NodeServices . layer ) , Effect . scoped ) ,
1802+ ) ;
0 commit comments