Support a per-project destination folder in sync-consumers.ps1

The engine/media-backend family (KioskDisplay, MediaAnalyzer,
MediaTools, MediaViewer, MediaServant, ModerationHub,
ProjectConfigurator) mounted this same snapshot via a git submodule at
'engine' instead of 'shared' - which broke in CI, since Gitea Actions'
injected token doesn't cover cross-repo submodule auth for a private
repo. Converting them to the same vendored-copy pattern every other
consumer already uses needed the destination folder name to be
per-project instead of hardcoded to 'shared'.

Also adds MediaDesktop, which previously tried to check out this repo
as a sibling directory in CI (outside the job's workspace root - Gitea
Actions rejects that outright) instead of vendoring a copy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Gabriel20xxandClaude Sonnet 5 committed 2026-09-01 11:21:21 +02:00
1 parent 43d77dd47c
commit 170076ef4d
1 file changed
+57 -30
+57 -30
View File
@@ -12,20 +12,44 @@ if ($Push -and -not $Commit) {
throw 'The -Push switch requires -Commit so that only generated synchronization changes are pushed.'
}
function New-ConsumerProject {
param(
[Parameter(Mandatory = $true)]
[string]$Path,
[string]$Destination = 'shared'
)
return [pscustomobject]@{ Path = $Path; Destination = $Destination }
}
# Destination defaults to 'shared' (the snapshot folder name most consumers
# use). The engine/media-backend family below mounts the same snapshot at
# 'engine' instead - historically a git submodule, converted to this same
# vendored-copy pattern for consistency and to drop the private-submodule
# checkout auth dependency in CI.
$consumerProjects = @(
'Original/AutoCode',
'Original/SimpleCollection',
'Original/CollabTable',
'Original/GameStream',
'Original/SyncServer',
'Original/UnraidMonitor',
'Original/PubliSafe',
'Forks/Bitmagnet',
'Forks/Heretic',
'Original/InfiniteVideo',
'Forks/MegaBasterd',
'Forks/HordeWorker',
'Original/OutdoorGames'
New-ConsumerProject 'Original/MediaDesktop'
New-ConsumerProject 'Original/AutoCode'
New-ConsumerProject 'Original/SimpleCollection'
New-ConsumerProject 'Original/CollabTable'
New-ConsumerProject 'Original/GameStream'
New-ConsumerProject 'Original/SyncServer'
New-ConsumerProject 'Original/UnraidMonitor'
New-ConsumerProject 'Original/PubliSafe'
New-ConsumerProject 'Forks/Bitmagnet'
New-ConsumerProject 'Forks/Heretic'
New-ConsumerProject 'Original/InfiniteVideo'
New-ConsumerProject 'Forks/MegaBasterd'
New-ConsumerProject 'Forks/HordeWorker'
New-ConsumerProject 'Original/OutdoorGames'
New-ConsumerProject 'Original/KioskDisplay' -Destination 'engine'
New-ConsumerProject 'Original/MediaAnalyzer' -Destination 'engine'
New-ConsumerProject 'Original/MediaTools' -Destination 'engine'
New-ConsumerProject 'Original/MediaViewer' -Destination 'engine'
New-ConsumerProject 'Central/MediaServant' -Destination 'engine'
New-ConsumerProject 'Central/ModerationHub' -Destination 'engine'
New-ConsumerProject 'Central/ProjectConfigurator' -Destination 'engine'
)
function Invoke-GitText {
@@ -216,7 +240,9 @@ Write-Host "Synchronizing $($sourceFiles.Count) tracked shared files from $sourc
$failures = New-Object 'System.Collections.Generic.List[string]'
foreach ($relativeProject in $consumerProjects) {
foreach ($consumerProject in $consumerProjects) {
$relativeProject = $consumerProject.Path
$destination = $consumerProject.Destination
$projectRoot = Join-Path $workspaceRoot ($relativeProject -replace '/', '\')
if (-not (Test-Path -LiteralPath $projectRoot -PathType Container)) {
$failures.Add("${relativeProject}: project directory not found")
@@ -225,19 +251,20 @@ foreach ($relativeProject in $consumerProjects) {
try {
$projectRoot = Resolve-FullPath $projectRoot
$destinationRoot = Join-Path $projectRoot 'shared'
$destinationRoot = Join-Path $projectRoot $destination
$isLegacyEligible = $destination -eq 'shared'
$legacyDirectoryName = ('Shared' + 'Code')
$projectDirectories = @(Get-ChildItem -LiteralPath $projectRoot -Directory -Force)
$destinationEntry = $projectDirectories | Where-Object { $_.Name -ceq 'shared' }
$legacyEntry = $projectDirectories | Where-Object { $_.Name -ceq $legacyDirectoryName }
$destinationEntry = $projectDirectories | Where-Object { $_.Name -ceq $destination }
$legacyEntry = if ($isLegacyEligible) { $projectDirectories | Where-Object { $_.Name -ceq $legacyDirectoryName } } else { $null }
if ($null -ne $destinationEntry -and $null -ne $legacyEntry) {
throw "Both shared and the legacy shared snapshot directory exist. Remove the legacy directory before synchronizing."
throw "Both $destination and the legacy shared snapshot directory exist. Remove the legacy directory before synchronizing."
}
$dirtyshared = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', 'shared'))
$dirtyLegacy = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', $legacyDirectoryName))
if (($dirtyshared.Count -gt 0 -or $dirtyLegacy.Count -gt 0) -and -not $Force) {
throw "shared has local changes. Commit them or rerun with -Force."
$dirtyDestination = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', $destination))
$dirtyLegacy = if ($isLegacyEligible) { @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', $legacyDirectoryName)) } else { @() }
if (($dirtyDestination.Count -gt 0 -or $dirtyLegacy.Count -gt 0) -and -not $Force) {
throw "$destination has local changes. Commit them or rerun with -Force."
}
if ($null -ne $legacyEntry) {
@@ -248,11 +275,11 @@ foreach ($relativeProject in $consumerProjects) {
New-Item -ItemType Directory -Force -Path $destinationRoot | Out-Null
$existingSharedFiles = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('ls-files', '--', 'shared') | Where-Object { $_ -like 'shared/*' })
foreach ($existingSharedFile in $existingSharedFiles) {
$relativeSharedFile = $existingSharedFile.Substring('shared/'.Length).Replace('\', '/')
if (-not $sourceFileSet.ContainsKey($relativeSharedFile)) {
$stalePath = Join-Path $destinationRoot ($relativeSharedFile -replace '/', '\')
$existingDestinationFiles = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('ls-files', '--', $destination) | Where-Object { $_ -like "$destination/*" })
foreach ($existingDestinationFile in $existingDestinationFiles) {
$relativeDestinationFile = $existingDestinationFile.Substring("$destination/".Length).Replace('\', '/')
if (-not $sourceFileSet.ContainsKey($relativeDestinationFile)) {
$stalePath = Join-Path $destinationRoot ($relativeDestinationFile -replace '/', '\')
if (Test-Path -LiteralPath $stalePath -PathType Leaf) {
Remove-Item -LiteralPath $stalePath -Force
}
@@ -315,15 +342,15 @@ foreach ($relativeProject in $consumerProjects) {
}
}
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', 'shared')
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', $destination)
foreach ($lockFile in $lockFiles) {
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', $lockFile)
}
$targetPaths = @('shared') + $lockFiles
$targetPaths = @($destination) + $lockFiles
$stagedChanges = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments (@('diff', '--cached', '--name-only', '--') + $targetPaths))
if ($Commit -and $stagedChanges.Count -gt 0) {
$commitMessage = "Sync shared snapshot from $sourceCommit"
$commitMessage = "Sync $destination snapshot from $sourceCommit"
$commitArguments = @('commit', '--only', '-m', $commitMessage, '--') + $targetPaths
$commitOutput = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments $commitArguments)
$commitOutput | ForEach-Object { Write-Host " $_" }