59 lines
1.9 KiB
PowerShell
59 lines
1.9 KiB
PowerShell
# ============================================================
|
|
# vendor.ps1 — vendiza los repos kaplar dentro de src/
|
|
#
|
|
# Por cada componente: guarda su remote en .upstream.json,
|
|
# elimina su .git y lo deja listo para el commit del monorepo.
|
|
#
|
|
# Uso (PowerShell, en la raíz del monorepo):
|
|
# ./scripts/vendor.ps1 # procesa src/game, login, querymanager, web, ipchanger
|
|
# ./scripts/vendor.ps1 -WhatIf # solo muestra qué haría
|
|
# ============================================================
|
|
param([switch]$WhatIf)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$components = @("game", "login", "querymanager", "web", "ipchanger")
|
|
|
|
foreach ($name in $components) {
|
|
$dir = Join-Path "src" $name
|
|
$gitDir = Join-Path $dir ".git"
|
|
|
|
if (-not (Test-Path $gitDir)) {
|
|
Write-Host "[vendor] $name : sin .git, se omite" -ForegroundColor DarkGray
|
|
continue
|
|
}
|
|
|
|
Push-Location $dir
|
|
$remote = git remote get-url origin 2>$null
|
|
$head = git rev-parse HEAD 2>$null
|
|
$branch = git rev-parse --abbrev-ref HEAD 2>$null
|
|
Pop-Location
|
|
|
|
$meta = @{
|
|
upstream = $remote
|
|
commit = $head
|
|
branch = $branch
|
|
vendoredAt = (Get-Date -Format "yyyy-MM-dd")
|
|
} | ConvertTo-Json
|
|
|
|
Write-Host "[vendor] $name : $remote @ $($head.Substring(0,8)) ($branch)"
|
|
|
|
if ($WhatIf) { continue }
|
|
|
|
Set-Content -Path "$dir\.upstream.json" -Value (
|
|
[pscustomobject]@{
|
|
upstream = "$remote"
|
|
commit = "$head"
|
|
branch = "$branch"
|
|
vendoredAt = (Get-Date -Format "yyyy-MM-dd")
|
|
} | ConvertTo-Json
|
|
)
|
|
|
|
# Elimina el git anidado: el contenido pasa a ser del monorepo
|
|
Remove-Item -Recurse -Force $gitDir
|
|
|
|
# Asegura que el monorepo ignore nada de estos dirs
|
|
Write-Host "[vendor] $name : vendizado OK" -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[vendor] Listo. Ahora: git add -A; git commit -m 'vendor: kaplar sources'"
|