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

evergreen-org-crawler

v0.2.3

Published

[![Main](https://github.com/ahm-monash/crawler/actions/workflows/main.yml/badge.svg)](https://github.com/ahm-monash/crawler/actions/workflows/main.yml)

Downloads

10

Readme

Organisation Crawler

Main

This library tracks how outdated your GitHub organisation dependencies are.

The organisation Crawler uses the GitHub GraphQL API to extract all of a GitHub organisation's repositories and their internal and external dependencies. The current version of dependencies of the crawled repositories are found using DependencyGraphManifest GraphQL object. The latest versions of the dependencies are requested from npm/rubygem/pypi API, it uses client-side rate limiter when querying these APIs.

These information are aggregated and returned as a json object which has a schema, this object can then be used to present the data.

Package Managers support

  • JavaScript
  • Python
  • Ruby

Output schema

RepoMap: Map<ID, Object> = {
    ID: {
        name: ID= "NAME",
        version: SemVer = VERSION,
        link: string = "LINK",
        internal: bool = IS_INTERNAL,
        archived: bool = IS_ARCHIVED,
        lastUpdated: string = DATE
        languageVersion?: string = "LANGUAGE_VERSION",
		oldName?: string = "OLD_NAME"
    },
    ...
}
DependencyList: Object[] = [
    {
        dep: ID = ID,
        dependencies: [int, SemVer] = [
            [ID, VERSION],
            ...
        ]
    },
    ...
]

Example usage

The only function that is needed to generate the json data is getJsonStructure:


import { getJsonStructure } from "evergreen-org-crawler"

// function getJsonStructure(accessToken: string, targetOrganisation: string, config: Configuration, { toUse, crawlStart, useCachedData }?: {
//     toUse?: string[];
//     crawlStart?: string | null;
//     useCachedData?: boolean;
// }): Promise<string>;

let res: any = getJsonStructure(
    accessToken,
		target_organisation,
    config, {
      toUse: ["NPM"],
      useCachedData: false
	  })

console.log(res)

If GitHub webhooks is enabled for the target organisation, these two functions are available:

import { handleGitHubWebhookPushEvents, handleGitHubWebhookRepositoryEvents } from "evergreen-org-crawler/build/webhooks/github";

// handleGitHubWebhookPushEvents(accessToken: string, targetOrganisation: string, payload: any, useCachedData?: boolean): Promise<void>;
// handleGitHubWebhookRepositoryEvents(accessToken: string, targetOrganisation: string, payload: any, useCachedData?: boolean): Promise<void>;

await handleGitHubWebhookRepositoryEvents(
  accessToken,
  target_organisation,
  {},
  false
);

When called these functions update the cache internally.

Setup Instructions

Before you commit, please configure pre-commit with:

pre-commit install

Now, every time you commit, it will run hooks to fix various styling and linting problem.

Running pre-commit hooks manually

pre-commit run --all-files

Skipping pre-commit hooks

Please avoid doing this at all cost.

git commit -n -m "Your commit message"

The -n allows you to skip git hooks.

ENV

.env file

GH_TOKEN= GitHub token that has full repo scope
targetOrganisation= The target GitHub organisation to track

The token is needed to query GitHub API and access private repositories

Configuration

Optional config.json file

{
	npmURL: optional, the URL to a specific npm host
	pipURL: optional, the URL to a specific pip host
	rubygemsURL: optional, the URL to a specific RubyGems host
}

Running

Clone the repository with:

git clone https://github.com/ahm-monash/crawler

In the root directory for the project, run the following to install the necessary dependencies:

npm install

Setup a .env file with the environment variables populated, the run the crawler with.

npm start

This will generate cachedData.json file which has a schema.

Execute jest test faster

Run a single file only npm run test <PATHTOFILE>

Use the flag --onlyFailures to only run failed tests in the previous execution npm run test --onlyFailures

Future work

  • [ ] Dedicated GraphQL files fro GraphQL query schemas
  • [ ] Improve retry mechanism for asynchronous requests, such that there is more variance in the retry mechanism when multiple requests fail at the same time.

Limitations

  • Each manifest file doesn't contain more that 250 dependencies
  • The dashboard depends on Dependency Graph manifest, which has some limitations, for example it cannot detect dependencies which:
    • Javascript:
      • use "foo": "github:user/repo
      • use "foo": "user/repo"
      • use "foo": "fileSystemPath"
    • Python
      • use foo fileSystemPath
  • There is a limit on the number of manifest files that can be fetched (link is dead)
  • Other dependency graph limits
  • repository_import events do not trigger update cache https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_import

Contributing

Contributions are most welcome!

Before opening a PR:

  • Make sure that there isn't an active PR already open which makes the same changes
  • Make sure to check if there are issues related to your PR
  • Make sure that your branch name follows {name}/{description}