ecodoc

1.3.0 • Public • Published

ecodoc

Manage docs across multiple packages

Ecodoc maps an array of GitHub repository names to their info, contributors, latest version, and readme.

Install

npm install --save ecodoc

Usage

Note: In order for this to work, you need to set GH_TOKEN environment variable, or pass in opts.token. Otherwise, GitHub rate limits to 60 requests per hour. This tool makes at least 1 request per repository to check if info is updated. It makes 4 more requests for the info, contributors, tags, and README.

If you are lazy, you can just put GH_TOKEN=... in front of a command that runs ecodoc:

GH_TOKEN=... npm run build

ecodoc(opts)

Create an ecodoc mapping function (called docs) with some options

  • cache (String): Path to where to store leveldb cache. Required
  • token (String): GitHub API Token. Defaults to GH_TOKEN env var. Required
  • cacheMap (Function): Map each project right before you cache it.
  • map (Function): Map all project info before you receive it.
var docs = ecodoc({
  cache: __dirname + '/cache',
  token: ..., // GH token, or just use `GH_TOKEN`
})

docs(projects, done)

Map project names to their info, latest version, contributors, and readme. They come from either requests or leveldb cache.

You can provide projects as an array of GitHub repos, as an object in groups of arrays.

docs([
  'audiojs/audio',
  'audiojs/audio-buffer'
], function (err, projects) {
  console.log(projects)
  // [ { repo: 'audiojs/audio', latest_version: 'v1.2.0' ... }
  //   { repo: 'audiojs/audio-buffer', latest_version: 'v1.0.0' ... } ]
})

Or in groups:

docs({
  core: [
    'audiojs/audio',
    'audiojs/audio-buffer'
  ],
  utility: [
    'audiojs/is-audio-buffer'
  ]
}, function (err, projects) {
  console.log(projects)
  // [ { name: 'audio', group: 'core', ... },
  //   { name: 'audio-buffer', group: 'core' },
  //   { name: 'is-audio-buffer', group: 'utility' } ]
})

project

This object contains:

{
  name: 'audio',            // project name
  repo: 'audiojs/audio',    // project repo
  desc: '...',              // project description
  group: 'core',            // project group (or falsy)
  latest_version: 'v1.2.0', // latest git tag version
  latest_ref: ...,          // latest git ref
  readme: ...,              // README contents base64 encoded
  contributors: [
    {
      username: 'dfcreative',                    // contributor username
      profile: 'https://github.com/dfcreative',  // contributor profile
      avatar: ...,                               // contributor avatar
      id: 300067,                                // contributor id
      contributions: 4                           // contributions
    }
    // ...
  ]
}

License

MIT © Jamen Marz


version travis downloads/month downloads license support me follow

Package Sidebar

Install

npm i ecodoc

Weekly Downloads

0

Version

1.3.0

License

MIT

Last publish

Collaborators

  • jamen