style: run formatter fixes (biome)\n\n๐ค Generated with [opencode](https://opencode.ai)\n\nCo-Authored-By: opencode <noreply@opencode.ai>
d699e4b9
2 file(s) ยท +103 โ103
| 10 | 10 | import { execa } from "execa"; |
|
| 11 | 11 | ||
| 12 | 12 | export const tanstackRouterInstaller = async ( |
|
| 13 | - | options: Required<ProjectOptions>, |
|
| 13 | + | options: Required<ProjectOptions>, |
|
| 14 | 14 | ): Promise<boolean> => { |
|
| 15 | - | const spinner = yoctoSpinner({ |
|
| 16 | - | text: "Setting up TanStack Router...", |
|
| 17 | - | }).start(); |
|
| 15 | + | const spinner = yoctoSpinner({ |
|
| 16 | + | text: "Setting up TanStack Router...", |
|
| 17 | + | }).start(); |
|
| 18 | 18 | ||
| 19 | - | try { |
|
| 20 | - | const { projectName, rpc, shadcn, tailwind, tanstackQuery } = options; |
|
| 19 | + | try { |
|
| 20 | + | const { projectName, rpc, shadcn, tailwind, tanstackQuery } = options; |
|
| 21 | 21 | ||
| 22 | - | const projectPath = path.resolve(process.cwd(), projectName); |
|
| 23 | - | spinner.text = "Installing TanStack Router..."; |
|
| 24 | - | await addPackageDependency({ |
|
| 25 | - | dependencies: [ |
|
| 26 | - | "@tanstack/react-router", |
|
| 27 | - | "@tanstack/react-router-devtools", |
|
| 28 | - | ], |
|
| 29 | - | target: "client", |
|
| 30 | - | projectName, |
|
| 31 | - | }); |
|
| 22 | + | const projectPath = path.resolve(process.cwd(), projectName); |
|
| 23 | + | spinner.text = "Installing TanStack Router..."; |
|
| 24 | + | await addPackageDependency({ |
|
| 25 | + | dependencies: [ |
|
| 26 | + | "@tanstack/react-router", |
|
| 27 | + | "@tanstack/react-router-devtools", |
|
| 28 | + | ], |
|
| 29 | + | target: "client", |
|
| 30 | + | projectName, |
|
| 31 | + | }); |
|
| 32 | 32 | ||
| 33 | - | await addPackageDependency({ |
|
| 34 | - | dependencies: ["@tanstack/router-plugin"], |
|
| 35 | - | devMode: true, |
|
| 36 | - | target: "client", |
|
| 37 | - | projectName, |
|
| 38 | - | }); |
|
| 33 | + | await addPackageDependency({ |
|
| 34 | + | dependencies: ["@tanstack/router-plugin"], |
|
| 35 | + | devMode: true, |
|
| 36 | + | target: "client", |
|
| 37 | + | projectName, |
|
| 38 | + | }); |
|
| 39 | 39 | ||
| 40 | - | const viteConfigTemplate = nameGenerator("vite.config.ts", { |
|
| 41 | - | tailwind, |
|
| 42 | - | shadcn, |
|
| 43 | - | tanstackRouter: true, |
|
| 44 | - | }); |
|
| 45 | - | const viteConfigSrc = path.join( |
|
| 46 | - | EXTRAS_DIR, |
|
| 47 | - | "client", |
|
| 48 | - | "vite.config.ts", |
|
| 49 | - | viteConfigTemplate, |
|
| 50 | - | ); |
|
| 51 | - | const viteConfigTarget = path.join(projectPath, "client", "vite.config.ts"); |
|
| 52 | - | fs.copySync(viteConfigSrc, viteConfigTarget); |
|
| 40 | + | const viteConfigTemplate = nameGenerator("vite.config.ts", { |
|
| 41 | + | tailwind, |
|
| 42 | + | shadcn, |
|
| 43 | + | tanstackRouter: true, |
|
| 44 | + | }); |
|
| 45 | + | const viteConfigSrc = path.join( |
|
| 46 | + | EXTRAS_DIR, |
|
| 47 | + | "client", |
|
| 48 | + | "vite.config.ts", |
|
| 49 | + | viteConfigTemplate, |
|
| 50 | + | ); |
|
| 51 | + | const viteConfigTarget = path.join(projectPath, "client", "vite.config.ts"); |
|
| 52 | + | fs.copySync(viteConfigSrc, viteConfigTarget); |
|
| 53 | 53 | ||
| 54 | - | const rootTsxSrc = path.join( |
|
| 55 | - | EXTRAS_DIR, |
|
| 56 | - | "client", |
|
| 57 | - | "src", |
|
| 58 | - | "routes", |
|
| 59 | - | "__root.tsx", |
|
| 60 | - | ); |
|
| 61 | - | const rootTsxTarget = path.join( |
|
| 62 | - | projectPath, |
|
| 63 | - | "client", |
|
| 64 | - | "src", |
|
| 65 | - | "routes", |
|
| 66 | - | "__root.tsx", |
|
| 67 | - | ); |
|
| 68 | - | fs.copySync(rootTsxSrc, rootTsxTarget); |
|
| 54 | + | const rootTsxSrc = path.join( |
|
| 55 | + | EXTRAS_DIR, |
|
| 56 | + | "client", |
|
| 57 | + | "src", |
|
| 58 | + | "routes", |
|
| 59 | + | "__root.tsx", |
|
| 60 | + | ); |
|
| 61 | + | const rootTsxTarget = path.join( |
|
| 62 | + | projectPath, |
|
| 63 | + | "client", |
|
| 64 | + | "src", |
|
| 65 | + | "routes", |
|
| 66 | + | "__root.tsx", |
|
| 67 | + | ); |
|
| 68 | + | fs.copySync(rootTsxSrc, rootTsxTarget); |
|
| 69 | 69 | ||
| 70 | - | const indexTsxSrc = path.join( |
|
| 71 | - | EXTRAS_DIR, |
|
| 72 | - | "client", |
|
| 73 | - | "src", |
|
| 74 | - | "routes", |
|
| 75 | - | "index.tsx", |
|
| 76 | - | nameGenerator("index.tsx", { tanstackQuery, tailwind, shadcn, rpc }), |
|
| 77 | - | ); |
|
| 78 | - | const indexTsxTarget = path.join( |
|
| 79 | - | projectPath, |
|
| 80 | - | "client", |
|
| 81 | - | "src", |
|
| 82 | - | "routes", |
|
| 83 | - | "index.tsx", |
|
| 84 | - | ); |
|
| 85 | - | fs.copySync(indexTsxSrc, indexTsxTarget); |
|
| 70 | + | const indexTsxSrc = path.join( |
|
| 71 | + | EXTRAS_DIR, |
|
| 72 | + | "client", |
|
| 73 | + | "src", |
|
| 74 | + | "routes", |
|
| 75 | + | "index.tsx", |
|
| 76 | + | nameGenerator("index.tsx", { tanstackQuery, tailwind, shadcn, rpc }), |
|
| 77 | + | ); |
|
| 78 | + | const indexTsxTarget = path.join( |
|
| 79 | + | projectPath, |
|
| 80 | + | "client", |
|
| 81 | + | "src", |
|
| 82 | + | "routes", |
|
| 83 | + | "index.tsx", |
|
| 84 | + | ); |
|
| 85 | + | fs.copySync(indexTsxSrc, indexTsxTarget); |
|
| 86 | 86 | ||
| 87 | - | const mainTsxSrc = path.join( |
|
| 88 | - | EXTRAS_DIR, |
|
| 89 | - | "client", |
|
| 90 | - | "src", |
|
| 91 | - | "main.tsx", |
|
| 92 | - | nameGenerator("main.tsx", { tanstackQuery, tanstackRouter: true }), |
|
| 93 | - | ); |
|
| 94 | - | const mainTsxTarget = path.join(projectPath, "client", "src", "main.tsx"); |
|
| 95 | - | fs.copySync(mainTsxSrc, mainTsxTarget); |
|
| 87 | + | const mainTsxSrc = path.join( |
|
| 88 | + | EXTRAS_DIR, |
|
| 89 | + | "client", |
|
| 90 | + | "src", |
|
| 91 | + | "main.tsx", |
|
| 92 | + | nameGenerator("main.tsx", { tanstackQuery, tanstackRouter: true }), |
|
| 93 | + | ); |
|
| 94 | + | const mainTsxTarget = path.join(projectPath, "client", "src", "main.tsx"); |
|
| 95 | + | fs.copySync(mainTsxSrc, mainTsxTarget); |
|
| 96 | 96 | ||
| 97 | - | const appTsxTarget = path.join(projectPath, "client", "src", "App.tsx"); |
|
| 98 | - | fs.remove(appTsxTarget); |
|
| 97 | + | const appTsxTarget = path.join(projectPath, "client", "src", "App.tsx"); |
|
| 98 | + | fs.remove(appTsxTarget); |
|
| 99 | 99 | ||
| 100 | - | spinner.text = "Generating TanStack Route Tree..."; |
|
| 100 | + | spinner.text = "Generating TanStack Route Tree..."; |
|
| 101 | 101 | ||
| 102 | - | // await execa("vite", ["--config", "vite.config.ts", "--force"], { |
|
| 103 | - | // cwd: path.join(projectPath, "client"), |
|
| 104 | - | // }); |
|
| 105 | - | // |
|
| 106 | - | await execa("bunx", ["vite", "build"], { |
|
| 107 | - | cwd: path.join(projectPath, "client"), |
|
| 108 | - | }); |
|
| 102 | + | // await execa("vite", ["--config", "vite.config.ts", "--force"], { |
|
| 103 | + | // cwd: path.join(projectPath, "client"), |
|
| 104 | + | // }); |
|
| 105 | + | // |
|
| 106 | + | await execa("bunx", ["vite", "build"], { |
|
| 107 | + | cwd: path.join(projectPath, "client"), |
|
| 108 | + | }); |
|
| 109 | 109 | ||
| 110 | - | await execa("bunx", ["tsc", "-b"], { |
|
| 111 | - | cwd: path.join(projectPath, "client"), |
|
| 112 | - | }); |
|
| 110 | + | await execa("bunx", ["tsc", "-b"], { |
|
| 111 | + | cwd: path.join(projectPath, "client"), |
|
| 112 | + | }); |
|
| 113 | 113 | ||
| 114 | - | spinner.success("TanStack Router setup completed"); |
|
| 115 | - | return true; |
|
| 116 | - | } catch (err: unknown) { |
|
| 117 | - | spinner.error("Failed to set up TanStack Router"); |
|
| 118 | - | if (err instanceof Error) { |
|
| 119 | - | consola.error(pc.red("Error:"), err.message); |
|
| 120 | - | } else { |
|
| 121 | - | consola.error(pc.red("Error: Unknown error")); |
|
| 122 | - | } |
|
| 123 | - | return false; |
|
| 124 | - | } |
|
| 114 | + | spinner.success("TanStack Router setup completed"); |
|
| 115 | + | return true; |
|
| 116 | + | } catch (err: unknown) { |
|
| 117 | + | spinner.error("Failed to set up TanStack Router"); |
|
| 118 | + | if (err instanceof Error) { |
|
| 119 | + | consola.error(pc.red("Error:"), err.message); |
|
| 120 | + | } else { |
|
| 121 | + | consola.error(pc.red("Error: Unknown error")); |
|
| 122 | + | } |
|
| 123 | + | return false; |
|
| 124 | + | } |
|
| 125 | 125 | }; |
| 12 | 12 | ||
| 13 | 13 | // Check if we're running from source or built version |
|
| 14 | 14 | // In development, __dirname will contain 'src', in production it won't |
|
| 15 | - | const isProduction = !__dirname.includes(path.sep + 'src' + path.sep); |
|
| 16 | - | const templatesPath = isProduction |
|
| 17 | - | ? path.resolve(__dirname, "templates", "extras") // dist/index.js -> dist/templates/extras |
|
| 18 | - | : path.resolve(__dirname, "..", "templates", "extras"); // src/utils -> src/templates/extras |
|
| 15 | + | const isProduction = !__dirname.includes(path.sep + "src" + path.sep); |
|
| 16 | + | const templatesPath = isProduction |
|
| 17 | + | ? path.resolve(__dirname, "templates", "extras") // dist/index.js -> dist/templates/extras |
|
| 18 | + | : path.resolve(__dirname, "..", "templates", "extras"); // src/utils -> src/templates/extras |
|
| 19 | 19 | ||
| 20 | 20 | export const EXTRAS_DIR = templatesPath; |