Skip to content

Commit

Permalink
Be resilient to certain missing fields in metadata.json (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyverald authored Jan 23, 2024
1 parent cd44a0a commit 3a4bb25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions data/moduleStaticProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ export const getStaticPropsModulePage = async (
const metadata = await getModuleMetadata(module)
let { versions } = metadata
versions = sortVersions(versions)
let yankedVersions = metadata.yanked_versions || {}

const versionInfos: VersionInfo[] = await Promise.all(
versions.map(async (version) => ({
version,
submission: await getSubmissionCommitOfVersion(module, version),
moduleInfo: await moduleInfo(module, version),
isYanked: Object.keys(metadata.yanked_versions).includes(version),
yankReason: metadata.yanked_versions[version] || null,
isYanked: Object.keys(yankedVersions).includes(version),
yankReason: yankedVersions[version] || null,
}))
)

Expand Down
4 changes: 2 additions & 2 deletions data/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ export const BUILDOZER_BIN = path.join(process.cwd(), 'bin', 'buildozer')

export interface Metadata {
homepage?: string
maintainers: Array<{
maintainers?: Array<{
email?: string
github?: string
name?: string
}>
repository?: string[]
versions: Array<string>
yanked_versions: {
yanked_versions?: {
[key: string]: string
}
}
Expand Down
2 changes: 1 addition & 1 deletion pages/modules/[module].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ const ModulePage: NextPage<ModulePageProps> = ({
<h3 className="font-bold text-xl mt-2">Maintainers</h3>
<div>
<ul>
{metadata.maintainers.map(({ name, email, github }) => (
{metadata.maintainers?.map(({ name, email, github }) => (
<li key={name}>
<span>
{email && (
Expand Down

0 comments on commit 3a4bb25

Please sign in to comment.