2024-08-07 12:11:10 -05:00
|
|
|
#!/usr/bin/env nu
|
|
|
|
|
|
|
|
def "check gh" [repo] {
|
|
|
|
if $in.exit_code != 0 {
|
|
|
|
print $"(ansi red) failed to run gh request for repo: ($repo)\n($in | reject exit_code)"
|
|
|
|
exit $in.exit_code
|
|
|
|
};
|
|
|
|
$in.stdout
|
|
|
|
}
|
|
|
|
|
|
|
|
def drop-v [] {
|
|
|
|
$in | each {|it|
|
|
|
|
if ($it | str starts-with 'v') {
|
|
|
|
$it | str substring 1..
|
|
|
|
} else { $it }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def "get tags" [] {
|
|
|
|
let repo = $in
|
|
|
|
(
|
|
|
|
gh api
|
|
|
|
-H "Accept: application/vnd.github+json"
|
|
|
|
-H "X-GitHub-Api-Version: 2022-11-28"
|
|
|
|
--paginate $"repos/($repo)/tags"
|
|
|
|
)
|
|
|
|
| complete
|
|
|
|
| check gh $repo
|
|
|
|
| from json
|
|
|
|
| where name =~ '^v?\d'
|
|
|
|
| get name
|
|
|
|
| drop-v
|
|
|
|
}
|
|
|
|
|
|
|
|
def repo-to-bin [] {
|
|
|
|
let name = $in | split row '/' | last
|
|
|
|
match $name {
|
|
|
|
"ripgrep" => "rg"
|
|
|
|
"cli" => "gh"
|
|
|
|
"neovim" => "nvim"
|
|
|
|
"nushell" => "nu"
|
|
|
|
_ => $name
|
|
|
|
}
|
|
|
|
}
|
2024-06-25 12:23:05 -05:00
|
|
|
|
2024-08-07 12:11:10 -05:00
|
|
|
def current-version [] {
|
|
|
|
run-external $in "--version"
|
|
|
|
| split row "\n"
|
|
|
|
| each {|s| $'| ' + $s}
|
|
|
|
| str join "\n"
|
|
|
|
}
|
2024-06-25 12:23:05 -05:00
|
|
|
|
2024-08-07 12:11:10 -05:00
|
|
|
def check-exe [] {
|
|
|
|
if (which $in | length ) == 0 {
|
|
|
|
print $"(ansi red_bold)($in) is not installed(ansi reset)"
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
def compare-versions [] {
|
2024-08-08 14:18:20 -05:00
|
|
|
each {||
|
2024-08-07 12:11:10 -05:00
|
|
|
let repo = $in
|
|
|
|
let $bin = $repo | repo-to-bin
|
|
|
|
if not ($bin | check-exe) { return }
|
|
|
|
let latest = $repo | get tags | first
|
|
|
|
let current = $bin | current-version
|
|
|
|
print $"(ansi cyan_bold)($repo)(ansi reset):
|
|
|
|
latest: ($latest)
|
|
|
|
current:
|
|
|
|
($current)
|
|
|
|
"
|
2024-08-08 14:18:20 -05:00
|
|
|
}
|
2024-08-07 12:11:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
junegunn/fzf
|
|
|
|
cli/cli
|
|
|
|
sharkdp/fd
|
|
|
|
jesseduffield/lazygit
|
|
|
|
neovim/neovim
|
|
|
|
BurntSushi/ripgrep
|
|
|
|
nushell/nushell
|
|
|
|
zyedidia/eget
|
|
|
|
prefix-dev/pixi
|
|
|
|
]
|
2024-08-08 14:18:20 -05:00
|
|
|
| compare-versions
|
2024-08-07 12:11:10 -05:00
|
|
|
| ignore
|