2023-05-16 21:38:03 +00:00
|
|
|
function Get-Update {
|
|
|
|
param (
|
|
|
|
[Parameter(Mandatory=$true)]
|
2023-05-18 17:15:11 +00:00
|
|
|
[String]$moduleName
|
2023-05-16 21:38:03 +00:00
|
|
|
)
|
|
|
|
|
2023-05-18 17:15:11 +00:00
|
|
|
$keyFile = "C:\Users\dmitr\.ssh\dmitry.kirdyashkin"
|
|
|
|
$localFolder = "C:\Users\dmitr\Documents\Repos\local\fvtt-shared-compendia"
|
|
|
|
$source = "192.168.1.200:/mnt/data/foundryvtt-v10/Data/modules/$moduleName/packs"
|
|
|
|
$destination = "$($localFolder)\$($moduleName)\packs"
|
|
|
|
$manifest = Get-Content $localFolder\$moduleName\module.json -Raw | `
|
|
|
|
ConvertFrom-Json
|
|
|
|
$dbName = $manifest | `
|
|
|
|
select-Object -ExpandProperty packs | `
|
|
|
|
Select-Object path | `
|
|
|
|
Split-Path -Leaf
|
|
|
|
|
2023-05-16 21:38:03 +00:00
|
|
|
if (!(Test-Path -Path $destination)){
|
|
|
|
New-Item -Path $destination -ItemType Directory -Force
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Host -ForegroundColor Cyan "`nDownloading packages..."
|
2023-05-18 17:15:11 +00:00
|
|
|
foreach ($db in $dbName) {
|
|
|
|
try {
|
|
|
|
scp -i "$($keyFile)" "owner@$($source)/$($db)" "$($destination)/$($db)"
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
}
|
2023-05-16 21:38:03 +00:00
|
|
|
}
|
|
|
|
|
2023-05-18 17:15:11 +00:00
|
|
|
# Get-Update -module sc-characters
|
2023-05-16 21:38:03 +00:00
|
|
|
|
2023-05-18 17:15:11 +00:00
|
|
|
function New-Archive {
|
2023-05-16 21:38:03 +00:00
|
|
|
param (
|
2023-05-18 17:15:11 +00:00
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[String]$moduleName
|
2023-05-16 21:38:03 +00:00
|
|
|
)
|
2023-05-18 17:15:11 +00:00
|
|
|
|
|
|
|
$localFolder = "C:\Users\dmitr\Documents\Repos\local\fvtt-shared-compendia"
|
|
|
|
# $moduleName = "sc-characters"
|
|
|
|
$uploadPath = "https://nexus.kdiva.ru/repository/generic/shared-compendia/$($moduleName)"
|
|
|
|
$manifest = Get-Content $localFolder\$moduleName\module.json -Raw | `
|
|
|
|
ConvertFrom-Json
|
|
|
|
|
2023-05-16 21:38:03 +00:00
|
|
|
#изменение версии и пути скачивания
|
|
|
|
Write-Host -ForegroundColor Cyan "`nModifying module.json..."
|
|
|
|
|
2023-05-18 17:15:11 +00:00
|
|
|
#увеличение версии
|
|
|
|
[version]$version=$manifest.version
|
|
|
|
$newVersion = ([version]::New($version.Major,$version.Minor,$version.Build+1)).ToString()
|
|
|
|
# установка версии
|
|
|
|
$manifest.version = $newVersion
|
|
|
|
#установка имени архива
|
|
|
|
$archiveName = "$moduleName-$newVersion.zip"
|
|
|
|
$manifest.download = "$uploadPath/$archiveName"
|
|
|
|
#изменение module.json
|
|
|
|
$manifest | ConvertTo-Json | Set-Content "$localFolder\$moduleName\module.json"
|
2023-05-16 21:38:03 +00:00
|
|
|
#создание архива
|
|
|
|
Write-Host -ForegroundColor Cyan "`nCreating archive..."
|
2023-05-18 17:15:11 +00:00
|
|
|
Get-ChildItem $localFolder\$moduleName -Recurse -Depth 0 |
|
2023-05-16 21:38:03 +00:00
|
|
|
Where-Object {$_.Name -notin $exclude} |
|
2023-05-18 17:15:11 +00:00
|
|
|
Compress-Archive -Force -DestinationPath "$localFolder\$moduleName\$archiveName"
|
2023-05-16 21:38:03 +00:00
|
|
|
|
|
|
|
#загрузка архива
|
|
|
|
Write-Host -ForegroundColor Cyan "`nUploading archive..."
|
2023-05-18 17:15:11 +00:00
|
|
|
curl.exe --user owner:5ehfv3fbj8 --upload-file $localFolder\$moduleName\$archiveName $uploadPath/$archiveName --upload-file $localFolder\$moduleName\module.json $uploadPath/module.json
|
2023-05-16 21:38:03 +00:00
|
|
|
|
|
|
|
#проверка и удаление архива
|
|
|
|
$response = Invoke-RestMethod -Method Get -Uri 'https://nexus.kdiva.ru/service/rest/v1/assets?repository=generic'
|
2023-05-18 17:40:16 +00:00
|
|
|
Start-Sleep -Seconds 5
|
2023-05-18 17:15:11 +00:00
|
|
|
if ($response.items.path -like "*$archiveName*"){
|
2023-05-16 21:38:03 +00:00
|
|
|
Write-Host -ForegroundColor Cyan "`nUploaded successfully`nDeleting local archive..."
|
2023-05-18 17:15:11 +00:00
|
|
|
Remove-Item -Path $localFolder/$moduleName/*.zip
|
2023-05-16 21:38:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
Write-Host -ForegroundColor Red "Archive not found"
|
|
|
|
}
|
|
|
|
}
|