Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give better error message if GitHub CLI or GIT isn't installed #898

Merged
merged 7 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ function RetryCommand {
catch {
$retryCount++
if ($retryCount -eq $MaxRetries) {
throw $_
throw
}
else {
Write-Host "Retrying after $RetryDelaySeconds seconds..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
& /usr/bin/env sudo pwsh -command "& chmod +x $ENV:aldocPath"
}
Write-Host "Installing/Updating docfx"
CmdDo -command dotnet -arguments @("tool","update","-g docfx")
CmdDo -command dotnet -arguments @("tool","update","-g docfx") -messageIfCmdNotFound "dotnet not found. Please install it from https://dotnet.microsoft.com/download"
}
return $ENV:aldocPath
}
Expand Down
24 changes: 19 additions & 5 deletions Actions/Github-Helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ function CmdDo {
[string] $arguments = "",
[switch] $silent,
[switch] $returnValue,
[string] $inputStr = ""
[string] $inputStr = "",
[string] $messageIfCmdNotFound = ""
)

$oldNoColor = "$env:NO_COLOR"
Expand Down Expand Up @@ -282,14 +283,27 @@ function CmdDo {
Write-Host $message
}
if ($returnValue) {
$message.Replace("`r","").Split("`n")
$message.Replace("`r", "").Split("`n")
}
}
else {
$message += "`n`nExitCode: "+$p.ExitCode + "`nCommandline: $command $arguments"
$message += "`n`nExitCode: " + $p.ExitCode + "`nCommandline: $command $arguments"
throw $message
}
}
catch [System.ComponentModel.Win32Exception] {
if ($_.Exception.NativeErrorCode -eq 2) {
if ($messageIfCmdNotFound) {
throw $messageIfCmdNotFound
}
else {
throw "Command $command not found, you might need to install that command."
}
}
else {
throw
}
}
finally {
try { [Console]::OutputEncoding = $oldEncoding } catch {}
$env:NO_COLOR = $oldNoColor
Expand Down Expand Up @@ -319,7 +333,7 @@ function invoke-gh {
$arguments += "$parameter "
}
}
cmdDo -command gh -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr
cmdDo -command gh -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr -messageIfCmdNotFound "Github CLI not found. Please install it from https://cli.github.com/"
}
}

Expand All @@ -343,7 +357,7 @@ function invoke-git {
$arguments += "$parameter "
}
}
cmdDo -command git -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr
cmdDo -command git -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr -messageIfCmdNotFound "Git not found. Please install it from https://git-scm.com/downloads"
}
}

Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Note that when using the preview version of AL-Go for GitHub, we recommend you U

### Issues
- Support release branches that start with releases/
- Issue 870 Improve Error Handling when CLI is missing

### Build modes
AL-Go ships with Default, Translated and Clean mode out of the box. Now you can also define custom build modes in addition to the ones shipped with AL-Go. This allows you to define your own build modes, which can be used to build your apps in different ways. By default, a custom build mode will build the apps similarly to the Default mode but this behavior can be overridden in e.g. script overrides in your repository.
Expand Down
Loading