hiroppy 1.0.25 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Get star count for a repository
3
+ * @param owner - Repository owner
4
+ * @param repo - Repository name
5
+ * @returns Promise<number> - Star count
6
+ */
7
+ export declare function getStarCount(owner: string, repo: string): Promise<number>;
8
+ /**
9
+ * Get star counts for multiple repositories
10
+ * @param repos - Array of repository names in "owner/repo" format
11
+ * @returns Promise<Record<string, number>> - Object mapping repo names to star counts
12
+ */
13
+ export declare function getStarCounts(repos: string[]): Promise<Record<string, number>>;
14
+ export interface RepositoryInfo {
15
+ name: string;
16
+ url: string;
17
+ description: string | null;
18
+ language: string | null;
19
+ stars: number;
20
+ forks: number;
21
+ openIssues: number;
22
+ defaultBranch: string;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ avatar: string;
26
+ }
27
+ /**
28
+ * Get repository information including star count
29
+ * @param owner - Repository owner
30
+ * @param repo - Repository name
31
+ * @returns Promise<RepositoryInfo> - Repository information
32
+ */
33
+ export declare function getRepositoryInfo(owner: string, repo: string): Promise<RepositoryInfo>;
34
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkBjC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,CAAC,CA4BzB"}
package/dist/github.js ADDED
@@ -0,0 +1,83 @@
1
+ import { Octokit } from "octokit";
2
+ let octokit = null;
3
+ function getOctokit() {
4
+ if (!octokit) {
5
+ const token = process.env.GITHUB_TOKEN;
6
+ if (!token) {
7
+ throw new Error("GITHUB_TOKEN environment variable is required");
8
+ }
9
+ octokit = new Octokit({ auth: token });
10
+ }
11
+ return octokit;
12
+ }
13
+ /**
14
+ * Get star count for a repository
15
+ * @param owner - Repository owner
16
+ * @param repo - Repository name
17
+ * @returns Promise<number> - Star count
18
+ */
19
+ export async function getStarCount(owner, repo) {
20
+ try {
21
+ const octokit = getOctokit();
22
+ const { data } = await octokit.rest.repos.get({
23
+ owner,
24
+ repo,
25
+ });
26
+ return data.stargazers_count;
27
+ }
28
+ catch (error) {
29
+ console.error(`Failed to fetch star count for ${owner}/${repo}:`, error);
30
+ return 0;
31
+ }
32
+ }
33
+ /**
34
+ * Get star counts for multiple repositories
35
+ * @param repos - Array of repository names in "owner/repo" format
36
+ * @returns Promise<Record<string, number>> - Object mapping repo names to star counts
37
+ */
38
+ export async function getStarCounts(repos) {
39
+ const results = {};
40
+ const promises = repos.map(async (repoName) => {
41
+ const [owner, repo] = repoName.split("/");
42
+ if (!owner || !repo) {
43
+ console.warn(`Invalid repository name format: ${repoName}. Expected "owner/repo"`);
44
+ return;
45
+ }
46
+ const stars = await getStarCount(owner, repo);
47
+ results[repoName] = stars;
48
+ });
49
+ await Promise.all(promises);
50
+ return results;
51
+ }
52
+ /**
53
+ * Get repository information including star count
54
+ * @param owner - Repository owner
55
+ * @param repo - Repository name
56
+ * @returns Promise<RepositoryInfo> - Repository information
57
+ */
58
+ export async function getRepositoryInfo(owner, repo) {
59
+ try {
60
+ const octokit = getOctokit();
61
+ const { data } = await octokit.rest.repos.get({
62
+ owner,
63
+ repo,
64
+ });
65
+ return {
66
+ name: data.full_name,
67
+ url: data.html_url,
68
+ description: data.description,
69
+ language: data.language,
70
+ stars: data.stargazers_count,
71
+ forks: data.forks_count,
72
+ openIssues: data.open_issues_count,
73
+ defaultBranch: data.default_branch,
74
+ createdAt: data.created_at,
75
+ updatedAt: data.updated_at,
76
+ avatar: data.owner.avatar_url,
77
+ };
78
+ }
79
+ catch (error) {
80
+ console.error(`Failed to fetch repository info for ${owner}/${repo}:`, error);
81
+ throw error;
82
+ }
83
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Get bookmark count from Hatena Bookmark
3
+ * @param entry - URL to get bookmark count for
4
+ * @returns Promise<number> - Bookmark count
5
+ */
6
+ export declare function getBookmark(entry: string): Promise<number>;
7
+ //# sourceMappingURL=hatena.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hatena.d.ts","sourceRoot":"","sources":["../src/hatena.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAahE"}
package/dist/hatena.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Get bookmark count from Hatena Bookmark
3
+ * @param entry - URL to get bookmark count for
4
+ * @returns Promise<number> - Bookmark count
5
+ */
6
+ export async function getBookmark(entry) {
7
+ try {
8
+ const url = `https://b.hatena.ne.jp/entry/json/${entry}`;
9
+ const res = await fetch(url);
10
+ if (!res.ok) {
11
+ throw new Error(`HTTP error! status: ${res.status}`);
12
+ }
13
+ const data = (await res.json());
14
+ return data.count || 0;
15
+ }
16
+ catch (error) {
17
+ console.error(`Failed to fetch bookmark for ${entry}:`, error);
18
+ return 0;
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./github.js";
2
+ export * from "./hatena.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./github.js";
2
+ export * from "./hatena.js";
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hiroppy",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "packageManager": "pnpm@10.11.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",