From bad715ee1a6378d062ae99f3277be03e3ad48c9a Mon Sep 17 00:00:00 2001 From: Rinat Date: Tue, 18 Jun 2024 15:32:20 +0200 Subject: [PATCH 1/5] feat: solidity frameworks --- src/config.ts | 2 +- src/main.ts | 2 +- src/types.ts | 22 ++++++++++++++++------ src/utils/parse-arguments-into-options.ts | 22 +++++++++++++++++++++- src/utils/prompt-for-missing-options.ts | 14 ++++---------- 5 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/config.ts b/src/config.ts index 08f152685..e886da234 100644 --- a/src/config.ts +++ b/src/config.ts @@ -4,7 +4,7 @@ const config: Config = { questions: [ typedQuestion({ type: "single-select", - name: "solidity-framework", + name: "solidityFramework", message: "What solidity framework do you want to use?", extensions: ["hardhat", "foundry", null], default: "hardhat", diff --git a/src/main.ts b/src/main.ts index 9f3f78f68..8c7748564 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,7 +55,7 @@ export async function createProject(options: Options) { }, }, { - title: `📡 Initializing Git repository ${options.extensions.includes("foundry") ? "and submodules" : ""}`, + title: `📡 Initializing Git repository${options.extensions.includes("foundry") ? " and submodules" : ""}`, task: () => createFirstGitCommit(targetDirectory, options), }, ], diff --git a/src/types.ts b/src/types.ts index 28d46d907..918db8672 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,11 +2,10 @@ import type { Question } from "inquirer"; export type Args = string[]; -export type RawOptions = { +type BaseOptions = { project: string | null; install: boolean | null; dev: boolean; - extensions: Extension[] | null; externalExtension: ExternalExtension | null; }; @@ -15,15 +14,26 @@ export type ExternalExtension = { branch?: string | null; }; -type NonNullableRawOptions = { - [Prop in keyof Omit]: NonNullable; +export type RawOptions = BaseOptions & { + solidityFramework: SolidityFramework | "none" | null; +}; + +type MergedOptions = BaseOptions & { + extensions: Extension[]; +}; + +type NonNullableMergedOptions = { + [Prop in keyof Omit]: NonNullable; } & { externalExtension: RawOptions["externalExtension"]; }; -export type Options = NonNullableRawOptions; +export type Options = NonNullableMergedOptions; + +export type SolidityFramework = "hardhat" | "foundry"; + +export type Extension = SolidityFramework; -export type Extension = "hardhat" | "foundry"; type NullExtension = null; export type ExtensionOrNull = Extension | NullExtension; // corresponds to inquirer question types: diff --git a/src/utils/parse-arguments-into-options.ts b/src/utils/parse-arguments-into-options.ts index 59159d452..10f3a8f07 100644 --- a/src/utils/parse-arguments-into-options.ts +++ b/src/utils/parse-arguments-into-options.ts @@ -39,6 +39,9 @@ export async function parseArgumentsIntoOptions(rawArgs: Args): Promise Boolean(ext) && ext !== "none"), externalExtension: options.externalExtension, }; - config.questions.forEach(question => { - const { name } = question; - const choice: Extension[] = [answers[name]].flat().filter(isDefined); - mergedOptions.extensions.push(...choice); - }); - return mergedOptions; } From f5ffb559d65a720bc364432d5a538c4f31f7bb8c Mon Sep 17 00:00:00 2001 From: Rinat Date: Wed, 19 Jun 2024 13:43:59 +0200 Subject: [PATCH 2/5] fix: change condition --- src/utils/parse-arguments-into-options.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/parse-arguments-into-options.ts b/src/utils/parse-arguments-into-options.ts index 10f3a8f07..ace89f5ea 100644 --- a/src/utils/parse-arguments-into-options.ts +++ b/src/utils/parse-arguments-into-options.ts @@ -1,4 +1,4 @@ -import type { Args, RawOptions } from "../types"; +import type { Args, RawOptions, SolidityFramework } from "../types"; import arg from "arg"; import * as https from "https"; import { getDataFromExternalExtensionArgument } from "./external-extensions"; @@ -88,10 +88,12 @@ export async function parseArgumentsIntoOptions(rawArgs: Args): Promise Date: Wed, 19 Jun 2024 14:40:52 +0200 Subject: [PATCH 3/5] chore: changeset --- .changeset/silver-fishes-marry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/silver-fishes-marry.md diff --git a/.changeset/silver-fishes-marry.md b/.changeset/silver-fishes-marry.md new file mode 100644 index 000000000..ebc6a1e33 --- /dev/null +++ b/.changeset/silver-fishes-marry.md @@ -0,0 +1,5 @@ +--- +"create-eth": patch +--- + +cli: solidity framework options From 56f2fff796c2c96524661fd641029960542b70fe Mon Sep 17 00:00:00 2001 From: Rinat Date: Wed, 19 Jun 2024 17:29:57 +0200 Subject: [PATCH 4/5] chore: remove todo --- src/utils/parse-arguments-into-options.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/parse-arguments-into-options.ts b/src/utils/parse-arguments-into-options.ts index ace89f5ea..1b68e5695 100644 --- a/src/utils/parse-arguments-into-options.ts +++ b/src/utils/parse-arguments-into-options.ts @@ -66,7 +66,6 @@ export async function parseArgumentsIntoOptions(rawArgs: Args): Promise Date: Wed, 19 Jun 2024 18:06:50 +0200 Subject: [PATCH 5/5] fix: change -f to -s --- src/utils/parse-arguments-into-options.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/parse-arguments-into-options.ts b/src/utils/parse-arguments-into-options.ts index 1b68e5695..4bf2be80e 100644 --- a/src/utils/parse-arguments-into-options.ts +++ b/src/utils/parse-arguments-into-options.ts @@ -35,12 +35,11 @@ export async function parseArgumentsIntoOptions(rawArgs: Args): Promise