Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out curated extensions uploaded as builds (3rd party extensions) #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 33 additions & 25 deletions packages/nextjs/pages/extensions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,36 +111,13 @@ export const getStaticProps: GetStaticProps<ExtensionsListProps> = async () => {
throw new Error("BGAPP_API_URL environment variable is not set");
}

const response = await fetch(`${BGAPP_API_URL}/builds?type=extension`);
const data = await response.json();
const thirdPartyExtensions = data.map((ext: any) => {
const githubUrlParts = ext.branch.split("/");
const githubUsername = githubUrlParts[3];
const repoName = githubUrlParts[4];

let installCommand = `npx create-eth@latest -e ${githubUsername}/${repoName}`;

if (githubUrlParts.length > 5) {
const branch = githubUrlParts[6];
installCommand = `${installCommand}:${branch}`;
}

return {
name: ext.name,
description: ext.desc,
github: ext.branch,
installCommand,
builder: ext.builder,
coBuilders: ext.coBuilders || [],
youtube: ext.videoUrl || null,
};
});

// Fetch curated extensions first to use as a filter
const responseCuratedExtensions = await fetch(
"https://raw.githubusercontent.com/scaffold-eth/create-eth/refs/heads/main/src/extensions.json",
);
const dataCuratedExtensions = (await responseCuratedExtensions.json()) as CuratedExtensionResponse;

// Transform curated extensions
const curatedExtensions: Extension[] = dataCuratedExtensions.map(ext => {
const name = ext.name || ext.extensionFlagValue;
const github = ext.branch ? `${ext.repository}/tree/${ext.branch}` : ext.repository;
Expand All @@ -156,6 +133,37 @@ export const getStaticProps: GetStaticProps<ExtensionsListProps> = async () => {
};
});

// Fetch and filter third-party extensions
const response = await fetch(`${BGAPP_API_URL}/builds?type=extension`);
const data = await response.json();

const thirdPartyExtensions = data
.filter(
(ext: any) => !curatedExtensions.find(curated => curated.github.toLowerCase() === ext.branch.toLowerCase()),
)
.map((ext: any) => {
const githubUrlParts = ext.branch.split("/");
const githubUsername = githubUrlParts[3];
const repoName = githubUrlParts[4];

let installCommand = `npx create-eth@latest -e ${githubUsername}/${repoName}`;

if (githubUrlParts.length > 5) {
const branch = githubUrlParts[6];
installCommand = `${installCommand}:${branch}`;
}

return {
name: ext.name,
description: ext.desc,
github: ext.branch,
installCommand,
builder: ext.builder,
coBuilders: ext.coBuilders || [],
youtube: ext.videoUrl || null,
};
});

return {
props: {
thirdPartyExtensions,
Expand Down
Loading