Skip to content

Commit 7d6ba4d

Browse files
Update README.md
1 parent 580f3bb commit 7d6ba4d

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Made with SvelteKit, TailwindCSS & shadcn-svelte.
1313
- RSS feeds for all packages
1414
- Dynamically computed badges to indicate whether a package is the Latest, a Major version, a Prerelease, or a Maintenance version
1515
- Sidebar with the number of unseen releases for each package
16-
- ...and more!
16+
- ...and much more!
1717

1818
## How does it work?
1919

@@ -27,6 +27,20 @@ wrapper around GitHub releases.
2727

2828
For more info, visit the [v2 release post](https://svelte-changelog.dev/devlog/v2).
2929

30+
### Run locally
31+
32+
The main requirements to run Svelte Changelog are the `.env` entries, which you can find an example of inside the `.env.example`:
33+
34+
- `GITHUB_TOKEN`: a [classic GitHub token](https://github.com/settings/tokens) with the `public_repo` scope (that's it), required for API requests.
35+
- `KV_REST_API_TOKEN` (optional): the token for the API of the KV service (Redis). You can leave it empty; an in-memory cache is used during development.
36+
- `KV_REST_API_URL` (optional): the URL for the API of the KV service (Redis). You can leave it empty; an in-memory cache is used during development.
37+
- `PUBLIC_POSTHOG_KEY` (optional): the token for the analytics service I use, [PostHog](https://posthog.com). You can leave it empty; analytics are disabled in dev environments.
38+
39+
> [!NOTE]
40+
> If other environment variables happen to be required for linting or compilation purposes, simply add them with an empty value inside your `.env` file
41+
42+
That's it: your GitHub token will do most of the job, and you can run the website like any regular SvelteKit app (`pnpm i` && `pnpm dev`).
43+
3044
## Missing a package?
3145

3246
If you think I missed a package, you can either open an issue or directly contribute.

src/lib/server/github-cache.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { dev } from "$app/environment";
2-
import { GITHUB_TOKEN, KV_REST_API_TOKEN, KV_REST_API_URL } from "$env/static/private";
2+
import {
3+
GH_APP_ID,
4+
GH_APP_INSTALLATION_TOKEN,
5+
GH_APP_PRIV_KEY_BASE64,
6+
GITHUB_TOKEN,
7+
KV_REST_API_TOKEN,
8+
KV_REST_API_URL
9+
} from "$env/static/private";
310
import type {
411
CommentAuthorAssociation,
512
Issue as GQLIssue,
@@ -8,7 +15,7 @@ import type {
815
ReferencedSubject
916
} from "@octokit/graphql-schema";
1017
import { Redis } from "@upstash/redis";
11-
import { Octokit } from "octokit";
18+
import { App, Octokit } from "octokit";
1219
import semver from "semver";
1320
import parseChangelog from "$lib/changelog-parser";
1421
import type { Repository } from "$lib/repositories";
@@ -182,7 +189,7 @@ export class GitHubCache {
182189
* @param githubToken the GitHub token for uncached API requests
183190
* @constructor
184191
*/
185-
constructor(redisUrl: string, redisToken: string, githubToken: string) {
192+
constructor(redisUrl: string, redisToken: string, octokit: Octokit) {
186193
this.#cache = new CacheHandler(
187194
new Redis({
188195
url: redisUrl,
@@ -191,9 +198,7 @@ export class GitHubCache {
191198
dev
192199
);
193200

194-
this.#octokit = new Octokit({
195-
auth: githubToken
196-
});
201+
this.#octokit = octokit;
197202
}
198203

199204
/**
@@ -977,4 +982,15 @@ export class GitHubCache {
977982
}
978983
}
979984

980-
export const githubCache = new GitHubCache(KV_REST_API_URL, KV_REST_API_TOKEN, GITHUB_TOKEN);
985+
export const githubCache = new GitHubCache(
986+
KV_REST_API_URL,
987+
KV_REST_API_TOKEN,
988+
GITHUB_TOKEN
989+
? new Octokit({
990+
auth: GITHUB_TOKEN
991+
})
992+
: await new App({
993+
appId: GH_APP_ID,
994+
privateKey: Buffer.from(GH_APP_PRIV_KEY_BASE64, "base64").toString("utf8")
995+
}).getInstallationOctokit(+GH_APP_INSTALLATION_TOKEN)
996+
);

0 commit comments

Comments
 (0)