fix(init): pull API keys into bootstrapped project subdirectory#195
fix(init): pull API keys into bootstrapped project subdirectory#195rafa-thayto merged 1 commit intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 944c1cd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 52 minutes and 43 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
After `clerk init` bootstraps a new project, the final `env pull` step resolved the linked profile via `process.cwd()` (still the parent directory), producing "No Clerk project linked to this directory" even though the freshly-created app was correctly linked under the subdir's absolute path. Thread `cwd` through `resolveAppContext` and `pull()` and pass `ctx.cwd` from init.
944e508 to
944c1cd
Compare
Summary
When
clerk initbootstraps a new project in a subdirectory and then runsenv pullat the end, it fails with:even though the Clerk app was just linked to the freshly-created subdirectory. Result:
✓ Clerk has been set upprints, then the command errors and.env.localis left without real API keys.Root cause:
pull()andresolveAppContext()both hardcodedprocess.cwd(), which is still the parent directory (init neverchdirs). The profile was correctly written under the subdir path byclerk link, but the subsequent lookup walked up from the parent and never found it.Fix: thread
cwdas an optional parameter throughresolveAppContext()andpull()(defaulting toprocess.cwd()for existing callers), passctx.cwdfrominit, and extract a sharedAppContextOptionsinterface soEnvPullOptionsextends it instead of redeclaring the fields. Also parallelizes the two independent awaits at the top ofpull()withPromise.all.Test plan
bun run typecheck,bun run lint,bun run format:check,bun run test— all green (72 test files pass)packages/cli-core/src/commands/env/pull.test.tsthat passescwdpointing at a directory distinct fromprocess.cwd()and asserts the keys are written inside that directory (and not inprocess.cwd())packages/cli-core/src/lib/config.test.tscoveringresolveAppContext({ cwd })finding profiles keyed by the explicit pathinitassertion to verifypullis called with{ file, cwd: ctx.cwd }mkdir /tmp/foo && cd /tmp/foo && clerk init, pick TanStack Start + create new Clerk app — verify flow ends without error and<project>/.env.localcontains real keys