diff --git a/generate-http-requests.bat b/generate-httpyac-requests.bat similarity index 88% rename from generate-http-requests.bat rename to generate-httpyac-requests.bat index 405ae37..e7ed4b6 100644 --- a/generate-http-requests.bat +++ b/generate-httpyac-requests.bat @@ -6,7 +6,7 @@ cd /D "%~dp0" echo. -@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\generate-http-requests.ps1 %* +@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\generate-httpyac-requests.ps1 %* echo. diff --git a/scripts/generate-http-requests.ps1 b/scripts/generate-httpyac-requests.ps1 similarity index 95% rename from scripts/generate-http-requests.ps1 rename to scripts/generate-httpyac-requests.ps1 index b0da455..58796a7 100644 --- a/scripts/generate-http-requests.ps1 +++ b/scripts/generate-httpyac-requests.ps1 @@ -1,14 +1,16 @@ #requires -Modules powershell-yaml param( - [string]$StartDir = (Split-Path -LiteralPath $MyInvocation.MyCommand.Path) + [string]$StartDir = (Resolve-Path -LiteralPath (Join-Path -Path (Split-Path -LiteralPath $MyInvocation.MyCommand.Path) -ChildPath "../bruno")), + [string]$OutputDir = (Resolve-Path -LiteralPath (Join-Path -Path (Split-Path -LiteralPath $MyInvocation.MyCommand.Path) -ChildPath "..")) ) $DEFAULT_ENV_VAR_VALUE = 'EDIT_VALUE_HERE' $VARIABLE_NAME_VALUE_SEPARATOR = '=' -function Find-WorkspaceRoot($startDir) { - $current = $startDir +function Find-WorkspaceRoot($dir) { + Write-Host "Processing workspace folder: '$dir'..." + $current = $dir while ($true) { if (Test-Path -LiteralPath (Join-Path $current 'workspace.yml')) { return $current @@ -997,7 +999,7 @@ function Write-JsFiles ($sourceDir, $outputRoot) { function Invoke-Main { # Workspace root - $workspaceRoot = Find-WorkspaceRoot $PSScriptRoot + $workspaceRoot = Find-WorkspaceRoot $StartDir $workspaceFile = Join-Path $workspaceRoot 'workspace.yml' $workspace = Parse-Workspace $workspaceFile $collections = @() @@ -1009,7 +1011,12 @@ function Invoke-Main { throw "No collections found in workspace.yml" } - $outputBaseRoot = Join-Path $workspaceRoot 'autodocs/httpyac' + $outputBaseRoot = Join-Path $OutputDir 'autodocs/httpyac' + if (-not (Test-Path $outputBaseRoot)) { + New-Item -ItemType Directory -Path $outputBaseRoot | Out-Null + } + $outputBaseRoot = Resolve-Path -LiteralPath $outputBaseRoot + Clean-Folder $outputBaseRoot foreach ($collection in $collections) { diff --git a/scripts/setup-json-environment.ps1 b/scripts/setup-json-environment.ps1 index 5f9e847..6eb89c6 100644 --- a/scripts/setup-json-environment.ps1 +++ b/scripts/setup-json-environment.ps1 @@ -25,8 +25,12 @@ function Ask-YesNo($message) { } # Funzione per chiedere un valore -function Ask-Value($key) { - return Read-Host "Valore per '$key' (digita `"`" per inserire stringa vuota e lascia vuoto per NON aggiornare)" +function Ask-Value($key, $currentValue) { + $currentValueHint = "" + if (-not [string]::IsNullOrEmpty($currentValue)) { + $currentValueHint = "[attuale: '$currentValue'] " + } + return Read-Host "Chiave '$key' $currentValueHint`n(digita `"`" per inserire stringa vuota e lascia vuoto per NON aggiornare)" } # Copia profonda preservando ordine @@ -79,8 +83,6 @@ foreach ($topKey in $parsedJson.Keys) { continue } - $inputValue = Ask-Value $key - if ($existingEnv -and $existingEnv["API"] -and $existingEnv["API"].Contains($sectionName)) { $oldValue = $existingEnv["API"][$sectionName][$key] } @@ -88,6 +90,8 @@ foreach ($topKey in $parsedJson.Keys) { $oldValue = "" } + $inputValue = Ask-Value $key $oldValue + if ($inputValue -eq "") { # Mantieni valore esistente se presente $newSection[$key] = $oldValue diff --git a/scripts/update-bruno-environments.ps1 b/scripts/update-bruno-environments.ps1 index 39c200a..8bfe777 100644 --- a/scripts/update-bruno-environments.ps1 +++ b/scripts/update-bruno-environments.ps1 @@ -1,6 +1,6 @@ # Percorsi file -$envFile = Join-Path $PSScriptRoot ".." "env.json" # JSON originale -$collectionsRoot = Join-Path $PSScriptRoot ".." "collections" # cartella di partenza delle collezioni +$envFile = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot ".." "env.json") # JSON originale +$collectionsRoot = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot ".." "bruno/collections") # cartella di partenza delle collezioni # Costanti $ENV_JSON_FILENAME = "env.json" diff --git a/scripts/update-http-requests-environments.ps1 b/scripts/update-httpyac-environments.ps1 similarity index 91% rename from scripts/update-http-requests-environments.ps1 rename to scripts/update-httpyac-environments.ps1 index e03834c..d373c9c 100644 --- a/scripts/update-http-requests-environments.ps1 +++ b/scripts/update-httpyac-environments.ps1 @@ -1,6 +1,6 @@ # Percorsi file -$envFile = Join-Path $PSScriptRoot ".." "env.json" # JSON originale -$collectionsRoot = Join-Path $PSScriptRoot ".." "autodocs/httpyac" # cartella di partenza delle collezioni +$envFile = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot ".." "env.json") # JSON originale +$collectionsRoot = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot ".." "autodocs/httpyac") # cartella di partenza delle collezioni # Costanti $API_SECTION_NAME = "API" diff --git a/update-http-requests-environments.bat b/update-httpyac-environments.bat similarity index 86% rename from update-http-requests-environments.bat rename to update-httpyac-environments.bat index f75f472..6df6afe 100644 --- a/update-http-requests-environments.bat +++ b/update-httpyac-environments.bat @@ -6,7 +6,7 @@ cd /D "%~dp0" echo. -@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\update-http-requests-environments.ps1 %* +@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\update-httpyac-environments.ps1 %* echo.