diff --git a/.package-list.js b/.package-list.js index d2ec62e56..2088f6401 100644 --- a/.package-list.js +++ b/.package-list.js @@ -4,37 +4,48 @@ * This file is used by `./scripts/update-package-list` */ -/** @type {import("./scripts/update-package-list/index.mjs").HeaderData['getVersionLink']} */ +/** @type {import("./scripts/update-package-list/index.mjs").GetVersionLinkFn} */ function createNpmBadge(data) { const npmBadge = `![npm](https://img.shields.io/npm/v/${data.name}.svg)`; return `[${npmBadge}](https://www.npmjs.com/package/${data.name})`; } +/** @type {import("./scripts/update-package-list/index.mjs").GetDependenciesLinkFn} */ +function createLibrariesioBadge(data) { + return `![Dependencies Status](https://img.shields.io/librariesio/release/npm/${data.name})`; +} + /** @type {import("./scripts/update-package-list/index.mjs").HeaderTable} */ const list = { 'packages': { header: 'Packages', getVersionLink: createNpmBadge, + getDependenciesLink: createLibrariesioBadge, }, 'packages/cli': { header: 'CLI', getVersionLink: createNpmBadge, + getDependenciesLink: createLibrariesioBadge, }, 'packages/cli-utils': { header: 'CLI Utilities', getVersionLink: createNpmBadge, + getDependenciesLink: createLibrariesioBadge, }, 'packages/ts-utils': { header: 'TypeScript Utilities', getVersionLink: createNpmBadge, + getDependenciesLink: createLibrariesioBadge, }, 'packages/ts-type-utils': { header: 'TypeScript Type Utilities', getVersionLink: createNpmBadge, + getDependenciesLink: createLibrariesioBadge, }, 'packages/jest-matchers': { header: 'Jest Matchers', getVersionLink: createNpmBadge, + getDependenciesLink: createLibrariesioBadge, }, 'actions': 'GitHub Actions', }; diff --git a/README.md b/README.md index 53494abe2..47b5bde66 100644 --- a/README.md +++ b/README.md @@ -17,43 +17,43 @@ | Package | Version | Dependencies | |-|-|-| -| [`@sounisi5011/check-pid-file`](./packages/check-pid-file) | [![npm](https://img.shields.io/npm/v/@sounisi5011/check-pid-file.svg)](https://www.npmjs.com/package/@sounisi5011/check-pid-file) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fcheck-pid-file)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fcheck-pid-file) | -| [`@sounisi5011/encrypted-archive`](./packages/encrypted-archive) | [![npm](https://img.shields.io/npm/v/@sounisi5011/encrypted-archive.svg)](https://www.npmjs.com/package/@sounisi5011/encrypted-archive) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fencrypted-archive)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fencrypted-archive) | -| [`@sounisi5011/stream-transform-from`](./packages/stream-transform-from) | [![npm](https://img.shields.io/npm/v/@sounisi5011/stream-transform-from.svg)](https://www.npmjs.com/package/@sounisi5011/stream-transform-from) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fstream-transform-from)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fstream-transform-from) | +| [`@sounisi5011/check-pid-file`](./packages/check-pid-file) | [![npm](https://img.shields.io/npm/v/@sounisi5011/check-pid-file.svg)](https://www.npmjs.com/package/@sounisi5011/check-pid-file) | ![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/check-pid-file) | +| [`@sounisi5011/encrypted-archive`](./packages/encrypted-archive) | [![npm](https://img.shields.io/npm/v/@sounisi5011/encrypted-archive.svg)](https://www.npmjs.com/package/@sounisi5011/encrypted-archive) | ![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/encrypted-archive) | +| [`@sounisi5011/stream-transform-from`](./packages/stream-transform-from) | [![npm](https://img.shields.io/npm/v/@sounisi5011/stream-transform-from.svg)](https://www.npmjs.com/package/@sounisi5011/stream-transform-from) | ![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/stream-transform-from) | ### CLI | Package | Version | Dependencies | |-|-|-| -| [`@sounisi5011/run-if-supported`](./packages/cli/run-if-supported) | [![npm](https://img.shields.io/npm/v/@sounisi5011/run-if-supported.svg)](https://www.npmjs.com/package/@sounisi5011/run-if-supported) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fcli%2Frun-if-supported)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fcli%2Frun-if-supported) | +| [`@sounisi5011/run-if-supported`](./packages/cli/run-if-supported) | [![npm](https://img.shields.io/npm/v/@sounisi5011/run-if-supported.svg)](https://www.npmjs.com/package/@sounisi5011/run-if-supported) | ![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/run-if-supported) | ### CLI Utilities | Package | Version | Dependencies | |-|-|-| -| [`@sounisi5011/cli-utils-top-level-await`](./packages/cli-utils/top-level-await-cli) | [![npm](https://img.shields.io/npm/v/@sounisi5011/cli-utils-top-level-await.svg)](https://www.npmjs.com/package/@sounisi5011/cli-utils-top-level-await) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fcli-utils%2Ftop-level-await-cli)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fcli-utils%2Ftop-level-await-cli) | +| [`@sounisi5011/cli-utils-top-level-await`](./packages/cli-utils/top-level-await-cli) | [![npm](https://img.shields.io/npm/v/@sounisi5011/cli-utils-top-level-await.svg)](https://www.npmjs.com/package/@sounisi5011/cli-utils-top-level-await) | ![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/cli-utils-top-level-await) | ### TypeScript Utilities | Package | Version | Dependencies | |-|-|-| -| [`@sounisi5011/ts-utils-is-property-accessible`](./packages/ts-utils/is-property-accessible) | [![npm](https://img.shields.io/npm/v/@sounisi5011/ts-utils-is-property-accessible.svg)](https://www.npmjs.com/package/@sounisi5011/ts-utils-is-property-accessible) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fts-utils%2Fis-property-accessible)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fts-utils%2Fis-property-accessible) | +| [`@sounisi5011/ts-utils-is-property-accessible`](./packages/ts-utils/is-property-accessible) | [![npm](https://img.shields.io/npm/v/@sounisi5011/ts-utils-is-property-accessible.svg)](https://www.npmjs.com/package/@sounisi5011/ts-utils-is-property-accessible) | ![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/ts-utils-is-property-accessible) | ### TypeScript Type Utilities | Package | Version | Dependencies | |-|-|-| -| [`@sounisi5011/ts-type-util-has-own-property`](./packages/ts-type-utils/has-own-property) | [![npm](https://img.shields.io/npm/v/@sounisi5011/ts-type-util-has-own-property.svg)](https://www.npmjs.com/package/@sounisi5011/ts-type-util-has-own-property) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fts-type-utils%2Fhas-own-property)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fts-type-utils%2Fhas-own-property) | -| [`@sounisi5011/ts-type-util-is-readonly-array`](./packages/ts-type-utils/is-readonly-array) | [![npm](https://img.shields.io/npm/v/@sounisi5011/ts-type-util-is-readonly-array.svg)](https://www.npmjs.com/package/@sounisi5011/ts-type-util-is-readonly-array) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fts-type-utils%2Fis-readonly-array)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fts-type-utils%2Fis-readonly-array) | +| [`@sounisi5011/ts-type-util-has-own-property`](./packages/ts-type-utils/has-own-property) | [![npm](https://img.shields.io/npm/v/@sounisi5011/ts-type-util-has-own-property.svg)](https://www.npmjs.com/package/@sounisi5011/ts-type-util-has-own-property) | ![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/ts-type-util-has-own-property) | +| [`@sounisi5011/ts-type-util-is-readonly-array`](./packages/ts-type-utils/is-readonly-array) | [![npm](https://img.shields.io/npm/v/@sounisi5011/ts-type-util-is-readonly-array.svg)](https://www.npmjs.com/package/@sounisi5011/ts-type-util-is-readonly-array) | ![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/ts-type-util-is-readonly-array) | ### Jest Matchers | Package | Version | Dependencies | |-|-|-| -| [`@sounisi5011/jest-binary-data-matchers`](./packages/jest-matchers/binary-data) | [![npm](https://img.shields.io/npm/v/@sounisi5011/jest-binary-data-matchers.svg)](https://www.npmjs.com/package/@sounisi5011/jest-binary-data-matchers) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fjest-matchers%2Fbinary-data)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fjest-matchers%2Fbinary-data) | +| [`@sounisi5011/jest-binary-data-matchers`](./packages/jest-matchers/binary-data) | [![npm](https://img.shields.io/npm/v/@sounisi5011/jest-binary-data-matchers.svg)](https://www.npmjs.com/package/@sounisi5011/jest-binary-data-matchers) | ![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/jest-binary-data-matchers) | ### GitHub Actions -| Package | Version | Dependencies | -|-|-|-| -| [`monorepo-workspace-submodules-finder-action`](./actions/monorepo-workspace-submodules-finder) | [`v1.3.2`](https://github.com/sounisi5011/npm-packages/tree/monorepo-workspace-submodules-finder-action-v1.3.2/actions/monorepo-workspace-submodules-finder) | [![Dependency Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=actions%2Fmonorepo-workspace-submodules-finder)](https://david-dm.org/sounisi5011/npm-packages?path=actions%2Fmonorepo-workspace-submodules-finder) | +| Package | Version | +|-|-| +| [`monorepo-workspace-submodules-finder-action`](./actions/monorepo-workspace-submodules-finder) | [`v1.3.2`](https://github.com/sounisi5011/npm-packages/tree/monorepo-workspace-submodules-finder-action-v1.3.2/actions/monorepo-workspace-submodules-finder) | diff --git a/packages/check-pid-file/README.md b/packages/check-pid-file/README.md index f4375efa5..2713c5fda 100644 --- a/packages/check-pid-file/README.md +++ b/packages/check-pid-file/README.md @@ -6,7 +6,7 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Minified Bundle Size Details](https://img.shields.io/bundlephobia/min/@sounisi5011/check-pid-file)](https://bundlephobia.com/result?p=%40sounisi5011%2Fcheck-pid-file) [![Install Size Details](https://packagephobia.com/badge?p=%40sounisi5011%2Fcheck-pid-file)](https://packagephobia.com/result?p=%40sounisi5011%2Fcheck-pid-file) -[![Dependencies Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fcheck-pid-file)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fcheck-pid-file) +![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/check-pid-file) [![Build Status](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml/badge.svg)](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml) [![Maintainability Status](https://api.codeclimate.com/v1/badges/26495b68302f7ff963c3/maintainability)](https://codeclimate.com/github/sounisi5011/npm-packages/maintainability) diff --git a/packages/cli-utils/top-level-await-cli/README.md b/packages/cli-utils/top-level-await-cli/README.md index 975e43d17..ee95332fa 100644 --- a/packages/cli-utils/top-level-await-cli/README.md +++ b/packages/cli-utils/top-level-await-cli/README.md @@ -5,7 +5,7 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Minified Bundle Size Details](https://img.shields.io/bundlephobia/min/@sounisi5011/cli-utils-top-level-await)](https://bundlephobia.com/result?p=%40sounisi5011%2Fcli-utils-top-level-await) [![Install Size Details](https://packagephobia.com/badge?p=%40sounisi5011%2Fcli-utils-top-level-await)](https://packagephobia.com/result?p=%40sounisi5011%2Fcli-utils-top-level-await) -[![Dependencies Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fcli-utils%2Ftop-level-await-cli)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fcli-utils%2Ftop-level-await-cli) +![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/cli-utils-top-level-await) [![Build Status](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml/badge.svg)](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml) [![Maintainability Status](https://api.codeclimate.com/v1/badges/26495b68302f7ff963c3/maintainability)](https://codeclimate.com/github/sounisi5011/npm-packages/maintainability) diff --git a/packages/cli/run-if-supported/README.md b/packages/cli/run-if-supported/README.md index 737b02e8e..32d8415a6 100644 --- a/packages/cli/run-if-supported/README.md +++ b/packages/cli/run-if-supported/README.md @@ -6,7 +6,7 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Minified Bundle Size Details](https://img.shields.io/bundlephobia/min/@sounisi5011/run-if-supported)](https://bundlephobia.com/result?p=%40sounisi5011%2Frun-if-supported) [![Install Size Details](https://packagephobia.com/badge?p=%40sounisi5011%2Frun-if-supported)](https://packagephobia.com/result?p=%40sounisi5011%2Frun-if-supported) -[![Dependencies Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fcli%2Frun-if-supported)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fcli%2Frun-if-supported) +![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/run-if-supported) [![Build Status](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml/badge.svg)](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml) [![Maintainability Status](https://api.codeclimate.com/v1/badges/26495b68302f7ff963c3/maintainability)](https://codeclimate.com/github/sounisi5011/npm-packages/maintainability) diff --git a/packages/encrypted-archive/README.md b/packages/encrypted-archive/README.md index d0d072a44..2917bc65b 100644 --- a/packages/encrypted-archive/README.md +++ b/packages/encrypted-archive/README.md @@ -6,7 +6,7 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Minified Bundle Size Details](https://img.shields.io/bundlephobia/min/@sounisi5011/encrypted-archive)](https://bundlephobia.com/result?p=%40sounisi5011%2Fencrypted-archive) [![Install Size Details](https://packagephobia.com/badge?p=%40sounisi5011%2Fencrypted-archive)](https://packagephobia.com/result?p=%40sounisi5011%2Fencrypted-archive) -[![Dependencies Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fencrypted-archive)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fencrypted-archive) +![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/encrypted-archive) [![Build Status](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml/badge.svg)](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml) [![Maintainability Status](https://api.codeclimate.com/v1/badges/26495b68302f7ff963c3/maintainability)](https://codeclimate.com/github/sounisi5011/npm-packages/maintainability) diff --git a/packages/jest-matchers/binary-data/README.md b/packages/jest-matchers/binary-data/README.md index 593372ac5..2feb68c7d 100644 --- a/packages/jest-matchers/binary-data/README.md +++ b/packages/jest-matchers/binary-data/README.md @@ -6,7 +6,7 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Minified Bundle Size Details](https://img.shields.io/bundlephobia/min/@sounisi5011/jest-binary-data-matchers)](https://bundlephobia.com/result?p=%40sounisi5011%2Fjest-binary-data-matchers) [![Install Size Details](https://packagephobia.com/badge?p=%40sounisi5011%2Fjest-binary-data-matchers)](https://packagephobia.com/result?p=%40sounisi5011%2Fjest-binary-data-matchers) -[![Dependencies Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fjest-matchers%2Fbinary-data)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fjest-matchers%2Fbinary-data) +![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/jest-binary-data-matchers) [![Build Status](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml/badge.svg)](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml) [![Maintainability Status](https://api.codeclimate.com/v1/badges/26495b68302f7ff963c3/maintainability)](https://codeclimate.com/github/sounisi5011/npm-packages/maintainability) diff --git a/packages/stream-transform-from/README.md b/packages/stream-transform-from/README.md index 745cdea0e..97cd39dc8 100644 --- a/packages/stream-transform-from/README.md +++ b/packages/stream-transform-from/README.md @@ -6,7 +6,7 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Minified Bundle Size Details](https://img.shields.io/bundlephobia/min/@sounisi5011/stream-transform-from)](https://bundlephobia.com/result?p=%40sounisi5011%2Fstream-transform-from) [![Install Size Details](https://packagephobia.com/badge?p=%40sounisi5011%2Fstream-transform-from)](https://packagephobia.com/result?p=%40sounisi5011%2Fstream-transform-from) -[![Dependencies Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fstream-transform-from)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fstream-transform-from) +![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/stream-transform-from) [![Build Status](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml/badge.svg)](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml) [![Maintainability Status](https://api.codeclimate.com/v1/badges/26495b68302f7ff963c3/maintainability)](https://codeclimate.com/github/sounisi5011/npm-packages/maintainability) diff --git a/packages/ts-utils/is-property-accessible/README.md b/packages/ts-utils/is-property-accessible/README.md index 905bbf7c9..53f8c8699 100644 --- a/packages/ts-utils/is-property-accessible/README.md +++ b/packages/ts-utils/is-property-accessible/README.md @@ -5,7 +5,7 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Minified Bundle Size Details](https://img.shields.io/bundlephobia/min/@sounisi5011/ts-utils-is-property-accessible)](https://bundlephobia.com/result?p=%40sounisi5011%2Fts-utils-is-property-accessible) [![Install Size Details](https://packagephobia.com/badge?p=%40sounisi5011%2Fts-utils-is-property-accessible)](https://packagephobia.com/result?p=%40sounisi5011%2Fts-utils-is-property-accessible) -[![Dependencies Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fts-utils%2Fis-property-accessible)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fts-utils%2Fis-property-accessible) +![Dependencies Status](https://img.shields.io/librariesio/release/npm/@sounisi5011/ts-utils-is-property-accessible) [![Build Status](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml/badge.svg)](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml) [![Maintainability Status](https://api.codeclimate.com/v1/badges/26495b68302f7ff963c3/maintainability)](https://codeclimate.com/github/sounisi5011/npm-packages/maintainability) diff --git a/scripts/publish-convert-readme.mjs b/scripts/publish-convert-readme.mjs index 0cb8ec441..d415cb4f2 100644 --- a/scripts/publish-convert-readme.mjs +++ b/scripts/publish-convert-readme.mjs @@ -47,7 +47,12 @@ function reportError(message) { */ function replaceURL(urlStr, { pkg, rootURL }) { if (pkg.version) { - if (urlStr.startsWith('https://img.shields.io/bundlephobia/') && !/\/\d+(?:\.\d+){2}$/.test(urlStr)) { + if ( + ( + urlStr.startsWith('https://img.shields.io/bundlephobia/') + || urlStr.startsWith('https://img.shields.io/librariesio/release/npm/') + ) && !/\/\d+(?:\.\d+){2}$/.test(urlStr) + ) { return `${urlStr}/${pkg.version}`; } if ( diff --git a/scripts/update-package-list/index.mjs b/scripts/update-package-list/index.mjs index 5d93bc641..34b82f9f6 100644 --- a/scripts/update-package-list/index.mjs +++ b/scripts/update-package-list/index.mjs @@ -14,8 +14,11 @@ import { getWorkspaceRoot, getWorkspaces } from 'workspace-tools'; * * @typedef {Object} HeaderData * @property {string} header - * @property {function(PackageInfo, UtilFuncs): string} getVersionLink - * @property {function(PackageInfo, UtilFuncs): string} getDependenciesLink + * @property {GetVersionLinkFn} getVersionLink + * @property {GetDependenciesLinkFn} [getDependenciesLink] + * + * @typedef {function(PackageInfo, UtilFuncs): string} GetVersionLinkFn + * @typedef {function(PackageInfo, UtilFuncs): (string | undefined)} GetDependenciesLinkFn * * @typedef {Object} PackageInfo * @property {import('workspace-tools').WorkspaceInfo[number]['name']} name @@ -29,7 +32,7 @@ import { getWorkspaceRoot, getWorkspaces } from 'workspace-tools'; * @property {string} packagePathURL * @property {string} headerText * @property {string} headerText - * @property {string} depsLink + * @property {string | undefined} depsLink * * @typedef {Object} UtilFuncs * @property {typeof strictUriEncode} strictUriEncode @@ -117,16 +120,6 @@ function getHeaderData(headerTable, relativePackagePath) { const releaseTag = `${data.noScopeName}-v${data.version}`; return `[\`v${data.version}\`](${data.repoData.browse(data.packagePathURL, { committish: releaseTag })})`; }, - getDependenciesLink(data) { - const repoName = `${data.repoData.user}/${data.repoData.project}`; - const davidDmBadge = `![Dependency Status](https://status.david-dm.org/gh/${repoName}.svg?path=${ - strictUriEncode(data.packagePathURL) - })`; - const davidDmLink = `[${davidDmBadge}](https://david-dm.org/${repoName}?path=${ - strictUriEncode(data.packagePathURL) - })`; - return davidDmLink; - }, }; do { const headerData = headerTable[path2url(relativePackagePath)]; @@ -182,7 +175,10 @@ async function updateMarkdown(filepath, rootPackageList, packageRoot) { packagePathURL: path2url(relativePackagePath), headerText, get depsLink() { - return getDependenciesLink(this, { strictUriEncode }); + if (typeof getDependenciesLink === 'function') { + return getDependenciesLink(this, { strictUriEncode }); + } + return undefined; }, }; return packageInfo; @@ -205,15 +201,49 @@ async function updateMarkdown(filepath, rootPackageList, packageRoot) { .join('\n'); const listText = [...packageMap.entries()] .map(([headerText, dataList]) => { + const rowDataList = dataList + .sort(({ name: a }, { name: b }) => a.localeCompare(b)) + .map(data => { + return { + 'Package': `[\`${data.name}\`](./${data.localURL})`, + 'Version': data.versionLink, + 'Dependencies': data.depsLink, + }; + }); + const isExistColumn = rowDataList.reduce( + /** + * @param {Object} isExistColumn + */ + (isExistColumn, rowData) => { + for (const [columnName, columnValue] of Object.entries(rowData)) { + isExistColumn[columnName] = isExistColumn[columnName] || Boolean(columnValue); + } + return isExistColumn; + }, + {}, + ); + /** + * @typedef {string[]} ColumnTextList + * @type {ColumnTextList} + */ + const columnNameList = Object.entries(isExistColumn) + .filter(([, isExist]) => isExist) + .map(([columnName]) => columnName); + /** @type {ColumnTextList[]} */ + const rowList = [ + columnNameList.map(columnName => ` ${columnName} `), + columnNameList.map(() => '-'), + ...rowDataList.map(rowData => { + const columnList = Object.entries(rowData) + .filter(([columnName]) => isExistColumn[columnName]) + .map(([, columnValue]) => columnValue ? ` ${columnValue} ` : ''); + return columnList; + }), + ]; return [ `### ${headerText}`, '', - '| Package | Version | Dependencies |', - '|-|-|-|', - ...dataList.sort(({ name: a }, { name: b }) => a.localeCompare(b)).map(data => { - const packageLink = `[\`${data.name}\`](./${data.localURL})`; - return `| ${packageLink} | ${data.versionLink} | ${data.depsLink} |`; - }), + ...rowList.map(columnList => `|${columnList.join('|')}|`), ].join('\n'); }) .join('\n\n'); diff --git a/scripts/update-readme-badge/index.mjs b/scripts/update-readme-badge/index.mjs index e0713fda4..6548edaff 100644 --- a/scripts/update-readme-badge/index.mjs +++ b/scripts/update-readme-badge/index.mjs @@ -125,6 +125,20 @@ function replacePackagephobia(pkg) { }; } +const LIBRARIES_IO_BADGE = + /!\[Dependenc(?:y|ies) Status\]\(https:\/\/img\.shields\.io\/librariesio\/release\/npm\/[^)]+\)/g; + +/** + * @param {*} pkg + * @returns {function(string): string} + */ +function replaceLibrariesIo(pkg) { + const pkgName = pkg.name; + return pkgName + ? () => `![Dependencies Status](https://img.shields.io/librariesio/release/npm/${pkgName})` + : origText => origText; +} + const DAVID_DM_BADGE = /\[!\[Dependencies Status\]\(https:\/\/status\.david-dm\.org\/gh\/(?:(?!\.svg\))[^?#)])+\.svg(?:[?#][^)]*)?\)\]\(https:\/\/david-dm\.org\/[^)]+\)/g; @@ -170,6 +184,7 @@ async function main() { .replace(NODE_VERSION_BADGE, replaceNodeVersion(pkg)) .replace(BUNDLEPHOBIA_BADGE, replaceBundlephobia(pkg)) .replace(PACKAGEPHOBIA_BADGE, replacePackagephobia(pkg)) + .replace(LIBRARIES_IO_BADGE, replaceLibrariesIo(pkg)) .replace(DAVID_DM_BADGE, replaceDavidDM(pkg, path.relative(repoRootpath, path.dirname(filepath)))); if (readmeText !== updatedReadmeText) {