0.0.2 • Published 3 years ago

list_org_published_modules v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

This tool take as input a GitHub organization or GitHub user name and list the modules it publishes on the major package manager repository: npm, maven, ect.

Note that it isn't a simple database query or API request, thus it is meant to be run periodically or triggered by webhooks.

As of now this module ony works with NPM

Run as a CLI tool

Example with Etalab

$ npx list_org_published_modules etalab --verbose

output (after ~4minutes):

[
    {
        "repoName": "codes-postaux",
        "modules": [
            {
                "type": "npm",
                "moduleName": "codes-postaux",
                "packageJsonDirPath": "/"
            }
        ]
    },
    {
        "repoName": "monuments-historiques",
        "modules": [
            {
                "type": "npm",
                "moduleName": "@sgmap/monuments-historiques",
                "packageJsonDirPath": "/"
            }
        ]
    },
    {
        "repoName": "api-geo",
        "modules": [
            {
                "type": "npm",
                "moduleName": "@etalab/api-geo",
                "packageJsonDirPath": "/"
            }
        ]
    }
    //...Many more entries
]

If you run the tools multiple times you will soon reach the GitHub API rate limit. To fix it, create a GitHub Personal Access Token and provide it as the environnement variable GITHUB_TOKEN when you run the build tool.

Use it in a Node or a Web project.

npm install list_org_published_modules
import {
    createOctokit,
    listGitHubOrganizationPublishedModulesFactory,
} from "list_org_published_modules";
//On the browser fetch is defined on window.fetch you don't need to import it.
import fetch from "node-fetch";

const githubOrganizationName = process.argv[2];

const { listGitHubOrganizationPublishedModules } = listGitHubOrganizationPublishedModulesFactory({
    ...createOctokit({ "github_token": undefined }),
    fetch,
});

const { evtRepoModules } = listGitHubOrganizationPublishedModules({ githubOrganizationName });

evtRepoModules.attach(console.log);

NOTE: The result are dispatched via an Evt

Development

The test app source code is located on the test-app branch and deployed via this workflow