-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.ts
75 lines (70 loc) · 1.59 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
interface Meta {
page: number;
resultsPerPage: number;
time: number;
totalCount: number;
totalPages: number;
}
interface Item {
name: string;
owner: {
login: string;
};
html_url: string;
description: string;
stargazers_count: number;
open_issues_count: number;
ssh_url: string;
}
interface Response {
total_count: number;
incomplete_results: boolean;
items: Item[];
}
try {
const res = await fetch(
`https://api.github.com/search/repositories?q=${Deno.args[0]}&sort=stars&order=desc`
);
const body: Response = await res.json();
const packages = {
items: body.items.map((item) => {
return {
title: `${item.name}`,
subtitle: `${item.description} (${item.owner.login} | ${item.stargazers_count} stars)`,
arg: item.html_url,
mods: {
alt: {
valid: true,
arg: `https://github.com/${item.owner.login}/${item.name}/issues`,
subtitle: `Open Issues ${item.open_issues_count}`,
},
cmd: {
valid: true,
arg: `https://github.com/${item.owner.login}/${item.name}/pulls`,
subtitle: "Open Pull requests",
},
},
text: {
copy: item.ssh_url,
largetype: item.ssh_url,
},
};
}),
};
console.log(JSON.stringify(packages));
} catch (error) {
console.log(
JSON.stringify({
items: [
{
title: error.name,
subtitle: error.message,
valid: false,
text: {
copy: error.stack,
},
},
],
})
);
}