Support arkenv add host [provider] for flat layouts (Phase 2) - #1324
Conversation
🦋 Changeset detectedLatest commit: e894a3e 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 |
arkenv
@arkenv/build
@arkenv/bun-plugin
@arkenv/cli
@arkenv/fumadocs-ui
@arkenv/nextjs
@arkenv/nuxt
@arkenv/vite-plugin
commit: |
There was a problem hiding this comment.
Important
Two issues need attention before merge: the PR is missing a changeset for the new @arkenv/cli feature, and arkenv add host does not respect the global --agent/--yes non-interactive flag when the provider is omitted.
Reviewed changes — Added the arkenv add host [provider] command, including CLI parsing, prompt wiring, a new AddUseCase, and an AST-based mutateEnvConfig helper that injects Vercel/Netlify preset keys into an existing flat env.ts schema.
- Add
AddUseCaseand wire it through composition/dispatch —packages/cli/src/cli/commands/add.ts,packages/cli/src/cli/composition.ts,packages/cli/src/index.ts - Parse
add host [provider]inCLI—packages/cli/src/cli/cli.ts - Add
selectprompt toPromptPort—packages/cli/src/adapters/prompt.adapter.ts,packages/cli/src/shared/ports/prompt.port.ts - Add
mutateEnvConfigAST helper —packages/cli/src/features/config-mutation/config-mutation.ts - Update help output and add tests —
packages/cli/src/cli/commands/help.ts,help.test.ts,cli.test.ts,add.test.ts,config-mutation.test.ts
⚠️ No changeset for the new command
This PR introduces a published-package feature for @arkenv/cli and the checklist claims a changeset was created, but .changeset/ contains no new changeset file. Without one, the change will not be included in a release.
Technical details
# No changeset for the new command
## Affected sites
- `.changeset/` — no new changeset file present for `@arkenv/cli`
## Required outcome
- Add a changeset describing the new `arkenv add host [provider]` command and the planned version bump for `@arkenv/cli`.Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ The previously missing changeset has been added; the agent-mode concern from the prior review remains unresolved.
Reviewed changes — The incremental commit adds a correctly-formatted changeset for the new arkenv add host [provider] command.
- Add changeset for
@arkenv/cli—.changeset/add-host-preset-add-command.md
Kimi K2 (free via Pullfrog for OSS) | 𝕏
| Support adding a hosting provider preset (Vercel or Netlify) to an existing `env.ts` configuration file: | ||
|
|
||
| ```bash | ||
| npx arkenv add host [provider] |
There was a problem hiding this comment.
| npx arkenv add host [provider] | |
| npx @arkenv/cli@latest add host [provider] |
| } | ||
|
|
||
| /** | ||
| * Prompts the user to select one option from a list. |
There was a problem hiding this comment.
(nitpick)
| * Prompts the user to select one option from a list. | |
| * Prompt the user to select one option from a list. |
| import type { Framework, Validator } from "../scaffold/plan"; | ||
| import { | ||
| getFieldDefinition, | ||
| getFrameworkPrefix, | ||
| getPresetKeys, | ||
| type HostPreset, | ||
| } from "../scaffold/templates/presets"; |
There was a problem hiding this comment.
| import type { Framework, Validator } from "../scaffold/plan"; | |
| import { | |
| getFieldDefinition, | |
| getFrameworkPrefix, | |
| getPresetKeys, | |
| type HostPreset, | |
| } from "../scaffold/templates/presets"; | |
| import { | |
| getFieldDefinition, | |
| getFrameworkPrefix, | |
| getPresetKeys, | |
| type HostPreset, | |
| type Framework, | |
| type Validator | |
| } from "@/features/scaffold"; |
| } | ||
|
|
||
| /** | ||
| * Transforms an env.ts schema file by merging host preset keys. |
There was a problem hiding this comment.
| * Transforms an env.ts schema file by merging host preset keys. | |
| * Transform an env.ts schema file by merging host preset keys. |
| isYes?: boolean, | ||
| ): Promise<ProjectOptions | null>; | ||
| /** | ||
| * Prompts the user to select one option from a list. |
There was a problem hiding this comment.
| * Prompts the user to select one option from a list. | |
| * Prompt the user to select one option from a list. |
There was a problem hiding this comment.
Consider a better approach than these if-else chains
5b6ed5a to
bf265be
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — minor suggestions inline.
Reviewed changes — the incremental commits since the prior review addressed the outstanding feedback for the arkenv add host [provider] command.
- Added
isYestoAddInputso--yes/--agentskips the provider prompt and defaults to Vercel. - Expanded env.ts discovery to check
./env.ts,src/env.ts, and the scanner-suggested path. - Extracted
detectValidatorto strip comments and match Zod/Valibot import statements, with unit tests. - Refactored
index.tscommand dispatch into a command map and shared error-handling path. - Fixed changeset command example and JSDoc wording from the prior review.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the commits since the prior review tightened validator import detection and added coverage for multi-line imports.
- Support multi-line
import { ... } from "zod"/from "valibot"indetectValidator—packages/cli/src/cli/commands/add.ts - Add unit tests for multi-line Zod and Valibot imports —
packages/cli/src/cli/commands/add.test.ts
Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
What a nice PR @abhimanyutiwaribot! Killing it 🚀 |
Bring arkenv add host [provider] onto v1, adapting field rendering to dialects and FRAMEWORK_CLIENT_PREFIXES instead of the v0 template helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
## Summary - Forward-ports [#1324](#1324) (`arkenv add host [provider]`) from `dev` onto `v1` - Re-implements under `packages/arkenv/` (v1 CLI) with dialect-based field rendering via `DIALECTS` / `tryFormatPresetFieldValue` and `FRAMEWORK_CLIENT_PREFIXES` - Adds `mutateEnvConfig`, prompt `select`, help/parser coverage, and a `minor` changeset for `arkenv` Fixes #1267 (v1 parity) ## Test plan - [x] `pnpm --filter arkenv exec vitest run` (342 tests) - [x] `pnpm --filter arkenv typecheck` - [ ] Manually: `arkenv add host vercel` against a flat `env.ts` - [ ] Manually: `arkenv add host` interactive prompt and missing-`env.ts` fallback Made with [Cursor](https://cursor.com) --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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 dev, this PR will be updated. # Releases ## @arkenv/cli@0.5.1 ### Patch Changes - #### Add `add host` command to CLI for adding hosting presets to existing schemas _[`#1324`](#1324) [`eed3cce`](eed3cce) [@abhimanyutiwaribot](https://github.com/abhimanyutiwaribot)_ Support adding a hosting provider preset (Vercel or Netlify) to an existing `env.ts` configuration file: ```bash npx @arkenv/cli@latest add host [provider] ``` - Prompts interactively to select Vercel or Netlify if the provider is omitted. - Auto-detects the framework (Next.js, Nuxt, Vite, Bun) and the validator engine (Zod, Valibot, or ArkType) to inject the preset fields with the correct syntax. - Fallback to logging the generated variable schemas to stdout with manual configuration instructions if `env.ts` is missing or unparseable. ## @arkenv/nuxt@0.0.7 ### Patch Changes - #### Fix number and boolean env values returning as strings _[`#1420`](#1420) [`aecac94`](aecac94) [@yamcodes](https://github.com/yamcodes)_ Keep coerced types when reading from `env`. A key declared as `"number"` or `"boolean"` now returns a number or boolean at runtime, not the raw string from Nuxt runtime config. ```ts import { createEnv } from "@arkenv/nuxt"; export const env = createEnv({ NUXT_PUBLIC_PORT: "number", PORT: "number", }); // Was "3000" (string) — now 3000 (number) env.NUXT_PUBLIC_PORT; env.PORT; ``` Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Description
Support the command
arkenv add host [provider]to dynamically add hosting provider presets (Vercel, Netlify) to an existingenv.tsconfig file. the change, auto detects the framework prefix and validator (ie. zod, valibot, or arktype) to inject the correct schemas.if
env.tsis missing or unparseable, it prints the proposed fields (the command prints the keys to stdout and exits gracefully with a message).Fixes #1267
Type of Change
Checklist
Add support for custom error messages- nofeat:, no trailing period, capitalized).pnpm changeset(if this affects a published package).For v0 (dev) PRs:
v1branch?Images
1.
2.
3.