npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

github-deployed-repos

v1.0.1

Published

An npm package to display deployed URLs of public GitHub repositories

Downloads

133

Readme

GitHub Deployed Repos

GitHub Deployed Repos is an npm package that retrieves all public repositories for a specified GitHub username and lists the URLs for the ones that are deployed (via GitHub Pages, or if the homepage URL is set in the repository).

Features

  • 📝 Fetches public repositories for any GitHub user.
  • 🚀 Lists deployed URLs for repositories with a homepage set in their package.json.
  • 🌐 Supports GitHub Pages URLs for repositories that are deployed via GitHub Pages.

Installation

You can install this package using npm:

npm install github-deployed-repos

Usage

To use this package, you simply need to require it and pass the GitHub username to fetch the deployed repositories.

Example:

// Import the getDeployedRepos function from the package
const { getDeployedRepos } = require('github-deployed-repos');

// Define the GitHub username
const username = 'your-github-username'; // Replace with the GitHub username you want to query

// Fetch and display deployed repositories
getDeployedRepos(username).then((deployedRepos) => {
    console.log('Deployed Repositories:');
    deployedRepos.forEach((repo) => {
        console.log(`- ${repo.name}: ${repo.url}`);
    });
}).catch((error) => {
    console.error('Error fetching deployed repositories:', error);
});

Output Example:

Deployed Repositories:
- my-repo-1: https://my-repo-1.github.io
- my-repo-2: https://my-custom-domain.com

How It Works

  • The function getDeployedRepos(username) makes a request to GitHub's API to fetch all public repositories of the user.
  • It checks if the homepage field in the package.json is set (this usually represents the deployment URL of the repository).
  • If no homepage is found, it attempts to construct the GitHub Pages URL (https://<username>.github.io/<repo-name>).

API

getDeployedRepos(username)

Fetches deployed repositories for the given GitHub username.

  • Parameters:

    • username: The GitHub username (string) for which you want to fetch public repositories.
  • Returns: A Promise that resolves to an array of objects, each representing a deployed repository:

    [
      {
        "name": "repo-name",
        "url": "https://deployed-url.com"
      }
    ]

Example:

getDeployedRepos('MrSanjayRaj').then((repos) => console.log(repos));

Error Handling

If an error occurs (e.g., invalid username, GitHub API issues), the Promise will be rejected. You can handle it using .catch():

getDeployedRepos('invalid-username')
  .then((repos) => console.log(repos))
  .catch((error) => console.error('Error fetching deployed repositories:', error));

Requirements

  • Node.js version 12 or higher.
  • GitHub account with public repositories.

Contributing

Contributions are welcome! Please open an issue or a pull request if you would like to contribute.

Steps to Contribute:

  1. Fork the repository.
  2. Create a new feature branch (git checkout -b feature/new-feature).
  3. Commit your changes (git commit -am 'Add a new feature').
  4. Push to the branch (git push origin feature/new-feature).
  5. Open a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Example Output

Here is what you can expect when the function is called:

Deployed Repositories:
- Portfolio: https://MrSanjayRaj.github.io/portfolio
- Blog: https://myblog.com