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

@birkheadc/github-repo-parser

v2.0.0

Published

Parses a specified user's public repositories for a specific file structure and uses that data to create an array of objects. Essentially, this facilitates the creation of a more advanced, API-legible README that can be stored directly in a project's repo

Downloads

7

Readme

Birkheadc's Github Repo Parser

Searches all of a user's public repositories for a specific folder, then parses those folders in order to collect meta-data about those repositories. Essentially facilitating the creation of advanced, API-legible READMEs.

How to Install

npm install @birkheadc/github-repo-parser

How to Use

import { GithubRepoParser } from '@birkheadc/github-repo-parser';

const parser = new GithubRepoParser({
  username: //your-github-username

  root?: //defaults to 'repo-parser-target', the name of the folder you will create in your repository to hold the data you want to store

  apiToken?: //optional, requests will use a token if provided, which will substantially increase Github API's rate limit
});

const data: GithubRepoParserResult[] | undefined = await parser.getAllData([ 'fileType1', 'fileType2' ]);
// array of fileTypes is optional

if (data !== undefined) {
  data.forEach(result => {
    // do what you want with your data!
    // if fileTypes were passed, result.files[fileType] will contain an array of strings, which are links to the file on github
  })
}

Setting Up the Repository

In order for the package to find and parse your repository, you must do two things:

  • First, you must include a keyword in your repository's README. This keyword defaults to repo-parser-target, but can be changed to whatever you like by passing a different value to the root? option of the constructor's config. Try to use something unique, or the parser might flag repositories you didn't mean it to.
  • Second, you must create folder with the name equal to this keyword. In this folder, create data.json, and fill it with the json object you want this repository to return. Also, if you want to host static files, create files, and in files, create any number of folders for each file type, like images or audio.

The end result is that GithubRepoParser.getAllData([ 'images', 'audio' ]) will return an array of GithubRepoParserResults.

Each result will contain result.json, which will be the contents of data.json; and result.files.images and result.files.audio, each of which will be an array of strings linking back to the static files in the files/images and files/audio folders.

Repo-Parser

This repository is parse-able by... this package! The contents of the repo-parser-target directory are meant to be consumed by an API using this very package.