2026-08-06 16:53:48 +02:00
|
|
|
[CmdletBinding()]
|
|
|
|
|
param(
|
|
|
|
|
[string]$SourceRepository,
|
|
|
|
|
[switch]$Force,
|
|
|
|
|
[switch]$Commit,
|
|
|
|
|
[switch]$Push
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
|
|
|
|
|
|
if ($Push -and -not $Commit) {
|
|
|
|
|
throw 'The -Push switch requires -Commit so that only generated synchronization changes are pushed.'
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-01 09:57:08 +02:00
|
|
|
function New-ConsumerProject {
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string]$Path,
|
|
|
|
|
|
|
|
|
|
[string]$Destination = 'shared'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return [pscustomobject]@{ Path = $Path; Destination = $Destination }
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-07 16:00:08 +02:00
|
|
|
# Destination defaults to 'shared' (the snapshot folder name every consumer
|
|
|
|
|
# uses) - originally a git submodule, converted to this vendored-copy pattern
|
|
|
|
|
# for consistency and to drop the private-submodule checkout auth dependency
|
|
|
|
|
# in CI. The media-family services (CarrierNode, ContentScanner, CraftStudio,
|
2026-09-12 15:48:17 +02:00
|
|
|
# MediaViewer, KioskDisplay, ModerationHub, ProjectConfigurator) used to mount
|
2026-09-07 16:00:08 +02:00
|
|
|
# a shared multi-flavor webui/media-backend at a separate 'engine' folder
|
|
|
|
|
# instead; each is now its own independent frontend/backend and vendors this
|
|
|
|
|
# snapshot the same way as every other consumer below.
|
2026-08-06 16:53:48 +02:00
|
|
|
$consumerProjects = @(
|
2026-09-01 11:18:01 +02:00
|
|
|
New-ConsumerProject 'Original/MediaDesktop'
|
2026-09-01 09:57:08 +02:00
|
|
|
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'
|
2026-09-07 16:00:08 +02:00
|
|
|
New-ConsumerProject 'Fork/Bitmagnet'
|
|
|
|
|
New-ConsumerProject 'Fork/Heretic'
|
2026-09-01 09:57:08 +02:00
|
|
|
New-ConsumerProject 'Original/InfiniteVideo'
|
2026-09-07 16:00:08 +02:00
|
|
|
New-ConsumerProject 'Fork/MegaBasterd'
|
2026-09-07 16:20:29 +02:00
|
|
|
New-ConsumerProject 'Fork/HordeWorker'
|
2026-09-01 09:57:08 +02:00
|
|
|
New-ConsumerProject 'Original/OutdoorGames'
|
2026-09-07 15:08:58 +02:00
|
|
|
New-ConsumerProject 'Original/KioskDisplay'
|
|
|
|
|
New-ConsumerProject 'Original/CraftStudio'
|
|
|
|
|
New-ConsumerProject 'Original/MediaViewer'
|
2026-09-07 16:00:08 +02:00
|
|
|
New-ConsumerProject 'Core/CarrierNode'
|
|
|
|
|
New-ConsumerProject 'Core/ContentScanner'
|
|
|
|
|
New-ConsumerProject 'Core/ModerationHub'
|
|
|
|
|
New-ConsumerProject 'Core/ProjectConfigurator'
|
|
|
|
|
New-ConsumerProject 'Core/AuthGuard'
|
2026-09-08 17:10:34 +02:00
|
|
|
New-ConsumerProject 'Core/OmniLogger'
|
2026-08-06 16:53:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
function Invoke-GitText {
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string]$WorkingDirectory,
|
|
|
|
|
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string[]]$Arguments
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$output = & git -C $WorkingDirectory @Arguments 2>&1
|
|
|
|
|
$exitCode = $LASTEXITCODE
|
|
|
|
|
if ($exitCode -ne 0) {
|
|
|
|
|
$diagnostics = @($output | ForEach-Object { [string]$_ } | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
|
|
|
|
|
$blockingDiagnostics = @($diagnostics | Where-Object { $_ -notmatch '^\s*(warning|hint):' })
|
|
|
|
|
if ($blockingDiagnostics.Count -eq 0) {
|
|
|
|
|
$diagnostics | ForEach-Object { Write-Warning $_ }
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$details = $diagnostics -join [Environment]::NewLine
|
|
|
|
|
throw "git $($Arguments -join ' ') failed in '$WorkingDirectory'. $details"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return @($output | ForEach-Object { [string]$_ })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Resolve-FullPath {
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string]$Path
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return (Resolve-Path -LiteralPath $Path -ErrorAction Stop).Path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Get-RelativePath {
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string]$BasePath,
|
|
|
|
|
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string]$TargetPath
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$base = (Resolve-FullPath $BasePath).TrimEnd('\') + '\'
|
|
|
|
|
$target = Resolve-FullPath $TargetPath
|
|
|
|
|
if (-not $target.StartsWith($base, [System.StringComparison]::OrdinalIgnoreCase)) {
|
|
|
|
|
throw "'$TargetPath' is not inside '$BasePath'."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $target.Substring($base.Length).Replace('\', '/')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Write-Utf8NoBom {
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string]$Path,
|
|
|
|
|
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string]$Content
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$encoding = New-Object System.Text.UTF8Encoding($false)
|
|
|
|
|
$normalizedContent = $Content.Replace("`r`n", "`n").Replace("`r", "`n")
|
|
|
|
|
[System.IO.File]::WriteAllText($Path, $normalizedContent, $encoding)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Convert-ToConsumerWebUiPackage {
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string]$PackagePath
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$manifest = Get-Content -LiteralPath $PackagePath -Raw | ConvertFrom-Json
|
|
|
|
|
$manifest.files = @('src', 'README.md')
|
2026-08-19 12:07:39 +02:00
|
|
|
if ($null -ne $manifest.dependencies) {
|
|
|
|
|
$designTokensDependency = $manifest.dependencies.PSObject.Properties['@gabriel20xx/design-tokens']
|
|
|
|
|
if ($null -ne $designTokensDependency) {
|
|
|
|
|
$manifest.dependencies.PSObject.Properties.Remove('@gabriel20xx/design-tokens')
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-06 16:53:48 +02:00
|
|
|
$manifest.svelte = './src/index.ts'
|
|
|
|
|
$manifest.types = './src/index.ts'
|
|
|
|
|
|
|
|
|
|
$rootExport = $manifest.exports.PSObject.Properties | Where-Object { $_.Name -eq '.' }
|
|
|
|
|
if ($null -ne $rootExport) {
|
|
|
|
|
$rootExport.Value.types = './src/index.ts'
|
|
|
|
|
$rootExport.Value.svelte = './src/index.ts'
|
|
|
|
|
$rootExport.Value.import = './src/index.ts'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$stylesExport = $manifest.exports.PSObject.Properties | Where-Object { $_.Name -eq './styles.css' }
|
|
|
|
|
if ($null -ne $stylesExport) {
|
|
|
|
|
$stylesExport.Value = './src/lib/styles.css'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$json = $manifest | ConvertTo-Json -Depth 20
|
|
|
|
|
Write-Utf8NoBom -Path $PackagePath -Content ($json + [Environment]::NewLine)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Convert-ToConsumerWebUiSources {
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
[string]$WebUiRoot
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$stylesPath = Join-Path $WebUiRoot 'src/lib/styles.css'
|
|
|
|
|
if (Test-Path -LiteralPath $stylesPath) {
|
|
|
|
|
$styles = Get-Content -LiteralPath $stylesPath -Raw
|
|
|
|
|
$styles = $styles.Replace("@import '@gabriel20xx/design-tokens/theme.css';", "@import '../../../design-tokens/theme.css';")
|
2026-08-19 12:07:39 +02:00
|
|
|
$styles = $styles.Replace('@import "@gabriel20xx/design-tokens/theme.css";', "@import '../../../design-tokens/theme.css';")
|
2026-08-06 16:53:48 +02:00
|
|
|
Write-Utf8NoBom -Path $stylesPath -Content $styles
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$svelteConfigPath = Join-Path $WebUiRoot 'svelte.config.js'
|
|
|
|
|
if (Test-Path -LiteralPath $svelteConfigPath) {
|
|
|
|
|
Write-Utf8NoBom -Path $svelteConfigPath -Content "export default {};`n"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Test-LocalSharedDependency {
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
$PackageManifest
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$localPackageNames = @(
|
|
|
|
|
'@gabriel20xx/web-ui',
|
|
|
|
|
'@gabriel20xx/node-backend'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
foreach ($sectionName in @('dependencies', 'devDependencies', 'optionalDependencies')) {
|
|
|
|
|
$sectionProperty = $PackageManifest.PSObject.Properties[$sectionName]
|
|
|
|
|
if ($null -eq $sectionProperty -or $null -eq $sectionProperty.Value) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($dependency in $sectionProperty.Value.PSObject.Properties) {
|
|
|
|
|
if ($dependency.Name -in $localPackageNames -and ([string]$dependency.Value).StartsWith('file:')) {
|
|
|
|
|
return $true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ([string]::IsNullOrWhiteSpace($SourceRepository)) {
|
|
|
|
|
$scriptParent = Resolve-FullPath (Join-Path $PSScriptRoot '..')
|
|
|
|
|
$scriptParentGitRoot = (Invoke-GitText -WorkingDirectory $scriptParent -Arguments @('rev-parse', '--show-toplevel') | Select-Object -First 1).Trim()
|
|
|
|
|
$scriptParentGitRoot = Resolve-FullPath $scriptParentGitRoot
|
|
|
|
|
if ($scriptParentGitRoot -ieq $scriptParent) {
|
|
|
|
|
$SourceRepository = $scriptParent
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$workspaceRoot = Split-Path -Parent (Split-Path -Parent $scriptParentGitRoot)
|
|
|
|
|
$SourceRepository = Join-Path $workspaceRoot 'shared'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sourceRoot = Resolve-FullPath $SourceRepository
|
|
|
|
|
$sourceRepositoryRoot = (Invoke-GitText -WorkingDirectory $sourceRoot -Arguments @('rev-parse', '--show-toplevel') | Select-Object -First 1).Trim()
|
|
|
|
|
$sourceRoot = Resolve-FullPath $sourceRepositoryRoot
|
2026-09-01 01:34:48 +02:00
|
|
|
|
|
|
|
|
# The workspace root is the ancestor directory that contains both 'Original'
|
2026-09-07 16:00:08 +02:00
|
|
|
# and 'Fork' (every consumer project lives under one of those, or under
|
|
|
|
|
# 'Core' for the central infrastructure services). Walk up from the shared
|
|
|
|
|
# repo instead of assuming a fixed nesting depth, since shared/ has moved
|
|
|
|
|
# before (e.g. Web/shared -> Web/Central/shared -> Web/Core/shared, with
|
|
|
|
|
# 'Forks' renamed to singular 'Fork' at the same time) and may move again.
|
2026-08-06 16:53:48 +02:00
|
|
|
$workspaceRoot = Split-Path -Parent $sourceRoot
|
2026-09-07 16:00:08 +02:00
|
|
|
while ($workspaceRoot -and -not ((Test-Path -LiteralPath (Join-Path $workspaceRoot 'Original') -PathType Container) -and (Test-Path -LiteralPath (Join-Path $workspaceRoot 'Fork') -PathType Container))) {
|
2026-09-01 01:34:48 +02:00
|
|
|
$parent = Split-Path -Parent $workspaceRoot
|
|
|
|
|
if (-not $parent -or $parent -eq $workspaceRoot) {
|
2026-09-07 16:00:08 +02:00
|
|
|
throw "Could not locate the workspace root (a directory containing both 'Original' and 'Fork') above $sourceRoot."
|
2026-09-01 01:34:48 +02:00
|
|
|
}
|
|
|
|
|
$workspaceRoot = $parent
|
|
|
|
|
}
|
2026-08-06 16:53:48 +02:00
|
|
|
$sourceCommit = (Invoke-GitText -WorkingDirectory $sourceRoot -Arguments @('rev-parse', '--short', 'HEAD') | Select-Object -First 1).Trim()
|
|
|
|
|
$sourceFiles = @(Invoke-GitText -WorkingDirectory $sourceRoot -Arguments @('ls-files') | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
|
|
|
|
|
|
|
|
|
|
$sourceFileSet = @{}
|
|
|
|
|
foreach ($sourceFile in $sourceFiles) {
|
|
|
|
|
$sourceFileSet[$sourceFile.Replace('\', '/')] = $true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write-Host "Synchronizing $($sourceFiles.Count) tracked shared files from $sourceCommit."
|
|
|
|
|
|
|
|
|
|
$failures = New-Object 'System.Collections.Generic.List[string]'
|
|
|
|
|
|
2026-09-01 09:57:08 +02:00
|
|
|
foreach ($consumerProject in $consumerProjects) {
|
|
|
|
|
$relativeProject = $consumerProject.Path
|
|
|
|
|
$destination = $consumerProject.Destination
|
2026-08-06 16:53:48 +02:00
|
|
|
$projectRoot = Join-Path $workspaceRoot ($relativeProject -replace '/', '\')
|
|
|
|
|
if (-not (Test-Path -LiteralPath $projectRoot -PathType Container)) {
|
|
|
|
|
$failures.Add("${relativeProject}: project directory not found")
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$projectRoot = Resolve-FullPath $projectRoot
|
2026-09-01 09:57:08 +02:00
|
|
|
$destinationRoot = Join-Path $projectRoot $destination
|
|
|
|
|
$isLegacyEligible = $destination -eq 'shared'
|
2026-08-06 16:53:48 +02:00
|
|
|
$legacyDirectoryName = ('Shared' + 'Code')
|
|
|
|
|
$projectDirectories = @(Get-ChildItem -LiteralPath $projectRoot -Directory -Force)
|
2026-09-01 09:57:08 +02:00
|
|
|
$destinationEntry = $projectDirectories | Where-Object { $_.Name -ceq $destination }
|
|
|
|
|
$legacyEntry = if ($isLegacyEligible) { $projectDirectories | Where-Object { $_.Name -ceq $legacyDirectoryName } } else { $null }
|
2026-08-06 16:53:48 +02:00
|
|
|
if ($null -ne $destinationEntry -and $null -ne $legacyEntry) {
|
2026-09-01 09:57:08 +02:00
|
|
|
throw "Both $destination and the legacy shared snapshot directory exist. Remove the legacy directory before synchronizing."
|
2026-08-06 16:53:48 +02:00
|
|
|
}
|
|
|
|
|
|
2026-09-01 09:57:08 +02:00
|
|
|
$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."
|
2026-08-06 16:53:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($null -ne $legacyEntry) {
|
|
|
|
|
$temporaryRenamePath = Join-Path $projectRoot ('.shared-sync-rename-' + [Guid]::NewGuid().ToString('N'))
|
|
|
|
|
Move-Item -LiteralPath $legacyEntry.FullName -Destination $temporaryRenamePath
|
|
|
|
|
Move-Item -LiteralPath $temporaryRenamePath -Destination $destinationRoot
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
New-Item -ItemType Directory -Force -Path $destinationRoot | Out-Null
|
|
|
|
|
|
2026-09-01 09:57:08 +02:00
|
|
|
$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 '/', '\')
|
2026-08-06 16:53:48 +02:00
|
|
|
if (Test-Path -LiteralPath $stalePath -PathType Leaf) {
|
|
|
|
|
Remove-Item -LiteralPath $stalePath -Force
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($sourceFile in $sourceFiles) {
|
|
|
|
|
$sourcePath = Join-Path $sourceRoot ($sourceFile -replace '/', '\')
|
|
|
|
|
$destinationPath = Join-Path $destinationRoot ($sourceFile -replace '/', '\')
|
|
|
|
|
$destinationDirectory = Split-Path -Parent $destinationPath
|
|
|
|
|
New-Item -ItemType Directory -Force -Path $destinationDirectory | Out-Null
|
|
|
|
|
Copy-Item -LiteralPath $sourcePath -Destination $destinationPath -Force
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$webUiPackagePath = Join-Path $destinationRoot 'packages/web-ui/package.json'
|
|
|
|
|
if (Test-Path -LiteralPath $webUiPackagePath) {
|
|
|
|
|
Convert-ToConsumerWebUiPackage -PackagePath $webUiPackagePath
|
|
|
|
|
Convert-ToConsumerWebUiSources -WebUiRoot (Join-Path $destinationRoot 'packages/web-ui')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lockFiles = @()
|
|
|
|
|
$sharedPrefix = ((Resolve-FullPath $destinationRoot).TrimEnd('\') + '\')
|
|
|
|
|
$packageFiles = @(Get-ChildItem -LiteralPath $projectRoot -Recurse -File -Filter 'package.json' -Force |
|
|
|
|
|
Where-Object {
|
|
|
|
|
$_.FullName -notlike "$sharedPrefix*" -and
|
|
|
|
|
$_.FullName -notmatch '\\node_modules\\'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
foreach ($packageFile in $packageFiles) {
|
|
|
|
|
$packageManifest = Get-Content -LiteralPath $packageFile.FullName -Raw | ConvertFrom-Json
|
|
|
|
|
if (-not (Test-LocalSharedDependency -PackageManifest $packageManifest)) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lockPath = Join-Path $packageFile.DirectoryName 'package-lock.json'
|
|
|
|
|
if (-not (Test-Path -LiteralPath $lockPath -PathType Leaf)) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relativeLockPath = Get-RelativePath -BasePath $projectRoot -TargetPath $lockPath
|
|
|
|
|
$trackedLock = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('ls-files', '--', $relativeLockPath))
|
|
|
|
|
$shouldStageLock = $trackedLock.Count -gt 0
|
|
|
|
|
Write-Host " Updating $relativeProject/$(Get-RelativePath -BasePath $projectRoot -TargetPath $lockPath)"
|
|
|
|
|
Push-Location -LiteralPath $packageFile.DirectoryName
|
|
|
|
|
try {
|
|
|
|
|
& npm install --package-lock-only --ignore-scripts --prefer-offline
|
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
|
|
|
throw "npm install --package-lock-only failed with exit code $LASTEXITCODE."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
Pop-Location
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($shouldStageLock -and $lockFiles -notcontains $relativeLockPath) {
|
|
|
|
|
$lockFiles += $relativeLockPath
|
|
|
|
|
}
|
|
|
|
|
elseif (-not $shouldStageLock) {
|
|
|
|
|
Write-Host " Leaving untracked/ignored lockfile out of the generated commit: $relativeLockPath"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-01 09:57:08 +02:00
|
|
|
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', $destination)
|
2026-08-06 16:53:48 +02:00
|
|
|
foreach ($lockFile in $lockFiles) {
|
|
|
|
|
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', $lockFile)
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-01 09:57:08 +02:00
|
|
|
$targetPaths = @($destination) + $lockFiles
|
2026-08-06 16:53:48 +02:00
|
|
|
$stagedChanges = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments (@('diff', '--cached', '--name-only', '--') + $targetPaths))
|
|
|
|
|
if ($Commit -and $stagedChanges.Count -gt 0) {
|
2026-09-01 09:57:08 +02:00
|
|
|
$commitMessage = "Sync $destination snapshot from $sourceCommit"
|
2026-08-06 16:53:48 +02:00
|
|
|
$commitArguments = @('commit', '--only', '-m', $commitMessage, '--') + $targetPaths
|
|
|
|
|
$commitOutput = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments $commitArguments)
|
|
|
|
|
$commitOutput | ForEach-Object { Write-Host " $_" }
|
|
|
|
|
$remainingStagedChanges = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments (@('diff', '--cached', '--name-only', '--') + $targetPaths))
|
|
|
|
|
if ($remainingStagedChanges.Count -gt 0) {
|
|
|
|
|
throw 'The generated synchronization changes remain staged after the commit.'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($Push) {
|
|
|
|
|
$pushOutput = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('push', 'origin', 'main'))
|
|
|
|
|
$pushOutput | ForEach-Object { Write-Host " $_" }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($stagedChanges.Count -gt 0) {
|
|
|
|
|
Write-Host "Synced $relativeProject."
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Write-Host "$relativeProject is already synchronized."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
$message = "${relativeProject}: $($_.Exception.Message)"
|
|
|
|
|
$failures.Add($message)
|
|
|
|
|
Write-Warning $message
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($failures.Count -gt 0) {
|
|
|
|
|
throw "shared synchronization failed for $($failures.Count) project(s): $($failures -join '; ')"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write-Host 'shared synchronization completed.'
|