diff --git a/samy.ps1 b/samy.ps1 index 180eddf..a77c966 100644 --- a/samy.ps1 +++ b/samy.ps1 @@ -91,29 +91,40 @@ $ConfirmPreference = 'None' # Configurable endpoints $Global:DattoWebhookUrl = 'https://bananas.svstools.ca/dattormm' - # SAMY asset config (change branch or base once and it updates everything) - $Script:SamyBranch = 'beta' # 'main' or 'beta' + # 1) Params / defaults / branch selection logic (change branch or base once and it updates everything) $Script:SamyRepoBase = 'https://git.svstools.ca/SVS_Public_Repo/SAMY/raw/branch' + $Script:SamyBranch = 'beta' # 'main' or 'beta' if (Get-Command Set-SvsPrinterRepoConfig -ErrorAction SilentlyContinue) { Set-SvsPrinterRepoConfig -RepoBase $Script:SamyRepoBase -Branch $Script:SamyBranch } - - # Top-left corner logo (SVS) - $Script:SamyTopLogoUrl = "$Script:SamyRepoBase/$Script:SamyBranch/SVS_logo.svg" - - # Background SAMY image used in CSS - $Script:SamyBgLogoUrl = "$Script:SamyRepoBase/$Script:SamyBranch/SAMY.png?raw=1" - $Script:SamyFaviconUrl = "$Script:SamyRepoBase/$Script:SamyBranch/SVS_Favicon.ico" - $Script:SamyCssUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.css?raw=1" - $Script:SamyJsUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.js?raw=1" - $Script:SamyHtmlUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.html?raw=1" + # 2) Build all remote URLs + $Script:SamyTopLogoUrl = "$Script:SamyRepoBase/$Script:SamyBranch/SVS_logo.svg?raw=1" + $Script:SamyBgLogoUrl = "$Script:SamyRepoBase/$Script:SamyBranch/SAMY.png?raw=1" + $Script:SamyFaviconUrl = "$Script:SamyRepoBase/$Script:SamyBranch/SVS_Favicon.ico?raw=1" + $Script:SamyCssUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.css?raw=1" + $Script:SamyJsUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.js?raw=1" + $Script:SamyHtmlUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.html?raw=1" + $Script:SamyTasksUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.tasks.json?raw=1" + $Script:SamyFunctionsUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.functions.ps1?raw=1" + + # Misc $Script:SamyHintText = "" - $Script:SamyTasksUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.tasks.json?raw=1" + # 3) Load remote functions (must be before calling them) + try { + $functionsContent = (Invoke-WebRequest -UseBasicParsing $Script:SamyFunctionsUrl -ErrorAction Stop).Content + } + catch { + throw "Failed to download samy.functions.ps1 from $Script:SamyFunctionsUrl. $($_.Exception.Message)" + } + . ([ScriptBlock]::Create($functionsContent)) + # 4) Now call functions that live in samy.functions.ps1 + # Initialize-NuGetProvider + # 5) Continue with rest of samy.ps1 logic (UI, CSS/JS/HTML download, etc.) # Initialize a global in-memory log cache if (-not $Global:LogCache -or -not ($Global:LogCache -is [System.Collections.ArrayList])) {