forked from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6b8b99
commit fe162b3
Showing
2 changed files
with
11 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,4 @@ | |
"repository": "https://github.com/scaffold-eth/create-eth-extensions", | ||
"branch": "randao" | ||
} | ||
] | ||
] |