diff --git a/src/executable/TypiaSetupWizard.ts b/src/executable/TypiaSetupWizard.ts index 58d879c582..40c2a526d0 100644 --- a/src/executable/TypiaSetupWizard.ts +++ b/src/executable/TypiaSetupWizard.ts @@ -1,5 +1,4 @@ import fs from "fs"; -import path from "path"; import { DetectResult, detect } from "package-manager-detector"; import { ArgumentParser } from "./setup/ArgumentParser"; @@ -7,15 +6,13 @@ import { CommandExecutor } from "./setup/CommandExecutor"; import { PackageManager } from "./setup/PackageManager"; import { PluginConfigurator } from "./setup/PluginConfigurator"; -const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "../../package.json"), "utf-8")); - export namespace TypiaSetupWizard { export interface IArguments { manager: "npm" | "pnpm" | "yarn" | "bun"; project: string | null; } - export async function setup(): Promise { + export const setup = async (): Promise => { console.log("----------------------------------------"); console.log(" Typia Setup Wizard"); console.log("----------------------------------------"); @@ -25,7 +22,11 @@ export namespace TypiaSetupWizard { const args: IArguments = await ArgumentParser.parse(pack)(inquiry); // INSTALL TYPESCRIPT COMPILERS - pack.install({ dev: true, modulo: "typescript", version: pkg.devDependencies.typescript as string }); + pack.install({ + dev: true, + modulo: "typescript", + version: await getTypeScriptVersion(), + }); pack.install({ dev: true, modulo: "ts-patch", version: "latest" }); args.project ??= (() => { const runner: string = pack.manager === "npm" ? "npx" : pack.manager; @@ -71,7 +72,7 @@ export namespace TypiaSetupWizard { // CONFIGURE TYPIA await PluginConfigurator.configure(args); CommandExecutor.run(`${pack.manager} run prepare`); - } + }; const inquiry: ArgumentParser.Inquiry = async ( pack, @@ -160,4 +161,14 @@ export namespace TypiaSetupWizard { if (result?.name === "npm") return null; // NPM case is still selectable return result?.name ?? null; }; + + const getTypeScriptVersion = async (): Promise => { + const content: string = await fs.promises.readFile( + `${__dirname}/package.json`, + "utf-8", + ); + const json: { devDependencies: { typescript: string } } = + JSON.parse(content); + return json.devDependencies.typescript; + }; }