wrap-git is a powerful Node.js package that provides an easy way to interact with the GitHub API. It wraps various endpoints and operations, enabling developers to access and summarize GitHub data with minimal effort. This package simplifies data retrieval and analysis from GitHub, making it an excellent choice for integrating GitHub functionalities into your applications.
- Fetch user profiles and organization data.
- Summarize commits, issues, repositories, pull requests, and languages used.
- Retrieve recent activities and statistics for a user.
- Modularized functions for easy integration into your project.
Install the package using npm:
npm install wrap-git
The package provides two main ways to use it: Wrapper Object and Direct Method Import.
The gitWrapped
function initializes the wrapper object with user profile data and provides access to various summarization methods. This approach is ideal if you need a centralized object to work with multiple GitHub functionalities.
const { gitWrapped } = require('wrap-git');
const gitToken = '******* YOUR PERSONAL ACCESS TOKEN ********';
const userInfo = async () => {
const wrapper = await gitWrapped('sgc93', gitToken);
if (wrapper.success) {
const profile = wrapper.profile;
console.log(profile);
const { commitSummerizer } = wrapper.methods;
const response = await commitSummerizer(profile.username, gitToken, profile.created_at);
if (response.success) {
console.log(response.data.totalCommits);
console.log(response.data.commitsPerYear);
} else {
console.log(response.error);
}
} else {
console.log(wrapper.error);
}
};
userInfo();
You can also directly import and use specific methods from the package. This approach is best if you only need certain functionalities without initializing the entire wrapper object.
const { getUserProfile, commitSummerizer, repoSummerizer } = require('wrap-git');
const gitToken = '******* YOUR PERSONAL ACCESS TOKEN ********';
const run = async () => {
const profile = await getUserProfile('sgc93', gitToken);
if (profile.success) {
console.log(profile.data);
const commits = await commitSummerizer(profile.data.username, gitToken, profile.data.created_at);
console.log(commits.data);
const repos = await repoSummerizer(profile.data.username, gitToken);
console.log(repos.data);
} else {
console.log(profile.error);
}
};
run();
Summarizes commit data for a user.
- Purpose: Provides an overview of a user’s commit activity, useful for analytics and reporting.
- Parameters:
username
: GitHub username.token
: Personal access token.created_at
: User account creation date.
- Returns: Total commits and commits per year (from the user's start till now).
Fetches the GitHub user profile.
- Purpose: Retrieve detailed user information for display or further analysis.
- Parameters:
username
: GitHub username.token
: Personal access token.
- Returns: User profile data including name, bio, repositories, gists, etc.
Summarizes issues created by the user.
- Purpose: Analyze issue contributions for project management or statistics.
- Parameters:
username
: GitHub username.token
: Personal access token.
- Returns: Total number of issues and other details.
Fetches the organizations the user belongs to.
- Purpose: Identify collaborations and memberships for organizational insights.
- Parameters:
username
: GitHub username.token
: Personal access token.
- Returns: Total number of organizations.
Retrieves recent activities of the user.
- Purpose: Track user activities such as commits, pull requests, and issue updates.
- Parameters:
username
: GitHub username.token
: Personal access token.
- Returns: List of recent activities (top 10).
Summarizes pull request data for the user.
- Purpose: Gain insights into pull request contributions and activity.
- Parameters:
username
: GitHub username.token
: Personal access token.
- Returns: Total pull requests.
Summarizes languages used across all repositories.
- Purpose: Determine language preferences and usage statistics.
- Parameters:
repos
: List of repositories.token
: Personal access token.
- Returns: Language usage stats: top language, language coverage, language per repo, LOC, etc.
Summarizes repository data for the user.
- Purpose: Analyze repository contributions and trends.
- Parameters:
repos
: User repositories.token
: Personal access token.
- Returns: Total repositories, popular repositories, and detailed stats.
Fetches all repositories of the user.
- Purpose: List all repositories for further processing or display.
- Parameters:
username
: GitHub username.token
: Personal access token.
- Returns: List of all repositories sorted by number of stars.
wrap-git
is designed to be seamlessly integrated into applications requiring GitHub data, such as:
- Personal Portfolios: Create visually appealing representations of GitHub activity.
- Dashboards: Build analytics dashboards showcasing user activities, language usage, and repository stats.
- Developer Tools: Enhance developer tools with GitHub insights like commit trends and pull request summaries.
- Project Management Apps: Monitor issues, pull requests, and repository contributions.
With its modularized functions and wrapper object, wrap-git
is flexible enough to fit various use cases and project architectures.
This package is inspired by git-wrapped.com and aims to bring similar capabilities to developers for programmatic GitHub API interaction.
We welcome contributions! Feel free to submit issues or create pull requests.
- Fork the repository.
- Create a new branch.
- Make your changes.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.