Skip to content

Commit

Permalink
changeset (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
escottalexander authored Oct 1, 2024
2 parents 858d566 + 7ac33d6 commit e11f4b7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-adults-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eth-tech-tree": patch
---

add new reset command
3 changes: 2 additions & 1 deletion src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -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 };
export { setupChallenge, submitChallenge, testChallenge, removeStorage };
13 changes: 13 additions & 0 deletions src/actions/remove-storage.ts
Original file line number Diff line number Diff line change
@@ -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.");
}
7 changes: 6 additions & 1 deletion src/tasks/handle-command.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
}

}
2 changes: 0 additions & 2 deletions src/tasks/parse-command-arguments-and-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e11f4b7

Please sign in to comment.