From dd79d8e54581bf8e8076a30e155e40d4f22b3f08 Mon Sep 17 00:00:00 2001 From: Maddy Montaquila Date: Thu, 19 Feb 2026 16:59:11 -0500 Subject: [PATCH] Update to Aspire 13 and fix contribution check logic - Upgrade Aspire SDK and packages from 9.4.0 to 13.3.0-preview (daily) - Replace Aspire.Hosting.NodeJs + CommunityToolkit.Aspire.Hosting.NodeJS.Extensions with Aspire.Hosting.JavaScript - Migrate AddNpmApp to AddJavaScriptApp (auto package install, env-based port config) - Update TFM from net9.0 to net10.0 - Fix contribution check: use server-side author filter instead of client-side pagination - Add NuGet.config with daily feed source mapping Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ContribBot.AppHost/AppHost.cs | 6 +-- ContribBot.AppHost/ContribBot.AppHost.csproj | 12 ++---- nuget.config | 16 ++++++++ src/index.ts | 43 ++++---------------- 4 files changed, 31 insertions(+), 46 deletions(-) create mode 100644 nuget.config diff --git a/ContribBot.AppHost/AppHost.cs b/ContribBot.AppHost/AppHost.cs index f878384..d1eb4fe 100644 --- a/ContribBot.AppHost/AppHost.cs +++ b/ContribBot.AppHost/AppHost.cs @@ -36,9 +36,8 @@ // Add the TypeScript Discord bot as an npm application using CommunityToolkit // This will automatically run npm install and use the start script from package.json -var discordBot = builder.AddNpmApp("contrib-verifier", "../") - .WithNpmPackageInstallation() - .WithHttpEndpoint(targetPort: 3000, name: "webhook") +var discordBot = builder.AddJavaScriptApp("contrib-verifier", "../") + .WithHttpEndpoint(port: 3000, env: "PORT") .WithExternalHttpEndpoints() .WithEnvironment("CLIENT_ID", clientId) .WithEnvironment("CLIENT_SECRET", clientSecret) @@ -48,7 +47,6 @@ .WithEnvironment("REPOSITORIES", repositories) .WithEnvironment("GUILD_ID", guildId) .WithEnvironment("ROLE_ID", roleId) - .WithEnvironment("PORT", "3000") .PublishAsDockerFile() .PublishAsAzureContainerApp((infra, app) => { diff --git a/ContribBot.AppHost/ContribBot.AppHost.csproj b/ContribBot.AppHost/ContribBot.AppHost.csproj index c62d221..66f751e 100644 --- a/ContribBot.AppHost/ContribBot.AppHost.csproj +++ b/ContribBot.AppHost/ContribBot.AppHost.csproj @@ -1,20 +1,16 @@ - - - + Exe - net9.0 + net10.0 enable enable ef99776f-7ec9-4f51-b3e2-ac7d85305153 - - - - + + diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..b48b0b0 --- /dev/null +++ b/nuget.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index de0ec51..51a217d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -49,41 +49,16 @@ async function checkContributionsToRepos(githubUsername: string, repositories: s const [owner, repoName] = repo.split('/'); if (!owner || !repoName) continue; - let allCommits: any[] = []; - let page = 1; - let hasMore = true; - - while (hasMore) { - try { - const { data: commits } = await octokit.repos.listCommits({ - owner, - repo: repoName, - since: sixMonthsAgo.toISOString(), - per_page: 100, - page - }); - - if (commits.length === 0) { - hasMore = false; - } else { - allCommits.push(...commits); - page++; - if (commits.length < 100 || page > 20) { - hasMore = false; - } - } - } catch (error) { - hasMore = false; - } - } - - // Check if user has contributed to this repository - const hasContributedToThis = allCommits.some(commit => - commit.author?.login?.toLowerCase() === githubUsername.toLowerCase() || - commit.committer?.login?.toLowerCase() === githubUsername.toLowerCase() - ); + // Use server-side author filter — no need to paginate through all commits + const { data: commits } = await octokit.repos.listCommits({ + owner, + repo: repoName, + author: githubUsername, + since: sixMonthsAgo.toISOString(), + per_page: 1 + }); - if (hasContributedToThis) { + if (commits.length > 0) { return { hasContributed: true, contributedRepo: repo }; }