diff --git a/SPLIT-samy.ps1 b/SPLIT-samy.ps1 index 825db25..96cc5fc 100644 --- a/SPLIT-samy.ps1 +++ b/SPLIT-samy.ps1 @@ -80,31 +80,45 @@ $Script:ChunkBase = "$Script:SamyGitRepo/src" # Load chunks (dependencies first) $chunks = @( - - - @{ Name = 'samy.functions.ps1'; Url = "$Script:ChunkBase/samy.functions.ps1?raw=1" }, + # 1) Config first: establishes all $Script:Samy*Url / ports / repo base @{ Name = 'config.ps1'; Url = "$Script:ChunkBase/config.ps1?raw=1" }, - @{ Name = 'logging.fallback.ps1'; Url = "$Script:ChunkBase/logging.fallback.ps1?raw=1" }, - @{ Name = 'remote.ps1'; Url = "$Script:ChunkBase/remote.ps1?raw=1" }, - @{ Name = 'helpers.ps1'; Url = "$Script:ChunkBase/helpers.ps1?raw=1" }, - @{ Name = 'tasks.ps1'; Url = "$Script:ChunkBase/tasks.ps1?raw=1" }, - @{ Name = 'http.ps1'; Url = "$Script:ChunkBase/http.ps1?raw=1" }, + # 2) Logging next: used everywhere + @{ Name = 'logging.fallback.ps1'; Url = "$Script:ChunkBase/logging.fallback.ps1?raw=1" }, + + # 3) Core helpers/utilities that others depend on + @{ Name = 'helpers.ps1'; Url = "$Script:ChunkBase/helpers.ps1?raw=1" }, + @{ Name = 'http.ps1'; Url = "$Script:ChunkBase/http.ps1?raw=1" }, + @{ Name = 'remote.ps1'; Url = "$Script:ChunkBase/remote.ps1?raw=1" }, + + # 4) Core data loaders / domain logic + @{ Name = 'tasks.ps1'; Url = "$Script:ChunkBase/tasks.ps1?raw=1" }, + + # 5) Integrations + installers @{ Name = 'svsmsp.install.ps1'; Url = "$Script:ChunkBase/svsmsp.install.ps1?raw=1" }, @{ Name = 'integrations.datto.ps1';Url = "$Script:ChunkBase/integrations.datto.ps1?raw=1" }, + # 6) UI renderer (Get-UIHtml depends on URLs + http helpers) @{ Name = 'ui.ps1'; Url = "$Script:ChunkBase/ui.ps1?raw=1" }, + + # 7) Handlers (depend on tasks/helpers/logging) @{ Name = 'handlers.datto.ps1'; Url = "$Script:ChunkBase/handlers.datto.ps1?raw=1" }, @{ Name = 'handlers.onboard.ps1'; Url = "$Script:ChunkBase/handlers.onboard.ps1?raw=1" }, @{ Name = 'handlers.offboard.ps1'; Url = "$Script:ChunkBase/handlers.offboard.ps1?raw=1" }, @{ Name = 'handlers.printers.ps1'; Url = "$Script:ChunkBase/handlers.printers.ps1?raw=1" }, + # 8) Router and server last (depend on UI + handlers + http) @{ Name = 'router.ps1'; Url = "$Script:ChunkBase/router.ps1?raw=1" }, @{ Name = 'server.ps1'; Url = "$Script:ChunkBase/server.ps1?raw=1" }, + # 9) Functions file can be early OR late, but safest is after config/logging. + @{ Name = 'samy.functions.ps1'; Url = "$Script:ChunkBase/samy.functions.ps1?raw=1" }, + + # 10) Entry point last @{ Name = 'core.ps1'; Url = "$Script:ChunkBase/core.ps1?raw=1" } ) + foreach ($c in $chunks) { $content = Import-SamyChunk -Url $c.Url -Name $c.Name . ([ScriptBlock]::Create($content))