MCPcopy Index your code
hub / github.com/craftreactnative/ui / createExpoRouterEntryFile

Function createExpoRouterEntryFile

cli/src/utils/project-detection.ts:168–196  ·  view source on GitHub ↗
(
  targetPath: string
)

Source from the content-addressed store, hash-verified

166 * Creates an index.ts file for Expo Router projects with craftrn-ui theme import
167 */
168export async function createExpoRouterEntryFile(
169 targetPath: string
170): Promise<void> {
171 const indexPath = path.join(targetPath, "index.ts");
172
173 // Check if index.ts already exists
174 if (await fs.pathExists(indexPath)) {
175 const content = await fs.readFile(indexPath, "utf8");
176
177 // If it already has our import, don't modify it
178 if (content.includes("@/craftrn-ui/themes/unistyles")) {
179 return;
180 }
181
182 // If it has expo-router/entry but not our import, add our import
183 if (content.includes("expo-router/entry")) {
184 const newContent = content + '\nimport "@/craftrn-ui/themes/unistyles";';
185 await fs.writeFile(indexPath, newContent, "utf8");
186 return;
187 }
188 }
189
190 // Create new index.ts file
191 const content = `import 'expo-router/entry'
192import "@/craftrn-ui/themes/unistyles";
193`;
194
195 await fs.writeFile(indexPath, content, "utf8");
196}
197
198/**
199 * Updates package.json to use index.ts as the main entry point instead of expo-router/entry

Callers 1

initCommandFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected