Merge branch 'feat/sync-parent-meta'
This commit is contained in:
18
ACTIONS.md
18
ACTIONS.md
@@ -65,3 +65,21 @@ ACTIONS:
|
||||
- no_unverified_claims
|
||||
outputs:
|
||||
- final_user_report
|
||||
meta:sync-parent:
|
||||
intent: sync_dependency_moduleshortdesc_from_parent_meta
|
||||
inputs:
|
||||
- parent_meta_git_url (optional; defaults to upstream)
|
||||
- Mods/DnD 5.5e AIO Russian/meta.lsx
|
||||
plan:
|
||||
- read_parent_moduleinfo_fields
|
||||
- validate_required_fields_folder_md5_name_publishhandle_uuid_version64
|
||||
- update_target_dependencies_moduleshortdesc_fields
|
||||
- validate_xml_structure
|
||||
- report_changed_fields
|
||||
checks:
|
||||
- xml_valid
|
||||
- required_parent_fields_present
|
||||
- only_dependencies_moduleshortdesc_changed
|
||||
outputs:
|
||||
- Mods/DnD 5.5e AIO Russian/meta.lsx
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
2. merging to `main` immediately and deleting the `fix/*`/`feat/*` branch.
|
||||
- If push fails: retry up to 2 more times with 3s pause.
|
||||
- Never auto-commit/auto-push without explicit user approval.
|
||||
- Approval prompts for pending actions: short direct question in imperative form, no soft/opening phrases.
|
||||
- If multiple actions or combinations are possible: provide a numbered options list so user can reply with a number.
|
||||
|
||||
### Cleanup (General)
|
||||
- Do not leave temporary/debug artifacts in repo.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<attribute id="Author" type="LSString" value="MikhailRaw"/>
|
||||
<attribute id="CharacterCreationLevelName" type="FixedString" value=""/>
|
||||
<attribute id="Description" type="LSString" value="Русский перевод мода DnD 5.5e All-in-One BEYOND. Перевод ещё в разработке: AI помогает быстро обновлять тексты, а финальные правки и качество мы проверяем вручную."/>
|
||||
<attribute id="FileSize" type="uint64" value="0"/>
|
||||
<attribute id="FileSize" type="uint64" value="2488095"/>
|
||||
<attribute id="Folder" type="LSString" value="DnD 5.5e AIO Russian"/>
|
||||
<attribute id="LobbyLevelName" type="FixedString" value=""/>
|
||||
<attribute id="MD5" type="LSString" value="c0a8f3412870277331306e0719fc6f77"/>
|
||||
@@ -32,7 +32,7 @@
|
||||
<attribute id="PublishHandle" type="uint64" value="5965149"/>
|
||||
<attribute id="StartupLevelName" type="FixedString" value=""/>
|
||||
<attribute id="UUID" type="FixedString" value="6401e84d-daf2-416d-adeb-99c03a2487a6"/>
|
||||
<attribute id="Version64" type="int64" value="281477124194306"/>
|
||||
<attribute id="Version64" type="int64" value="281477124194307"/>
|
||||
<children>
|
||||
<node id="PublishVersion">
|
||||
<attribute id="Version64" type="int64" value="281477124194304"/>
|
||||
|
||||
91
scripts/sync-parent-meta.ps1
Normal file
91
scripts/sync-parent-meta.ps1
Normal file
@@ -0,0 +1,91 @@
|
||||
param(
|
||||
[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"
|
||||
|
||||
$resolvedTargetMetaPath = [System.IO.Path]::GetFullPath($TargetMetaPath)
|
||||
|
||||
if (-not (Test-Path -LiteralPath $resolvedTargetMetaPath)) {
|
||||
throw "Target meta.lsx was not found: '$resolvedTargetMetaPath'."
|
||||
}
|
||||
|
||||
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
|
||||
[xml]$targetXml = $targetRaw
|
||||
|
||||
$parentModuleInfo = $parentXml.SelectSingleNode('/save/region/node/children/node[@id="ModuleInfo"]')
|
||||
if ($null -eq $parentModuleInfo) {
|
||||
throw "ModuleInfo node was not found in parent meta downloaded from '$ParentMetaUrl'."
|
||||
}
|
||||
|
||||
$requiredFields = @("Folder", "MD5", "Name", "PublishHandle", "UUID", "Version64")
|
||||
$sourceValues = @{}
|
||||
|
||||
foreach ($field in $requiredFields) {
|
||||
$node = $parentModuleInfo.SelectSingleNode("attribute[@id='$field']")
|
||||
if ($null -eq $node) {
|
||||
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 meta downloaded from '$ParentMetaUrl'."
|
||||
}
|
||||
|
||||
$sourceValues[$field] = $value
|
||||
}
|
||||
|
||||
$targetDependencyNode = $targetXml.SelectSingleNode('/save/region/node/children/node[@id="Dependencies"]/children/node[@id="ModuleShortDesc"]')
|
||||
if ($null -eq $targetDependencyNode) {
|
||||
throw "Dependencies/ModuleShortDesc node was not found in target meta: '$resolvedTargetMetaPath'."
|
||||
}
|
||||
|
||||
$changedFields = @()
|
||||
foreach ($field in $requiredFields) {
|
||||
$targetAttr = $targetDependencyNode.SelectSingleNode("attribute[@id='$field']")
|
||||
if ($null -eq $targetAttr) {
|
||||
throw "Target Dependencies/ModuleShortDesc attribute '$field' is missing in '$resolvedTargetMetaPath'."
|
||||
}
|
||||
|
||||
$currentValue = $targetAttr.GetAttribute("value")
|
||||
$newValue = [string]$sourceValues[$field]
|
||||
if ($currentValue -ne $newValue) {
|
||||
$targetAttr.SetAttribute("value", $newValue)
|
||||
$changedFields += $field
|
||||
}
|
||||
}
|
||||
|
||||
if ($changedFields.Count -eq 0) {
|
||||
Write-Host "[sync-parent-meta.ps1] No changes needed. Target dependency data is already up to date."
|
||||
} else {
|
||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||
$settings = New-Object System.Xml.XmlWriterSettings
|
||||
$settings.Encoding = $utf8Bom
|
||||
$settings.Indent = $true
|
||||
$settings.IndentChars = " "
|
||||
$settings.NewLineChars = "`n"
|
||||
$settings.NewLineHandling = [System.Xml.NewLineHandling]::Replace
|
||||
|
||||
$writer = [System.Xml.XmlWriter]::Create($resolvedTargetMetaPath, $settings)
|
||||
try {
|
||||
$targetXml.WriteTo($writer)
|
||||
} finally {
|
||||
$writer.Dispose()
|
||||
}
|
||||
|
||||
Write-Host ("[sync-parent-meta.ps1] Updated fields: " + ($changedFields -join ", "))
|
||||
}
|
||||
Reference in New Issue
Block a user