material-motion / tools

The Material Motion team's tools
Other
7 stars 5 forks source link

Generate badges/shields table automatically #173

Closed pingpongboss closed 7 years ago

pingpongboss commented 7 years ago

Create a tool to generate the contents of https://material-motion.github.io/material-motion/ automatically.

This tool should also generate a text version of the table for weekly updates.

jverkoey commented 7 years ago

To get all repos:

curl -i https://api.github.com/orgs/material-motion/repos | grep full_name | cut -d: -f2
jverkoey commented 7 years ago
# Generate a markdown table with images
mdm shields table

# Generate a markdown table with text (must hit .json shields.io api)
mdm shields table astext
appsforartists commented 7 years ago

it is my duty as the resident web guy to post the js equivalent:

fetch(
  'https://api.github.com/orgs/material-motion/repos'
).then(
  response => response.json()
).then(
  repos => repos.map(
    repo => repo.full_name
  )
).then(
  fullNames => {
    // do something with fullNames here
    console.log(fullNames);
  }
)
pingpongboss commented 7 years ago

We're like a little sitcom. We've each got our own roles.

appsforartists commented 7 years ago

Battery's dying, but here's a sketch:

fetch(
  'https://api.github.com/orgs/material-motion/repos?per_page=100'
).then(
  response => response.json()
).then(
  repos => repos.map(
    repo => (
      {
        orgAndRepoSlug: repo.full_name,
        docsURL: repo.homepage,
      }
    ) 
  )
).then(
  repoMetadata => (
    {
      android: repoMetadata.filter(
        ({ orgAndRepoSlug }) => orgAndRepoSlug.endsWith('android')
      ),
      js: repoMetadata.filter(
        ({ orgAndRepoSlug }) => orgAndRepoSlug.endsWith('js')
      ),
      apple: repoMetadata.filter(
        ({ orgAndRepoSlug }) => orgAndRepoSlug.endsWith('swift') || orgAndRepoSlug.endsWith('objc')
      ),
    }
  )
).then(
  ({ android, js, apple }) => (
    {
      android: android.map(
        ({ orgAndRepoSlug, docsURL }) => [
          `[${ orgAndRepoSlug }](https://github.com/${ orgAndRepoSlug }/)`,
          `[![Build Status](https://travis-ci.org/${ orgAndRepoSlug }.svg?branch=develop)](https://travis-ci.org/${ orgAndRepoSlug }/)`,
          `[![codecov](https://codecov.io/gh/${ orgAndRepoSlug }/branch/develop/graph/badge.svg)](https://codecov.io/gh/${ orgAndRepoSlug }/)`,
          `[![Release](https://img.shields.io/github/release/${ orgAndRepoSlug }.svg)](https://github.com/${ orgAndRepoSlug }/releases/latest/)`,
          `[![Docs](https://img.shields.io/badge/jitpack-docs-green.svg)](${ docsURL })`,
          `[![Open issues](https://img.shields.io/github/issues/${ orgAndRepoSlug }.svg)](https://github.com/${ orgAndRepoSlug }/issues/)`,
        ]
      ),
      js: js.map(
        ({ orgAndRepoSlug, docsURL }) => {
          const packageName = orgAndRepoSlug.split('/').pop().replace('-js', '');

          return [
            `[${ orgAndRepoSlug }](https://github.com/${ orgAndRepoSlug })`,
            `[![Build Status](https://travis-ci.org/${ orgAndRepoSlug }.svg?branch=develop)](https://travis-ci.org/${ orgAndRepoSlug }/)`,
            `[![codecov](https://codecov.io/gh/${ orgAndRepoSlug }/branch/develop/graph/badge.svg)](https://codecov.io/gh/${ orgAndRepoSlug }/)`,
            `[![Release](https://img.shields.io/npm/v/${ packageName }.svg)](https://www.npmjs.com/package/${ packageName }/)`,
            `[![Open issues](https://img.shields.io/github/issues/${ orgAndRepoSlug }.svg)](https://github.com/${ orgAndRepoSlug }/issues/)`,
          ]
        }
      ),
      apple: apple.map(
        ({ orgAndRepoSlug, docsURL }) => {
          const packageName = docsURL
            ? (/http:\/\/cocoadocs.org\/docsets\/(\w+)/.exec(docsURL) || []).pop()
            : console.warn(`${ orgAndRepoSlug } doesn't have homepage set correctly!`) || '';

          return [
            `[${ orgAndRepoSlug }](https://github.com/${ orgAndRepoSlug })`,
            `[![Build Status](https://travis-ci.org/${ orgAndRepoSlug }.svg?branch=develop)](https://travis-ci.org/${ orgAndRepoSlug }/)`,
            `[![codecov](https://codecov.io/gh/${ orgAndRepoSlug }/branch/develop/graph/badge.svg)](https://codecov.io/gh/${ orgAndRepoSlug }/)`,
            `[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/${ packageName }.svg)](https://cocoapods.org/pods/${ packageName }/)`,
            `[![Platform](https://img.shields.io/cocoapods/p/${ packageName }.svg)](http://cocoadocs.org/docsets/${ packageName })`,
            `[![Docs](https://img.shields.io/cocoapods/metrics/doc-percent/${ packageName }.svg)](${ docsURL })`,
            `[![Open issues](https://img.shields.io/github/issues/${ orgAndRepoSlug }.svg)](https://github.com/${ orgAndRepoSlug }/issues/)`,
          ]
        }
      ),
    }
  )
).then(
  ({ apple, android, js }) => `
## Apple platform support
| Library | Build status | Coverage | Version | Platforms | Docs | Issues | 
|---------|:------------:|:--------:|:-------:|:---------:|:----:|:------:|
${ apple.map(repo => `| ${ repo.join(' | ') } |`).join('\n') }

## Android platform support

| Library | Build status | Coverage | Version | Docs | Issues |
|---------|:------------:|:--------:|:-------:|:----:|:------:|
${ android.map(repo => `| ${ repo.join(' | ') } |`).join('\n') }

## Web platform support

| Library | Build status | Coverage | Version | Issues |
|---------|:------------:|:--------:|:-------:|:------:|
${ js.map(repo => `| ${ repo.join(' | ') } |`).join('\n') }
`
).then(console.log)
appsforartists commented 7 years ago

Apple platform support

Library Build status Coverage Version Platforms Docs Issues
material-motion/experiments-swift Build Status codecov CocoaPods Compatible Platform [Docs]() Open issues
material-motion/material-motion-experiments-objc Build Status codecov CocoaPods Compatible Platform [Docs]() Open issues
material-motion/runtime-objc Build Status codecov CocoaPods Compatible Platform Docs Open issues
material-motion/transitions-objc Build Status codecov CocoaPods Compatible Platform Docs Open issues
material-motion/conventions-objc Build Status codecov CocoaPods Compatible Platform [Docs]() Open issues
material-motion/coreanimation-swift Build Status codecov CocoaPods Compatible Platform Docs Open issues
material-motion/direct-manipulation-swift Build Status codecov CocoaPods Compatible Platform Docs Open issues
material-motion/pop-swift Build Status codecov CocoaPods Compatible Platform Docs Open issues
material-motion/catalog-swift Build Status codecov CocoaPods Compatible Platform [Docs]() Open issues
material-motion/coreanimation-transitions-swift Build Status codecov CocoaPods Compatible Platform Docs Open issues
material-motion/pop-transitions-swift Build Status codecov CocoaPods Compatible Platform Docs Open issues
material-motion/indefinite-observable-swift Build Status codecov CocoaPods Compatible Platform Docs Open issues

Android platform support

Library Build status Coverage Version Docs Issues
material-motion/experiments-android Build Status codecov Release [Docs]() Open issues
material-motion/conventions-android Build Status codecov Release Docs Open issues
material-motion/expression-android Build Status codecov Release Docs Open issues
material-motion/family-tween-android Build Status codecov Release [Docs]() Open issues
material-motion/runtime-android Build Status codecov Release Docs Open issues
material-motion/transitions-android Build Status codecov Release [Docs]() Open issues
material-motion/family-rebound-android Build Status codecov Release [Docs]() Open issues
material-motion/family-direct-manipulation-android Build Status codecov Release [Docs]() Open issues
material-motion/gestures-android Build Status codecov Release [Docs]() Open issues
material-motion/catalog-android Build Status codecov Release [Docs]() Open issues

Web platform support

Library Build status Coverage Version Issues
material-motion/material-motion-js Build Status codecov Release Open issues
material-motion/streams-experiment-js Build Status codecov Release Open issues
material-motion/indefinite-observable-js Build Status codecov Release Open issues
appsforartists commented 7 years ago

Hmm... I don't see indefinite-observable in either chart

jverkoey commented 7 years ago
appsforartists commented 7 years ago

I tested the regex on a real URL and forgot to replace with docsURL. fixed that bit

appsforartists commented 7 years ago

For JS: https://api.github.com/repos/material-motion/material-motion-js/contents/packages?ref=stable

appsforartists commented 7 years ago

TODO: move checkboxes to issues