function update-archive { param ( #$exclude = @(".gitignore","export","audio","temp",".git","create-archive.ps1"), $workFolder = "..\modules", $moduleName = "shared-compendia", $uploadPath = "http://192.168.1.200:8082/repository/zip-repo" ) #изменение версии и пути скачивания Write-Host -ForegroundColor Cyan "`nModifying module.json..." $content = Get-Content "$workFolder\$moduleName\src\module.json" | ConvertFrom-Json $oldVersion = $content.version $oldIndex = $oldVersion.ToString().split(".")[2] -as [int] $newIndex = ($oldIndex + 1).ToString() $patch = $oldVersion.LastIndexOf(".") $newVersion = $oldVersion.Substring(0, $patch) + "." + $newIndex $content.version = $newVersion $archiveName = "$moduleName-$newVersion.zip" $content.download = "$uploadPath/$moduleName/$archiveName" $content | ConvertTo-Json | Set-Content "$workFolder\$moduleName\src\module.json" Write-Host "Version Changed $oldVersion -> $newVersion" #создание архива Write-Host -ForegroundColor Cyan "`nCreating archive..." Get-ChildItem $workFolder\$moduleName\src\ -Recurse -Depth 0 | Where-Object {$_.Name -notin $exclude} | Compress-Archive -Force -DestinationPath "$workFolder\$moduleName\$archiveName" Copy-Item -Path "$workFolder\$moduleName\src\module.json" -Destination "$workFolder\$moduleName\module.json" -Force #загрузка архива Write-Host -ForegroundColor Cyan "`nUploading archive..." curl.exe --user upload:12345 --upload-file $workFolder\$moduleName\$archiveName $uploadPath/$moduleName/$archiveName --upload-file $workFolder\$moduleName\module.json $uploadPath/$moduleName/module.json #проверка и удаление архива $response = curl.exe --user upload:12345 -X GET 'http://192.168.1.200:8082/service/rest/v1/assets?repository=zip-repo' | ConvertFrom-Json if ($response.items.path -like "*$archiveName*"){ Write-Host -ForegroundColor Cyan "`nUploaded successfully`nDeleting local archive..." Remove-Item -Path $workFolder/$moduleName/*.zip } else { Write-Host -ForegroundColor Red "Archive not found" } }