Streamline management of API collections #1
@@ -6,7 +6,7 @@ cd /D "%~dp0"
|
|||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\generate-http-requests.ps1 %*
|
@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\generate-httpyac-requests.ps1 %*
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
#requires -Modules powershell-yaml
|
#requires -Modules powershell-yaml
|
||||||
|
|
||||||
param(
|
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'
|
$DEFAULT_ENV_VAR_VALUE = 'EDIT_VALUE_HERE'
|
||||||
$VARIABLE_NAME_VALUE_SEPARATOR = '='
|
$VARIABLE_NAME_VALUE_SEPARATOR = '='
|
||||||
|
|
||||||
function Find-WorkspaceRoot($startDir) {
|
function Find-WorkspaceRoot($dir) {
|
||||||
$current = $startDir
|
Write-Host "Processing workspace folder: '$dir'..."
|
||||||
|
$current = $dir
|
||||||
while ($true) {
|
while ($true) {
|
||||||
if (Test-Path -LiteralPath (Join-Path $current 'workspace.yml')) {
|
if (Test-Path -LiteralPath (Join-Path $current 'workspace.yml')) {
|
||||||
return $current
|
return $current
|
||||||
@@ -997,7 +999,7 @@ function Write-JsFiles ($sourceDir, $outputRoot) {
|
|||||||
|
|
||||||
function Invoke-Main {
|
function Invoke-Main {
|
||||||
# Workspace root
|
# Workspace root
|
||||||
$workspaceRoot = Find-WorkspaceRoot $PSScriptRoot
|
$workspaceRoot = Find-WorkspaceRoot $StartDir
|
||||||
$workspaceFile = Join-Path $workspaceRoot 'workspace.yml'
|
$workspaceFile = Join-Path $workspaceRoot 'workspace.yml'
|
||||||
$workspace = Parse-Workspace $workspaceFile
|
$workspace = Parse-Workspace $workspaceFile
|
||||||
$collections = @()
|
$collections = @()
|
||||||
@@ -1009,7 +1011,12 @@ function Invoke-Main {
|
|||||||
throw "No collections found in workspace.yml"
|
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
|
Clean-Folder $outputBaseRoot
|
||||||
|
|
||||||
foreach ($collection in $collections) {
|
foreach ($collection in $collections) {
|
||||||
@@ -25,8 +25,12 @@ function Ask-YesNo($message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Funzione per chiedere un valore
|
# Funzione per chiedere un valore
|
||||||
function Ask-Value($key) {
|
function Ask-Value($key, $currentValue) {
|
||||||
return Read-Host "Valore per '$key' (digita `"`" per inserire stringa vuota e lascia vuoto per NON aggiornare)"
|
$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
|
# Copia profonda preservando ordine
|
||||||
@@ -79,8 +83,6 @@ foreach ($topKey in $parsedJson.Keys) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
$inputValue = Ask-Value $key
|
|
||||||
|
|
||||||
if ($existingEnv -and $existingEnv["API"] -and $existingEnv["API"].Contains($sectionName)) {
|
if ($existingEnv -and $existingEnv["API"] -and $existingEnv["API"].Contains($sectionName)) {
|
||||||
$oldValue = $existingEnv["API"][$sectionName][$key]
|
$oldValue = $existingEnv["API"][$sectionName][$key]
|
||||||
}
|
}
|
||||||
@@ -88,6 +90,8 @@ foreach ($topKey in $parsedJson.Keys) {
|
|||||||
$oldValue = ""
|
$oldValue = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$inputValue = Ask-Value $key $oldValue
|
||||||
|
|
||||||
if ($inputValue -eq "") {
|
if ($inputValue -eq "") {
|
||||||
# Mantieni valore esistente se presente
|
# Mantieni valore esistente se presente
|
||||||
$newSection[$key] = $oldValue
|
$newSection[$key] = $oldValue
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Percorsi file
|
# Percorsi file
|
||||||
$envFile = Join-Path $PSScriptRoot ".." "env.json" # JSON originale
|
$envFile = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot ".." "env.json") # JSON originale
|
||||||
$collectionsRoot = Join-Path $PSScriptRoot ".." "collections" # cartella di partenza delle collezioni
|
$collectionsRoot = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot ".." "bruno/collections") # cartella di partenza delle collezioni
|
||||||
|
|
||||||
# Costanti
|
# Costanti
|
||||||
$ENV_JSON_FILENAME = "env.json"
|
$ENV_JSON_FILENAME = "env.json"
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
# Percorsi file
|
# Percorsi file
|
||||||
$envFile = Join-Path $PSScriptRoot ".." "env.json" # JSON originale
|
$envFile = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot ".." "env.json") # JSON originale
|
||||||
$collectionsRoot = Join-Path $PSScriptRoot ".." "autodocs/httpyac" # cartella di partenza delle collezioni
|
$collectionsRoot = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot ".." "autodocs/httpyac") # cartella di partenza delle collezioni
|
||||||
|
|
||||||
# Costanti
|
# Costanti
|
||||||
$API_SECTION_NAME = "API"
|
$API_SECTION_NAME = "API"
|
||||||
@@ -6,7 +6,7 @@ cd /D "%~dp0"
|
|||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\update-http-requests-environments.ps1 %*
|
@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\update-httpyac-environments.ps1 %*
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
Reference in New Issue
Block a user