From a3d956b0493428b97aa9635e9d80e4f3638d3bef Mon Sep 17 00:00:00 2001 From: Rinat Date: Thu, 28 Mar 2024 16:54:43 +0100 Subject: [PATCH] Templatise readme quickstart section (#790) --- templates/base/README.md.template.mjs | 101 +++++++++++++----- .../extensions/foundry/README.md.args.mjs | 47 +------- .../extensions/hardhat/README.md.args.mjs | 47 +------- 3 files changed, 87 insertions(+), 108 deletions(-) diff --git a/templates/base/README.md.template.mjs b/templates/base/README.md.template.mjs index 8e5eb60c3..1ced6039c 100644 --- a/templates/base/README.md.template.mjs +++ b/templates/base/README.md.template.mjs @@ -1,6 +1,68 @@ import { withDefaults } from "../utils.js"; -const contents = ({ solidityFrameWork, quickStart }) => +const getQuickStart = ({ + solidityFramework, + networkConfigPath, + contractsPath, + scriptsPath, + testCommand, +}) => `## Quickstart + +To get started with Scaffold-ETH 2, follow the steps below: + +1. Install dependencies if it was skipped in CLI: + +\`\`\` +cd my-dapp-example +yarn install +\`\`\` + +${ + Boolean(solidityFramework[0]) + ? `2. Run a local network in the first terminal: + +\`\`\` +yarn chain +\`\`\` + +This command starts a local Ethereum network using ${solidityFramework[0]}. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in ${networkConfigPath[0]}. + +3. On a second terminal, deploy the test contract: + +\`\`\` +yarn deploy +\`\`\` + +This command deploys a test smart contract to the local network. The contract is located in ${contractsPath[0]} and can be modified to suit your needs. The \`yarn deploy\` command uses the deploy script located in ${scriptsPath[0]} to deploy the contract to the network. You can also customize the deploy script. + +4. On a third terminal, start your NextJS app:` + : "2. Start your NextJS app:" +} + +\`\`\` +yarn start +\`\`\` + +Visit your app on: \`http://localhost:3000\`. You can interact with your smart contract using the \`Debug Contracts\` page. You can tweak the app config in \`packages/nextjs/scaffold.config.ts\`. +${ + Boolean(solidityFramework[0]) + ? ` +Run smart contract test with ${testCommand[0]} + +- Edit your smart contract \`YourContract.sol\` in ${contractsPath[0]} +- Edit your frontend homepage at \`packages/nextjs/app/page.tsx\`. For guidance on [routing](https://nextjs.org/docs/app/building-your-application/routing/defining-routes) and configuring [pages/layouts](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts) checkout the Next.js documentation. +- Edit your deployment scripts in ${scriptsPath[0]} +` + : "" +}`; + +const contents = ({ + solidityFramework, + networkConfigPath, + contractsPath, + scriptsPath, + testCommand, +}) => `# ๐Ÿ— Scaffold-ETH 2

@@ -11,10 +73,10 @@ const contents = ({ solidityFrameWork, quickStart }) => ๐Ÿงช An open-source, up-to-date toolkit for building decentralized applications (dapps) on the Ethereum blockchain. It's designed to make it easier for developers to create and deploy smart contracts and build user interfaces that interact with those contracts. โš™๏ธ Built using NextJS, RainbowKit, ${ - Boolean(solidityFrameWork[0]) ? solidityFrameWork[0] + ", " : "" + Boolean(solidityFramework[0]) ? solidityFramework[0] + ", " : "" }Wagmi, Viem, and Typescript. ${ - Boolean(solidityFrameWork[0]) + Boolean(solidityFramework[0]) ? "\n- โœ… **Contract Hot Reload**: Your frontend auto-adapts to your smart contract as you edit it." : "" } @@ -33,8 +95,13 @@ Before you begin, you need to install the following tools: - Yarn ([v1](https://classic.yarnpkg.com/en/docs/install/) or [v2+](https://yarnpkg.com/getting-started/install)) - [Git](https://git-scm.com/downloads) -${quickStart[0]} - +${getQuickStart({ + solidityFramework, + networkConfigPath, + contractsPath, + scriptsPath, + testCommand, +})} ## Documentation Visit our [docs](https://docs.scaffoldeth.io) to learn how to start building with Scaffold-ETH 2. @@ -48,23 +115,9 @@ We welcome contributions to Scaffold-ETH 2! Please see [CONTRIBUTING.MD](https://github.com/scaffold-eth/scaffold-eth-2/blob/main/CONTRIBUTING.md) for more information and guidelines for contributing to Scaffold-ETH 2.`; export default withDefaults(contents, { - solidityFrameWork: "", - quickStart: `## Quickstart - -To get started with Scaffold-ETH 2, follow the steps below: - -1. Install dependencies if it was skipped in CLI: - -\`\`\` -cd my-dapp-example -yarn install -\`\`\` - -2. Start your NextJS app: - -\`\`\` -yarn start -\`\`\` - -Visit your app on: \`http://localhost:3000\`. You can interact with your smart contract using the \`Debug Contracts\` page. You can tweak the app config in \`packages/nextjs/scaffold.config.ts\`.`, + solidityFramework: "", + networkConfigPath: "", + contractsPath: "", + scriptsPath: "", + testCommand: "", }); diff --git a/templates/extensions/foundry/README.md.args.mjs b/templates/extensions/foundry/README.md.args.mjs index 4379af638..750d91ae8 100644 --- a/templates/extensions/foundry/README.md.args.mjs +++ b/templates/extensions/foundry/README.md.args.mjs @@ -1,42 +1,5 @@ -export const quickStart = `## Quickstart - -To get started with Scaffold-ETH 2, follow the steps below: - -1. Install dependencies if it was skipped in CLI: - -\`\`\` -cd my-dapp-example -yarn install -\`\`\` - -2. Run a local network in the first terminal: - -\`\`\` -yarn chain -\`\`\` - -This command starts a local Ethereum network using Foundry. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in \`packages/foundry/foundry.toml\`. - -3. On a second terminal, deploy the test contract: - -\`\`\` -yarn deploy -\`\`\` - -This command deploys a test smart contract to the local network. The contract is located in \`packages/foundry/contracts\` and can be modified to suit your needs. The \`yarn deploy\` command uses the deploy script located in \`packages/foundry/script\` to deploy the contract to the network. You can also customize the deploy script. - -4. On a third terminal, start your NextJS app: - -\`\`\` -yarn start -\`\`\` - -Visit your app on: \`http://localhost:3000\`. You can interact with your smart contract using the \`Debug Contracts\` page. You can tweak the app config in \`packages/nextjs/scaffold.config.ts\`. - -Run smart contract test with \`yarn foundry:test\` - -- Edit your smart contract \`YourContract.sol\` in \`packages/foundry/contracts\` -- Edit your frontend homepage at \`packages/nextjs/app/page.tsx\`. For guidance on [routing](https://nextjs.org/docs/app/building-your-application/routing/defining-routes) and configuring [pages/layouts](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts) checkout the Next.js documentation. -- Edit your deployment scripts in \`packages/foundry/script\``; - -export const solidityFrameWork = "Foundry"; +export const solidityFramework = "Foundry"; +export const networkConfigPath = `\`packages/foundry/foundry.toml\``; +export const contractsPath = `\`packages/foundry/contracts\``; +export const scriptsPath = `\`packages/foundry/script\``; +export const testCommand = `\`yarn foundry:test\``; diff --git a/templates/extensions/hardhat/README.md.args.mjs b/templates/extensions/hardhat/README.md.args.mjs index 06da83b51..a390c43e4 100644 --- a/templates/extensions/hardhat/README.md.args.mjs +++ b/templates/extensions/hardhat/README.md.args.mjs @@ -1,42 +1,5 @@ -export const quickStart = `## Quickstart - -To get started with Scaffold-ETH 2, follow the steps below: - -1. Install dependencies if it was skipped in CLI: - -\`\`\` -cd my-dapp-example -yarn install -\`\`\` - -2. Run a local network in the first terminal: - -\`\`\` -yarn chain -\`\`\` - -This command starts a local Ethereum network using Hardhat. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in \`packages/hardhat/hardhat.config.ts\`. - -3. On a second terminal, deploy the test contract: - -\`\`\` -yarn deploy -\`\`\` - -This command deploys a test smart contract to the local network. The contract is located in \`packages/hardhat/contracts\` and can be modified to suit your needs. The \`yarn deploy\` command uses the deploy script located in \`packages/hardhat/deploy\` to deploy the contract to the network. You can also customize the deploy script. - -4. On a third terminal, start your NextJS app: - -\`\`\` -yarn start -\`\`\` - -Visit your app on: \`http://localhost:3000\`. You can interact with your smart contract using the \`Debug Contracts\` page. You can tweak the app config in \`packages/nextjs/scaffold.config.ts\`. - -Run smart contract test with \`yarn hardhat:test\` - -- Edit your smart contract \`YourContract.sol\` in \`packages/hardhat/contracts\` -- Edit your frontend homepage at \`packages/nextjs/app/page.tsx\`. For guidance on [routing](https://nextjs.org/docs/app/building-your-application/routing/defining-routes) and configuring [pages/layouts](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts) checkout the Next.js documentation. -- Edit your deployment scripts in \`packages/hardhat/deploy\``; - -export const solidityFrameWork = "Hardhat"; +export const solidityFramework = "Hardhat"; +export const networkConfigPath = `\`packages/hardhat/hardhat.config.ts\``; +export const contractsPath = `\`packages/hardhat/contracts\``; +export const scriptsPath = `\`packages/hardhat/deploy\``; +export const testCommand = `\`yarn hardhat:test\``;