|
| 1 | +<# |
| 2 | +Synopsis: Curated sync from repo → Google Drive (dry-run by default) |
| 3 | +Usage: |
| 4 | + pwsh ./tools/ops/sync_drive.ps1 # preview only |
| 5 | + pwsh ./tools/ops/sync_drive.ps1 -Target "G:\\My Drive\\TEC_NWO" # set target |
| 6 | + pwsh ./tools/ops/sync_drive.ps1 -Target "G:\\My Drive\\TEC_NWO" -Execute |
| 7 | +
|
| 8 | +Notes: |
| 9 | + - Uses robocopy with /L for dry-run preview or actual copy when -Execute. |
| 10 | + - Copies only curated sources to avoid churn and duplicates. |
| 11 | + - Excludes caches, build outputs, temp, datastores, and hidden folders. |
| 12 | +#> |
| 13 | + |
| 14 | +param( |
| 15 | + [string]$Target = 'G:\\My Drive\\TEC_NWO', |
| 16 | + [switch]$Execute |
| 17 | +) |
| 18 | + |
| 19 | +Set-StrictMode -Version Latest |
| 20 | +$ErrorActionPreference = 'Stop' |
| 21 | + |
| 22 | +$Root = Resolve-Path -LiteralPath "$PSScriptRoot/../.." | Select-Object -ExpandProperty Path |
| 23 | +Write-Host "Curated Drive sync from: $Root -> $Target" -ForegroundColor Cyan |
| 24 | + |
| 25 | +if (-not (Test-Path -LiteralPath $Target)) { |
| 26 | + Write-Host "Target does not exist, creating: $Target" -ForegroundColor Yellow |
| 27 | + New-Item -ItemType Directory -Path $Target -Force | Out-Null |
| 28 | +} |
| 29 | + |
| 30 | +$Dry = $true |
| 31 | +if ($Execute) { $Dry = $false } |
| 32 | + |
| 33 | +# Directories to include (top-level relative to repo root) |
| 34 | +$IncludeDirs = @( |
| 35 | + 'assets', 'docs', 'lore', 'public', 'catalogs', 'notebooks' |
| 36 | +) |
| 37 | + |
| 38 | +# Specific files at root to include |
| 39 | +$IncludeFiles = @( |
| 40 | + 'README.md', 'README_ARCHITECTURE.md', 'QUICKSTART.md', 'SYSTEM_STATUS.md' |
| 41 | +) |
| 42 | + |
| 43 | +# Common excludes (dirs) |
| 44 | +$ExcludeDirs = @( |
| 45 | + '.git', '.github', '.vscode', '.tmp.driveupload', '.tmp.drivedownload', |
| 46 | + 'node_modules', 'dist', 'build', 'datastore', 'artifacts', |
| 47 | + 'tec_datacore', 'tec_mcp_server', 'src', 'services', 'orchestration', |
| 48 | + 'infra', 'infrastructure', 'prisma', 'tests', 'tools', 'scripts' |
| 49 | +) |
| 50 | + |
| 51 | +# Common excludes (files) |
| 52 | +$ExcludeFiles = @('*.log', '*.tsbuildinfo', '*.lcov', '*.pyc', '*.pyo', '*.pyd') |
| 53 | + |
| 54 | +$roboFlags = @('/E', '/FFT', '/Z', '/R:1', '/W:1', '/XD') + $ExcludeDirs + @('/XF') + $ExcludeFiles |
| 55 | +if ($Dry) { $roboFlags = @('/L') + $roboFlags } |
| 56 | + |
| 57 | +function Sync-Dir { |
| 58 | + param([string]$RelDir) |
| 59 | + $src = Join-Path $Root $RelDir |
| 60 | + if (Test-Path -LiteralPath $src) { |
| 61 | + $dst = Join-Path $Target $RelDir |
| 62 | + if (-not (Test-Path -LiteralPath $dst)) { New-Item -ItemType Directory -Path $dst -Force | Out-Null } |
| 63 | + Write-Host "Syncing dir: $RelDir" -ForegroundColor Green |
| 64 | + robocopy $src $dst @roboFlags | Out-Host |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +function Sync-File { |
| 69 | + param([string]$RelFile) |
| 70 | + $src = Join-Path $Root $RelFile |
| 71 | + if (Test-Path -LiteralPath $src) { |
| 72 | + Write-Host "Syncing file: $RelFile" -ForegroundColor Green |
| 73 | + $dst = Join-Path $Target $RelFile |
| 74 | + $dstDir = Split-Path -Parent $dst |
| 75 | + if (-not (Test-Path -LiteralPath $dstDir)) { New-Item -ItemType Directory -Path $dstDir -Force | Out-Null } |
| 76 | + if ($Dry) { |
| 77 | + Write-Host " [DRY] robocopy $(Split-Path -Parent $src) $dstDir $(Split-Path -Leaf $src)" -ForegroundColor DarkGray |
| 78 | + } else { |
| 79 | + robocopy (Split-Path -Parent $src) $dstDir (Split-Path -Leaf $src) | Out-Host |
| 80 | + } |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +foreach ($d in $IncludeDirs) { Sync-Dir -RelDir $d } |
| 85 | +foreach ($f in $IncludeFiles) { Sync-File -RelFile $f } |
| 86 | + |
| 87 | +if ($Dry) { |
| 88 | + Write-Host "Dry-run complete. Re-run with -Execute to copy changes." -ForegroundColor Yellow |
| 89 | +} else { |
| 90 | + Write-Host "Sync complete." -ForegroundColor Cyan |
| 91 | +} |
0 commit comments