From 86acb3c40a11b4c165087e2846ee6748dc343d9f Mon Sep 17 00:00:00 2001 From: Leo Ribeiro Date: Fri, 18 Oct 2024 12:36:29 -0400 Subject: [PATCH] Complete Released Packages (#6) --- .../src/components/LanguageIcon.astro | 35 ++++++ .../src/components/ProjectDetails.astro | 4 + .../components/ProjectDetailsPackages.astro | 100 ++++++++++++++++++ projects-dashboard/src/content/config.ts | 28 +++-- .../content/project/TBD54566975_tbdex-rust.md | 4 +- .../content/project/TBD54566975_web5-js.md | 12 +-- ...e_example-java-kotlin-maven-multimodule.md | 18 ++++ projects-dashboard/src/lib/badge.ts | 55 +++++++++- 8 files changed, 232 insertions(+), 24 deletions(-) create mode 100644 projects-dashboard/src/components/LanguageIcon.astro create mode 100644 projects-dashboard/src/components/ProjectDetailsPackages.astro diff --git a/projects-dashboard/src/components/LanguageIcon.astro b/projects-dashboard/src/components/LanguageIcon.astro new file mode 100644 index 0000000..8fb22a3 --- /dev/null +++ b/projects-dashboard/src/components/LanguageIcon.astro @@ -0,0 +1,35 @@ +--- +import type { Language } from "../content/config"; + +type Props = { + language: Language; +}; + +const { language } = Astro.props; + +const iconMap = { + javascript: { icon: "js", color: "#c9af00" }, + typescript: { icon: "ts", color: "#3178c6" }, + kotlin: { icon: "kt", color: "#6b47d2" }, + swift: { icon: "swift", color: "#f05138" }, + rust: { icon: "rs", color: "#dea584" }, + go: { icon: "go", color: "#00ADD8" }, + java: { icon: "java", color: "#b07219" }, + python: { icon: "py", color: "#3572A5" }, +}; +--- + +
+ {iconMap[language].icon} +
+ + diff --git a/projects-dashboard/src/components/ProjectDetails.astro b/projects-dashboard/src/components/ProjectDetails.astro index d2d5c04..54aa79a 100644 --- a/projects-dashboard/src/components/ProjectDetails.astro +++ b/projects-dashboard/src/components/ProjectDetails.astro @@ -1,6 +1,9 @@ --- import type { CollectionEntry } from 'astro:content'; + import ProjectBadge from './ProjectBadge.astro'; +import ProjectDetailsPackages from './ProjectDetailsPackages.astro'; + type Props = CollectionEntry<'project'>['data']; const { title, description, repo, ciChecks, licenses, securityScans, scoreCards, sastChecks, tests, packages } = Astro.props; @@ -39,6 +42,7 @@ const { title, description, repo, ciChecks, licenses, securityScans, scoreCards, {tests.map(test => )} } + {packages && packages.length > 0 && } diff --git a/projects-dashboard/src/content/config.ts b/projects-dashboard/src/content/config.ts index 01fcc85..1cfe94f 100644 --- a/projects-dashboard/src/content/config.ts +++ b/projects-dashboard/src/content/config.ts @@ -21,7 +21,7 @@ const languageSchema = z.enum([ export type Language = z.infer; -const artifactTypeSchema = z.enum(["npm", "maven", "pip", "reference-docs"]); +const artifactTypeSchema = z.enum(["npm", "maven", "reference-docs"]); export type ArtifactType = z.infer; @@ -36,18 +36,26 @@ const packageSchema = z.object({ repoPath: z.string().optional(), language: languageSchema, artifacts: z.array(artifactSchema), + ghTagFilter: z.string().optional(), }); +const badgeTypeSchema = z.enum([ + "github-actions", + "github-license", + "github-tag", + "fossa-license", + "fossa-security", + "ossf", + "codecov", + "tbd-vectors", + "npm", + "maven", + "reference-docs", +]); + +export type BadgeType = z.infer; const badgeSchema = z.object({ - type: z.enum([ - "github-actions", - "github-license", - "fossa-license", - "fossa-security", - "ossf", - "codecov", - "tbd-vectors", - ]), + type: badgeTypeSchema, label: z.string().optional(), value: z.string().optional(), }); diff --git a/projects-dashboard/src/content/project/TBD54566975_tbdex-rust.md b/projects-dashboard/src/content/project/TBD54566975_tbdex-rust.md index 4bb5c2e..baf7505 100644 --- a/projects-dashboard/src/content/project/TBD54566975_tbdex-rust.md +++ b/projects-dashboard/src/content/project/TBD54566975_tbdex-rust.md @@ -20,11 +20,11 @@ tests: - type: "codecov" packages: - packageName: "xyz.block.tbdex" - repoPath: "packages/common" + repoPath: "bound/kt" language: "kotlin" artifacts: - type: "maven" - value: "xyz.block.tbdex" + value: "xyz.block/tbdex" - type: "reference-docs" value: "https://tbd54566975.github.io/tbdex-rs/kt/v4.0.0/" # TODO: get version dynamically --- diff --git a/projects-dashboard/src/content/project/TBD54566975_web5-js.md b/projects-dashboard/src/content/project/TBD54566975_web5-js.md index 09932c9..502ba1c 100644 --- a/projects-dashboard/src/content/project/TBD54566975_web5-js.md +++ b/projects-dashboard/src/content/project/TBD54566975_web5-js.md @@ -29,12 +29,14 @@ packages: - packageName: "@web5/common" repoPath: "packages/common" language: "typescript" + ghTagFilter: "@web5/common@*" artifacts: - type: "npm" value: "@web5/common" - packageName: "@web5/credentials" repoPath: "packages/credentials" language: "typescript" + ghTagFilter: "@web5/credentials@*" artifacts: - type: "npm" value: "@web5/credentials" @@ -43,6 +45,7 @@ packages: - packageName: "@web5/crypto" repoPath: "packages/crypto" language: "typescript" + ghTagFilter: "@web5/crypto@*" artifacts: - type: "npm" value: "@web5/crypto" @@ -51,14 +54,7 @@ packages: - packageName: "@web5/dids" repoPath: "packages/dids" language: "typescript" - artifacts: - - type: "npm" - value: "@web5/dids" - - type: "reference-docs" - value: "https://tbd54566975.github.io/web5-js/modules/_web5_dids.html" - - packageName: "@web5/dids" - repoPath: "packages/dids" - language: "typescript" + ghTagFilter: "@web5/dids@*" artifacts: - type: "npm" value: "@web5/dids" diff --git a/projects-dashboard/src/content/project/block-open-source_example-java-kotlin-maven-multimodule.md b/projects-dashboard/src/content/project/block-open-source_example-java-kotlin-maven-multimodule.md index 1d87c2d..e1f2cda 100644 --- a/projects-dashboard/src/content/project/block-open-source_example-java-kotlin-maven-multimodule.md +++ b/projects-dashboard/src/content/project/block-open-source_example-java-kotlin-maven-multimodule.md @@ -23,4 +23,22 @@ sastChecks: value: "codeql.yml" tests: - type: "codecov" +packages: + - packageName: "java-kotlin-maven-example-api" + repoPath: "api" + language: "java" + artifacts: + - type: "maven" + value: "xyz.block/java-kotlin-maven-example-api" + - packageName: "java-kotlin-maven-example-impl" + repoPath: "impl" + language: "java" + artifacts: + - type: "maven" + value: "xyz.block/java-kotlin-maven-example-impl" + - packageName: "java-kotlin-maven-example-parent" + language: "java" + artifacts: + - type: "maven" + value: "xyz.block/java-kotlin-maven-example-parent" --- diff --git a/projects-dashboard/src/lib/badge.ts b/projects-dashboard/src/lib/badge.ts index 9c30573..de9b789 100644 --- a/projects-dashboard/src/lib/badge.ts +++ b/projects-dashboard/src/lib/badge.ts @@ -1,3 +1,5 @@ +import type { BadgeType } from "../content/config"; + interface Repo { owner: string; name: string; @@ -13,8 +15,8 @@ function getDefaultBadgeSource( function getGithubActionsBadge( repo: Repo, - value: string, - label: string + value = "ci.yml", + label = "ci" ): [string, string] { const badgeSrc = `https://img.shields.io/github/actions/workflow/status/${repo.owner}/${repo.name}/${value}?style=flat-square&branch=main&logo=github&label=${label}&logoColor=FFFFFF`; const href = `https://github.com/${repo.owner}/${repo.name}/actions/workflows/${value}`; @@ -27,6 +29,15 @@ function getGithubLicenseBadge(repo: Repo): [string, string] { return [badgeSrc, href]; } +function getGithubTagBadge(repo: Repo, value?: string): [string, string] { + let badgeSrc = `https://img.shields.io/github/v/release/${repo.owner}/${repo.name}?logo=github&label=tag&style=flat-square&color=4c1`; + if (value) { + badgeSrc += `&filter=${value}`; + } + const href = `https://github.com/${repo.owner}/${repo.name}/releases`; + return [badgeSrc, href]; +} + function getFossaBadge(repo: Repo, issueType: string): [string, string] { const badgeSrc = `https://app.fossa.com/api/projects/custom%2B588%2Fgithub.com%2F${repo.owner}%2F${repo.name}.svg?type=shield&issueType=${issueType}`; const href = `https://app.fossa.com/projects/custom%2B588%2Fgithub.com%2F${repo.owner}%2F${repo.name}?ref=badge_shield&issueType=${issueType}`; @@ -51,17 +62,47 @@ function getTbdVectorsBadge(repo: Repo): [string, string] { return [badgeSrc, href]; } +function getNpmBadge(value?: string): [string, string] { + if (!value) { + throw new Error("NPM package artifact value is required for badge"); + } + const badgeSrc = `https://img.shields.io/npm/v/${value}.svg?style=flat-square&logo=npm&label=npm ${value}&logoColor=FFFFFF&color=4c1`; + const href = `https://www.npmjs.com/package/${value}`; + return [badgeSrc, href]; +} + +function getMavenBadge(value?: string): [string, string] { + if (!value) { + throw new Error("Maven package artifact value is required for badge"); + } + const artifactName = value.split("/")[1]; + const badgeSrc = `https://img.shields.io/maven-central/v/${value}?color=b07219&label=mvn ${artifactName}&logo=apachemaven&style=flat-square` + const href = `https://central.sonatype.com/artifact/${value}`; + return [badgeSrc, href]; +} + +function getReferenceDocsBadge(value?: string): [string, string] { + if (!value) { + throw new Error("Reference docs URL is required for badge"); + } + const badgeSrc = `https://img.shields.io/badge/API Reference Docs-purple?style=flat-square`; + const href = value; + return [badgeSrc, href]; +} + export function getBadgeInfo( repo: Repo, - type: string, + type: BadgeType, label?: string, value?: string ): [string, string] { switch (type) { case "github-actions": - return getGithubActionsBadge(repo, value ?? "ci.yml", label ?? "gh"); + return getGithubActionsBadge(repo, value, label); case "github-license": return getGithubLicenseBadge(repo); + case "github-tag": + return getGithubTagBadge(repo, value); case "fossa-license": return getFossaBadge(repo, "license"); case "fossa-security": @@ -72,6 +113,12 @@ export function getBadgeInfo( return getCodecovBadge(repo); case "tbd-vectors": return getTbdVectorsBadge(repo); + case "npm": + return getNpmBadge(value); + case "maven": + return getMavenBadge(value); + case "reference-docs": + return getReferenceDocsBadge(value); default: return [ getDefaultBadgeSource(type, label ?? "badge", value ?? "value"),