| 1 | import type { ProjectOptions } from "@/types"; |
| 2 | import { setupBiome } from "./setup-biome"; |
| 3 | import path from "node:path"; |
| 4 | import { tanstackQueryInstaller } from "@/installers/tanstack-query"; |
| 5 | import { rpcInstaller } from "@/installers/rpc"; |
| 6 | import { reactRouterInstaller } from "@/installers/react-router"; |
| 7 | import { reactRouterMpaInstaller } from "@/installers/react-router-mpa"; |
| 8 | import { tanstackRouterInstaller } from "@/installers/tanstack-router"; |
| 9 | |
| 10 | export async function installPackages( |
| 11 | options: Required<ProjectOptions>, |
| 12 | ): Promise<boolean> { |
| 13 | const { projectName, rpc, router, linter, tanstackQuery } = options; |
| 14 | |
| 15 | const projectPath = path.resolve(process.cwd(), projectName); |
| 16 | |
| 17 | if (rpc) { |
| 18 | await rpcInstaller(options); |
| 19 | } |
| 20 | |
| 21 | if (linter === "biome") { |
| 22 | await setupBiome(projectPath); |
| 23 | } |
| 24 | |
| 25 | if (tanstackQuery) { |
| 26 | await tanstackQueryInstaller(options); |
| 27 | } |
| 28 | |
| 29 | if (router !== "none") { |
| 30 | switch (router) { |
| 31 | case "reactrouter": { |
| 32 | await reactRouterInstaller(options); |
| 33 | break; |
| 34 | } |
| 35 | case "reactroutermpa": { |
| 36 | await reactRouterMpaInstaller(options); |
| 37 | break; |
| 38 | } |
| 39 | case "tanstackrouter": { |
| 40 | await tanstackRouterInstaller(options); |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | return false; |
| 47 | } |