MCPcopy
hub / github.com/t3-oss/create-t3-app / selectPageFile

Function selectPageFile

cli/src/helpers/selectBoilerplate.ts:111–146  ·  view source on GitHub ↗
({
  projectDir,
  packages,
}: SelectBoilerplateProps)

Source from the content-addressed store, hash-verified

109
110// Similar to index, but for app router
111export const selectPageFile = ({
112 projectDir,
113 packages,
114}: SelectBoilerplateProps) => {
115 const indexFileDir = path.join(PKG_ROOT, "template/extras/src/app/page");
116
117 const usingTRPC = packages.trpc.inUse;
118 const usingTw = packages.tailwind.inUse;
119 const usingAuth = packages?.nextAuth.inUse;
120 const usingBetterAuth = packages?.betterAuth.inUse;
121
122 let indexFile = "base.tsx";
123 if (usingTRPC && usingTw && usingBetterAuth) {
124 indexFile = "with-better-auth-trpc-tw.tsx";
125 } else if (usingTRPC && !usingTw && usingBetterAuth) {
126 indexFile = "with-better-auth-trpc.tsx";
127 } else if (!usingTRPC && usingTw && usingBetterAuth) {
128 indexFile = "with-better-auth-tw.tsx";
129 } else if (!usingTRPC && !usingTw && usingBetterAuth) {
130 indexFile = "with-better-auth.tsx";
131 } else if (usingTRPC && usingTw && usingAuth) {
132 indexFile = "with-auth-trpc-tw.tsx";
133 } else if (usingTRPC && !usingTw && usingAuth) {
134 indexFile = "with-auth-trpc.tsx";
135 } else if (usingTRPC && usingTw) {
136 indexFile = "with-trpc-tw.tsx";
137 } else if (usingTRPC && !usingTw) {
138 indexFile = "with-trpc.tsx";
139 } else if (!usingTRPC && usingTw) {
140 indexFile = "with-tw.tsx";
141 }
142
143 const indexSrc = path.join(indexFileDir, indexFile);
144 const indexDest = path.join(projectDir, "src/app/page.tsx");
145 fs.copySync(indexSrc, indexDest);
146};

Callers 1

createProjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected