├── test └── test.spec.js ├── .gitignore ├── LICENSE ├── .github ├── workflows │ ├── automerge.yml │ ├── semantic-pull-request.yml │ ├── stale.yml │ ├── generated-pr.yml │ └── js-test-and-release.yml └── dependabot.yml ├── LICENSE-APACHE ├── README.md ├── LICENSE-MIT ├── CHANGELOG.md ├── src ├── index.js └── badges.js └── package.json /test/test.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | /* eslint-env mocha */ 3 | 4 | describe('Write me :D', () => { 5 | 6 | }) 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | dist 4 | .docs 5 | .coverage 6 | node_modules 7 | package-lock.json 8 | yarn.lock 9 | .vscode 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /.github/workflows/automerge.yml: -------------------------------------------------------------------------------- 1 | name: Automerge 2 | on: [ pull_request ] 3 | 4 | jobs: 5 | automerge: 6 | uses: protocol/.github/.github/workflows/automerge.yml@master 7 | with: 8 | job: 'automerge' 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "10:00" 8 | open-pull-requests-limit: 10 9 | commit-message: 10 | prefix: "deps" 11 | prefix-development: "deps(dev)" 12 | -------------------------------------------------------------------------------- /.github/workflows/semantic-pull-request.yml: -------------------------------------------------------------------------------- 1 | name: Semantic PR 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | - edited 8 | - synchronize 9 | 10 | jobs: 11 | main: 12 | uses: pl-strflt/.github/.github/workflows/reusable-semantic-pull-request.yml@v0.3 13 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Close Stale Issues 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | workflow_dispatch: 7 | 8 | permissions: 9 | issues: write 10 | pull-requests: write 11 | 12 | jobs: 13 | stale: 14 | uses: ipdxco/unified-github-workflows/.github/workflows/reusable-stale-issue.yml@v1 15 | -------------------------------------------------------------------------------- /.github/workflows/generated-pr.yml: -------------------------------------------------------------------------------- 1 | name: Close Generated PRs 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | workflow_dispatch: 7 | 8 | permissions: 9 | issues: write 10 | pull-requests: write 11 | 12 | jobs: 13 | stale: 14 | uses: ipdxco/unified-github-workflows/.github/workflows/reusable-generated-pr.yml@v1 15 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /.github/workflows/js-test-and-release.yml: -------------------------------------------------------------------------------- 1 | name: test & maybe release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | workflow_dispatch: 9 | 10 | permissions: 11 | contents: write 12 | packages: write 13 | 14 | concurrency: 15 | group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }} 16 | cancel-in-progress: true 17 | 18 | jobs: 19 | js-test-and-release: 20 | uses: pl-strflt/uci/.github/workflows/js-test-and-release.yml@v0.0 21 | secrets: 22 | DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} 23 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} 24 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 25 | UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }} 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # package-table 2 | 3 | [![codecov](https://img.shields.io/codecov/c/github/ipfs-shipyard/package-table.svg?style=flat-square)](https://codecov.io/gh/ipfs-shipyard/package-table) 4 | [![CI](https://img.shields.io/github/actions/workflow/status/ipfs-shipyard/package-table/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs-shipyard/package-table/actions/workflows/js-test-and-release.yml?query=branch%3Amain) 5 | 6 | > Auto generate a package table in markdown from JSON 7 | 8 | # Install 9 | 10 | ```console 11 | $ npm i package-table 12 | ``` 13 | 14 | # License 15 | 16 | Licensed under either of 17 | 18 | - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) 19 | - MIT ([LICENSE-MIT](LICENSE-MIT) / ) 20 | 21 | # Contribution 22 | 23 | Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. 24 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.5.7](https://github.com/ipfs-shipyard/package-table/compare/v0.5.6...v0.5.7) (2023-11-17) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * use configured branch for coverage url generation ([#41](https://github.com/ipfs-shipyard/package-table/issues/41)) ([d429c06](https://github.com/ipfs-shipyard/package-table/commit/d429c0660d37a0fd9f603caae8c0eb3bd85ba938)) 7 | 8 | 9 | ### Dependencies 10 | 11 | * **dev:** bump the npm_and_yarn at /. security update group with 1 update ([#42](https://github.com/ipfs-shipyard/package-table/issues/42)) ([bdf0e46](https://github.com/ipfs-shipyard/package-table/commit/bdf0e4640d5c9b370f8a014d7fa42c8b6c5c454e)) 12 | 13 | ## [0.5.6](https://github.com/ipfs-shipyard/package-table/compare/v0.5.5...v0.5.6) (2023-05-10) 14 | 15 | 16 | ### Bug Fixes 17 | 18 | * update deps and project ([d9483eb](https://github.com/ipfs-shipyard/package-table/commit/d9483ebf67be42dc89a223ed8b96ad95d66ee2c4)) 19 | * Use Libraries.io for Deps ([#35](https://github.com/ipfs-shipyard/package-table/issues/35)) ([9b87875](https://github.com/ipfs-shipyard/package-table/commit/9b878751c2a94ecd43b148ca5e249f54c0f95882)) 20 | 21 | 22 | ### Trivial Changes 23 | 24 | * add release script ([775cbf3](https://github.com/ipfs-shipyard/package-table/commit/775cbf37298b3a56ca87c04e4a7e9940cca01a1a)) 25 | * **deps:** bump codecov from 3.2.0 to 3.7.1 ([#16](https://github.com/ipfs-shipyard/package-table/issues/16)) ([755209f](https://github.com/ipfs-shipyard/package-table/commit/755209fce1726144c05a01c2cb800cfa426b7d5c)) 26 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 'use strict' 3 | 4 | const { parseArgs } = require('node:util') 5 | const path = require('path') 6 | const packageBadges = require('./badges') 7 | 8 | const argv = parseArgs({ 9 | options: { 10 | data: { 11 | type: 'string' 12 | } 13 | } 14 | }) 15 | 16 | if (!argv.values.data) { 17 | console.log('Need to pass --data=') // eslint-disable-line no-console 18 | process.exit() 19 | } 20 | 21 | let data 22 | 23 | if (path.isAbsolute(argv.values.data)) { 24 | data = require(argv.values.data) 25 | } else { 26 | data = require(path.join(process.cwd(), argv.values.data)) 27 | } 28 | 29 | // Creates the table row for a package 30 | const generatePackageRow = async item => { 31 | const promises = data.columns.map(col => packageBadges[col](...item)) 32 | const vals = await Promise.all(promises) 33 | 34 | return `| ${vals.join(' | ')} |` 35 | } 36 | 37 | // Generates a row for the table, depending if it's a package or a heading 38 | const generateRow = item => { 39 | if (Array.isArray(item)) { 40 | return generatePackageRow(item) 41 | } else { 42 | return `| **${item}** |` 43 | } 44 | } 45 | 46 | (async () => { 47 | const header = `| ${data.columns.join(' | ')} |` 48 | const hr = `| ${data.columns.map(() => '---------').join('|')} |` 49 | const promises = data.rows.map(row => generateRow(row)) 50 | const rows = (await Promise.all(promises)).join('\n') 51 | 52 | console.log([header, hr, rows].join('\n')) // eslint-disable-line no-console 53 | })() 54 | -------------------------------------------------------------------------------- /src/badges.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const badgeExists = async (url) => { 4 | const res = await fetch(url) 5 | 6 | return res.statusCode !== 404 7 | } 8 | 9 | const name = (gh, pkg, branch = 'main') => { 10 | return `[\`${pkg}\`](//github.com/${gh})` 11 | } 12 | 13 | const npmVersion = (gh, pkg, branch = 'main') => { 14 | return `[![npm](https://img.shields.io/npm/v/${encodeURIComponent(pkg)}.svg?maxAge=86400&style=flat-square)](//github.com/${gh}/releases)` 15 | } 16 | 17 | const deps = (gh, pkg, branch = 'main') => { 18 | return `[![Deps](https://img.shields.io/librariesio/release/npm/${encodeURIComponent(pkg)}?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/${encodeURIComponent(pkg)})` 19 | } 20 | 21 | const ciTravis = async (gh, pkg, branch = 'main', ci = 'main.yml') => { 22 | const url = `https://flat.badgen.net/travis/${gh}/${branch}` 23 | 24 | if (await badgeExists(url)) { 25 | return `[![Travis CI](${url})](https://travis-ci.com/${gh})` 26 | } else { 27 | return 'N/A' 28 | } 29 | } 30 | 31 | const ciGitHub = async (gh, pkg, branch = 'main', ci = 'main.yml') => { 32 | const url = `https://img.shields.io/github/actions/workflow/status/${gh}/${ci}?branch=${branch}&label=ci&style=flat-square` 33 | 34 | if (await badgeExists(url)) { 35 | return `[![GitHub CI](${url})](//github.com/${gh}/actions?query=branch%3A${branch}+workflow%3Aci+)` 36 | } else { 37 | return 'N/A' 38 | } 39 | } 40 | 41 | const coverage = (gh, pkg, branch = 'main') => { 42 | return `[![codecov](https://codecov.io/gh/${gh}/branch/${branch}/graph/badge.svg?style=flat-square)](https://codecov.io/gh/${gh})` 43 | } 44 | 45 | const description = (gh, pkg, desc) => desc 46 | 47 | module.exports = { 48 | Package: name, 49 | Name: name, 50 | Version: npmVersion, 51 | Deps: deps, 52 | CI: ciGitHub, 53 | 'CI/Travis': ciTravis, 54 | Coverage: coverage, 55 | Description: description 56 | } 57 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "package-table", 3 | "version": "0.5.7", 4 | "description": "Auto generate a package table in markdown from JSON ", 5 | "author": "David Dias ", 6 | "license": "Apache-2.0 OR MIT", 7 | "homepage": "https://github.com/ipfs-shipyard/package-table#readme", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/ipfs-shipyard/package-table.git" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/ipfs-shipyard/package-table/issues" 14 | }, 15 | "keywords": [ 16 | "JSON", 17 | "Markdown", 18 | "module", 19 | "packages", 20 | "table", 21 | "track" 22 | ], 23 | "bin": "src/index.js", 24 | "main": "src/index.js", 25 | "files": [ 26 | "src", 27 | "dist" 28 | ], 29 | "eslintConfig": { 30 | "extends": "ipfs", 31 | "parserOptions": { 32 | "project": true 33 | } 34 | }, 35 | "release": { 36 | "branches": [ 37 | "main" 38 | ], 39 | "plugins": [ 40 | [ 41 | "@semantic-release/commit-analyzer", 42 | { 43 | "preset": "conventionalcommits", 44 | "releaseRules": [ 45 | { 46 | "breaking": true, 47 | "release": "major" 48 | }, 49 | { 50 | "revert": true, 51 | "release": "patch" 52 | }, 53 | { 54 | "type": "feat", 55 | "release": "minor" 56 | }, 57 | { 58 | "type": "fix", 59 | "release": "patch" 60 | }, 61 | { 62 | "type": "docs", 63 | "release": "patch" 64 | }, 65 | { 66 | "type": "test", 67 | "release": "patch" 68 | }, 69 | { 70 | "type": "deps", 71 | "release": "patch" 72 | }, 73 | { 74 | "scope": "no-release", 75 | "release": false 76 | } 77 | ] 78 | } 79 | ], 80 | [ 81 | "@semantic-release/release-notes-generator", 82 | { 83 | "preset": "conventionalcommits", 84 | "presetConfig": { 85 | "types": [ 86 | { 87 | "type": "feat", 88 | "section": "Features" 89 | }, 90 | { 91 | "type": "fix", 92 | "section": "Bug Fixes" 93 | }, 94 | { 95 | "type": "chore", 96 | "section": "Trivial Changes" 97 | }, 98 | { 99 | "type": "docs", 100 | "section": "Documentation" 101 | }, 102 | { 103 | "type": "deps", 104 | "section": "Dependencies" 105 | }, 106 | { 107 | "type": "test", 108 | "section": "Tests" 109 | } 110 | ] 111 | } 112 | } 113 | ], 114 | "@semantic-release/changelog", 115 | "@semantic-release/npm", 116 | "@semantic-release/github", 117 | "@semantic-release/git" 118 | ] 119 | }, 120 | "scripts": { 121 | "lint": "aegir lint", 122 | "test": "aegir test -t node", 123 | "release": "aegir release" 124 | }, 125 | "devDependencies": { 126 | "aegir": "^41.1.9" 127 | } 128 | } 129 | --------------------------------------------------------------------------------