diff --git a/playbooks/download-db.yml b/playbooks/download-db.yml deleted file mode 100644 index eb734b6..0000000 --- a/playbooks/download-db.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: archive db - archive: - path: /mnt/data/foundryvtt-v10/Data/modules/shared-compendia/packs - dest: /mnt/data/temp.tar.gz \ No newline at end of file diff --git a/scripts/update-archive.psm1 b/scripts/update-archive.psm1 new file mode 100644 index 0000000..bc9a654 --- /dev/null +++ b/scripts/update-archive.psm1 @@ -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" + } +} diff --git a/scripts/update-module.ps1 b/scripts/update-module.ps1 new file mode 100644 index 0000000..3e81db9 --- /dev/null +++ b/scripts/update-module.ps1 @@ -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 +} diff --git a/src/module.json b/src/module.json index e8a9301..56aed01 100644 --- a/src/module.json +++ b/src/module.json @@ -1,121 +1,121 @@ { - "id": "shared-compendia", - "name": "shared-compendia", - "title": "Shared Compendia", - "description": "Personal compendia-sharing module.", - "authors": [ - { - "name": "leego neit" - } - ], - "version": "1.0.68", - "minimumCoreVersion": "9", - "compatibility": { - "minimum": "9", - "verified": "10", - "maximum": "10" - }, - "manifest": "http://192.168.1.200:8082/repository/zip-repo/shared-compendia/module.json", - "download": "http://192.168.1.200:8082/repository/zip-repo/shared-compendia/shared-compendia-1.0.68.zip", - "packs": [ - { - "name": "sc-actors", - "label": "sc actors", - "path": "packs/sc-actors.db", - "entity": "Actor", - "type": "Actor", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-creatures", - "label": "sc creatures", - "path": "packs/sc-creatures.db", - "entity": "Actor", - "type": "Actor", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-classes", - "label": "sc classes", - "path": "packs/sc-classes.db", - "entity": "Item", - "type": "Item", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-class-features", - "label": "sc class features", - "path": "packs/sc-class-features.db", - "entity": "Item", - "type": "Item", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-races", - "label": "sc races", - "path": "packs/sc-races.db", - "entity": "Item", - "type": "Item", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-racial-features", - "label": "sc racial features", - "path": "packs/sc-racial-features.db", - "entity": "Item", - "type": "Item", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-items", - "label": "sc items", - "path": "packs/sc-items.db", - "entity": "Item", - "type": "Item", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-spells", - "label": "sc spells", - "path": "packs/sc-spells.db", - "entity": "Item", - "type": "Item", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-actions", - "label": "sc actions", - "path": "packs/sc-actions.db", - "entity": "Item", - "type": "Item", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-conditions", - "label": "sc conditions", - "path": "packs/sc-conditions.db", - "entity": "Item", - "type": "Item", - "module": "shared-compendia", - "system": "dnd5e" - }, - { - "name": "sc-backgrounds", - "label": "sc backgrounds", - "path": "packs/sc-backgrounds.db", - "entity": "Item", - "type": "Item", - "module": "shared-compendia", - "system": "dnd5e" - } - ] + "id": "shared-compendia", + "name": "shared-compendia", + "title": "Shared Compendia", + "description": "Personal compendia-sharing module.", + "authors": [ + { + "name": "leego neit" + } + ], + "version": "1.0.74", + "minimumCoreVersion": "9", + "compatibility": { + "minimum": "9", + "verified": "10", + "maximum": "10" + }, + "manifest": "https://nexus.kdiva.ru/repository/generic/shared-compendia/module.json", + "download": "https://nexus.kdiva.ru/repository/generic/shared-compendia/shared-compendia-1.0.74.zip", + "packs": [ + { + "name": "sc-actors", + "label": "sc actors", + "path": "packs/sc-actors.db", + "entity": "Actor", + "type": "Actor", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-creatures", + "label": "sc creatures", + "path": "packs/sc-creatures.db", + "entity": "Actor", + "type": "Actor", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-classes", + "label": "sc classes", + "path": "packs/sc-classes.db", + "entity": "Item", + "type": "Item", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-class-features", + "label": "sc class features", + "path": "packs/sc-class-features.db", + "entity": "Item", + "type": "Item", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-races", + "label": "sc races", + "path": "packs/sc-races.db", + "entity": "Item", + "type": "Item", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-racial-features", + "label": "sc racial features", + "path": "packs/sc-racial-features.db", + "entity": "Item", + "type": "Item", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-items", + "label": "sc items", + "path": "packs/sc-items.db", + "entity": "Item", + "type": "Item", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-spells", + "label": "sc spells", + "path": "packs/sc-spells.db", + "entity": "Item", + "type": "Item", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-actions", + "label": "sc actions", + "path": "packs/sc-actions.db", + "entity": "Item", + "type": "Item", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-conditions", + "label": "sc conditions", + "path": "packs/sc-conditions.db", + "entity": "Item", + "type": "Item", + "module": "shared-compendia", + "system": "dnd5e" + }, + { + "name": "sc-backgrounds", + "label": "sc backgrounds", + "path": "packs/sc-backgrounds.db", + "entity": "Item", + "type": "Item", + "module": "shared-compendia", + "system": "dnd5e" + } + ] }