Skip to content

Commit

Permalink
use branch as obj key always
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Nov 22, 2024
1 parent b6b8b99 commit fe162b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
32 changes: 10 additions & 22 deletions src/curated-extensions.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import { ExternalExtension } from "./types";
import extensions from "./extensions.json";

interface ExternalExtensionWithName extends ExternalExtension {
name?: string;
}
const CURATED_EXTENSIONS = extensions.reduce<Record<string, ExternalExtension>>((acc, ext) => {
if (!ext.branch || !ext.repository || !ext.description) {
throw new Error(`Extension missing required fields: ${JSON.stringify(ext)}`);
}

const CURATED_EXTENSIONS: { [key: string]: ExternalExtension } = extensions
.map((extension: ExternalExtensionWithName) => {
let name = extension.name;
if (!name && extension.branch) {
name = extension.branch;
}
if (!name) {
throw new Error("Extension must have a name or branch");
}
return {
[name]: {
repository: extension.repository,
branch: extension.branch,
},
};
})
.reduce((acc, extension) => {
return { ...acc, ...extension };
});
acc[ext.branch] = {
repository: ext.repository,
branch: ext.branch,
};
return acc;
}, {});

export { CURATED_EXTENSIONS };
2 changes: 1 addition & 1 deletion src/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"repository": "https://github.com/scaffold-eth/create-eth-extensions",
"branch": "randao"
}
]
]

0 comments on commit fe162b3

Please sign in to comment.