main
Dmitry Kirdyashkin 2023-05-17 00:38:07 +03:00
parent 933349f595
commit ede9492da7
4 changed files with 183 additions and 124 deletions

View File

@ -1,5 +0,0 @@
---
- name: archive db
archive:
path: /mnt/data/foundryvtt-v10/Data/modules/shared-compendia/packs
dest: /mnt/data/temp.tar.gz

View File

@ -0,0 +1,42 @@
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"
}
}

View File

@ -0,0 +1,22 @@
Import-Module ./update-archive.psm1
Import-Module ./update-db.psm1
#Скачивание обновлений БД мира
Write-Host -ForegroundColor Cyan -NoNewline "`nDownload DB updates?(y/n): "
$answerDbUpd = Read-Host
if ($answerDbUpd -eq "y"){
update-db
}
elseif ($answerDbUpd -eq "n") {
Write-Host "Skipping DB updates`n"
}
#Обновить модуль
Write-Host -ForegroundColor Cyan -NoNewline "`nUpdate archive?(y/n): "
$answerArchUpd = Read-Host
if ($answerArchUpd -eq "y"){
update-archive
}
elseif ($answerArchUpd -eq "n") {
break
}

View File

@ -8,15 +8,15 @@
"name": "leego neit" "name": "leego neit"
} }
], ],
"version": "1.0.68", "version": "1.0.74",
"minimumCoreVersion": "9", "minimumCoreVersion": "9",
"compatibility": { "compatibility": {
"minimum": "9", "minimum": "9",
"verified": "10", "verified": "10",
"maximum": "10" "maximum": "10"
}, },
"manifest": "http://192.168.1.200:8082/repository/zip-repo/shared-compendia/module.json", "manifest": "https://nexus.kdiva.ru/repository/generic/shared-compendia/module.json",
"download": "http://192.168.1.200:8082/repository/zip-repo/shared-compendia/shared-compendia-1.0.68.zip", "download": "https://nexus.kdiva.ru/repository/generic/shared-compendia/shared-compendia-1.0.74.zip",
"packs": [ "packs": [
{ {
"name": "sc-actors", "name": "sc-actors",