Ask for router option
758a50e2
4 file(s) · +38 −1
Binary file — no preview.
| 7 | 7 | export async function installPackages( |
|
| 8 | 8 | options: Required<ProjectOptions>, |
|
| 9 | 9 | ): Promise<boolean> { |
|
| 10 | - | const { projectName, rpc, linter, tanstackQuery } = options; |
|
| 10 | + | const { projectName, rpc, router, linter, tanstackQuery } = options; |
|
| 11 | 11 | ||
| 12 | 12 | const projectPath = path.resolve(process.cwd(), projectName); |
|
| 13 | 13 | ||
| 17 | 17 | ||
| 18 | 18 | if (linter === "biome") { |
|
| 19 | 19 | await setupBiome(projectPath); |
|
| 20 | + | } |
|
| 21 | + | ||
| 22 | + | if (router !== "none") { |
|
| 23 | + | switch (router) { |
|
| 24 | + | case "reactrouter": { |
|
| 25 | + | break; |
|
| 26 | + | } |
|
| 27 | + | case: "tanstackrouter": { |
|
| 28 | + | break; |
|
| 29 | + | } |
|
| 30 | + | } |
|
| 20 | 31 | } |
|
| 21 | 32 | ||
| 22 | 33 | if (tanstackQuery) { |
|
| 93 | 93 | linter = linterResponse as "eslint" | "biome"; |
|
| 94 | 94 | } |
|
| 95 | 95 | ||
| 96 | + | let router = options.router; |
|
| 97 | + | ||
| 98 | + | if (!options.yes && !options.router) { |
|
| 99 | + | const { data: routerResponse, error } = await tryCatch( |
|
| 100 | + | consola.prompt("Select a client router:", { |
|
| 101 | + | type: "select", |
|
| 102 | + | options: [ |
|
| 103 | + | { label: "None (default)", value: "none" }, |
|
| 104 | + | { label: "React Router", value: "reactrouter" }, |
|
| 105 | + | { label: "TanStack Router", value: "tanstackrouter" }, |
|
| 106 | + | ], |
|
| 107 | + | initial: "none", |
|
| 108 | + | cancel: "reject", |
|
| 109 | + | }), |
|
| 110 | + | ); |
|
| 111 | + | ||
| 112 | + | if (error) { |
|
| 113 | + | console.log(pc.yellow("Project creation cancelled.")); |
|
| 114 | + | process.exit(1); |
|
| 115 | + | } |
|
| 116 | + | ||
| 117 | + | router = routerResponse as "none" | "reactrouter" | "tanstackrouter"; |
|
| 118 | + | } |
|
| 119 | + | ||
| 96 | 120 | let useTanstackQuery = options.tanstackQuery; |
|
| 97 | 121 | ||
| 98 | 122 | if (!options.yes && !options.tanstackQuery) { |
|
| 122 | 146 | shadcn: templateChoice === "shadcn", |
|
| 123 | 147 | rpc: useRpc, |
|
| 124 | 148 | linter, |
|
| 149 | + | router, |
|
| 125 | 150 | tanstackQuery: useTanstackQuery, |
|
| 126 | 151 | }; |
|
| 127 | 152 | } |
|
| 14 | 14 | shadcn?: boolean; |
|
| 15 | 15 | rpc?: boolean; |
|
| 16 | 16 | linter?: "eslint" | "biome"; |
|
| 17 | + | router?: "none" | "reactrouter" | "tanstackrouter"; |
|
| 17 | 18 | tanstackQuery?: boolean; |
|
| 18 | 19 | }; |
|
| 19 | 20 |