Skip to content

Commit

Permalink
Update GH star script for future run on CI (#961)
Browse files Browse the repository at this point in the history
* Update GH star script for future run on CI

* Add generated github file

* Update file
  • Loading branch information
djfarrelly authored Nov 22, 2024
1 parent dcaaa96 commit 25d3381
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
7 changes: 5 additions & 2 deletions components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import Dropdown from "./Dropdown";

// Manual count of stars on GitHub for now
// Run pnpm run github:stars to get the latest count
const GITHUB_STARS = 2943;
import githubData from "src/data/github.json";

const githubStars = githubData.stars;

const menu: {
title: string;
Expand Down Expand Up @@ -202,6 +204,7 @@ const repos = [
"inngest/inngest-py",
"inngest/inngestgo",
"inngest/inngest-kt",
"inngest/agent-kit",
"inngest/workflow-kit",
];

Expand All @@ -217,7 +220,7 @@ function OpenSourceButton({ className = "" }: { className?: string }) {
<>
<span className="hidden lg:inline">Open Source</span>
<RiGithubFill className="h-4 w-4 shrink-0" />
<span>{(GITHUB_STARS / 1000).toFixed(1)}K</span>
<span>{(githubStars / 1000).toFixed(1)}K</span>
</>
}
items={items}
Expand Down
4 changes: 4 additions & 0 deletions data/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"__generated": "File generated at 2024-11-22T19:48:40.956Z",
"stars": 2957
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"env:pull": "vercel env pull",
"env:add": "vercel env add",
"env:rm": "vercel env rm",
"github:stars": "pnpm dlx ts-node ./utils/github.ts",
"github:stars": "pnpm dlx ts-node ./scripts/updateGithubStars.ts",
"preinstall": "npx only-allow pnpm"
},
"dependencies": {
Expand Down
19 changes: 19 additions & 0 deletions scripts/updateGithubStars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import fs from "node:fs";
import path from "node:path";
import { getTotalStars } from "../utils/github";

const FILENAME = "./data/github.json";
const filepath = path.join(__dirname, "..", FILENAME);

async function main() {
const totalStars = await getTotalStars("inngest");

const fileTemplate = {
__generated: `File generated at ${new Date().toISOString()}`,
stars: totalStars,
};
fs.writeFileSync(filepath, JSON.stringify(fileTemplate, null, 2));
console.log(`${totalStars} total stars`);
}

main();
9 changes: 1 addition & 8 deletions utils/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@ async function getRepoStars(org) {
return repos;
}

async function getTotalStars(org) {
export async function getTotalStars(org) {
const repos = await getRepoStars(org);
const totalStars = repos.reduce((acc, repo) => acc + repo.stars, 0);
return totalStars;
}

async function main() {
const totalStars = await getTotalStars("inngest");
console.log(`${totalStars} total stars`);
}

main();

0 comments on commit 25d3381

Please sign in to comment.