Skip to content

Commit 94dd318

Browse files
committed
feat(sorting): add gitlab api
1 parent 24838eb commit 94dd318

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

scripts/sort_themes.nu

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ export def github [
2727
}
2828
}
2929

30+
# Gitlab API.
31+
export def gitlab [
32+
token?: string # API Token.
33+
]: record<owner: string, name: string> -> record<pushed_at: string, stargazers_count: int, avatar: string> {
34+
let repo = $in
35+
36+
let headers = if ($token | is-empty) {
37+
[]
38+
} else {
39+
{
40+
Authorization: $"Bearer ($token)"
41+
}
42+
}
43+
44+
let item = http get $"https://gitlab.com/api/v4/projects/($repo.owner)%2F($repo.name)" --headers $headers
45+
46+
{
47+
pushed_at: $item.last_activity_at
48+
stargazers_count: ($item.star_count | into int)
49+
avatar: $item.namespace.avatar_url
50+
}
51+
}
52+
3053
# In case of not having API, clone and get information yourself.
3154
export def clone [
3255
--temp: string = '/tmp/firefoxcss-store/' # Temporary folder to save themes.
@@ -104,6 +127,9 @@ export def main [
104127
let info = if ($item.link | str contains 'github') {
105128
sleep $delay
106129
$item.link | parse_link | github $token
130+
} else if ($item.link | str contains 'gitlab') {
131+
sleep $delay
132+
$item.link | parse_link | gitlab $token
107133
} else {
108134
$item.link | parse_link | clone
109135
}

0 commit comments

Comments
 (0)