-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall.ps1
More file actions
578 lines (524 loc) · 24.1 KB
/
Copy pathinstall.ps1
File metadata and controls
578 lines (524 loc) · 24.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# install.ps1 - Windows bootstrap for Claude Code Starter Kit
# Usage: irm https://raw.githubusercontent.com/cloudnative-co/claude-code-starter-kit/main/install.ps1 | iex
# Git Bash mode: powershell -File install.ps1 --git-bash
$ErrorActionPreference = "Stop"
function Write-Info($msg) { Write-Host "[INFO] $msg" -ForegroundColor Cyan }
function Write-Ok($msg) { Write-Host "[ OK] $msg" -ForegroundColor Green }
function Write-Warn($msg) { Write-Host "[WARN] $msg" -ForegroundColor Yellow }
function Write-Err($msg) { Write-Host "[ERROR] $msg" -ForegroundColor Red }
# ---------------------------------------------------------------------------
# Helper: Test if Ubuntu is ready (can execute commands)
# Temporarily lowers ErrorActionPreference to avoid stderr from wsl.exe
# being treated as a terminating error under $ErrorActionPreference=Stop.
# ---------------------------------------------------------------------------
function Test-UbuntuReady {
param([string]$Distro = "Ubuntu")
$savedEAP = $ErrorActionPreference
$ErrorActionPreference = "SilentlyContinue"
try {
$result = wsl -d $Distro -- echo "READY" 2>&1
$ErrorActionPreference = $savedEAP
if ($null -eq $result) { return $false }
$cleaned = ($result | Out-String).Trim()
return $cleaned -match "READY"
} catch {
$ErrorActionPreference = $savedEAP
return $false
}
}
# ---------------------------------------------------------------------------
# Helper: Check if WSL command exists and works
# ---------------------------------------------------------------------------
function Test-WslInstalled {
$savedEAP = $ErrorActionPreference
$ErrorActionPreference = "SilentlyContinue"
try {
$null = wsl --status 2>&1
$code = $LASTEXITCODE
$ErrorActionPreference = $savedEAP
return ($code -eq 0)
} catch {
$ErrorActionPreference = $savedEAP
return $false
}
}
# ---------------------------------------------------------------------------
# Helper: Find the actual Ubuntu distro name (e.g. "Ubuntu", "Ubuntu-24.04")
# wsl -l outputs UTF-16LE with null bytes, so use .NET to decode
# ---------------------------------------------------------------------------
function Find-UbuntuDistro {
try {
$proc = New-Object System.Diagnostics.Process
$proc.StartInfo.FileName = "wsl.exe"
$proc.StartInfo.Arguments = "-l -q"
$proc.StartInfo.UseShellExecute = $false
$proc.StartInfo.RedirectStandardOutput = $true
$proc.StartInfo.StandardOutputEncoding = [System.Text.Encoding]::Unicode
$proc.Start() | Out-Null
$output = $proc.StandardOutput.ReadToEnd()
$proc.WaitForExit()
# Parse lines and find first Ubuntu distro (e.g. "Ubuntu", "Ubuntu-24.04")
$lines = $output -split "`n" | ForEach-Object {
($_ -replace "`0", "").Trim()
} | Where-Object { $_ -ne "" }
foreach ($line in $lines) {
if ($line -match "^Ubuntu") { return $line }
}
return $null
} catch {
return $null
}
}
# ---------------------------------------------------------------------------
# Helper: Find Git Bash
# ---------------------------------------------------------------------------
function Find-GitBash {
$gitPaths = @(
"$env:ProgramFiles\Git\bin\bash.exe",
"${env:ProgramFiles(x86)}\Git\bin\bash.exe",
"$env:LOCALAPPDATA\Programs\Git\bin\bash.exe"
)
foreach ($p in $gitPaths) {
if (Test-Path $p) { return $p }
}
# Try to find git in PATH and derive bash.exe location
$gitCmd = Get-Command git -ErrorAction SilentlyContinue
if ($gitCmd) {
$gitDir = Split-Path (Split-Path $gitCmd.Source)
$candidate = Join-Path $gitDir "bin\bash.exe"
if (Test-Path $candidate) { return $candidate }
}
return $null
}
# ---------------------------------------------------------------------------
# Helper: Check if Windows Terminal is installed
# ---------------------------------------------------------------------------
function Test-WindowsTerminal {
$wtPaths = @(
"$env:LOCALAPPDATA\Microsoft\WindowsApps\wt.exe"
)
foreach ($p in $wtPaths) {
if (Test-Path $p) { return $true }
}
if (Get-Command wt -ErrorAction SilentlyContinue) { return $true }
return $false
}
# ---------------------------------------------------------------------------
# Mode 1: WSL2 + Windows Terminal (default, recommended)
# ---------------------------------------------------------------------------
function Install-ViaWSL {
# Admin check (needed for WSL install)
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Err "WSL2 のインストールには管理者権限が必要です。"
Write-Err "Administrator privileges are required for WSL2 installation."
Write-Host ""
Write-Info "PowerShell を右クリックして「管理者として実行」を選択し、再度実行してください。"
Write-Info "Right-click PowerShell, select 'Run as Administrator', then try again."
Write-Host ""
Write-Info "管理者権限が使えない場合は Git Bash モードをお試しください:"
Write-Info "If admin is unavailable, try Git Bash mode:"
Write-Host " powershell -File install.ps1 --git-bash" -ForegroundColor Yellow
exit 1
}
# Windows version check
$build = [System.Environment]::OSVersion.Version.Build
Write-Info "Windows Build: $build"
if ($build -lt 19041) {
Write-Err "Windows Build $build is too old. WSL2 requires Build 19041 or later."
Write-Err "Please update Windows and try again."
exit 1
}
Write-Ok "Windows version compatible with WSL2"
# Step 1: Ensure WSL is installed
if (-not (Test-WslInstalled)) {
Write-Info "WSL is not installed. Installing WSL with Ubuntu..."
wsl --install -d Ubuntu
Write-Host ""
Write-Warn "============================================="
Write-Warn " WSL がインストールされました。再起動が必要です。"
Write-Warn " WSL has been installed. RESTART REQUIRED."
Write-Warn "============================================="
Write-Warn ""
Write-Warn "再起動後、もう一度このコマンドを実行してください:"
Write-Warn "After restart, run this command again:"
Write-Warn ""
Write-Warn ' irm https://raw.githubusercontent.com/cloudnative-co/claude-code-starter-kit/main/install.ps1 | iex'
Write-Warn ""
Write-Warn "セットアップは中断した場所から自動的に再開されます。"
Write-Warn "The setup will automatically continue from where it left off."
Write-Warn ""
Read-Host "Enter を押すと再起動します(Ctrl+C でキャンセル) / Press Enter to restart now (or Ctrl+C to cancel)"
Restart-Computer -Force
exit 0
}
Write-Ok "WSL is installed"
# Step 2: Ensure Ubuntu is registered and ready
$ubuntuDistro = Find-UbuntuDistro
if (-not $ubuntuDistro) {
Write-Info "Ubuntu is not installed in WSL. Installing..."
wsl --install -d Ubuntu
Write-Info "Waiting for Ubuntu installation to complete..."
Start-Sleep -Seconds 5
$ubuntuDistro = Find-UbuntuDistro
if (-not $ubuntuDistro) { $ubuntuDistro = "Ubuntu" }
}
Write-Info "WSL distro: $ubuntuDistro"
if (-not (Test-UbuntuReady -Distro $ubuntuDistro)) {
Write-Host ""
Write-Info "Ubuntu の初期設定が必要です。"
Write-Info "Ubuntu needs initial user setup."
Write-Host ""
Write-Info "この画面で UNIX ユーザー名とパスワードを設定します。"
Write-Info "You will create a UNIX username and password here."
Write-Host ""
Read-Host "Enter を押して Ubuntu セットアップを開始 / Press Enter to start Ubuntu setup"
# Run wsl inline so user setup happens in the current terminal
# (no separate window that blocks and confuses users)
Write-Host ""
Write-Warn "ユーザー名とパスワードを設定してください。"
Write-Warn "設定が終わったら exit と入力して Enter を押してください。"
Write-Warn "After creating your username/password, type 'exit' and press Enter."
Write-Host ""
$savedEAP = $ErrorActionPreference
$ErrorActionPreference = "SilentlyContinue"
wsl -d $ubuntuDistro
$ErrorActionPreference = $savedEAP
# Verify Ubuntu is now ready
if (-not (Test-UbuntuReady -Distro $ubuntuDistro)) {
Write-Warn "Ubuntu の準備確認に失敗しましたが、セットアップを続行します..."
Write-Warn "Ubuntu readiness check failed, but continuing setup..."
}
}
Write-Ok "WSL2 with Ubuntu is ready"
# Step 3: Run Linux bootstrap inside WSL
Write-Info "WSL 内で Claude Code Starter Kit をセットアップしています..."
Write-Info "Running Claude Code Starter Kit setup inside WSL..."
$bootstrapScript = @'
#!/bin/bash
set -euo pipefail
# If running as root and a normal user exists, re-exec as that user
# (WSL defaults to root when initial user setup was skipped or failed)
if [[ "$(id -u)" -eq 0 ]]; then
_normal_user=$(awk -F: '$3 >= 1000 && $3 < 65534 && $7 !~ /(nologin|false)$/ { print $1; exit }' /etc/passwd)
if [[ -n "${_normal_user:-}" ]]; then
echo "[INFO] root で実行中。ユーザー $_normal_user に切り替えます..."
echo "[INFO] Running as root. Switching to user: $_normal_user"
if sudo -i -H -u "$_normal_user" bash "$0"; then
exit 0
fi
echo "[WARN] ユーザー切り替えに失敗。root で続行します。"
echo "[WARN] Failed to switch user. Continuing as root."
fi
fi
REPO_URL="https://github.com/cloudnative-co/claude-code-starter-kit.git"
INSTALL_DIR="$HOME/.claude-starter-kit"
# Safety guard: prevent rm -rf on dangerous paths
# NOTE: copy of _safe_install_dir in install.sh — keep all 4 copies in sync
# (CI compares normalized bodies in tests/unit/test-install-bootstrap.sh).
_safe_install_dir() {
# Normalize: strip ALL trailing slashes (so "$HOME//" cannot bypass checks)
local dir="$1"
while [[ "$dir" == */ ]]; do
dir="${dir%/}"
done
[[ -z "$dir" ]] && return 1
# Require an absolute path
[[ "$dir" != /* ]] && return 1
# Block $HOME itself
[[ "$dir" == "$HOME" || "$dir" == "${HOME%/}" ]] && return 1
# Block system directories and their subtrees
case "$dir" in
/|/bin|/bin/*|/sbin|/sbin/*|/etc|/etc/*|/usr|/usr/*|/var|/var/*|/tmp|/tmp/*)
return 1 ;;
/home|/root|/opt|/Applications|/Applications/*|/Library|/Library/*)
return 1 ;;
/System|/System/*|/dev|/dev/*|/proc|/proc/*)
return 1 ;;
esac
# Require at least 3 path components (e.g. /home/user/dir)
local depth
depth="$(printf '%s' "$dir" | tr -cd '/' | wc -c | tr -d ' ')"
[[ "$depth" -lt 3 ]] && return 1
return 0
}
if ! _safe_install_dir "$INSTALL_DIR"; then
echo "[ERROR] Refusing to use INSTALL_DIR='$INSTALL_DIR' (dangerous path)"
exit 1
fi
_clone_to_temp_and_swap() {
local target="$1"
local parent
parent="$(dirname "$target")"
mkdir -p "$parent"
rm -rf "$parent"/.claude-starter-kit.clone.* 2>/dev/null || true
local tmp_dir
tmp_dir="$(mktemp -d "$parent/.claude-starter-kit.clone.XXXXXX")"
if git clone --depth 1 "$REPO_URL" "$tmp_dir/repo"; then
rm -rf "$target"
mv "$tmp_dir/repo" "$target"
rm -rf "$tmp_dir"
return 0
fi
rm -rf "$tmp_dir"
return 1
}
# Install only missing tools (skip sudo if everything is present)
_missing=()
command -v git &>/dev/null || _missing+=(git)
command -v curl &>/dev/null || _missing+=(curl)
command -v jq &>/dev/null || _missing+=(jq)
command -v dos2unix &>/dev/null || _missing+=(dos2unix)
if [[ ${#_missing[@]} -gt 0 ]] && command -v apt-get &>/dev/null; then
echo "[INFO] Installing missing tools: ${_missing[*]}"
sudo apt-get update -qq
sudo apt-get install -y "${_missing[@]}" 2>/dev/null || true
fi
# Clone or update the repo
if [[ -d "$INSTALL_DIR/.git" ]]; then
# Dirty check: abort if local changes exist
if [[ -n "$(git -C "$INSTALL_DIR" status --porcelain 2>/dev/null)" ]]; then
echo "[ERROR] Local changes detected in $INSTALL_DIR" >&2
echo "[INFO] Run: cd $INSTALL_DIR && git stash -u" >&2
exit 1
fi
echo "[INFO] Updating existing installation..."
git -C "$INSTALL_DIR" pull --ff-only 2>/dev/null || {
_clone_to_temp_and_swap "$INSTALL_DIR"
}
else
echo "[INFO] Cloning Claude Code Starter Kit..."
_clone_to_temp_and_swap "$INSTALL_DIR"
fi
# Fix line endings for WSL
find "$INSTALL_DIR" -name "*.sh" -exec dos2unix {} \; 2>/dev/null || true
find "$INSTALL_DIR" -name "*.conf" -exec dos2unix {} \; 2>/dev/null || true
chmod +x "$INSTALL_DIR/setup.sh"
chmod +x "$INSTALL_DIR/uninstall.sh" 2>/dev/null || true
echo "[INFO] Starting interactive setup..."
exec bash "$INSTALL_DIR/setup.sh" </dev/tty
'@
$tempFile = [System.IO.Path]::GetTempFileName()
[System.IO.File]::WriteAllText($tempFile, $bootstrapScript.Replace("`r`n", "`n"))
$wslPath = wsl -d $ubuntuDistro wslpath -a ($tempFile -replace '\\', '/')
wsl -d $ubuntuDistro bash $wslPath
Remove-Item -Path $tempFile -Force -ErrorAction SilentlyContinue
# Step 4: Check if Windows Terminal is installed
$hasWT = Test-WindowsTerminal
Write-Host ""
Write-Ok "Setup complete! / セットアップ完了!"
Write-Host ""
Write-Host "========================================================" -ForegroundColor Cyan
Write-Host " Claude Code の始め方 / Getting Started" -ForegroundColor White
Write-Host "========================================================" -ForegroundColor Cyan
Write-Host ""
if ($hasWT) {
Write-Host " Windows Terminal がインストール済みです。" -ForegroundColor Green
Write-Host ""
Write-Host " 1. Windows Terminal を開く" -ForegroundColor Green
Write-Host " Windows キーを押して「Terminal」と入力して Enter" -ForegroundColor White
Write-Host ""
Write-Host " 2. Ubuntu タブを開く" -ForegroundColor Green
Write-Host " タブバーの「v」をクリック → 「Ubuntu」を選択" -ForegroundColor White
Write-Host ""
Write-Host " 3. プロジェクトフォルダに移動して Claude Code を起動" -ForegroundColor Green
Write-Host " cd ~/my-project" -ForegroundColor Yellow
Write-Host " claude" -ForegroundColor Yellow
} else {
Write-Host " 推奨: Windows Terminal をインストールしてください" -ForegroundColor Yellow
Write-Host " Recommended: Install Windows Terminal" -ForegroundColor Yellow
Write-Host ""
Write-Host " Microsoft Store を開いて「Windows Terminal」と検索、" -ForegroundColor White
Write-Host " または以下のコマンドでインストール:" -ForegroundColor White
Write-Host " winget install --id=Microsoft.WindowsTerminal" -ForegroundColor Yellow
Write-Host ""
Write-Host " インストール後:" -ForegroundColor Green
Write-Host " 1. Windows Terminal を開く (Windows キー →「Terminal」)" -ForegroundColor White
Write-Host " 2. タブバーの「v」→「Ubuntu」を選択" -ForegroundColor White
Write-Host " 3. 以下を実行:" -ForegroundColor White
Write-Host " claude" -ForegroundColor Yellow
Write-Host ""
Write-Host " ---" -ForegroundColor DarkGray
Write-Host ""
Write-Host " 今すぐ使う場合 (Windows Terminal なし):" -ForegroundColor Green
Write-Host " PowerShell で以下を実行:" -ForegroundColor White
Write-Host " wsl" -ForegroundColor Yellow
Write-Host " claude" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "========================================================" -ForegroundColor Cyan
Write-Host ""
Write-Warn "重要: この PowerShell ウィンドウを閉じて、新しいターミナルを開いてください。"
Write-Warn "Important: Close this window and open a new terminal."
Write-Warn "セットアップで追加された設定は、ターミナルを再起動するまで反映されません。"
Write-Host ""
Write-Warn "注意: PowerShell から直接 claude を実行することはできません。"
Write-Warn "Note: You cannot run claude directly from PowerShell."
Write-Warn "必ず WSL (Ubuntu) 環境内で実行してください。"
Write-Host ""
Write-Host " PowerShell からワンコマンドで起動する場合:" -ForegroundColor DarkGray
Write-Host " wsl -d $ubuntuDistro -- bash -lc 'claude'" -ForegroundColor DarkGray
Write-Host ""
Write-Host " アンインストール / Uninstall:" -ForegroundColor DarkGray
Write-Host " wsl -d $ubuntuDistro -- bash -lc '~/.claude-starter-kit/uninstall.sh'" -ForegroundColor DarkGray
Write-Host ""
}
# ---------------------------------------------------------------------------
# Mode 2: Native Windows (Git Bash) — fallback for environments without WSL
# ---------------------------------------------------------------------------
function Install-ViaGitBash {
Write-Info "Git Bash モードでセットアップします..."
Write-Info "Setting up Claude Code with Git Bash (native Windows)..."
Write-Host ""
# Step 1: Check for Git for Windows
$gitBash = Find-GitBash
if (-not $gitBash) {
Write-Warn "Git for Windows is not installed."
if (Get-Command winget -ErrorAction SilentlyContinue) {
Write-Info "Installing Git for Windows via winget..."
winget install --id=Git.Git --accept-package-agreements --accept-source-agreements
# Re-check after install
$gitBash = Find-GitBash
}
if (-not $gitBash) {
Write-Err "Git for Windows could not be installed automatically."
Write-Err "Please install from: https://gitforwindows.org/"
Write-Err "Then run this script again."
exit 1
}
}
Write-Ok "Git Bash found: $gitBash"
# Step 2: Clone and run setup via Git Bash
$bootstrapScript = @'
#!/bin/bash
set -euo pipefail
REPO_URL="https://github.com/cloudnative-co/claude-code-starter-kit.git"
INSTALL_DIR="$HOME/.claude-starter-kit"
# Safety guard: prevent rm -rf on dangerous paths
# NOTE: copy of _safe_install_dir in install.sh — keep all 4 copies in sync
# (CI compares normalized bodies in tests/unit/test-install-bootstrap.sh).
_safe_install_dir() {
# Normalize: strip ALL trailing slashes (so "$HOME//" cannot bypass checks)
local dir="$1"
while [[ "$dir" == */ ]]; do
dir="${dir%/}"
done
[[ -z "$dir" ]] && return 1
# Require an absolute path
[[ "$dir" != /* ]] && return 1
# Block $HOME itself
[[ "$dir" == "$HOME" || "$dir" == "${HOME%/}" ]] && return 1
# Block system directories and their subtrees
case "$dir" in
/|/bin|/bin/*|/sbin|/sbin/*|/etc|/etc/*|/usr|/usr/*|/var|/var/*|/tmp|/tmp/*)
return 1 ;;
/home|/root|/opt|/Applications|/Applications/*|/Library|/Library/*)
return 1 ;;
/System|/System/*|/dev|/dev/*|/proc|/proc/*)
return 1 ;;
esac
# Require at least 3 path components (e.g. /home/user/dir)
local depth
depth="$(printf '%s' "$dir" | tr -cd '/' | wc -c | tr -d ' ')"
[[ "$depth" -lt 3 ]] && return 1
return 0
}
if ! _safe_install_dir "$INSTALL_DIR"; then
echo "[ERROR] Refusing to use INSTALL_DIR='$INSTALL_DIR' (dangerous path)"
exit 1
fi
_clone_to_temp_and_swap() {
local target="$1"
local parent
parent="$(dirname "$target")"
mkdir -p "$parent"
rm -rf "$parent"/.claude-starter-kit.clone.* 2>/dev/null || true
local tmp_dir
tmp_dir="$(mktemp -d "$parent/.claude-starter-kit.clone.XXXXXX")"
if git clone --depth 1 "$REPO_URL" "$tmp_dir/repo"; then
rm -rf "$target"
mv "$tmp_dir/repo" "$target"
rm -rf "$tmp_dir"
return 0
fi
rm -rf "$tmp_dir"
return 1
}
# Clone or update the repo
if [[ -d "$INSTALL_DIR/.git" ]]; then
# Dirty check: abort if local changes exist
if [[ -n "$(git -C "$INSTALL_DIR" status --porcelain 2>/dev/null)" ]]; then
echo "[ERROR] Local changes detected in $INSTALL_DIR" >&2
echo "[INFO] Run: cd $INSTALL_DIR && git stash -u" >&2
exit 1
fi
echo "[INFO] Updating existing installation..."
git -C "$INSTALL_DIR" pull --ff-only 2>/dev/null || {
_clone_to_temp_and_swap "$INSTALL_DIR"
}
else
echo "[INFO] Cloning Claude Code Starter Kit..."
_clone_to_temp_and_swap "$INSTALL_DIR"
fi
chmod +x "$INSTALL_DIR/setup.sh"
chmod +x "$INSTALL_DIR/uninstall.sh" 2>/dev/null || true
echo "[INFO] Starting interactive setup..."
exec bash "$INSTALL_DIR/setup.sh" </dev/tty
'@
$tempFile = [System.IO.Path]::GetTempFileName()
[System.IO.File]::WriteAllText($tempFile, $bootstrapScript.Replace("`r`n", "`n"))
& $gitBash --login -i $tempFile
$bashExitCode = $LASTEXITCODE
Remove-Item -Path $tempFile -Force -ErrorAction SilentlyContinue
if ($bashExitCode -ne 0) {
Write-Err "Setup may not have completed successfully."
Write-Err "セットアップが正常に完了しなかった可能性があります。"
Write-Err ""
Write-Err "To retry / 再実行:"
Write-Err " Open Git Bash and run: ~/.claude-starter-kit/setup.sh"
exit $bashExitCode
}
Write-Host ""
Write-Ok "Setup complete! / セットアップ完了!"
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Claude Code の始め方" -ForegroundColor White
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host " 1. Git Bash を開く" -ForegroundColor Green
Write-Host ""
Write-Host " 方法 A: デスクトップの何もない場所を右クリック" -ForegroundColor White
Write-Host " →「Git Bash Here」を選択" -ForegroundColor White
Write-Host ""
Write-Host " 方法 B: キーボードの Windows キーを押して" -ForegroundColor White
Write-Host " 「Git Bash」と入力して Enter" -ForegroundColor White
Write-Host ""
Write-Host " 2. 作業したいフォルダに移動" -ForegroundColor Green
Write-Host " 以下のように入力して Enter:" -ForegroundColor White
Write-Host " cd ~/Documents/my-project" -ForegroundColor Yellow
Write-Host ""
Write-Host " 3. Claude Code を起動" -ForegroundColor Green
Write-Host " 以下のように入力して Enter:" -ForegroundColor White
Write-Host " claude" -ForegroundColor Yellow
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Warn "注意: この PowerShell ウィンドウでは claude は使えません。"
Write-Warn " 必ず上記の方法で Git Bash を開いてください。"
Write-Host ""
Write-Host "----------------------------------------" -ForegroundColor DarkGray
Write-Host " アンインストール (Git Bash で実行):" -ForegroundColor DarkGray
Write-Host " ~/.claude-starter-kit/uninstall.sh" -ForegroundColor DarkGray
Write-Host ""
}
# ---------------------------------------------------------------------------
# Main: Default to WSL2 (recommended), --git-bash for native Windows
# ---------------------------------------------------------------------------
Write-Host ""
Write-Host "Claude Code Starter Kit - Windows Setup" -ForegroundColor White -BackgroundColor DarkCyan
Write-Host ""
if ($args -contains "--git-bash") {
Install-ViaGitBash
} else {
Install-ViaWSL
}