From 366176c6cac03798c2bb7496f5a2d7d84d430413 Mon Sep 17 00:00:00 2001 From: David Dias Date: Wed, 22 Aug 2018 11:55:33 +0200 Subject: [PATCH] feat: use package-table vs custom script --- README.md | 10 +-- package-list.json | 31 +++++++ scripts/generate-package-table-for-readme.js | 88 -------------------- 3 files changed, 34 insertions(+), 95 deletions(-) create mode 100644 package-list.json delete mode 100755 scripts/generate-package-table-for-readme.js diff --git a/README.md b/README.md index 503c342..bee14fd 100644 --- a/README.md +++ b/README.md @@ -139,12 +139,8 @@ initIpld('/tmp/ifpsrepo', (err, ipld) => { ## Packages -Listing of dependencies from the IPFS ecosystem. +Listing of dependencies from the IPLD ecosystem. - | Package | Version | Deps | CI | Coverage | | ---------|---------|---------|---------|--------- | | **IPLD Formats** | @@ -155,12 +151,12 @@ Please use the same script if you need to update this table. | [`ipld-git`](//github.com/ipld/js-ipld-git) | [![npm](https://img.shields.io/npm/v/ipld-git.svg?maxAge=86400&style=flat-square)](//github.com/ipld/js-ipld-git/releases) | [![Deps](https://david-dm.org/ipld/js-ipld-git.svg?style=flat-square)](https://david-dm.org/ipld/js-ipld-git) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipld/js-ipld-git/master)](https://ci.ipfs.team/job/ipld/job/js-ipld-git/job/master/) | [![codecov](https://codecov.io/gh/ipld/js-ipld-git/branch/master/graph/badge.svg)](https://codecov.io/gh/ipld/js-ipld-git) | | [`ipld-raw`](//github.com/ipld/js-ipld-raw) | [![npm](https://img.shields.io/npm/v/ipld-raw.svg?maxAge=86400&style=flat-square)](//github.com/ipld/js-ipld-raw/releases) | [![Deps](https://david-dm.org/ipld/js-ipld-raw.svg?style=flat-square)](https://david-dm.org/ipld/js-ipld-raw) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipld/js-ipld-raw/master)](https://ci.ipfs.team/job/ipld/job/js-ipld-raw/job/master/) | [![codecov](https://codecov.io/gh/ipld/js-ipld-raw/branch/master/graph/badge.svg)](https://codecov.io/gh/ipld/js-ipld-raw) | | [`ipld-zcash`](//github.com/ipld/js-ipld-zcash) | [![npm](https://img.shields.io/npm/v/ipld-zcash.svg?maxAge=86400&style=flat-square)](//github.com/ipld/js-ipld-zcash/releases) | [![Deps](https://david-dm.org/ipld/js-ipld-zcash.svg?style=flat-square)](https://david-dm.org/ipld/js-ipld-zcash) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipld/js-ipld-zcash/master)](https://ci.ipfs.team/job/ipld/job/js-ipld-zcash/job/master/) | [![codecov](https://codecov.io/gh/ipld/js-ipld-zcash/branch/master/graph/badge.svg)](https://codecov.io/gh/ipld/js-ipld-zcash) | -| **Storage** | +| **Data Types (non IPLD specific)** | | [`multihashes`](//github.com/multiformats/js-multihash) | [![npm](https://img.shields.io/npm/v/multihashes.svg?maxAge=86400&style=flat-square)](//github.com/multiformats/js-multihash/releases) | [![Deps](https://david-dm.org/multiformats/js-multihash.svg?style=flat-square)](https://david-dm.org/multiformats/js-multihash) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=multiformats/js-multihash/master)](https://ci.ipfs.team/job/multiformats/job/js-multihash/job/master/) | [![codecov](https://codecov.io/gh/multiformats/js-multihash/branch/master/graph/badge.svg)](https://codecov.io/gh/multiformats/js-multihash) | | [`ipfs-block`](//github.com/ipfs/js-ipfs-block) | [![npm](https://img.shields.io/npm/v/ipfs-block.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-block/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-block.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-block) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipfs/js-ipfs-block/master)](https://ci.ipfs.team/job/ipfs/job/js-ipfs-block/job/master/) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-block/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-ipfs-block) | +| **Storage** | | [`ipfs-repo`](//github.com/ipfs/js-ipfs-repo) | [![npm](https://img.shields.io/npm/v/ipfs-repo.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-repo/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-repo.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-repo) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipfs/js-ipfs-repo/master)](https://ci.ipfs.team/job/ipfs/job/js-ipfs-repo/job/master/) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-repo/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-ipfs-repo) | | [`interface-datastore`](//github.com/ipfs/interface-datastore) | [![npm](https://img.shields.io/npm/v/interface-datastore.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/interface-datastore/releases) | [![Deps](https://david-dm.org/ipfs/interface-datastore.svg?style=flat-square)](https://david-dm.org/ipfs/interface-datastore) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipfs/interface-datastore/master)](https://ci.ipfs.team/job/ipfs/job/interface-datastore/job/master/) | [![codecov](https://codecov.io/gh/ipfs/interface-datastore/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/interface-datastore) | -| **Exchange** | | [`ipfs-block-service`](//github.com/ipfs/js-ipfs-block-service) | [![npm](https://img.shields.io/npm/v/ipfs-block-service.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-block-service/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-block-service.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-block-service) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipfs/js-ipfs-block-service/master)](https://ci.ipfs.team/job/ipfs/job/js-ipfs-block-service/job/master/) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-block-service/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-ipfs-block-service) | | **Generics/Utils** | | [`is-ipfs`](//github.com/ipfs/is-ipfs) | [![npm](https://img.shields.io/npm/v/is-ipfs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/is-ipfs/releases) | [![Deps](https://david-dm.org/ipfs/is-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/is-ipfs) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipfs/is-ipfs/master)](https://ci.ipfs.team/job/ipfs/job/is-ipfs/job/master/) | [![codecov](https://codecov.io/gh/ipfs/is-ipfs/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/is-ipfs) | diff --git a/package-list.json b/package-list.json new file mode 100644 index 0000000..3f1063e --- /dev/null +++ b/package-list.json @@ -0,0 +1,31 @@ +{ + "columns": [ + "Package", + "Version", + "Deps", + "CI", + "Coverage" + ], + "rows": [ + "IPLD Formats", + ["ipld/js-ipld-bitcoin", "ipld-bitcoin"], + ["ipld/js-ipld-dag-cbor", "ipld-dag-cbor"], + ["ipld/js-ipld-dag-pb", "ipld-dag-pb"], + ["ipld/js-ipld-ethereum", "ipld-ethereum"], + ["ipld/js-ipld-git", "ipld-git"], + ["ipld/js-ipld-raw", "ipld-raw"], + ["ipld/js-ipld-zcash", "ipld-zcash"], + + "Data Types (non IPLD specific)", + ["multiformats/js-multihash", "multihashes"], + ["ipfs/js-ipfs-block", "ipfs-block"], + + "Storage", + ["ipfs/js-ipfs-repo", "ipfs-repo"], + ["ipfs/interface-datastore", "interface-datastore"], + ["ipfs/js-ipfs-block-service", "ipfs-block-service"], + + "Generics/Utils", + ["ipfs/is-ipfs", "is-ipfs"] + ] +} diff --git a/scripts/generate-package-table-for-readme.js b/scripts/generate-package-table-for-readme.js deleted file mode 100755 index e3a7757..0000000 --- a/scripts/generate-package-table-for-readme.js +++ /dev/null @@ -1,88 +0,0 @@ -#! /usr/bin/env node - -// This script generates the table of packages you can see in the readme - -// Columns to show at the header of the table -const columns = [ - 'Package', - 'Version', - 'Deps', - 'CI', - 'Coverage' -] - -// Headings are a string -// Arrays are packages. Index 0 is the GitHub repo and index 1 is the npm package -const rows = [ - 'IPLD Formats', - ['ipld/js-ipld-bitcoin', 'ipld-bitcoin'], - ['ipld/js-ipld-dag-cbor', 'ipld-dag-cbor'], - ['ipld/js-ipld-dag-pb', 'ipld-dag-pb'], - ['ipld/js-ipld-ethereum', 'ipld-ethereum'], - ['ipld/js-ipld-git', 'ipld-git'], - ['ipld/js-ipld-raw', 'ipld-raw'], - ['ipld/js-ipld-zcash', 'ipld-zcash'], - - 'Storage', - ['multiformats/js-multihash', 'multihashes'], - ['ipfs/js-ipfs-block', 'ipfs-block'], - ['ipfs/js-ipfs-repo', 'ipfs-repo'], - ['ipfs/interface-datastore', 'interface-datastore'], - - 'Exchange', - ['ipfs/js-ipfs-block-service', 'ipfs-block-service'], - - 'Generics/Utils', - ['ipfs/is-ipfs', 'is-ipfs'], -] - -const isItemPackage = (item) => { - return Array.isArray(item) -} - -const packageBadges = [ - // Package - (gh, npm) => `[\`${npm}\`](//github.com/${gh})`, - // Version - (gh, npm) => `[![npm](https://img.shields.io/npm/v/${npm}.svg?maxAge=86400&style=flat-square)](//github.com/${gh}/releases)`, - // Deps - (gh, npm) => `[![Deps](https://david-dm.org/${gh}.svg?style=flat-square)](https://david-dm.org/${gh})`, - // CI - (gh, npm) => { - // Need to fix the path for jenkins links, as jenkins adds `/job/` between everything - const jenkinsPath = gh.split('/').join('/job/') - return `[![jenkins](https://ci.ipfs.team/buildStatus/icon?job=${gh}/master)](https://ci.ipfs.team/job/${jenkinsPath}/job/master/)` - }, - // Coverage - (gh, npm) => `[![codecov](https://codecov.io/gh/${gh}/branch/master/graph/badge.svg)](https://codecov.io/gh/${gh})` -] - -// Creates the table row for a package -const generatePackageRow = (item) => { - const row = packageBadges.map((func) => { - // First string is GitHub path, second is npm package name - return func(item[0], item[1]) - }).join(' | ') - const fullRow = `| ${row} |` - return fullRow -} - -// Generates a row for the table, depending if it's a package or a heading -const generateRow = (item) => { - if (isItemPackage(item)) { - return generatePackageRow(item) - } else { - return `| **${item}** |` - } -} - -const header = `| ${columns.join(' | ')} |` -const hr = `| ${columns.map(() => '---------').join('|')} |` - -const toPrint = [ - header, - hr, - rows.map((row) => generateRow(row)).join('\n') -] - -toPrint.forEach((t) => console.log(t))