-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
120 lines (94 loc) · 6.15 KB
/
install.ps1
File metadata and controls
120 lines (94 loc) · 6.15 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
# Firefly Framework CLI Installer for Windows
# Usage:
# irm https://raw.githubusercontent.com/fireflyframework/fireflyframework-cli/main/install.ps1 | iex
# $env:FLYWORK_VERSION = "v26.02.03"; .\install.ps1
$ErrorActionPreference = "Stop"
$Repo = "fireflyframework/fireflyframework-cli"
$Binary = "flywork"
# ── Banner ───────────────────────────────────────────────────────────────────
Write-Host ""
Write-Host " _____.__ _____.__" -ForegroundColor Cyan
Write-Host "_/ ____\__|______ _____/ ____\ | ___.__. " -ForegroundColor Cyan
Write-Host "\ __\| \_ __ \_/ __ \ __\| |< | |" -ForegroundColor Cyan
Write-Host " | | | || | \/\ ___/| | | |_\___ |" -ForegroundColor Cyan
Write-Host " |__| |__||__| \___ >__| |____/ ____|" -ForegroundColor Cyan
Write-Host " \/ \/" -ForegroundColor Cyan
Write-Host " _____ __" -ForegroundColor Cyan
Write-Host "_/ ____\___________ _____ ______ _ _____________| | __" -ForegroundColor Cyan
Write-Host "\ __\\_ __ \__ \ / \_/ __ \ \/ \/ / _ \_ __ \ |/ /" -ForegroundColor Cyan
Write-Host " | | | | \// __ \| Y Y \ ___/\ ( <_> ) | \/ <" -ForegroundColor Cyan
Write-Host " |__| |__| (____ /__|_| /\___ >\/\_/ \____/|__| |__|_ \" -ForegroundColor Cyan
Write-Host " \/ \/ \/ \/" -ForegroundColor Cyan
Write-Host ""
Write-Host " Firefly Framework CLI Installer" -ForegroundColor Cyan
Write-Host ""
function Write-Info($msg) { Write-Host " i $msg" -ForegroundColor Cyan }
function Write-Ok($msg) { Write-Host " ✓ $msg" -ForegroundColor Green }
function Write-Warn($msg) { Write-Host " ! $msg" -ForegroundColor Yellow }
function Write-Err($msg) { Write-Host " ✗ $msg" -ForegroundColor Red; exit 1 }
# ── Detect architecture ──────────────────────────────────────────────────────
$Arch = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq "Arm64") { "arm64" } else { "amd64" }
Write-Info "Detected platform: windows/$Arch"
# ── Resolve version ──────────────────────────────────────────────────────────
$Version = $env:FLYWORK_VERSION
if (-not $Version) {
Write-Info "Fetching latest release..."
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -Headers @{ "User-Agent" = "flywork-installer" }
$Version = $release.tag_name
} catch {
Write-Err "Could not determine latest version: $_"
}
}
# Ensure version starts with 'v' (matches Makefile archive naming)
if ($Version -notmatch "^v") { $Version = "v$Version" }
Write-Info "Version: $Version"
# ── Resolve install directory ────────────────────────────────────────────────
$InstallDir = $env:FLYWORK_INSTALL_DIR
if (-not $InstallDir) {
$InstallDir = Join-Path $env:LOCALAPPDATA "flywork\bin"
}
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
Write-Info "Install directory: $InstallDir"
# ── Download ─────────────────────────────────────────────────────────────────
$ArchiveName = "$Binary-$Version-windows-$Arch.zip"
$DownloadUrl = "https://github.com/$Repo/releases/download/$Version/$ArchiveName"
$TmpDir = Join-Path ([System.IO.Path]::GetTempPath()) "flywork-install-$(Get-Random)"
New-Item -ItemType Directory -Path $TmpDir -Force | Out-Null
try {
Write-Info "Downloading $ArchiveName..."
Invoke-WebRequest -Uri $DownloadUrl -OutFile (Join-Path $TmpDir $ArchiveName) -UseBasicParsing
} catch {
Write-Err "Download failed — check that version $Version exists for windows/$Arch"
}
# ── Extract & install ────────────────────────────────────────────────────────
Write-Info "Extracting..."
Expand-Archive -Path (Join-Path $TmpDir $ArchiveName) -DestinationPath $TmpDir -Force
$ExtractedBin = Get-ChildItem -Path $TmpDir -Recurse -Filter "$Binary.exe" | Select-Object -First 1
if (-not $ExtractedBin) {
Write-Err "Binary not found in archive"
}
Copy-Item -Path $ExtractedBin.FullName -Destination (Join-Path $InstallDir "$Binary.exe") -Force
Write-Ok "Installed $Binary.exe to $InstallDir"
# ── Update PATH ──────────────────────────────────────────────────────────────
$UserPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$InstallDir*") {
$NewPath = "$InstallDir;$UserPath"
[System.Environment]::SetEnvironmentVariable("Path", $NewPath, "User")
$env:Path = "$InstallDir;$env:Path"
Write-Warn "Added $InstallDir to user PATH — restart your terminal for changes to take effect"
}
# ── Cleanup ──────────────────────────────────────────────────────────────────
Remove-Item -Recurse -Force $TmpDir -ErrorAction SilentlyContinue
# ── Verify ───────────────────────────────────────────────────────────────────
Write-Host ""
try {
& (Join-Path $InstallDir "$Binary.exe") version
Write-Ok "Installation complete!"
} catch {
Write-Warn "Installed, but could not verify. Restart your terminal and run: flywork version"
}
Write-Host ""
Write-Info "Get started: flywork setup"