mirror of
https://github.com/yusufipk/RepoHub.git
synced 2026-09-11 10:36:07 +00:00
fix: correct Windows package installation script generation
- Fixed package identifier usage: now uses `name` field (winget ID) instead of `id` field throughout Windows script - Enhanced error handling with exit code checking and consistent [OK]/[ERROR] prefixes for better visibility - Standardized PowerShell string quotes to single quotes for consistency
This commit is contained in:
@@ -132,13 +132,13 @@ echo "Installation completed!"`
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateWindowsScript(packages: SelectedPackage[]): string {
|
function generateWindowsScript(packages: SelectedPackage[]): string {
|
||||||
const packageNames = packages.map(p => p.id).join(' ')
|
const packageNames = packages.map(p => p.name).join(' ')
|
||||||
|
|
||||||
return `# RepoHub Installation Script for Windows
|
return `# RepoHub Installation Script for Windows
|
||||||
# Generated on ${new Date().toISOString()}
|
# Generated on ${new Date().toISOString()}
|
||||||
# This script is idempotent and safe to run multiple times
|
# This script is idempotent and safe to run multiple times
|
||||||
|
|
||||||
Write-Host "Starting package installation for Windows..."
|
Write-Host 'Starting package installation for Windows...'
|
||||||
|
|
||||||
# Try to unblock this script (no-op if not needed)
|
# Try to unblock this script (no-op if not needed)
|
||||||
try { Unblock-File -Path $MyInvocation.MyCommand.Path -ErrorAction SilentlyContinue } catch {}
|
try { Unblock-File -Path $MyInvocation.MyCommand.Path -ErrorAction SilentlyContinue } catch {}
|
||||||
@@ -151,9 +151,9 @@ if (-not $isAdmin) {
|
|||||||
|
|
||||||
# Ensure winget is available
|
# Ensure winget is available
|
||||||
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
|
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||||
Write-Warning "Windows Package Manager (winget) is not installed."
|
Write-Warning 'Windows Package Manager (winget) is not installed.'
|
||||||
Write-Host "We'll open the Microsoft Store page for 'App Installer' (includes winget)."
|
Write-Host "We'll open the Microsoft Store page for 'App Installer' (includes winget)."
|
||||||
Write-Host "After installation completes, please re-run this script."
|
Write-Host 'After installation completes, please re-run this script.'
|
||||||
try {
|
try {
|
||||||
Start-Process "ms-windows-store://pdp/?productId=9NBLGGH4NNS1"
|
Start-Process "ms-windows-store://pdp/?productId=9NBLGGH4NNS1"
|
||||||
} catch {
|
} catch {
|
||||||
@@ -163,21 +163,25 @@ if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Install packages using winget
|
# Install packages using winget
|
||||||
Write-Host "Installing packages: ${packageNames}"
|
Write-Host 'Installing packages: ${packageNames}'
|
||||||
|
|
||||||
$packages = @(${packages.map(p => `'${p.id}'`).join(', ')})
|
$packages = @(${packages.map(p => `'${p.name}'`).join(', ')})
|
||||||
|
|
||||||
foreach ($package in $packages) {
|
foreach ($package in $packages) {
|
||||||
Write-Host "Installing $package..."
|
Write-Host "Installing $package..."
|
||||||
try {
|
try {
|
||||||
winget install --id $package --accept-package-agreements --accept-source-agreements -e
|
winget install --id $package --accept-package-agreements --accept-source-agreements -e
|
||||||
Write-Host "✓ $package installed successfully"
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Host "[ERROR] $package installation failed with exit code $LASTEXITCODE"
|
||||||
|
} else {
|
||||||
|
Write-Host "[OK] $package installed successfully"
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "✗ $package installation failed: $_"
|
Write-Host "[ERROR] $package installation failed: $_"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Installation completed!"`
|
Write-Host 'Installation completed!'`
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateMacOSScript(packages: SelectedPackage[]): string {
|
function generateMacOSScript(packages: SelectedPackage[]): string {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export class WingetPackageFetcher {
|
|||||||
if (!packageSet.has(identifier)) {
|
if (!packageSet.has(identifier)) {
|
||||||
packageSet.add(identifier)
|
packageSet.add(identifier)
|
||||||
allPackages.push({
|
allPackages.push({
|
||||||
name: pkg.name,
|
name: identifier,
|
||||||
publisher: publisher.name,
|
publisher: publisher.name,
|
||||||
version: 'latest',
|
version: 'latest',
|
||||||
description: `${pkg.name} by ${publisher.name}`
|
description: `${pkg.name} by ${publisher.name}`
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export interface Package {
|
|||||||
platform?: string | Platform
|
platform?: string | Platform
|
||||||
platform_id?: string
|
platform_id?: string
|
||||||
repository: 'official' | 'third-party'
|
repository: 'official' | 'third-party'
|
||||||
|
download_url?: string
|
||||||
lastUpdated?: string
|
lastUpdated?: string
|
||||||
downloads?: number
|
downloads?: number
|
||||||
popularity?: number
|
popularity?: number
|
||||||
|
|||||||
Reference in New Issue
Block a user