File size: 2,227 Bytes
40338c8 | 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 | param(
[string]$RepoId = "KLP2-PCD/KLP2",
[string]$TargetDir = "",
[switch]$SkipApps,
[switch]$SkipContributorSetup
)
$ErrorActionPreference = "Stop"
function Write-Step {
param([string]$Message)
Write-Host ""
Write-Host "==> $Message" -ForegroundColor Cyan
}
function Has-Command {
param([string]$Name)
return [bool](Get-Command $Name -ErrorAction SilentlyContinue)
}
function Install-WithWinget {
param(
[string]$PackageId,
[string]$Name
)
Write-Step "Install/cek $Name"
winget install --id $PackageId --exact --accept-source-agreements --accept-package-agreements --silent
}
Write-Step "Bootstrap installer Windows"
if (-not (Has-Command "winget")) {
throw "winget tidak ditemukan. Install 'App Installer' dari Microsoft Store, lalu jalankan script ini lagi."
}
if (-not $SkipApps) {
if (-not (Has-Command "git")) {
Install-WithWinget -PackageId "Git.Git" -Name "Git for Windows"
} else {
Write-Host "Git sudah tersedia: $(& git --version)"
}
if (-not (Has-Command "python")) {
Install-WithWinget -PackageId "Python.Python.3.10" -Name "Python 3.10"
} else {
Write-Host "Python sudah tersedia: $(& python --version)"
}
if (-not (Has-Command "code")) {
Install-WithWinget -PackageId "Microsoft.VisualStudioCode" -Name "Visual Studio Code"
} else {
Write-Host "VS Code sudah tersedia."
}
} else {
Write-Host "Skip install aplikasi karena parameter -SkipApps dipakai."
}
Write-Step "Refresh PATH untuk sesi PowerShell ini"
$machinePath = [Environment]::GetEnvironmentVariable("Path", "Machine")
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$env:Path = "$machinePath;$userPath"
if ($SkipContributorSetup) {
Write-Host "Bootstrap selesai. setup_contributor.ps1 tidak dijalankan karena -SkipContributorSetup dipakai."
exit 0
}
$setupScript = Join-Path $PSScriptRoot "setup_contributor.ps1"
if (-not (Test-Path $setupScript)) {
throw "setup_contributor.ps1 tidak ditemukan di folder yang sama dengan install_windows.ps1."
}
Write-Step "Jalankan setup kontributor project"
& $setupScript -RepoId $RepoId -TargetDir $TargetDir
|