Skip to content

Commit 31a1161

Browse files
committed
feat(sorting): add github functionality
1 parent 63fa41b commit 31a1161

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

scripts/sort_themes.nu

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
# Maintainer: BeyondMagic - João Farias 2024 <beyondmagic@mail.ru>
66

77
# Github API.
8-
export def github []: record<owner: string, name: string> -> record<pushed_at: string, stargazers_count: int, avatar: string> {
9-
let item = {
10-
#...
11-
pushed_at: '2023-03-06T16:47:46Z'
12-
stargazers_count: '2'
13-
owner: {
14-
avatar_url: 'https://avatars.githubusercontent.com/u/9977591?v=4'
15-
}
8+
export def github [
9+
token: string # API Token.
10+
]: record<owner: string, name: string> -> record<pushed_at: string, stargazers_count: int, avatar: string> {
11+
let repo = $in
12+
13+
let item = http get $"https://api.github.com/repos/($repo.owner)/($repo.name)" --headers {
14+
Authorization: $"Bearer ($token)"
1615
}
1716

1817
{
@@ -98,7 +97,7 @@ export def main [
9897

9998
let info = if ($item.link | str contains 'github') {
10099
sleep $delay
101-
$item.link | parse_link | github
100+
$item.link | parse_link | github $token
102101
} else {
103102
$item.link | parse_link | clone
104103
}

0 commit comments

Comments
 (0)