Skip to content

Commit ed0f517

Browse files
committed
Simplify
1 parent b36759c commit ed0f517

File tree

1 file changed

+5
-90
lines changed

1 file changed

+5
-90
lines changed

scripts/Install-Rubberduck-VBA.ps1

Lines changed: 5 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -230,103 +230,18 @@ if (-not $rubberduckInstallPath) {
230230
Write-Host "🎉 Rubberduck installed successfully and is (almost) ready to use!"
231231
}
232232

233-
# Now we need to download the artifacts from the latest build in https://github.com/DecimalTurn/Rubberduck/actions/runs/14609505761/artifacts/2990874874
234-
# The artifacts are stored in a zip file and we need to extract them to the installation folder.
235-
236-
Write-Host "⏳ Downloading and installing additional components..."
233+
Write-Host "⏳ Downloading and installing CLI-Friendly DLL components..."
237234

238235
# Define the artifact URL and download location
239236
$artifactUrl = "https://github.com/DecimalTurn/Rubberduck/actions/runs/14609505761/artifacts/2990874874"
240237
$artifactZipPath = "$env:TEMP\RubberduckArtifacts.zip"
241238
$rubberduckInstallDir = $rubberduckInstallPath # Use the path returned by Test-RubberduckInstalled
242239

243-
# Function to check if we have GitHub CLI installed
244-
function Test-GitHubCLI {
245-
try {
246-
$null = Get-Command gh -ErrorAction Stop
247-
return $true
248-
} catch {
249-
return $false
250-
}
251-
}
240+
Write-Host "📥 Downloading artifacts from $artifactUrl..."
241+
Invoke-WebRequest -Uri $artifactUrl -OutFile $artifactZipPath
252242

253-
# Download the artifact
254-
try {
255-
# If we don't have an install path, try default location
256-
if (-not $rubberduckInstallDir) {
257-
$commonAppDataPath = [System.Environment]::GetFolderPath("CommonApplicationData")
258-
$rubberduckInstallDir = "$commonAppDataPath\Rubberduck"
259-
Write-Host "🔍 Using default installation directory: $rubberduckInstallDir"
260-
}
261-
262-
# Check if GitHub CLI is available
263-
if (Test-GitHubCLI) {
264-
# Use GitHub CLI to download the artifact
265-
Write-Host "📥 Downloading artifact using GitHub CLI..."
266-
gh auth status -t > $null 2>&1
267-
if ($LASTEXITCODE -ne 0) {
268-
Write-Host "⚠️ GitHub CLI not authenticated. Please run 'gh auth login' first."
269-
throw "GitHub CLI authentication required"
270-
}
271-
272-
# Download the artifact using GitHub CLI
273-
gh run download 14609505761 -n "Rubberduck-Custom-Extensions" -D "$env:TEMP"
274-
$artifactExtractPath = "$env:TEMP\Rubberduck-Custom-Extensions"
275-
} else {
276-
# Fallback to direct download if GitHub CLI is not available
277-
Write-Host "📥 Downloading artifact using direct download..."
278-
# Note: This might require authentication token in a real scenario
279-
Invoke-WebRequest -Uri $artifactUrl -OutFile $artifactZipPath -Headers @{
280-
"Accept" = "application/vnd.github.v3+json"
281-
# "Authorization" = "token $env:GITHUB_TOKEN" # Uncomment and set token if needed
282-
}
283-
284-
# Create temporary directory for extraction
285-
$artifactExtractPath = "$env:TEMP\Rubberduck-Custom-Extensions"
286-
New-Item -ItemType Directory -Path $artifactExtractPath -Force | Out-Null
287-
288-
# Extract the zip file
289-
Write-Host "📦 Extracting artifact..."
290-
Expand-Archive -Path $artifactZipPath -DestinationPath $artifactExtractPath -Force
291-
}
292-
293-
# Ensure the installation directory exists
294-
if (-not (Test-Path $rubberduckInstallDir)) {
295-
Write-Host "⚠️ Rubberduck installation directory not found at expected location: $rubberduckInstallDir"
296-
# Try to find the installation directory
297-
$commonAppDataPath = [System.Environment]::GetFolderPath("CommonApplicationData")
298-
$possiblePath = "$commonAppDataPath\Rubberduck"
299-
if (Test-Path $possiblePath) {
300-
$rubberduckInstallDir = $possiblePath
301-
Write-Host "✅ Found Rubberduck installation directory at: $rubberduckInstallDir"
302-
} else {
303-
throw "Could not locate Rubberduck installation directory"
304-
}
305-
}
306-
307-
# Copy the files to the installation directory
308-
Write-Host "📋 Installing custom extensions to $rubberduckInstallDir..."
309-
Get-ChildItem -Path $artifactExtractPath -Recurse -File | ForEach-Object {
310-
$destinationPath = Join-Path -Path $rubberduckInstallDir -ChildPath $_.Name
311-
Copy-Item -Path $_.FullName -Destination $destinationPath -Force
312-
Write-Host " - Installed: $($_.Name)"
313-
}
314-
315-
# Clean up temporary files
316-
if (Test-Path $artifactZipPath) {
317-
Remove-Item -Path $artifactZipPath -Force
318-
}
319-
if (Test-Path $artifactExtractPath) {
320-
Remove-Item -Path $artifactExtractPath -Recurse -Force
321-
}
322-
323-
Write-Host "✅ Custom extensions installed successfully to Rubberduck installation!"
324-
325-
} catch {
326-
Write-Host "❌ Error installing custom extensions: $($_.Exception.Message)"
327-
Write-Host " You may need to manually download and install the artifacts from:"
328-
Write-Host " $artifactUrl"
329-
}
243+
Write-Host "📦 Extracting artifacts to $rubberduckInstallDir..."
244+
Expand-Archive -Path $artifactZipPath -DestinationPath $rubberduckInstallDir -Force
330245

331246
Write-Host "🏁 Rubberduck installation and configuration completed."
332247

0 commit comments

Comments
 (0)