Skip to content

Commit a439b46

Browse files
authored
Merge pull request #143 from alchemyplatform/dn/use-scaffold-chain
feat: use scaffold alchemy chain for yarn chain
2 parents 8810f73 + eb71a20 commit a439b46

File tree

7 files changed

+149
-345
lines changed

7 files changed

+149
-345
lines changed

index.js

Lines changed: 7 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@
33
import chalk from "chalk";
44
import inquirer from "inquirer";
55
import { Command } from "commander";
6-
import {
7-
setupProjectDirectory,
8-
isInsideScaffoldAlchemyProject,
9-
updateProjectConfig,
10-
} from "./src/utils/directory.js";
6+
import { setupProjectDirectory } from "./src/utils/setup-project.js";
7+
import { setupChain } from "./src/utils/setup-chain.js";
118
import { logo } from "./src/utils/ascii-art.js";
12-
import {
13-
projectNamePrompt,
14-
chainPrompt,
15-
VALID_CHAINS,
16-
} from "./src/prompts/project-prompts.js";
9+
import { projectNamePrompt } from "./src/prompts/project-prompts.js";
1710
import { printOutroMessage } from "./src/utils/outro.js";
1811
import { checkNodeVersion } from "./src/utils/version-check.js";
1912

@@ -25,70 +18,20 @@ program
2518

2619
const options = program.opts();
2720

28-
async function getChain() {
29-
let chain = getChainOption();
30-
if (!chain) {
31-
const chainAnswer = await inquirer.prompt([chainPrompt]);
32-
chain = chainAnswer.chain;
33-
}
34-
return chain;
35-
}
36-
37-
function getChainOption() {
38-
if (options.chain && !VALID_CHAINS.includes(options.chain)) {
39-
console.error(
40-
chalk.red(
41-
`Error: Invalid chain "${
42-
options.chain
43-
}". Valid chains are: ${VALID_CHAINS.join(", ")}`
44-
)
45-
);
46-
process.exit(1);
47-
}
48-
49-
return options.chain;
50-
}
51-
52-
async function handleExistingProject() {
53-
const chain = await getChain();
54-
console.log(
55-
chalk.green(
56-
`\nUpdating chain configuration to ${chalk.bold(chain)}...\n`
57-
)
58-
);
59-
updateProjectConfig(chain);
60-
console.log(chalk.green("Chain configuration updated successfully!"));
61-
}
62-
6321
async function handleNewProject() {
6422
console.log(chalk.blue(logo));
6523

6624
const { projectName } = await inquirer.prompt([projectNamePrompt]);
6725

68-
const chain = await getChain();
26+
const { projectDir } = await setupProjectDirectory(projectName, inquirer);
27+
28+
await setupChain(projectDir, options);
6929

70-
const { projectDir } = await setupProjectDirectory(
71-
projectName,
72-
chain,
73-
inquirer
74-
);
75-
console.log(
76-
chalk.green(
77-
`\nCreating a new web3 dapp in ${chalk.bold(
78-
projectDir
79-
)} using ${chalk.bold(chain)} chain...\n`
80-
)
81-
);
8230
await printOutroMessage(projectName);
8331
}
8432

8533
async function main() {
86-
if (isInsideScaffoldAlchemyProject()) {
87-
await handleExistingProject();
88-
} else {
89-
await handleNewProject();
90-
}
91-
34+
await handleNewProject();
9235
checkNodeVersion();
9336
}
9437

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-web3-dapp",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"keywords": [
55
"create-web3-dapp",
66
"create web3 dapp",

src/config/chains.js

Lines changed: 0 additions & 112 deletions
This file was deleted.

src/prompts/project-prompts.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import chalk from "chalk";
2-
import { CHAIN_CONFIGS, VALID_CHAINS } from "../config/chains.js";
3-
41
export const projectNamePrompt = {
52
type: "input",
63
name: "projectName",
@@ -11,15 +8,3 @@ export const projectNamePrompt = {
118
return "Project name may only include letters, numbers, underscores and hashes.";
129
},
1310
};
14-
15-
export const chainPrompt = {
16-
type: "list",
17-
name: "chain",
18-
message: "Which chain would you like to use?",
19-
choices: CHAIN_CONFIGS.map((chain) => ({
20-
name: chalk[chain.color](chain.displayName),
21-
value: chain.shortName,
22-
})),
23-
};
24-
25-
export { VALID_CHAINS };

src/utils/directory.js

Lines changed: 0 additions & 153 deletions
This file was deleted.

0 commit comments

Comments
 (0)