222 lines
11 KiB
PowerShell
222 lines
11 KiB
PowerShell
# 너드나비스 조직 레포 - Windows PC 셋업
|
|
# 사용: PowerShell에서 실행
|
|
# .\setup_windows.ps1 ← 기본 셋업만
|
|
# .\setup_windows.ps1 -CreateShortcuts ← 기본 셋업 + 바탕화면 바로가기 3종 생성
|
|
# .\setup_windows.ps1 -NerdNavisRoot "C:\..." ← 레포 경로 지정
|
|
# .\setup_windows.ps1 -CreateShortcuts -ClaudeExePath "C:\Tools\claude\claude.exe"
|
|
# ← claude.exe 자동 탐지 실패 시 경로 수동 지정
|
|
|
|
param(
|
|
[string]$NerdNavisRoot = $(Resolve-Path (Join-Path $PSScriptRoot "..")).Path,
|
|
[string]$UnityRoot = "",
|
|
[string]$FrameworkRoot = "",
|
|
[string]$GiteaUrl = "https://burning.i234.me",
|
|
[string]$GiteaSsh = "ssh://git@burning.i234.me:30030",
|
|
[switch]$CreateShortcuts,
|
|
[string]$ClaudeExePath = ""
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# 경로 추정: NerdNavisRoot 드라이브 기반 동적 default (PC별 하드코딩 회피)
|
|
# 사용자가 -UnityRoot/-FrameworkRoot 명시하면 그 값 우선, 미명시면 NerdNavisRoot 드라이브의 \NerdNavis\* 패턴으로 추정
|
|
$rootDriveLetter = (Split-Path $NerdNavisRoot -Qualifier).TrimEnd(':')
|
|
if (-not $UnityRoot) { $UnityRoot = "${rootDriveLetter}:\NerdNavis\FilGoodBandits\DeckBuilding" }
|
|
if (-not $FrameworkRoot) { $FrameworkRoot = "${rootDriveLetter}:\NerdNavis\NerdNavis.Framework" }
|
|
|
|
Write-Host "=== 너드나비스 조직 레포 셋업 ==="
|
|
Write-Host "NerdNavisRoot: $NerdNavisRoot"
|
|
Write-Host "UnityRoot: $UnityRoot $(if (-not (Test-Path $UnityRoot)) { '(경로 미존재 - paths.local.json 생성 후 수동 수정 권장)' })"
|
|
Write-Host "FrameworkRoot: $FrameworkRoot $(if (-not (Test-Path $FrameworkRoot)) { '(경로 미존재 - paths.local.json 생성 후 수동 수정 권장)' })"
|
|
|
|
# 1. Git 확인
|
|
git --version | Out-Null
|
|
if (-not $?) { throw "Git이 설치되지 않았습니다." }
|
|
|
|
# 2. paths.local.json 생성
|
|
$pathsFile = Join-Path $NerdNavisRoot "paths.local.json"
|
|
if (-not (Test-Path $pathsFile)) {
|
|
$paths = [ordered]@{
|
|
"_description" = "로컬 환경 경로. 커밋 금지."
|
|
NERDNAVIS_ROOT = $NerdNavisRoot
|
|
UNITY_PROJECT_ROOT = $UnityRoot
|
|
FRAMEWORK_PKG_ROOT = $FrameworkRoot
|
|
TABLE_EXPORT_ROOT = (Join-Path $UnityRoot "Assets\ResWork\Table\Export")
|
|
GITEA_URL = $GiteaUrl
|
|
GITEA_SSH = $GiteaSsh
|
|
HOSTNAME = $env:COMPUTERNAME
|
|
}
|
|
# UTF-8 BOM 없음으로 명시 출력 (PowerShell 5.1의 기본 -Encoding utf8은 BOM 포함 + 한국어 깨짐 이슈 회피)
|
|
$jsonText = $paths | ConvertTo-Json -Depth 5
|
|
[System.IO.File]::WriteAllText($pathsFile, $jsonText, [System.Text.UTF8Encoding]::new($false))
|
|
Write-Host "paths.local.json 작성 완료 (UTF-8 no BOM): $pathsFile"
|
|
} else {
|
|
Write-Host "paths.local.json 이미 존재. 유지."
|
|
}
|
|
|
|
# 3. Claude 사용자 메모리 연결 (junction)
|
|
$claudeMemoryBase = "$env:USERPROFILE\.claude\projects"
|
|
$orgMemoryTarget = Join-Path $NerdNavisRoot "memory\org"
|
|
|
|
if (-not (Test-Path $orgMemoryTarget)) {
|
|
New-Item -ItemType Directory -Path $orgMemoryTarget | Out-Null
|
|
}
|
|
|
|
$hashDirs = @()
|
|
if (Test-Path $claudeMemoryBase) {
|
|
# Claude Code는 프로젝트 경로의 각 세그먼트를 '-'로 이어 해시 폴더명을 만든다
|
|
# (예: E:\NerdNavisAi → E--NerdNavisAi, C:\Users\PC\Documents\너드나비스 → C--Users-PC-Documents-너드나비스)
|
|
# NerdNavisRoot의 리프 이름·드라이브 prefix·관례적 키워드를 모두 포괄하도록 필터 확장
|
|
$rootLeaf = Split-Path $NerdNavisRoot -Leaf
|
|
$rootDrive = (Split-Path $NerdNavisRoot -Qualifier).TrimEnd(':')
|
|
$hashDirs = Get-ChildItem $claudeMemoryBase -Directory -ErrorAction SilentlyContinue |
|
|
Where-Object {
|
|
$_.Name -like "*Documents*" -or
|
|
$_.Name -like "*너드나비스*" -or
|
|
$_.Name -like "*NerdNavis*" -or
|
|
$_.Name -like "*$rootLeaf*" -or
|
|
$_.Name -like "$rootDrive--*"
|
|
}
|
|
}
|
|
|
|
foreach ($d in $hashDirs) {
|
|
$memLink = Join-Path $d.FullName "memory"
|
|
if (Test-Path $memLink) {
|
|
$attr = (Get-Item $memLink -Force).Attributes
|
|
if (($attr -band [IO.FileAttributes]::ReparsePoint) -eq 0) {
|
|
# 실체 폴더. 백업 후 junction으로 교체
|
|
$bak = "$memLink.bak-$(Get-Date -Format yyyyMMddHHmmss)"
|
|
Rename-Item $memLink $bak
|
|
Write-Host "기존 memory 폴더 백업: $bak"
|
|
cmd /c mklink /J "`"$memLink`"" "`"$orgMemoryTarget`"" | Out-Null
|
|
Write-Host "Junction 생성: $memLink -> $orgMemoryTarget"
|
|
} else {
|
|
Write-Host "이미 junction/symlink. 유지: $memLink"
|
|
}
|
|
} else {
|
|
cmd /c mklink /J "`"$memLink`"" "`"$orgMemoryTarget`"" | Out-Null
|
|
Write-Host "Junction 생성: $memLink -> $orgMemoryTarget"
|
|
}
|
|
}
|
|
|
|
if ($hashDirs.Count -eq 0) {
|
|
Write-Warning "Claude 프로젝트 해시 폴더를 찾지 못했습니다. 수동 연결 필요."
|
|
}
|
|
|
|
# 4. .claude/settings.json 부서 동기화 (루트 SOT → 개발실/기획실 복제)
|
|
# Claude Code는 .claude/ 계층 auto-merge를 지원하지 않으므로 자식 디렉토리에서 세션 시작 시
|
|
# 루트 settings.json을 인식하지 못함. 이를 우회하기 위해 루트 settings.json을 부서 디렉토리로 복제.
|
|
$rootSettings = Join-Path $NerdNavisRoot ".claude\settings.json"
|
|
if (Test-Path $rootSettings) {
|
|
$deptPaths = @("개발실", "기획실")
|
|
foreach ($dept in $deptPaths) {
|
|
$deptClaudeDir = Join-Path $NerdNavisRoot "$dept\.claude"
|
|
$deptSettings = Join-Path $deptClaudeDir "settings.json"
|
|
if (-not (Test-Path $deptClaudeDir)) {
|
|
New-Item -ItemType Directory -Path $deptClaudeDir -Force | Out-Null
|
|
}
|
|
Copy-Item -Path $rootSettings -Destination $deptSettings -Force
|
|
Write-Host "settings.json 동기화: $dept/.claude/settings.json"
|
|
}
|
|
} else {
|
|
Write-Warning "루트 .claude/settings.json 미발견. 부서 동기화 생략."
|
|
}
|
|
|
|
# 5. (선택) 부서별 바탕화면 바로가기 3종 생성
|
|
# Claude Code 앱의 "New Session"은 현재 열린 프로젝트 컨텍스트 내에서 새 대화를 만드는 동작이라
|
|
# 루트에서 앱이 시작되면 부서 폴더 진입이 어려움. 각 부서 폴더를 WorkingDirectory로 지정한 바로가기로 우회.
|
|
if ($CreateShortcuts) {
|
|
Write-Host ""
|
|
Write-Host "=== 부서별 바탕화면 바로가기 생성 ==="
|
|
|
|
# 1) MSIX/Store 패키지 우선 탐지 (PD님 환경 표준)
|
|
$msixPkg = $null
|
|
try { $msixPkg = Get-AppxPackage -Name '*Claude*' -ErrorAction SilentlyContinue | Select-Object -First 1 } catch {}
|
|
|
|
$msixLaunchArg = $null
|
|
if ($msixPkg) {
|
|
# AppxManifest에서 AppId 추출
|
|
$manifestPath = Join-Path $msixPkg.InstallLocation 'AppxManifest.xml'
|
|
$appId = 'App'
|
|
if (Test-Path $manifestPath) {
|
|
try {
|
|
[xml]$m = Get-Content $manifestPath
|
|
$appIdNode = $m.Package.Applications.Application | Select-Object -First 1
|
|
if ($appIdNode -and $appIdNode.Id) { $appId = $appIdNode.Id }
|
|
} catch {}
|
|
}
|
|
$msixLaunchArg = "shell:AppsFolder\$($msixPkg.PackageFamilyName)!$appId"
|
|
Write-Host "Claude MSIX 패키지 탐지: $($msixPkg.PackageFamilyName) / AppId=$appId"
|
|
}
|
|
|
|
# 2) MSIX 미탐지 시 일반 claude.exe 탐색 (fallback)
|
|
if (-not $msixLaunchArg -and -not $ClaudeExePath) {
|
|
$candidatePaths = @(
|
|
"$env:LOCALAPPDATA\Programs\claude\claude.exe",
|
|
"$env:LOCALAPPDATA\AnthropicClaude\claude.exe",
|
|
"$env:LOCALAPPDATA\claude\claude.exe",
|
|
"$env:ProgramFiles\claude\claude.exe",
|
|
"${env:ProgramFiles(x86)}\claude\claude.exe",
|
|
"$env:LOCALAPPDATA\Programs\Claude\Claude.exe"
|
|
)
|
|
foreach ($cp in $candidatePaths) {
|
|
if (Test-Path $cp) { $ClaudeExePath = $cp; Write-Host "claude.exe 자동 탐지: $ClaudeExePath"; break }
|
|
}
|
|
if (-not $ClaudeExePath) {
|
|
$where = (Get-Command claude.exe -ErrorAction SilentlyContinue).Source
|
|
if ($where) { $ClaudeExePath = $where; Write-Host "claude.exe PATH에서 탐지: $ClaudeExePath" }
|
|
}
|
|
}
|
|
|
|
if (-not $msixLaunchArg -and (-not $ClaudeExePath -or -not (Test-Path $ClaudeExePath))) {
|
|
Write-Warning "Claude 실행 수단 탐지 실패 (MSIX·exe 모두). 바로가기 생성 생략."
|
|
Write-Warning "수동 지정: .\setup_windows.ps1 -CreateShortcuts -ClaudeExePath '<실제 경로>'"
|
|
} else {
|
|
$WshShell = New-Object -ComObject WScript.Shell
|
|
$desktop = [Environment]::GetFolderPath("Desktop")
|
|
|
|
$targets = @(
|
|
@{ Name = "너드나비스_총괄PM"; Dir = $NerdNavisRoot; Desc = "너드나비스 총괄PM 세션 (루트)" },
|
|
@{ Name = "너드나비스_개발팀"; Dir = (Join-Path $NerdNavisRoot "개발실"); Desc = "너드나비스 개발팀 세션" },
|
|
@{ Name = "너드나비스_기획팀"; Dir = (Join-Path $NerdNavisRoot "기획실"); Desc = "너드나비스 기획팀 세션" }
|
|
)
|
|
|
|
foreach ($t in $targets) {
|
|
if (-not (Test-Path $t.Dir)) {
|
|
Write-Warning "대상 디렉토리 없음. 건너뜀: $($t.Dir)"
|
|
continue
|
|
}
|
|
$shortcutPath = Join-Path $desktop "$($t.Name).lnk"
|
|
$sc = $WshShell.CreateShortcut($shortcutPath)
|
|
if ($msixLaunchArg) {
|
|
# MSIX 앱: explorer.exe shell:AppsFolder\... 방식
|
|
$sc.TargetPath = "explorer.exe"
|
|
$sc.Arguments = $msixLaunchArg
|
|
} else {
|
|
# 일반 exe 방식
|
|
$sc.TargetPath = $ClaudeExePath
|
|
$sc.IconLocation = "$ClaudeExePath,0"
|
|
}
|
|
$sc.WorkingDirectory = $t.Dir
|
|
$sc.Description = $t.Desc
|
|
$sc.Save()
|
|
Write-Host "바로가기 생성: $shortcutPath (WD=$($t.Dir))"
|
|
}
|
|
|
|
Write-Host ""
|
|
if ($msixLaunchArg) {
|
|
Write-Host "바로가기 3종 생성 완료 (MSIX 모드)."
|
|
Write-Host "※ MSIX 앱은 WorkingDirectory가 전달되지 않을 수 있음. 바로가기 더블클릭 후 실제 프로젝트 경로 확인 필수."
|
|
} else {
|
|
Write-Host "바로가기 3종 생성 완료."
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "셋업 완료. 'git pull'로 최신 상태 유지 권장."
|
|
Write-Host "※ .claude/settings.json 변경사항은 세션 재시작 후 적용됨."
|
|
if (-not $CreateShortcuts) {
|
|
Write-Host "※ 부서별 바탕화면 바로가기 필요 시: .\setup_windows.ps1 -CreateShortcuts"
|
|
}
|