| 199 | * Updates package.json to use index.ts as the main entry point instead of expo-router/entry |
| 200 | */ |
| 201 | export 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 |