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

Function updatePackageJsonMainEntry

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

Source from the content-addressed store, hash-verified

199 * Updates package.json to use index.ts as the main entry point instead of expo-router/entry
200 */
201export async function updatePackageJsonMainEntry(
202 targetPath: string
203): Promise<void> {
204 const packageJsonPath = path.join(targetPath, "package.json");
205
206 try {
207 const packageJson = await fs.readJson(packageJsonPath);
208
209 // Only update if main is currently set to expo-router/entry
210 if (packageJson.main === "expo-router/entry") {
211 packageJson.main = "index.ts";
212 await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
213 }
214 } catch (error) {
215 throw new Error(
216 `Failed to update package.json: ${
217 error instanceof Error ? error.message : "Unknown error"
218 }`
219 );
220 }
221}
222
223/**
224 * Detects the main app/source folder for the project

Callers 1

initCommandFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected