898 cli auto detect existing env files and suggest a schema#904
Conversation
- Introduced automatic detection of `.env.example` files during the `arkenv init` process to improve user onboarding. - Added functionality to extract environment variable keys from `.env.example`. - Implemented dynamic key integration for schema templates (`arktype`, `zod`, `valibot`). - Updated prompts to allow users to accept or decline `.env.example`-based scaffolding.
🦋 Changeset detectedLatest commit: d3726b9 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 (5)
WalkthroughThis PR implements automatic detection of ChangesEnvironment Example Detection & Schema Scaffolding
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 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. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
…Env CLI - Added `.env.example` parser utility to extract environment variable keys. - Updated `arktype`, `zod`, and `valibot` templates to render dynamic schema keys. - Enhanced CLI prompts for `.env.example` detection and user confirmation. - Integrated extracted keys into schema scaffolding with fallback defaults. - Added comprehensive tests for parsing, prompts, and template scaffolding.
arkenv
@arkenv/bun-plugin
@arkenv/cli
@arkenv/fumadocs-ui
@arkenv/vite-plugin
commit: |
📦 Bundle Size Report✅ All size limits passed! |
…ne CLI visuals - Removed the `frameworkNote` parameter from `arktype`, `zod`, and `valibot` templates for simplicity. - Updated CLI output to display ArkEnv version and improved visual formatting with a new symbol. - Bumped `@clack/prompts` dependency to v1.3.0 for updated features and stability.
…in ArkEnv CLI - Added robust parsing of `.env.example` to extract variable keys. - Updated `init` wizard to suggest extracted keys for schema scaffolding. - Refined scaffolding templates by removing introductory comments.
- Updated documentation to include `.env.example` detection and key extraction. - Refined `init` command steps to highlight enhanced schema scaffolding workflow.
…stallation - Enhanced CLI visuals: display version in help page and intro. - Updated `env.ts` to support refined variable definitions and schema types. - Resolved Node.js DEP0190 deprecation warning in scaffolding logic. - Fixed duplicate output during dependency installation by piping process logs.
…ing output - Added support for automatic dependency installation using detected package manager. - Updated scaffolding output to reflect streamlined process and improved messaging. - Enhanced CLI prompts with recommended options for `.env.example` key usage. - Refactored scaffolding logic to return installation command details.
…olding - Consolidated `@clack/prompts` imports into a single line. - Simplified logging message for dependency installation output. - Removed color formatting redundancy for package manager output.
- Removed framework-specific notes from scaffolding templates for clarity. - Updated CLI output with live dependency installation progress and simplified messaging. - Streamlined tests by eliminating checks for framework-specific notes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
packages/cli/src/env-parser.test.ts (1)
37-44: ⚡ Quick winRename this test to match the asserted behavior.
Line 37 says “case-insensitive,” but the assertion on Line 43 verifies lowercase keys are preserved. A title like “should preserve lowercase keys” would be clearer.
As per coding guidelines, “Unit tests should focus on individual function logic and edge cases.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/env-parser.test.ts` around lines 37 - 44, Rename the test title to match the asserted behavior: change the it(...) description currently "should handle lowercase keys (case-insensitive)" to something like "should preserve lowercase keys" so the test name reflects that parseEnvExample returns lowercase keys unchanged; only update the string description in the test around the it(...) that calls parseEnvExample, no code logic changes required.openspec/changes/cli-auto-detect-env-example/specs/cli-schema-suggestion/spec.md (1)
20-21: ⚡ Quick winTighten this acceptance criterion to be deterministic.
Line 21’s “or appropriate default validators” is ambiguous for compliance testing. Consider listing exact expected mappings (or linking to a canonical rule table) so implementations and tests converge.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openspec/changes/cli-auto-detect-env-example/specs/cli-schema-suggestion/spec.md` around lines 20 - 21, The acceptance criterion is ambiguous because "or appropriate default validators" is not deterministic; update the THEN clause for the keys PORT and DATABASE_URL to state exact expected schema mappings (e.g., PORT: "string" or "integer" and DATABASE_URL: "string" — pick the canonical validators your spec uses) or replace that phrase with a link/reference to the canonical validator table; specifically edit the sentence referencing keys PORT and DATABASE_URL to list the precise validator strings (or a clear authoritative rule link) so tests can assert exact values.packages/cli/src/scaffold.ts (1)
1-1: ⚡ Quick winRemove unused
spawnimport.The
spawnimport is no longer used in this file after refactoring the install execution toindex.ts.♻️ Proposed fix
-import { spawn } from "node:child_process"; import { existsSync } from "node:fs";🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/scaffold.ts` at line 1, Remove the unused import "spawn" from the top of the file: delete the import specifier `spawn` from the import statement `import { spawn } from "node:child_process";` in packages/cli/src/scaffold.ts since the install execution was moved to index.ts and no code in this file references `spawn`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.idea/vcs.xml:
- Line 51: Remove the JetBrains-local VCS mapping entry from .idea/vcs.xml by
deleting the <mapping directory="$PROJECT_DIR$/app" vcs="Git" /> element so
IDE-specific config isn't committed; leave other project-wide VCS mappings
intact and ensure the file no longer contains that local "$PROJECT_DIR$/app"
mapping before committing.
In `@openspec/changes/cli-auto-detect-env-example/design.md`:
- Around line 30-31: The design doc uses `keys: string[]` in the
Decision/Rationale but the rest of the change set uses `envKeys`; update the doc
to use `envKeys` consistently by replacing `keys: string[]` with `envKeys:
string[]` and adjust the explanatory text to refer to `envKeys` (including
mentions of template functions that accept an optional envKeys array and the
fallback to `NODE_ENV` and `PORT`) so all sections (Decision, Rationale,
tasks/tests/implementation) use the same identifier.
In `@openspec/changes/cli-auto-detect-env-example/proposal.md`:
- Line 10: Replace the inconsistent generated filename in the proposal so it
matches the implementation/docs: change the mention of `arkenv.ts` to the
canonical `env.ts` (or vice versa if you prefer that as the canonical name)
throughout the proposal text and any examples, ensuring all references (e.g.,
the sentence about generating a starter arkenv.ts/env.ts and any subsequent
example filenames) use the same single filename (`env.ts`) to remove ambiguity.
---
Nitpick comments:
In
`@openspec/changes/cli-auto-detect-env-example/specs/cli-schema-suggestion/spec.md`:
- Around line 20-21: The acceptance criterion is ambiguous because "or
appropriate default validators" is not deterministic; update the THEN clause for
the keys PORT and DATABASE_URL to state exact expected schema mappings (e.g.,
PORT: "string" or "integer" and DATABASE_URL: "string" — pick the canonical
validators your spec uses) or replace that phrase with a link/reference to the
canonical validator table; specifically edit the sentence referencing keys PORT
and DATABASE_URL to list the precise validator strings (or a clear authoritative
rule link) so tests can assert exact values.
In `@packages/cli/src/env-parser.test.ts`:
- Around line 37-44: Rename the test title to match the asserted behavior:
change the it(...) description currently "should handle lowercase keys
(case-insensitive)" to something like "should preserve lowercase keys" so the
test name reflects that parseEnvExample returns lowercase keys unchanged; only
update the string description in the test around the it(...) that calls
parseEnvExample, no code logic changes required.
In `@packages/cli/src/scaffold.ts`:
- Line 1: Remove the unused import "spawn" from the top of the file: delete the
import specifier `spawn` from the import statement `import { spawn } from
"node:child_process";` in packages/cli/src/scaffold.ts since the install
execution was moved to index.ts and no code in this file references `spawn`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 70e9ad96-926c-4b51-9a77-21db2ca320f6
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (27)
.changeset/clean-cli-install-output.md.changeset/cool-rivers-remain.md.idea/vcs.xmlapps/playgrounds/arkenv-cli/src/env.tsapps/www/content/docs/cli/index.mdxgh-issue-workflow.skillopenspec/changes/cli-auto-detect-env-example/.openspec.yamlopenspec/changes/cli-auto-detect-env-example/design.mdopenspec/changes/cli-auto-detect-env-example/proposal.mdopenspec/changes/cli-auto-detect-env-example/specs/cli-env-example-detection/spec.mdopenspec/changes/cli-auto-detect-env-example/specs/cli-schema-suggestion/spec.mdopenspec/changes/cli-auto-detect-env-example/tasks.mdpackages/cli/package.jsonpackages/cli/src/env-parser.test.tspackages/cli/src/env-parser.tspackages/cli/src/env-template.test.tspackages/cli/src/env-template.tspackages/cli/src/index.tspackages/cli/src/prompts.test.tspackages/cli/src/prompts.tspackages/cli/src/scaffold.test.tspackages/cli/src/scaffold.tspackages/cli/src/templates/arktype.tspackages/cli/src/templates/valibot.tspackages/cli/src/templates/zod.tspackages/cli/src/visuals.tspnpm-workspace.yaml
💤 Files with no reviewable changes (1)
- packages/cli/src/env-template.test.ts
- Updated test to clarify and preserve lowercase key behavior. - Adjusted template parameter naming for consistency (`keys` → `envKeys`). - Improved schema generation example in docs to reflect updated validator usage (`a.string()`). - Removed unused import in scaffolding logic for cleanup.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @arkenv/cli@0.0.3 ### Patch Changes - #### Improve CLI UI and fix installation output _[`#904`](#904) [`ef17a38`](ef17a38) [@yamcodes](https://github.com/yamcodes)_ - Display CLI version on the help page and at startup - Fix "doubling up" of terminal output during dependency installation by piping process output - Resolve Node.js DEP0190 deprecation warning in scaffolding logic - #### Auto-detect `.env.example` keys during init and suggest schema _[`#904`](#904) [`ef17a38`](ef17a38) [@yamcodes](https://github.com/yamcodes)_ - Robust parsing of `.env.example` to extract variable keys - Integration with the `init` wizard to suggest keys for scaffolding - Minimal scaffolding templates without introductory comments or platform notes - Simplified CLI output with live dependency installation progress - Updated CLI documentation and added post-scaffold guidance to refine types Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Closes #898
Summary by CodeRabbit
Release Notes
New Features
.env.examplefiles and suggests schema keys during CLI initializationBug Fixes
Documentation
.env.exampledetection details and post-scaffold guidanceImprovements