Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove octokit dependency #681

Merged
merged 8 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
branches: [main, master]
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test:
timeout-minutes: 60
Expand Down
158 changes: 0 additions & 158 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@ai-sdk/azure": "^1.0.7",
"@googlemaps/react-wrapper": "^1.1.35",
"@googlemaps/typescript-guards": "^2.0.1",
"@octokit/rest": "^21.0.2",
"@playwright/test": "^1.49.0",
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
26 changes: 26 additions & 0 deletions src/data/projects/vscode-extension-pack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"index": 7,
"name": "VS Code Extension Pack",
"headline": "Curated VS Code Extensions for Veterans Learning JavaScript",
"long_description": [
"The Vets Who Code Extension Pack is a thoughtfully curated collection of Visual Studio Code extensions tailored to enhance the learning experience of veterans embarking on their JavaScript development journey. Recognizing the challenges that new developers face in setting up an efficient development environment, this extension pack simplifies the process by providing essential tools in a single, easy-to-install package.",
"Key features of the extension pack include:",
"- **Comprehensive Toolset**: Integrates a selection of extensions that cover code linting, debugging, version control, and more, ensuring that learners have access to the tools necessary for effective development.",
"- **Streamlined Setup**: Eliminates the need for learners to search for and install individual extensions, reducing setup time and allowing them to focus on coding.",
"- **Enhanced Learning Experience**: By providing a standardized set of tools, the extension pack fosters a consistent learning environment, enabling veterans to concentrate on mastering JavaScript without the distraction of configuring their development setup."
],
"technologies": [
"Visual Studio Code",
"JavaScript",
"ESLint",
"Live Server",
"GitHub Copilot"
],
"owner": "Vets-Who-Code",
"repo": "vetswhocode-extension-pack",
"live_url": "https://marketplace.visualstudio.com/items?itemName=VetsWhoCode.vetswhocode-extension-pack",
"thumbnail": {
"src": "https://res.cloudinary.com/vetswhocode/image/upload/f_auto,q_auto/v1736209366/projects/vscode-exension-pack_sops0a.png",
"alt": "Vets Who Code Extension Pack Thumbnail"
}
}
24 changes: 24 additions & 0 deletions src/data/projects/vscode-theme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"index": 8,
"name": "Hashflag VS Code Theme",
"headline": "Military-Inspired VS Code Color Theme by Vets Who Code",
"long_description": [
"The Vets Who Code VS Code Theme, known as 'HashFlag,' is a color theme for Visual Studio Code inspired by military valor and spirit. Developed by Vets Who Code, a non-profit organization dedicated to helping veterans transition into technology careers, this theme offers a patriotic coding experience.",
"Key features of the theme include:",
"- **Patriotic Palette**: A color scheme featuring navy blues, army greens, and bold accents of red and gold, capturing the essence of military service and the American flag.",
"- **Optimized for Readability**: Contrasts designed to reduce eye strain, making it suitable for long coding sessions.",
"- **Universal Appeal**: Enhances workflow across various development activities, including debugging and coding."
],
"technologies": [
"Visual Studio Code",
"JSON",
"Color Theme Development"
],
"owner": "Vets-Who-Code",
"repo": "vetswhocode-vs-code-theme",
"live_url": "https://marketplace.visualstudio.com/items?itemName=OfficialVetsWhoCode.HashFlag",
"thumbnail": {
"src": "https://res.cloudinary.com/vetswhocode/image/upload/f_auto,q_auto/v1736209857/projects/vscode-theme_pkurqi.png",
"alt": "Vets Who Code VS Code Theme Thumbnail"
}
}
26 changes: 26 additions & 0 deletions src/data/projects/vwc-github-page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"index": 9,
"name": "Engineering SOPs and Field Manual",
"headline": "Supplementary Guide for Vets Who Code Engineering Practices",
"long_description": [
"The Vets Who Code Engineering SOPs and Field Manual serves as a technical and operational guide for the Vets Who Code community. Hosted on GitHub Pages, this platform consolidates best practices, coding standards, and project workflows tailored to support veterans transitioning into software development.",
"Key features of the manual include:",
"- **Standard Operating Procedures (SOPs)**: Documents standardized workflows, coding practices, and tools to ensure consistency across projects.",
"- **Field Manual for Developers**: Provides practical advice, troubleshooting tips, and technical guidelines to navigate common challenges in software development.",
"- **Community Focused Content**: Encourages contributions and feedback from the Vets Who Code community, creating a living document that evolves with the organization's needs."
],
"technologies": [
"HTML",
"CSS",
"JavaScript",
"Jekyll",
"GitHub Pages"
],
"owner": "Vets-Who-Code",
"repo": "vets-who-code.github.io",
"live_url": "https://vets-who-code.github.io/",
"thumbnail": {
"src": "https://res.cloudinary.com/vetswhocode/image/upload/f_auto,q_auto/bo_1px_solid_black/v1736209366/projects/Vets_Who_Code_github_page_nrp3bu.png",
"alt": "Vets Who Code Engineering SOPs and Field Manual Thumbnail"
}
}
79 changes: 48 additions & 31 deletions src/lib/github.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Octokit } from "@octokit/rest";
import { VWCContributor, GithubRepo, GithubContributor } from "@utils/types";
import { VWCContributor, GithubRepo, GithubContributor, GithubUser } from "@utils/types";
import axios from "axios";

const token = process.env.GITHUB_ACCESS_TOKEN || "";
const octokit = new Octokit({ auth: token });
const token = process.env.GITHUB_TOKEN || "";
const git_api = axios.create({
baseURL: "https://api.github.com",
headers: {
Authorization: `Bearer ${token}`,
},
});

export const getProjectContributors = async (
owner: string,
Expand All @@ -12,48 +17,60 @@ export const getProjectContributors = async (
const topContributors = await getGithubRepoContributors(owner, repo, top);
const projectContributors = Promise.all(
topContributors.map(async (contributor) => {
const user = await octokit.rest.users.getByUsername({
username: contributor.login,
});
if (user.data.name) {
const response = await git_api.get(`/users/${contributor.login}`);
if (response.status == 200) {
const user = response.data as GithubUser;
return {
...contributor,
...user.data,
name: user.data.name!,
...user,
};
} else {
if ("error" in response) {
throw new Error(
`Error fetching user data for ${contributor.login}\nStatus code: ${response.status}\nError: ${response.error}`
);
}
throw new Error(
`Error fetching user data for ${contributor.login}\nStatus code: ${response.status}`
);
}
return;
})
);
return (await projectContributors).filter((contributor) => contributor !== undefined);
return await projectContributors;
};

export const getGithubRepo = async (owner: string, repo: string): Promise<GithubRepo> => {
const response = await octokit.rest.repos.get({
owner: owner,
repo: repo,
});
return response.data;
const response = await git_api.get(`/repos/${owner}/${repo}`);
if (response.status == 200) {
return response.data as GithubRepo;
} else {
if ("error" in response) {
throw new Error(
`Error fetching repo data for ${owner}/${repo}\nStatus code: ${response.status}\nError: ${response.error}`
);
}
throw new Error(
`Error fetching repo data for ${owner}/${repo}\nStatus code: ${response.status}`
);
}
};

export const getGithubRepoContributors = async (
owner: string,
repo: string,
top: number = 4
): Promise<GithubContributor[]> => {
const response = await octokit.rest.repos.listContributors({
owner: owner,
repo: repo,
per_page: top,
});
const contributors = response.data.map((contributor) => {
if (contributor.login) {
return {
...contributor,
login: contributor.login!,
};
const response = await git_api.get(`/repos/${owner}/${repo}/contributors`);
if (response.status == 200) {
return (response.data as GithubContributor[]).slice(0, top);
} else {
if ("error" in response) {
throw new Error(
`Error fetching contributor data for ${owner}/${repo}\nStatus code: ${response.status}\nError: ${response.error}`
);
}
return;
});
return contributors.filter((contributor) => contributor !== undefined);
throw new Error(
`Error fetching contributor data for ${owner}/${repo}\nStatus code: ${response.status}`
);
}
};
Loading
Loading