github-overview 0.0.0-stage → 0.1.1
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.
- package/LICENSE +21 -0
- package/README.md +63 -2
- package/bin/cli.mjs +89 -0
- package/docs/screenshot-dark.png +0 -0
- package/docs/screenshot-light.png +0 -0
- package/package.json +34 -4
- package/public/index.html +723 -0
- package/src/config.mjs +41 -0
- package/src/github.mjs +113 -0
- package/src/npm.mjs +67 -0
- package/src/server.mjs +160 -0
- package/src/store.mjs +71 -0
- package/src/summary.mjs +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 regrevia
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# github-overview
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
自己的 GitHub 仓库,一个页面看完:浏览与克隆的趋势、npm 等外部来源的下载、流量落在哪些页面、外部人提了多少 issue 和 PR,右边一段 AI 写的摘要。
|
|
4
|
+
|
|
5
|
+
不依赖第三方统计服务,只跑一个本地 Node 进程:读你自己的 token,把数据抓下来存到本地,页面在浏览器里打开。
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## 用法
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx github-overview init --repo owner/repo --npm 包名
|
|
13
|
+
npx github-overview start # http://127.0.0.1:4317
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- 首次同步把 14 天内的流量存到本地,之后每 6 小时自动刷新(`--refresh` 可改),页面上的「刷新」随时手动同步。
|
|
17
|
+
- AI 摘要:`npx github-overview config --apikey KEY --baseurl URL`,只存本机 `~/.config/github-overview/config.json`。
|
|
18
|
+
- 没配 AI 也能用,摘要走内置模板。
|
|
19
|
+
|
|
20
|
+
## 为什么需要它
|
|
21
|
+
|
|
22
|
+
GitHub 自带的 traffic 只给 14 天,而且只有浏览和克隆,看不到 npm 下载。发行版一多、渠道一散,判断「这次发版有没有人真用上」就得自己拼数据。这个项目把 GitHub traffic、npm 下载、发版记录放在同一条时间轴上,再用一句话说清发生了什么。
|
|
23
|
+
|
|
24
|
+
## 口径
|
|
25
|
+
|
|
26
|
+
| 名字 | 含义 |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| 浏览 | 打开页面的总次数 |
|
|
29
|
+
| 访客 | 去重后的人数,一个人来三次算一个 |
|
|
30
|
+
| 克隆 | `git clone` 的总次数 |
|
|
31
|
+
| 克隆人数 | 去重后的人数 |
|
|
32
|
+
| 发版 | 窗口内发布的版本,含 npm 发布时间 |
|
|
33
|
+
| 外部贡献 | 别人提的 issue 和 PR,作者自己的不计 |
|
|
34
|
+
|
|
35
|
+
- 浏览和克隆是两个指标,不相加。
|
|
36
|
+
- 页面构成是浏览落在哪些页面,来源是从哪个站进来,两者分开。
|
|
37
|
+
- 预估真实用户只取访客人数,克隆数不参与人数估算。
|
|
38
|
+
|
|
39
|
+
## 数据源
|
|
40
|
+
|
|
41
|
+
| 来源 | 指标 | 粒度 |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| GitHub traffic | 浏览、克隆、页面、来源 | 每日 + 快照 |
|
|
44
|
+
| GitHub search | 外部 issue、PR | 按创建时间 |
|
|
45
|
+
| GitHub alerts | 安全告警 | 快照 |
|
|
46
|
+
| npm | 每日下载、版本时间 | 每日(约 2–3 天延迟) |
|
|
47
|
+
|
|
48
|
+
首个版本做 GitHub + npm,其余来源按同一接口追加。
|
|
49
|
+
|
|
50
|
+
## 14 天窗口
|
|
51
|
+
|
|
52
|
+
GitHub 的 traffic 只保留最近 14 天,所以第一次运行就要开始存快照。30 天、90 天视图读本地存储:缺失的日子标注从哪天开始有数据,不画成 0。
|
|
53
|
+
|
|
54
|
+
## 路线
|
|
55
|
+
|
|
56
|
+
- [x] 页面与视觉规范
|
|
57
|
+
- [x] 本地存储与 GitHub / npm 抓取
|
|
58
|
+
- [x] 定时刷新与手动刷新
|
|
59
|
+
- [x] 面板内配置(AI 的 base URL 与 key)
|
|
60
|
+
- [x] AI 摘要,未配置时用模板
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
MIT
|
package/bin/cli.mjs
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readConfig, writeConfig, parseRepo, CONFIG_PATH } from "./../src/config.mjs";
|
|
3
|
+
import { createApp } from "./../src/server.mjs";
|
|
4
|
+
|
|
5
|
+
const argv = process.argv.slice(2);
|
|
6
|
+
const cmd = argv[0] && !argv[0].startsWith("-") ? argv[0] : "start";
|
|
7
|
+
const flag = (...names) => {
|
|
8
|
+
for (const n of names) {
|
|
9
|
+
const i = argv.indexOf(n);
|
|
10
|
+
if (i >= 0) return argv[i + 1];
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const repoArg = flag("--repo", "-r");
|
|
16
|
+
const port = Number(flag("--port", "-p") || process.env.PORT || 4317);
|
|
17
|
+
const npmArg = flag("--npm");
|
|
18
|
+
const days = Number(flag("--days") || 7);
|
|
19
|
+
const intervalHours = Number(flag("--refresh") || 6);
|
|
20
|
+
|
|
21
|
+
function usage() {
|
|
22
|
+
console.log(`github-overview
|
|
23
|
+
|
|
24
|
+
github-overview init --repo owner/repo [--npm 包名]
|
|
25
|
+
github-overview start [--port 4317] [--days 7] [--refresh 6]
|
|
26
|
+
github-overview sync
|
|
27
|
+
github-overview config --apikey KEY --baseurl URL
|
|
28
|
+
`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
if (cmd === "init") {
|
|
33
|
+
const { owner, name } = parseRepo(repoArg || flag("--repo"));
|
|
34
|
+
const next = { ...readConfig(), repo: `${owner}/${name}`, npm: npmArg || name };
|
|
35
|
+
writeConfig(next);
|
|
36
|
+
console.log(`已写入 ${CONFIG_PATH}`);
|
|
37
|
+
console.log(`仓库 ${next.repo},npm 包 ${next.npm}`);
|
|
38
|
+
console.log("下一步:github-overview start");
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (cmd === "config") {
|
|
43
|
+
const next = { ...readConfig() };
|
|
44
|
+
const apikey = flag("--apikey");
|
|
45
|
+
const baseurl = flag("--baseurl");
|
|
46
|
+
if (apikey) next.apikey = apikey;
|
|
47
|
+
if (baseurl) next.baseurl = baseurl.replace(/\/$/, "");
|
|
48
|
+
writeConfig(next);
|
|
49
|
+
console.log(`AI 配置已保存到 ${CONFIG_PATH}`);
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const cfg = readConfig();
|
|
54
|
+
const repo = repoArg || cfg.repo;
|
|
55
|
+
if (!repo) {
|
|
56
|
+
usage();
|
|
57
|
+
console.log("还没有配置仓库,先跑:github-overview init --repo owner/repo");
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (cmd === "sync") {
|
|
62
|
+
const app = createApp({ repo, days });
|
|
63
|
+
const out = await app.sync();
|
|
64
|
+
console.log(`同步完成 ${out.syncedAt}`);
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (cmd === "start") {
|
|
69
|
+
const app = createApp({ repo, days });
|
|
70
|
+
const addr = await app.listen(port);
|
|
71
|
+
console.log(`github-overview 在 http://127.0.0.1:${addr.port}`);
|
|
72
|
+
const tick = async () => {
|
|
73
|
+
try {
|
|
74
|
+
const out = await app.sync();
|
|
75
|
+
console.log(`同步 ${out.syncedAt}`);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.log(`同步失败:${e.message}`);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
tick();
|
|
81
|
+
setInterval(tick, Math.max(1, intervalHours) * 3600e3);
|
|
82
|
+
await new Promise(() => {});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
usage();
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.error(String(e.message || e));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-overview",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Private dashboard for your own GitHub repos: traffic, clones, npm downloads and an AI summary in one view.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"github-overview": "bin/cli.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src",
|
|
12
|
+
"public",
|
|
13
|
+
"docs",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"start": "node bin/cli.mjs"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"github",
|
|
25
|
+
"traffic",
|
|
26
|
+
"analytics",
|
|
27
|
+
"npm",
|
|
28
|
+
"dashboard",
|
|
29
|
+
"self-hosted"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/regrevia/github-overview.git"
|
|
35
|
+
}
|
|
36
|
+
}
|