From 88e49fd67f2344d17aa4c55d04d0d0db2c7fba79 Mon Sep 17 00:00:00 2001 From: moontai0724 Date: Wed, 9 Oct 2024 01:50:39 +0800 Subject: [PATCH] refactor: move get-option(s) out of transformers --- src/{transformers => }/get-option.spec.ts | 12 +++++++----- src/{transformers => }/get-option.ts | 12 +++++++----- src/{transformers => }/get-options.spec.ts | 0 src/{transformers => }/get-options.ts | 0 src/index.ts | 2 ++ src/transformers/index.ts | 2 -- 6 files changed, 16 insertions(+), 12 deletions(-) rename src/{transformers => }/get-option.spec.ts (89%) rename src/{transformers => }/get-option.ts (84%) rename src/{transformers => }/get-options.spec.ts (100%) rename src/{transformers => }/get-options.ts (100%) diff --git a/src/transformers/get-option.spec.ts b/src/get-option.spec.ts similarity index 89% rename from src/transformers/get-option.spec.ts rename to src/get-option.spec.ts index 20c3d8e..7094a29 100644 --- a/src/transformers/get-option.spec.ts +++ b/src/get-option.spec.ts @@ -19,11 +19,13 @@ const getStringOption = vi.fn().mockReturnValue({ type: "mocked" }); let component: typeof import("./get-option"); beforeAll(async () => { - vi.doMock("./array", () => ({ getArrayOption })); - vi.doMock("./boolean", () => ({ getBooleanOption })); - vi.doMock("./choice", () => ({ getChoiceOption })); - vi.doMock("./number", () => ({ getNumberOption })); - vi.doMock("./string", () => ({ getStringOption })); + vi.doMock("./transformers", () => ({ + getArrayOption, + getBooleanOption, + getChoiceOption, + getNumberOption, + getStringOption, + })); component = await import("./get-option"); }); diff --git a/src/transformers/get-option.ts b/src/get-option.ts similarity index 84% rename from src/transformers/get-option.ts rename to src/get-option.ts index da3df64..ce44b37 100644 --- a/src/transformers/get-option.ts +++ b/src/get-option.ts @@ -10,11 +10,13 @@ import { } from "@sinclair/typebox"; import type { Options } from "yargs"; -import { getArrayOption } from "./array"; -import { getBooleanOption } from "./boolean"; -import { getChoiceOption } from "./choice"; -import { getNumberOption } from "./number"; -import { getStringOption } from "./string"; +import { + getArrayOption, + getBooleanOption, + getChoiceOption, + getNumberOption, + getStringOption, +} from "./transformers"; export function getOption( schema: T, diff --git a/src/transformers/get-options.spec.ts b/src/get-options.spec.ts similarity index 100% rename from src/transformers/get-options.spec.ts rename to src/get-options.spec.ts diff --git a/src/transformers/get-options.ts b/src/get-options.ts similarity index 100% rename from src/transformers/get-options.ts rename to src/get-options.ts diff --git a/src/index.ts b/src/index.ts index a8401e8..b179045 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,3 @@ +export * from "./get-option"; +export * from "./get-options"; export * from "./transformers"; diff --git a/src/transformers/index.ts b/src/transformers/index.ts index b8e3d50..53793e5 100644 --- a/src/transformers/index.ts +++ b/src/transformers/index.ts @@ -1,7 +1,5 @@ export * from "./array"; export * from "./boolean"; export * from "./choice"; -export * from "./get-option"; -export * from "./get-options"; export * from "./number"; export * from "./string";