Skip to content

Commit

Permalink
test with stock data
Browse files Browse the repository at this point in the history
  • Loading branch information
DarrenBaldwin07 committed Oct 16, 2023
1 parent cbf8f38 commit 4c1b12a
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 66 deletions.
110 changes: 66 additions & 44 deletions ui/src/pages/extensions/[ext]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,50 +329,72 @@ export async function getStaticProps({ params }: { params: { ext: string } }) {
return extensions.sort((a, b) => compareBySemver(a.version, b.version))
}

try {
try {
const extRes = await fetch(
`${REGISTRY_URL}/extensions/detail/${params.ext}`
)
extensions = await extRes.json()!
sortExtensions(extensions)
} catch (error) {
return Promise.reject(
Error(`Failed to fetch '${params.ext}' from Trunk: ${error}`)
)
}
const latestVersion: Extension = extensions[extensions.length - 1]
if (
extensions &&
latestVersion?.repository &&
latestVersion.repository.includes("github.com")
) {
const repo = latestVersion.repository

try {
readme = await getReadme(repo)
repoDescription = latestVersion.description
} catch (err) {
console.log(`getReadme failed: ${err}`)
return Promise.reject(Error(`getReadmeAndDescription failed: ${err}`))
}
}
const test = {
categories: ["Tooling / Admin"],
createdAt: "2023-04-21T20:00:22.576493+00:00",
description:
"adminpack provides a number of support functions which pgAdmin and other administration and management tools can use to provide additional functionality, such as remote management of server log files.",
documentation: "https://www.postgresql.org/docs/current/adminpack.html",
homepage: "https://www.postgresql.org",
latestVersion: "2.1.0",
license: "PostgreSQL",
name: "adminpack",
owners: null,
repository:
"https://github.com/postgres/postgres/tree/master/contrib/adminpack",
updatedAt: "2023-08-28T18:48:27.880262+00:00",
slug: "idk",
tags: ["test"],
version: "0.1.5",
}

return {
props: { extension: latestVersion, readme, repoDescription },
revalidate: 10,
notFound: true,
}
} catch (error: any) {
console.log(
"********** STATIC PROPS ERROR **********",
error.message,
params,
extensions
)
return {
props: { extension: null, readme: "", repoDescription: "" },
notFound: true,
}
return {
props: { extension: test, readme, repoDescription },
revalidate: 10,
}

// try {
// try {
// const extRes = await fetch(
// `${REGISTRY_URL}/extensions/detail/${params.ext}`
// )
// extensions = await extRes.json()!
// sortExtensions(extensions)
// } catch (error) {
// return Promise.reject(
// Error(`Failed to fetch '${params.ext}' from Trunk: ${error}`)
// )
// }
// const latestVersion: Extension = extensions[extensions.length - 1]
// if (
// extensions &&
// latestVersion?.repository &&
// latestVersion.repository.includes("github.com")
// ) {
// const repo = latestVersion.repository

// try {
// readme = await getReadme(repo)
// repoDescription = latestVersion.description
// } catch (err) {
// console.log(`getReadme failed: ${err}`)
// return Promise.reject(Error(`getReadmeAndDescription failed: ${err}`))
// }
// }

// return {
// props: { extension: latestVersion, readme, repoDescription },
// revalidate: 10,
// }
// } catch (error: any) {
// console.log(
// "********** STATIC PROPS ERROR **********",
// error.message,
// params,
// extensions
// )
// return {
// props: { extension: null, readme: "", repoDescription: "" },
// }
// }
}
44 changes: 22 additions & 22 deletions ui/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
export type Extension = {
slug: string;
name: string;
description: string;
categories: string[];
tags: string[];
owners: Owner[];
license: string;
version: string;
repository?: string;
homepage?: string;
updatedAt: string;
};
slug: string
name: string
description: string
categories: string[]
tags: string[]
owners: Owner[] | null
license: string
version: string
repository?: string
homepage?: string
updatedAt: string
}

export type Owner = {
useId: string;
userName: string;
};
useId: string
userName: string
}
export type Category = {
slug: string;
name: string;
extension_count: number;
};
slug: string
name: string
extension_count: number
}

export type CategoriesForGrid = {
[key: string]: {
displayName: string;
};
};
displayName: string
}
}

0 comments on commit 4c1b12a

Please sign in to comment.