diff --git a/.changeset/cyan-adults-exercise.md b/.changeset/cyan-adults-exercise.md new file mode 100644 index 0000000..9616114 --- /dev/null +++ b/.changeset/cyan-adults-exercise.md @@ -0,0 +1,5 @@ +--- +"eth-tech-tree": patch +--- + +add new reset command diff --git a/src/actions/index.ts b/src/actions/index.ts index f0ec1c2..ecaa3b6 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -1,5 +1,6 @@ import { setupChallenge } from "./setup-challenge"; import { submitChallenge } from "./submit-challenge"; import { testChallenge } from "./test-challenge"; +import { removeStorage } from "./remove-storage"; -export { setupChallenge, submitChallenge, testChallenge }; \ No newline at end of file +export { setupChallenge, submitChallenge, testChallenge, removeStorage }; \ No newline at end of file diff --git a/src/actions/remove-storage.ts b/src/actions/remove-storage.ts new file mode 100644 index 0000000..f1bea4f --- /dev/null +++ b/src/actions/remove-storage.ts @@ -0,0 +1,13 @@ +import fs from "fs"; +import path from "path"; + +export function removeStorage() { + console.log("Resetting storage..."); + const configPath = path.join(process.cwd(), "storage"); + if (!fs.existsSync(configPath)) { + console.log("Storage does not exist. Nothing to reset."); + return; + } + fs.rmSync(configPath, { recursive: true }); + console.log("Storage reset successfully."); +} \ No newline at end of file diff --git a/src/tasks/handle-command.ts b/src/tasks/handle-command.ts index 295ace9..16d262d 100644 --- a/src/tasks/handle-command.ts +++ b/src/tasks/handle-command.ts @@ -1,5 +1,5 @@ import { CommandOptions } from "./parse-command-arguments-and-options"; -import { setupChallenge, submitChallenge } from "../actions"; +import { removeStorage, setupChallenge, submitChallenge } from "../actions"; export async function handleCommand(commands: CommandOptions) { const { command, installLocation, challenge, contractAddress, dev, help } = commands; @@ -17,4 +17,9 @@ export async function handleCommand(commands: CommandOptions) { await submitChallenge(challenge as string, contractAddress as string); } + if (command === "reset") { + // Delete the storage files + removeStorage(); + } + } \ No newline at end of file diff --git a/src/tasks/parse-command-arguments-and-options.ts b/src/tasks/parse-command-arguments-and-options.ts index 3237cc0..4967c07 100644 --- a/src/tasks/parse-command-arguments-and-options.ts +++ b/src/tasks/parse-command-arguments-and-options.ts @@ -5,8 +5,6 @@ import inquirer from "inquirer"; import { isValidAddress } from "../utils/helpers"; import { promptForMissingUserState } from "./prompt-for-missing-user-state"; -// End goal it to be able to trigger tasks based on the commands and options sent in. -// eth-tech-tree setup token-wrapper-weth type Commands = { setup: SetupCommand; submit: SubmitCommand;