Skip to content

Commit 6b5dcee

Browse files
committed
chore: formatting, minor cleanup
1 parent 8cc4aab commit 6b5dcee

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

scripts/github-notifications.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ function run() {
8080
});
8181
}
8282

83-
// CALL GITHUB API https://docs.github.com/en/rest/activity/notifications?apiVersion=2022-11-28#list-notifications-for-the-authenticated-user
83+
// CALL GITHUB API
84+
// DOCS https://docs.github.com/en/rest/activity/notifications?apiVersion=2022-11-28#list-notifications-for-the-authenticated-user
8485
const parameter = showReadNotifs ? "?all=true" : "";
8586
const response = httpRequestWithHeaders("https://api.github.com/notifications" + parameter, [
8687
"Accept: application/vnd.github.v3+json",

scripts/public-github-repo-search.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,16 @@ function run(argv) {
6565
return JSON.stringify({ items: [{ title: "Waiting for query…", valid: false }] });
6666
}
6767

68+
// DOCS https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#search-repositories
69+
const apiURL = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}`;
70+
const response = JSON.parse(httpRequest(apiURL));
71+
6872
const forkOnClone = $.getenv("fork_on_clone") === "1";
6973
const depthInfo = $.getenv("clone_depth") ? ` (depth ${$.getenv("clone_depth")})` : "";
70-
const apiURL = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}`;
7174

7275
/** @type {AlfredItem[]} */
73-
const repos = JSON.parse(httpRequest(apiURL))
74-
.items.filter((/** @type {GithubRepo} */ repo) => !(repo.fork || repo.archived))
76+
const repos = response.items
77+
.filter((/** @type {GithubRepo} */ repo) => !(repo.fork || repo.archived))
7578
.map((/** @type {GithubRepo} */ repo) => {
7679
// calculate relative date
7780
// INFO pushed_at refers to commits only https://github.com/orgs/community/discussions/24442
@@ -83,7 +86,9 @@ function run(argv) {
8386
"★ " + repo.stargazers_count,
8487
lastUpdated,
8588
repo.description,
86-
].join(" · ");
89+
]
90+
.filter(Boolean)
91+
.join(" · ");
8792

8893
const cloneSubtitle = "⌃: Shallow Clone " + depthInfo + (forkOnClone ? " & Fork" : "");
8994
const secondUrl = repo.homepage || repo.html_url + "/releases";
@@ -110,6 +115,7 @@ function run(argv) {
110115
};
111116
});
112117

118+
// GUARD no results
113119
if (repos.length === 0) {
114120
repos.push({
115121
title: "🚫 No results",

scripts/public-issue-search.js

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env osascript -l JavaScript
22
ObjC.import("stdlib");
3-
ObjC.import("Foundation");
43
const app = Application.currentApplication();
54
app.includeStandardAdditions = true;
5+
//──────────────────────────────────────────────────────────────────────────────
66

77
function alfredMatcher(str) {
88
const clean = str.replace(/[-()_.:#]/g, " ");
9-
const camelCaseSeperated = str.replace(/([A-Z])/g, " $1");
10-
return [clean, camelCaseSeperated, str].join(" ");
9+
const camelCaseSeparated = str.replace(/([A-Z])/g, " $1");
10+
return [clean, camelCaseSeparated, str].join(" ");
1111
}
1212

1313
//──────────────────────────────────────────────────────────────────────────────
@@ -17,20 +17,16 @@ const repoID = $.getenv("repoID");
1717

1818
// get plugin issues
1919
const issueAPIURL =
20-
"https://api.github.com/repos/" + repoID
21-
+ "/issues?state=all"
22-
+ "&per_page=100"; // GitHub API only returns 100 results https://stackoverflow.com/questions/30656761/github-search-api-only-return-30-results
20+
"https://api.github.com/repos/" + repoID + "/issues?state=all" + "&per_page=100"; // GitHub API only returns 100 results https://stackoverflow.com/questions/30656761/github-search-api-only-return-30-results
2321
console.log(issueAPIURL);
24-
const issueJSON =
25-
JSON.parse(app.doShellScript("curl -s \"" + issueAPIURL + "\""))
26-
.sort((x, y) => {
27-
const a = x.state;
28-
const b = y.state;
29-
return a === b ? 0 : a < b ? 1 : -1; // eslint-disable-line no-nested-ternary
30-
});
22+
const issueJSON = JSON.parse(app.doShellScript('curl -s "' + issueAPIURL + '"')).sort((x, y) => {
23+
const a = x.state;
24+
const b = y.state;
25+
return a === b ? 0 : a < b ? 1 : -1; // eslint-disable-line no-nested-ternary
26+
});
3127

3228
// existing issues
33-
issueJSON.forEach(issue => {
29+
issueJSON.forEach((issue) => {
3430
const title = issue.title;
3531
const issueCreator = issue.user.login;
3632

@@ -52,10 +48,10 @@ issueJSON.forEach(issue => {
5248
].join(" ");
5349

5450
jsonArray.push({
55-
"title": state + title,
56-
"match": issueMatcher,
57-
"subtitle": "#" + issue.number + " by " + issueCreator + comments,
58-
"arg": issue.html_url,
51+
title: state + title,
52+
match: issueMatcher,
53+
subtitle: "#" + issue.number + " by " + issueCreator + comments,
54+
arg: issue.html_url,
5955
});
6056
});
6157

0 commit comments

Comments
 (0)