Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,17 @@ function Test-Requirements {
try {
$kernel = docker info --format '{{.KernelVersion}}' 2>$null
Write-Verbose "KernelVersion='$kernel'"
if ($kernel -match 'microsoft|WSL2')
{
Write-InfoLog "Detected Docker is using WSL2."
} elseif ($kernel -match 'linuxkit') {
if ($kernel -match 'microsoft|WSL2')
{
Comment on lines +439 to +440

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the elseif and else blocks that follow, consider placing the opening brace on the same line as the if statement. This improves readability by maintaining a consistent style throughout the conditional block.

            if ($kernel -match 'microsoft|WSL2') {

Write-InfoLog "Detected Docker is using WSL2."
} elseif ($kernel -match 'linuxkit') {
$script:ERROR_CODE = 4
Write-WarnLog "Detected Docker is using Hyper-V, please reinstall Docker with WSL2. Hyper-V is not supported. Use at your own risk!"
} else {
$script:ERROR_CODE = 5
Write-WarnLog "Cannot determine if Docker is using WSL2. Please ensure Docker is using WSL2."
}
} catch {
} catch {
$script:ERROR_CODE = 5
Write-WarnLog "docker info failed. Cannot determine if Docker is using WSL2. Please ensure Docker is using WSL2."
}
Expand All @@ -468,7 +468,7 @@ function Test-Requirements {

# Check network connectivity
try {
$response = Invoke-WebRequest -Uri "https://install.rocketgraph.com" -Method Head
$response = Invoke-WebRequest -Uri "https://install.rocketgraph.com" -Method Head -UseBasicParsing

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The URL https://install.rocketgraph.com is hardcoded. This URL is also used on line 203. To improve maintainability and avoid potential inconsistencies, consider defining this URL as a script-level constant at the beginning of the file, for example: $BaseInstallUrl = 'https://install.rocketgraph.com'. This would make it easier to update in the future.

if ($response.StatusCode -ne 200) {
throw "Non-200 status code"
}
Expand Down Expand Up @@ -585,13 +585,13 @@ function Get-ConfigurationFiles {
$changes = $false
Write-InfoLog "Checking for potentially new keys added to env.template since initial install."
Write-InfoLog "This may help identify missing entries in .env, but some may be false positives."

$existing = Get-Content ".env"
$template = Get-Content "env.template"

foreach ($line in $template) {
if ($line -match '^\s*$|^\s*#') { continue } # Skip empty lines and comments

$key = ($line -split '=')[0]
if (-not ($existing -match "^$key=")) {
Write-WarnLog "Key '$key' is present in env.template but not found in .env. If this key is new, consider adding it:"
Expand Down Expand Up @@ -702,4 +702,4 @@ try {
}
}

exit $ERROR_CODE
exit $ERROR_CODE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The script's exit logic can be simplified and made more consistent. The finally block on lines 699-703 duplicates the pausing logic from the Exit-Script function. Additionally, the script uses exit directly in some places (e.g., line 698) and Exit-Script in others. Consider refactoring to use a single exit mechanism. For example, the main try/catch could be simplified to always call Exit-Script at the end:

try {
    Start-Installation
} catch {
    Write-ErrorLog "Script error: $_"
    $script:ERROR_CODE = 1
}

Exit-Script $script:ERROR_CODE

This would replace lines 696-705, remove the finally block, and ensure consistent exit behavior.