website
git clone https://git.pyrossh.dev/website
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
dfd8d69
— pyrossh
2026-07-07T12:03:14+05:30
feat: add repo commits workers
- packages/workers/repos/commits/detail/package.json +14 -0
- packages/workers/repos/commits/detail/src/index.tsx +45 -0
- packages/workers/repos/commits/detail/tsconfig.json +4 -0
- packages/workers/repos/commits/detail/wrangler.jsonc +10 -0
- packages/workers/repos/commits/index/package.json +14 -0
- packages/workers/repos/commits/index/src/index.tsx +38 -0
- packages/workers/repos/commits/index/tsconfig.json +4 -0
- packages/workers/repos/commits/index/wrangler.jsonc +10 -0
packages/workers/repos/commits/detail/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pyrossh/repos-commits-detail",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.tsx",
|
|
7
|
+
"types": "src/index.tsx",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@pyrossh/config": "workspace:*",
|
|
10
|
+
"@pyrossh/core": "workspace:*",
|
|
11
|
+
"@pyrossh/types": "workspace:*",
|
|
12
|
+
"@pyrossh/ui": "workspace:*"
|
|
13
|
+
}
|
|
14
|
+
}
|
packages/workers/repos/commits/detail/src/index.tsx
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { RepoLayout } from "@pyrossh/ui";
|
|
2
|
+
import { getRepo, getCommits, generateHTMLDiff } from "@pyrossh/core";
|
|
3
|
+
import type { Env } from "@pyrossh/types";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
7
|
+
const url = new URL(request.url);
|
|
8
|
+
const parts = url.pathname.split("/").filter(Boolean);
|
|
9
|
+
const repoId = parts[2];
|
|
10
|
+
const hash = parts[4];
|
|
11
|
+
|
|
12
|
+
const repo = getRepo(repoId);
|
|
13
|
+
if (!repo) return Response.redirect(`${url.origin}/404`, 302);
|
|
14
|
+
|
|
15
|
+
if (!hash) return Response.redirect(`${url.origin}/repos/${repo.id}/commits`, 302);
|
|
16
|
+
|
|
17
|
+
const commits = await getCommits(env.REPOS, repo.id);
|
|
18
|
+
const commit = commits.find((c) => c.hash === hash);
|
|
19
|
+
if (!commit) return Response.redirect(`${url.origin}/repos/${repo.id}/commits`, 302);
|
|
20
|
+
|
|
21
|
+
const diffHtml = await generateHTMLDiff(env.REPOS, repo.id, commit.hash);
|
|
22
|
+
|
|
23
|
+
return new Response(
|
|
24
|
+
<RepoLayout repo={repo} request={request} currentTab="Commits">
|
|
25
|
+
<div class="event">
|
|
26
|
+
<div>
|
|
27
|
+
<a href={`/repos/${repo.id}/commits/${commit.hash}`}>{commit.hash.substring(0, 7)}</a>—
|
|
28
|
+
<strong>{commit.author_name}</strong>
|
|
29
|
+
<small class="pull-right">
|
|
30
|
+
<span>{commit.date}</span>
|
|
31
|
+
</small>
|
|
32
|
+
</div>
|
|
33
|
+
<pre class="commit">{commit.message}</pre>
|
|
34
|
+
</div>
|
|
35
|
+
<div dangerouslySetInnerHTML={{ __html: diffHtml }} />
|
|
36
|
+
</RepoLayout>,
|
|
37
|
+
{
|
|
38
|
+
headers: {
|
|
39
|
+
"Content-Type": "text/html",
|
|
40
|
+
"Cache-Control": "public, max-age=300, s-maxage=3600",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
};
|
packages/workers/repos/commits/detail/tsconfig.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.base.json",
|
|
3
|
+
"include": ["src"]
|
|
4
|
+
}
|
packages/workers/repos/commits/detail/wrangler.jsonc
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/cloudflare/workers-sdk/main/packages/wrangler/config-schema.json",
|
|
3
|
+
"name": "pyrossh-repos-commits-detail",
|
|
4
|
+
"main": "src/index.tsx",
|
|
5
|
+
"compatibility_date": "2026-07-07",
|
|
6
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
7
|
+
"workers_dev": false,
|
|
8
|
+
"routes": [{ "pattern": "pyrossh.dev/repos/*/commits/*", "custom_domain": true }],
|
|
9
|
+
"r2_buckets": [{ "binding": "REPOS", "bucket_name": "pyrossh-repos-prd" }],
|
|
10
|
+
}
|
packages/workers/repos/commits/index/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pyrossh/repos-commits-index",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.tsx",
|
|
7
|
+
"types": "src/index.tsx",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@pyrossh/config": "workspace:*",
|
|
10
|
+
"@pyrossh/core": "workspace:*",
|
|
11
|
+
"@pyrossh/types": "workspace:*",
|
|
12
|
+
"@pyrossh/ui": "workspace:*"
|
|
13
|
+
}
|
|
14
|
+
}
|
packages/workers/repos/commits/index/src/index.tsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RepoLayout } from "@pyrossh/ui";
|
|
2
|
+
import { getRepo, getCommits } from "@pyrossh/core";
|
|
3
|
+
import type { Env } from "@pyrossh/types";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
7
|
+
const url = new URL(request.url);
|
|
8
|
+
const parts = url.pathname.split("/").filter(Boolean);
|
|
9
|
+
const repoId = parts[2];
|
|
10
|
+
const repo = getRepo(repoId);
|
|
11
|
+
if (!repo) return Response.redirect(`${url.origin}/404`, 302);
|
|
12
|
+
|
|
13
|
+
const commits = await getCommits(env.REPOS, repo.id);
|
|
14
|
+
|
|
15
|
+
return new Response(
|
|
16
|
+
<RepoLayout repo={repo} request={request} currentTab="Commits">
|
|
17
|
+
{commits.map((commit) => (
|
|
18
|
+
<div class="event">
|
|
19
|
+
<div>
|
|
20
|
+
<a href={`/repos/${repo.id}/commits/${commit.hash}`}>{commit.hash.substring(0, 7)}</a>
|
|
21
|
+
—<strong>{commit.author_name}</strong>
|
|
22
|
+
<small class="pull-right">
|
|
23
|
+
<span>{commit.date}</span>
|
|
24
|
+
</small>
|
|
25
|
+
</div>
|
|
26
|
+
<pre class="commit">{commit.message}</pre>
|
|
27
|
+
</div>
|
|
28
|
+
))}
|
|
29
|
+
</RepoLayout>,
|
|
30
|
+
{
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "text/html",
|
|
33
|
+
"Cache-Control": "public, max-age=300, s-maxage=3600",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
};
|
packages/workers/repos/commits/index/tsconfig.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.base.json",
|
|
3
|
+
"include": ["src"]
|
|
4
|
+
}
|
packages/workers/repos/commits/index/wrangler.jsonc
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/cloudflare/workers-sdk/main/packages/wrangler/config-schema.json",
|
|
3
|
+
"name": "pyrossh-repos-commits-index",
|
|
4
|
+
"main": "src/index.tsx",
|
|
5
|
+
"compatibility_date": "2026-07-07",
|
|
6
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
7
|
+
"workers_dev": false,
|
|
8
|
+
"routes": [{ "pattern": "pyrossh.dev/repos/*/commits", "custom_domain": true }],
|
|
9
|
+
"r2_buckets": [{ "binding": "REPOS", "bucket_name": "pyrossh-repos-prd" }],
|
|
10
|
+
}
|