refactor: move config file discovery to shared util (#10677)
### Description
https://github.com/vercel/turborepo/pull/10619 put this logic in a
shared place, but looks like I missed this spot.
### Testing Instructions
This should be a pure refactor, so CI should catch regressions.