firgiawann commited on
Commit
40338c8
·
verified ·
1 Parent(s): 4899cb8

Add Windows one-command installer for contributors

Browse files
Files changed (1) hide show
  1. install_windows.ps1 +75 -0
install_windows.ps1 ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ param(
2
+ [string]$RepoId = "KLP2-PCD/KLP2",
3
+ [string]$TargetDir = "",
4
+ [switch]$SkipApps,
5
+ [switch]$SkipContributorSetup
6
+ )
7
+
8
+ $ErrorActionPreference = "Stop"
9
+
10
+ function Write-Step {
11
+ param([string]$Message)
12
+ Write-Host ""
13
+ Write-Host "==> $Message" -ForegroundColor Cyan
14
+ }
15
+
16
+ function Has-Command {
17
+ param([string]$Name)
18
+ return [bool](Get-Command $Name -ErrorAction SilentlyContinue)
19
+ }
20
+
21
+ function Install-WithWinget {
22
+ param(
23
+ [string]$PackageId,
24
+ [string]$Name
25
+ )
26
+
27
+ Write-Step "Install/cek $Name"
28
+ winget install --id $PackageId --exact --accept-source-agreements --accept-package-agreements --silent
29
+ }
30
+
31
+ Write-Step "Bootstrap installer Windows"
32
+
33
+ if (-not (Has-Command "winget")) {
34
+ throw "winget tidak ditemukan. Install 'App Installer' dari Microsoft Store, lalu jalankan script ini lagi."
35
+ }
36
+
37
+ if (-not $SkipApps) {
38
+ if (-not (Has-Command "git")) {
39
+ Install-WithWinget -PackageId "Git.Git" -Name "Git for Windows"
40
+ } else {
41
+ Write-Host "Git sudah tersedia: $(& git --version)"
42
+ }
43
+
44
+ if (-not (Has-Command "python")) {
45
+ Install-WithWinget -PackageId "Python.Python.3.10" -Name "Python 3.10"
46
+ } else {
47
+ Write-Host "Python sudah tersedia: $(& python --version)"
48
+ }
49
+
50
+ if (-not (Has-Command "code")) {
51
+ Install-WithWinget -PackageId "Microsoft.VisualStudioCode" -Name "Visual Studio Code"
52
+ } else {
53
+ Write-Host "VS Code sudah tersedia."
54
+ }
55
+ } else {
56
+ Write-Host "Skip install aplikasi karena parameter -SkipApps dipakai."
57
+ }
58
+
59
+ Write-Step "Refresh PATH untuk sesi PowerShell ini"
60
+ $machinePath = [Environment]::GetEnvironmentVariable("Path", "Machine")
61
+ $userPath = [Environment]::GetEnvironmentVariable("Path", "User")
62
+ $env:Path = "$machinePath;$userPath"
63
+
64
+ if ($SkipContributorSetup) {
65
+ Write-Host "Bootstrap selesai. setup_contributor.ps1 tidak dijalankan karena -SkipContributorSetup dipakai."
66
+ exit 0
67
+ }
68
+
69
+ $setupScript = Join-Path $PSScriptRoot "setup_contributor.ps1"
70
+ if (-not (Test-Path $setupScript)) {
71
+ throw "setup_contributor.ps1 tidak ditemukan di folder yang sama dengan install_windows.ps1."
72
+ }
73
+
74
+ Write-Step "Jalankan setup kontributor project"
75
+ & $setupScript -RepoId $RepoId -TargetDir $TargetDir