fix: resolve --file absolute paths in clerk env pull#270
Conversation
`resolveTargetFile` used `path.join(cwd, flag)`, which doesn't reset on an absolute argument. `--file /Users/u/clerk-dev.env` from a project cwd silently landed at `<cwd>/Users/u/clerk-dev.env` while the success message still claimed it was written at the user's path. Swap to `path.resolve` so absolute paths are honored and relative paths still resolve against cwd. Fixes #269
🦋 Changeset detectedLatest commit: 7578b86 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
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ 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 (2)
📝 WalkthroughWalkthroughThis PR fixes a critical bug in Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
|
!snapshot |
Two cleanup passes on the env-pull test file: - `pull.test.ts:397` checked `Bun.file(join(tempDir, absoluteTarget)).exists()` to assert "nothing was written inside cwd". But `path.join` with an absolute second arg concatenates rather than nests (the exact bug the source fix addresses), so the assertion was vacuous. Replaced with a check that the default fallback `.env.local` was not created inside cwd — a meaningful invariant that --file fully overrides auto-detection. - Renamed the second test to describe what it actually asserts (absolute path with no package.json) instead of "framework detection fails", and dropped the unnecessary `app`/`instance` flags so it differs from T1 only in the missing package.json. - Trimmed two paraphrase comments in the same test. - Shortened the WHY comment in `resolveTargetFile` to one line.
Snapshot publishednpm install -g clerk@1.2.1-snapshot.5a5b2ea
|
Summary
clerk env pull --file <path>prints success but writes no file (exits 1) when framework cannot be detected #269.clerk env pull --file <absolute path>no longer silently writes under the project cwd; it writes exactly where the user asked.resolveTargetFilecalledpath.join(cwd, flag), which doesn't treat an absolute second arg as a reset.--file /Users/u/clerk-dev.envfrom/Users/u/Developer/some-dirproduced/Users/u/Developer/some-dir/Users/u/clerk-dev.env.Bun.writeauto-creates parent dirs, so the wrong write succeeded and the success log (which printedoptions.fileverbatim) was misleading. Swapped topath.resolve— absolute paths are honored, relative paths still resolve against cwd.Test plan
pull.test.ts > "writes --file to an absolute path outside cwd"— file lands at the absolute path, not nested under cwd; success log shows the resolved path.pull.test.ts > "writes --file with no package.json present (framework detection fails)"— reproduces the exact scenario from the issue (non-framework dir + absolute--file) and verifies keys land at the requested path.bun run format/bun run lint/bun run typecheck/bun run testall pass locally (97/97).clerk env pull --file /tmp/foo.envfrom a fresh dir against the prebuilt binary once CI publishes the preview build.