MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / generateRemixFormRoute

Function generateRemixFormRoute

src/commands/generateFormRouteFile.ts:7–41  ·  view source on GitHub ↗
(uri: vscode.Uri)

Source from the content-addressed store, hash-verified

5import { getRemixRootFromFileUri } from "../utils/file";
6
7export 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};

Callers

nothing calls this directly

Calls 5

getRemixRootFromFileUriFunction · 0.90
getConfigFunction · 0.90
generateRemixHookFormFunction · 0.90
generateConformFormFunction · 0.90

Tested by

no test coverage detected