(uri: vscode.Uri)
| 5 | import { getRemixRootFromFileUri } from "../utils/file"; |
| 6 | |
| 7 | export const generateRemixFormRoute = async (uri: vscode.Uri) => { |
| 8 | const rootDir = await getRemixRootFromFileUri(uri); |
| 9 | if (!rootDir) { |
| 10 | return; |
| 11 | } |
| 12 | const config = getConfig(); |
| 13 | const template = config.get<string>("formRouteTemplate"); |
| 14 | |
| 15 | const fileName = await vscode.window.showInputBox({ |
| 16 | prompt: "Enter the name of the route to generate", |
| 17 | }); |
| 18 | |
| 19 | if (!fileName) { |
| 20 | return; |
| 21 | } |
| 22 | const filePath = vscode.Uri.joinPath(uri, fileName + ".tsx"); |
| 23 | |
| 24 | if (template) { |
| 25 | await vscode.workspace.fs.writeFile(filePath, Buffer.from(template)); |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | const formHandler = config.get("formHandler") || "remix-hook-form"; |
| 30 | |
| 31 | await vscode.workspace.fs.writeFile( |
| 32 | filePath, |
| 33 | Buffer.from(formHandler === "remix-hook-form" ? generateRemixHookForm() : generateConformForm()), |
| 34 | ); |
| 35 | await askInstallDependenciesPrompt( |
| 36 | rootDir, |
| 37 | formHandler === "remix-hook-form" |
| 38 | ? ["react-hook-form", "remix-hook-form", "@remix-run/react", "@hookform/resolvers", "zod"] |
| 39 | : ["@conform-to/react", "@conform-to/zod", "@remix-run/react", "zod"], |
| 40 | ); |
| 41 | }; |
nothing calls this directly
no test coverage detected