From eaf84ad605e81734c485097279d308b76dfad832 Mon Sep 17 00:00:00 2001 From: Shahovalov MIkhail Date: Thu, 9 Apr 2026 10:58:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20=D1=81?= =?UTF-8?q?=D0=B8=D0=BD=D1=85=D1=80=D0=BE=D0=BD=D0=B8=D0=B7=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20parent=20meta=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2?= =?UTF-8?q?=D0=B5=D0=B4=D0=B5=D0=BD=20=D0=BD=D0=B0=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D1=80=D1=83=D0=B7=D0=BA=D1=83=20=D0=B8=D0=B7=20git?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ACTIONS.md | 2 +- scripts/sync-parent-meta.ps1 | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ACTIONS.md b/ACTIONS.md index 85a147c..6d197cf 100644 --- a/ACTIONS.md +++ b/ACTIONS.md @@ -68,7 +68,7 @@ ACTIONS: meta:sync-parent: intent: sync_dependency_moduleshortdesc_from_parent_meta inputs: - - parent_meta_path + - parent_meta_git_url (optional; defaults to upstream) - Mods/DnD 5.5e AIO Russian/meta.lsx plan: - read_parent_moduleinfo_fields diff --git a/scripts/sync-parent-meta.ps1 b/scripts/sync-parent-meta.ps1 index 92b4f7b..4296303 100644 --- a/scripts/sync-parent-meta.ps1 +++ b/scripts/sync-parent-meta.ps1 @@ -1,23 +1,27 @@ param( - [Parameter(Mandatory = $true)] - [string]$ParentMetaPath, + [string]$ParentMetaUrl = "https://raw.githubusercontent.com/Yoonmoonsik/dnd55e/main/Mods/DnD2024_897914ef-5c96-053c-44af-0be823f895fe/meta.lsx", [string]$TargetMetaPath = "Mods/DnD 5.5e AIO Russian/meta.lsx" ) $ErrorActionPreference = "Stop" -$resolvedParentMetaPath = [System.IO.Path]::GetFullPath($ParentMetaPath) $resolvedTargetMetaPath = [System.IO.Path]::GetFullPath($TargetMetaPath) -if (-not (Test-Path -LiteralPath $resolvedParentMetaPath)) { - throw "Parent meta.lsx was not found: '$resolvedParentMetaPath'." -} - if (-not (Test-Path -LiteralPath $resolvedTargetMetaPath)) { throw "Target meta.lsx was not found: '$resolvedTargetMetaPath'." } -$parentRaw = Get-Content -LiteralPath $resolvedParentMetaPath -Raw +if ([string]::IsNullOrWhiteSpace($ParentMetaUrl)) { + throw "ParentMetaUrl must not be empty." +} + +try { + $parentResponse = Invoke-WebRequest -Uri $ParentMetaUrl -UseBasicParsing -TimeoutSec 60 +} catch { + throw "Failed to download parent meta.lsx from '$ParentMetaUrl': $($_.Exception.Message)" +} + +$parentRaw = $parentResponse.Content $targetRaw = Get-Content -LiteralPath $resolvedTargetMetaPath -Raw [xml]$parentXml = $parentRaw @@ -25,7 +29,7 @@ $targetRaw = Get-Content -LiteralPath $resolvedTargetMetaPath -Raw $parentModuleInfo = $parentXml.SelectSingleNode('/save/region/node/children/node[@id="ModuleInfo"]') if ($null -eq $parentModuleInfo) { - throw "ModuleInfo node was not found in parent meta: '$resolvedParentMetaPath'." + throw "ModuleInfo node was not found in parent meta downloaded from '$ParentMetaUrl'." } $requiredFields = @("Folder", "MD5", "Name", "PublishHandle", "UUID", "Version64") @@ -34,12 +38,12 @@ $sourceValues = @{} foreach ($field in $requiredFields) { $node = $parentModuleInfo.SelectSingleNode("attribute[@id='$field']") if ($null -eq $node) { - throw "Required parent ModuleInfo attribute '$field' is missing in '$resolvedParentMetaPath'." + throw "Required parent ModuleInfo attribute '$field' is missing in meta downloaded from '$ParentMetaUrl'." } $value = $node.GetAttribute("value") if ([string]::IsNullOrWhiteSpace($value)) { - throw "Required parent ModuleInfo attribute '$field' has empty value in '$resolvedParentMetaPath'." + throw "Required parent ModuleInfo attribute '$field' has empty value in meta downloaded from '$ParentMetaUrl'." } $sourceValues[$field] = $value