Skip to content

Commit

Permalink
Removed Foundry support (for now). Changed the cli welcome message.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkomelin committed Mar 29, 2024
1 parent 3834fce commit d54624e
Show file tree
Hide file tree
Showing 29 changed files with 13 additions and 924 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"bin": "bin/create-dapp-se2.js",
"scripts": {
"build": "rollup -c rollup.config.js",
"build-run": "yarn build && yarn cli",
"dev": "rollup -c rollup.config.js --watch",
"cli": "node bin/create-dapp-se2.js",
"test": "echo \"Error: no test specified\" && exit 1",
Expand All @@ -22,7 +23,6 @@
"scaffold-eth 2",
"wagmi",
"hardhat",
"foundry",
"viem",
"rainbowkit"
],
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config: Config = {
type: "single-select",
name: "solidity-framework",
message: "What solidity framework do you want to use?",
extensions: ["hardhat", "foundry", null],
extensions: ["hardhat", null],
default: "hardhat",
}),
],
Expand Down
14 changes: 6 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import chalk from "chalk";
import Listr from "listr";
import path from "path";
import { fileURLToPath } from "url";
import {
copyTemplateFiles,
createFirstGitCommit,
createProjectDirectory,
installPackages,
createFirstGitCommit,
prettierFormat,
} from "./tasks";
import type { Options } from "./types";
import { renderOutroMessage } from "./utils/render-outro-message";
import chalk from "chalk";
import Listr from "listr";
import path from "path";
import { fileURLToPath } from "url";

export async function createProject(options: Options) {
console.log(`\n`);
Expand Down Expand Up @@ -55,9 +55,7 @@ export async function createProject(options: Options) {
},
},
{
title: `📡 Initializing Git repository ${
options.extensions.includes("foundry") ? "and submodules" : ""
}`,
title: `📡 Initializing Git repository`,
task: () => createFirstGitCommit(targetDirectory, options),
},
]);
Expand Down
63 changes: 1 addition & 62 deletions src/tasks/create-first-git-commit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { execa } from "execa";
import { Options } from "../types";
import path from "path";

// Checkout the latest release tag in a git submodule
async function checkoutLatestTag(submodulePath: string): Promise<void> {
Expand All @@ -26,73 +25,13 @@ export async function createFirstGitCommit(
options: Options
) {
try {
// TODO: Move the logic for adding submodules to tempaltes
if (options.extensions?.includes("foundry")) {
const foundryWorkSpacePath = path.resolve(
targetDir,
"packages",
"foundry"
);
await execa(
"git",
[
"submodule",
"add",
"https://github.com/foundry-rs/forge-std",
"lib/forge-std",
],
{
cwd: foundryWorkSpacePath,
}
);
await execa(
"git",
[
"submodule",
"add",
"https://github.com/OpenZeppelin/openzeppelin-contracts",
"lib/openzeppelin-contracts",
],
{
cwd: foundryWorkSpacePath,
}
);
await execa(
"git",
[
"submodule",
"add",
"https://github.com/gnsps/solidity-bytes-utils",
"lib/solidity-bytes-utils",
],
{
cwd: foundryWorkSpacePath,
}
);
await execa("git", ["submodule", "update", "--init", "--recursive"], {
cwd: foundryWorkSpacePath,
});
await checkoutLatestTag(
path.resolve(foundryWorkSpacePath, "lib", "forge-std")
);
await checkoutLatestTag(
path.resolve(foundryWorkSpacePath, "lib", "openzeppelin-contracts")
);
}

// TODO: Move the logic for adding submodules to templates
await execa("git", ["add", "-A"], { cwd: targetDir });
await execa(
"git",
["commit", "-m", "Initial commit with 🏗️ Scaffold-ETH 2", "--no-verify"],
{ cwd: targetDir }
);

// Update the submodule, since we have checked out the latest tag in the previous step of foundry
if (options.extensions?.includes("foundry")) {
await execa("git", ["submodule", "update", "--init", "--recursive"], {
cwd: path.resolve(targetDir, "packages", "foundry"),
});
}
} catch (e: any) {
// cast error as ExecaError to get stderr

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type Options = NonNullableRawOptions;

export type Extension =
| "hardhat"
| "foundry"

type NullExtension = null;
export type ExtensionOrNull = Extension | NullExtension;
// corresponds to inquirer question types:
Expand Down
2 changes: 1 addition & 1 deletion src/utils/render-intro-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from "chalk";

export const TITLE_TEXT = `
${chalk.bold.blue("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+")}
${chalk.bold.blue("| Create Scaffold-ETH 2 app |")}
${chalk.bold.blue("| Create Fhenix DApp |")}
${chalk.bold.blue("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+")}
`;

Expand Down
21 changes: 2 additions & 19 deletions src/utils/render-outro-message.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Options } from "../types";
import chalk from "chalk";
import { execa } from "execa";
import type { Options } from "../types";

export async function renderOutroMessage(options: Options) {
let message = `
Expand All @@ -12,28 +11,12 @@ export async function renderOutroMessage(options: Options) {
${chalk.dim("cd")} ${options.project}
`;

if (
options.extensions.includes("hardhat") ||
options.extensions.includes("foundry")
) {
if (options.extensions.includes("hardhat")) {
message += `
\t${chalk.bold("Start the local development node")}
\t${chalk.dim("yarn")} chain
`;

if (options.extensions.includes("foundry")) {
try {
await execa("foundryup", ["-h"]);
} catch (error) {
message += `
\t${chalk.bold.yellow(
"(NOTE: Foundryup is not installed in your system)"
)}
\t${chalk.dim("Checkout: https://getfoundry.sh")}
`;
}
}

message += `
\t${chalk.bold("In a new terminal window, deploy your contracts")}
\t${chalk.dim("yarn")} deploy
Expand Down
15 changes: 0 additions & 15 deletions templates/extensions/foundry/.vercelignore.args.mjs

This file was deleted.

5 changes: 0 additions & 5 deletions templates/extensions/foundry/README.md.args.mjs

This file was deleted.

18 changes: 0 additions & 18 deletions templates/extensions/foundry/package.json

This file was deleted.

3 changes: 0 additions & 3 deletions templates/extensions/foundry/packages/foundry/.env.example

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions templates/extensions/foundry/packages/foundry/.prettier.json

This file was deleted.

This file was deleted.

Loading

0 comments on commit d54624e

Please sign in to comment.