Skip to content

Commit 84c1dfa

Browse files
vplasenciacedoor
authored andcommitted
refactor(cli): change cli template names
1 parent ee6e1c1 commit 84c1dfa

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

packages/cli/src/index.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,20 @@ const { description, version } = JSON.parse(readFileSync(`${packagePath}/package
1717

1818
const supportedNetworks = ["sepolia", "goerli", "mumbai", "optimism-goerli", "arbitrum", "arbitrum-goerli"]
1919

20-
const supportedTemplates = ["hardhat", "hardhat-nextjs-semaphoreethers", "hardhat-nextjs-semaphoresubgraph"]
20+
const supportedTemplates = [
21+
{
22+
value: "contracts-hardhat",
23+
name: "Hardhat"
24+
},
25+
{
26+
value: "monorepo-ethers",
27+
name: "Hardhat + Next.js + SemaphoreEthers"
28+
},
29+
{
30+
value: "monorepo-subgraph",
31+
name: "Hardhat + Next.js + SemaphoreSubgraph"
32+
}
33+
]
2134

2235
program
2336
.name("semaphore")
@@ -48,7 +61,7 @@ program
4861
template = await getSupportedTemplate(supportedTemplates)
4962
}
5063

51-
if (!supportedTemplates.includes(template)) {
64+
if (!supportedTemplates.some((t) => t.value === template)) {
5265
console.info(`\n ${logSymbols.error}`, `error: the template '${template}' is not supported\n`)
5366
return
5467
}

packages/cli/src/inquirerPrompts.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ export async function getProjectName() {
1010
return projectName
1111
}
1212

13-
export async function getSupportedTemplate(supportedTemplates: string[]) {
13+
export async function getSupportedTemplate(supportedTemplates: { value: string; name: string }[]) {
1414
const { selectedTemplate } = await inquirer.prompt({
1515
name: "selectedTemplate",
1616
type: "list",
1717
message: "Select one of the supported templates:",
18-
default: supportedTemplates[0],
19-
choices: supportedTemplates
18+
default: 0,
19+
choices: supportedTemplates.map((template) => ({
20+
value: template.value,
21+
name: `${template.value} (${template.name})`
22+
}))
2023
})
2124
return selectedTemplate
2225
}
@@ -26,7 +29,7 @@ export async function getSupportedNetwork(supportedNetworks: string[]) {
2629
name: "selectedNetwork",
2730
type: "list",
2831
message: "Select one of the supported networks:",
29-
default: supportedNetworks[0],
32+
default: 0,
3033
choices: supportedNetworks
3134
})
3235
return selectedNetwork
@@ -37,6 +40,7 @@ export async function getGroupId(groupIds: string[]) {
3740
name: "selectedGroupId",
3841
type: "list",
3942
message: "Select one of the following existing group ids:",
43+
default: 0,
4044
choices: groupIds
4145
})
4246

0 commit comments

Comments
 (0)