Repository navigation
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
✅ Staging deployment successful! Preview: https://viteplus-staging.void.app/ |
|
Cloudflare builds and deploys previews for this pull request. Learn more about Cloudflare previews.
Updated: |
CLI artifact sizes (
|
| Artifact | Format | Base | PR | Change |
|---|---|---|---|---|
packages/cli/dist |
Directory total | 2.52 MiB | 2.61 MiB | +92.45 KiB (+3.58%) |
packages/core/dist |
Directory total | 4.29 MiB | 4.29 MiB | 0 B (0.00%) |
| Combined package dist | Directory total | 6.81 MiB | 6.90 MiB | +92.45 KiB (+1.33%) |
vp (Linux x64) |
Binary | 9.28 MiB | 9.28 MiB | +4.00 KiB (+0.04%) |
vp (Linux x64) |
gzip -9 | 4.24 MiB | 4.24 MiB | -63 B (-0.00%) |
| NAPI (Linux x64) | Binary | 37.97 MiB | 38.04 MiB | +68.00 KiB (+0.17%) |
| NAPI (Linux x64) | gzip -9 | 15.32 MiB | 15.33 MiB | +16.05 KiB (+0.10%) |
vp (macOS ARM64) |
Binary | 6.11 MiB | 6.11 MiB | +16 B (+0.00%) |
vp (macOS ARM64) |
gzip -9 | 3.63 MiB | 3.63 MiB | +118 B (+0.00%) |
| NAPI (macOS ARM64) | Binary | 44.38 MiB | 44.43 MiB | +48.42 KiB (+0.11%) |
| NAPI (macOS ARM64) | gzip -9 | 19.42 MiB | 19.43 MiB | +13.59 KiB (+0.07%) |
vp (Windows x64) |
Binary | 7.25 MiB | 7.25 MiB | +512 B (+0.01%) |
vp (Windows x64) |
gzip -9 | 3.32 MiB | 3.32 MiB | +262 B (+0.01%) |
| NAPI (Windows x64) | Binary | 33.86 MiB | 33.92 MiB | +61.00 KiB (+0.18%) |
| NAPI (Windows x64) | gzip -9 | 14.02 MiB | 14.04 MiB | +20.50 KiB (+0.14%) |
| Trampoline (Windows x64) | Binary | 13.50 KiB | 13.50 KiB | 0 B (0.00%) |
| Trampoline (Windows x64) | gzip -9 | 7.09 KiB | 7.09 KiB | 0 B (0.00%) |
| Installer (Windows x64) | Binary | 4.69 MiB | 4.69 MiB | 0 B (0.00%) |
| Installer (Windows x64) | gzip -9 | 2.25 MiB | 2.25 MiB | 0 B (0.00%) |
| | Command | Runs | Behavior | | ||
| | -------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `vp dotenv init` | `varlock init`, or `varlock init --agent` with `--no-interactive` | Scaffold `.env.schema` from existing `.env` files and code, add the `.gitignore` exception when needed, pick a type-generation decorator. | | ||
| | `vp dotenv check` | `varlock load --format json --agent` | Validate schema plus local values. Discard stdout and print a `pass:` line. varlock reports errors on stderr. This is the CI entry point. Fails, like every subcommand except `init`, when the directory has no schema. | |
There was a problem hiding this comment.
Does vp check need to include this feature? If a project has a .env.schema file, should vp check also automatically run this check?
|
|
||
| `init` scans your `.env` files and your code, writes `.env.schema` with decorators inferred for each variable, and adds `!.env.schema` to `.gitignore` when the file would otherwise be ignored. Review the schema and mark each secret with `@sensitive`. | ||
|
|
||
| `varlock init` also adds `varlock` to the `dependencies` in `package.json`. Keep it, at the version that Vite+ bundles (`vp --version` lists it): TypeScript resolves `varlock/env` from your project to apply the generated `ENV` types, and package managers share one copy when the versions match. `vp dotenv init` prints a reminder with the version when it sees the new dependency. |
There was a problem hiding this comment.
Need to find a solution that prevents the project from directly depending on varlock.
|
|
||
| 1. `.env.schema`: the committed schema and default values | ||
| 2. `.env`: loaded, but prefer the files below | ||
| 3. `.env.local`: your machine-only values, git-ignored |
There was a problem hiding this comment.
If a vp tool reads .env.local and gets cached, the content of .env.local will be fingerprinted even though it's git-gignored. Do we need to do anything about this?
ae214b9 to
8293bde
Compare
|
How
Modes. varlock selects
The mode is the lowest-priority source. When the mode does not select the environment, Vite+ prints a warning that names the cause: a schema without
Guide sections: Vite modes, Using |
Preview binary sizes (
|
| Binary | Latest release | Preview | Change |
|---|---|---|---|
vp (macOS ARM64) |
6.11 MiB | 6.11 MiB | -16 B (-0.00%) |
| NAPI (macOS ARM64) | 44.35 MiB | 44.39 MiB | +48.44 KiB (+0.11%) |
vp (macOS x64) |
7.71 MiB | 7.71 MiB | +16 B (+0.00%) |
| NAPI (macOS x64) | 49.94 MiB | 50.03 MiB | +84.09 KiB (+0.16%) |
vp (Linux ARM64 GNU) |
7.72 MiB | 7.72 MiB | 0 B (0.00%) |
| NAPI (Linux ARM64 GNU) | 33.66 MiB | 33.71 MiB | +56.00 KiB (+0.16%) |
vp (Linux ARM64 musl) |
7.80 MiB | 7.80 MiB | +672 B (+0.01%) |
| NAPI (Linux ARM64 musl) | 32.87 MiB | 32.92 MiB | +54.25 KiB (+0.16%) |
vp (Linux x64 GNU) |
9.28 MiB | 9.28 MiB | 0 B (0.00%) |
| NAPI (Linux x64 GNU) | 37.89 MiB | 37.97 MiB | +80.00 KiB (+0.21%) |
vp (Linux x64 musl) |
9.35 MiB | 9.36 MiB | +3.34 KiB (+0.03%) |
| NAPI (Linux x64 musl) | 37.08 MiB | 37.16 MiB | +80.00 KiB (+0.21%) |
vp (Windows x64) |
7.25 MiB | 7.25 MiB | -1.50 KiB (-0.02%) |
| NAPI (Windows x64) | 33.49 MiB | 33.56 MiB | +74.50 KiB (+0.22%) |
| Trampoline (Windows x64) | 13.00 KiB | 13.00 KiB | 0 B (0.00%) |
| Installer (Windows x64) | 4.70 MiB | 4.70 MiB | 0 B (0.00%) |
vp (Windows ARM64) |
6.45 MiB | 6.45 MiB | +2.00 KiB (+0.03%) |
| NAPI (Windows ARM64) | 29.50 MiB | 29.55 MiB | +51.00 KiB (+0.17%) |
| Trampoline (Windows ARM64) | 13.00 KiB | 13.00 KiB | 0 B (0.00%) |
| Installer (Windows ARM64) | 3.87 MiB | 3.87 MiB | 0 B (0.00%) |
gzip -9 sizes
| Binary | Latest release | Preview | Change |
|---|---|---|---|
vp (macOS ARM64) |
3.63 MiB | 3.63 MiB | -747 B (-0.02%) |
| NAPI (macOS ARM64) | 19.40 MiB | 19.42 MiB | +21.92 KiB (+0.11%) |
vp (macOS x64) |
3.82 MiB | 3.82 MiB | -1.98 KiB (-0.05%) |
| NAPI (macOS x64) | 20.75 MiB | 20.78 MiB | +23.06 KiB (+0.11%) |
vp (Linux ARM64 GNU) |
4.18 MiB | 4.18 MiB | +3 B (+0.00%) |
| NAPI (Linux ARM64 GNU) | 14.52 MiB | 14.54 MiB | +22.69 KiB (+0.15%) |
vp (Linux ARM64 musl) |
4.21 MiB | 4.21 MiB | +501 B (+0.01%) |
| NAPI (Linux ARM64 musl) | 14.22 MiB | 14.24 MiB | +23.93 KiB (+0.16%) |
vp (Linux x64 GNU) |
4.24 MiB | 4.24 MiB | -185 B (-0.00%) |
| NAPI (Linux x64 GNU) | 15.27 MiB | 15.30 MiB | +21.49 KiB (+0.14%) |
vp (Linux x64 musl) |
4.27 MiB | 4.27 MiB | -327 B (-0.01%) |
| NAPI (Linux x64 musl) | 14.95 MiB | 14.97 MiB | +22.84 KiB (+0.15%) |
vp (Windows x64) |
3.32 MiB | 3.32 MiB | +566 B (+0.02%) |
| NAPI (Windows x64) | 13.88 MiB | 13.91 MiB | +23.96 KiB (+0.17%) |
| Trampoline (Windows x64) | 7.14 KiB | 7.14 KiB | -2 B (-0.03%) |
| Installer (Windows x64) | 2.25 MiB | 2.25 MiB | -24 B (-0.00%) |
vp (Windows ARM64) |
3.18 MiB | 3.18 MiB | +1.77 KiB (+0.05%) |
| NAPI (Windows ARM64) | 13.15 MiB | 13.17 MiB | +22.74 KiB (+0.17%) |
| Trampoline (Windows ARM64) | 6.93 KiB | 6.93 KiB | 0 B (0.00%) |
| Installer (Windows ARM64) | 2.15 MiB | 2.15 MiB | +67 B (+0.00%) |
Raw sizes are uncompressed file sizes. gzip sizes recompress each binary at level 9; they are not package or download archive sizes.
The baseline uses published release files, including NAPI packages from npm at the same version. Build versions and toolchains can affect the difference.
Registry bridge build (
|
| Package | Version |
|---|---|
vite-plus |
0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88c |
@voidzero-dev/vite-plus-core |
0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88c |
create-vite-plus |
0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88c |
Install the Vite+ CLI built from this commit, then migrate a project:
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/voidzero-dev/vite-plus/a82db6d743fa458af8136cacda88afb848aff88c/packages/cli/install.sh | VP_PR_VERSION=3670 VP_LEGACY_INSTALLER_URL=https://raw.githubusercontent.com/voidzero-dev/vite-plus/a82db6d743fa458af8136cacda88afb848aff88c/packages/cli/install-legacy.sh bash# Windows (PowerShell)
$env:VP_PR_VERSION="3670"; $env:VP_LEGACY_INSTALLER_URL="https://raw.githubusercontent.com/voidzero-dev/vite-plus/a82db6d743fa458af8136cacda88afb848aff88c/packages/cli/install-legacy.ps1"; irm https://raw.githubusercontent.com/voidzero-dev/vite-plus/a82db6d743fa458af8136cacda88afb848aff88c/packages/cli/install.ps1 | iexOr install with Homebrew (macOS / glibc Linux):
These commands use the formula and binary from this published commit. Replace brew install with brew reinstall if the tap package is already installed.
If Homebrew Core’s vite-plus is installed, run brew uninstall vite-plus first. This keeps your user data; do not run vp implode to switch installations.
(
set -eu
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_VP_PR_VERSION=a82db6d743fa458af8136cacda88afb848aff88c
brew tap voidzero-dev/vite-plus https://github.com/voidzero-dev/vite-plus
preview_tap="$(brew --repository voidzero-dev/vite-plus)"
git -C "$preview_tap" fetch --depth=1 https://github.com/voidzero-dev/vite-plus.git "$HOMEBREW_VP_PR_VERSION"
git -C "$preview_tap" switch --detach "$HOMEBREW_VP_PR_VERSION"
brew install voidzero-dev/vite-plus/vp
brew test voidzero-dev/vite-plus/vp
"$(brew --prefix)/bin/vp"
)The tap stays at the tested commit. Return it to main after testing:
git -C "$(brew --repository voidzero-dev/vite-plus)" switch mainOr download the standalone Windows installer built from this commit:
| Architecture | Installer |
|---|---|
| x64 | vp-setup-x86_64-pc-windows-msvc.exe |
| Arm64 | vp-setup-aarch64-pc-windows-msvc.exe |
GitHub requires you to sign in and downloads each installer as a ZIP artifact. Extract vp-setup.exe, then run it against this preview build:
.\vp-setup.exe --version "0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88c" --registry "https://registry-bridge.viteplus.dev/"After installing, upgrade the current project's vite-plus to this test build with:
vp migrateOr create a new project from this commit without installing the CLI:
export npm_config_registry=https://registry-bridge.viteplus.dev/ pnpm_config_registry=https://registry-bridge.viteplus.dev/
pnpm create vite-plus@0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88c # or: npm create vite-plus@0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88c$env:npm_config_registry="https://registry-bridge.viteplus.dev/"; $env:pnpm_config_registry="https://registry-bridge.viteplus.dev/"
pnpm create vite-plus@0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88c # or: npm create vite-plus@0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88cpnpm 11+ reads pnpm_config_registry, npm and older pnpm read npm_config_registry. The new project pins this build, so keep the registry set for later installs, or configure it as below.
Or point your package manager at the bridge registry https://registry-bridge.viteplus.dev/:
| Package manager | Registry config |
|---|---|
| npm / pnpm / Bun | .npmrc: registry=https://registry-bridge.viteplus.dev/ |
| Yarn (v2+) | .yarnrc.yml: npmRegistryServer: "https://registry-bridge.viteplus.dev/" |
Then pin the build (vite aliases to vite-plus-core; pnpm can use a catalog, npm an overrides entry):
{
"devDependencies": {
"vite-plus": "0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88c",
"vite": "npm:@voidzero-dev/vite-plus-core@0.0.0-commit.a82db6d743fa458af8136cacda88afb848aff88c"
}
}
🐳 Docker preview imageBuilt from this PR's registry bridge build:
# remove any stale local copy from a previous run, then pull fresh
docker rmi ghcr.io/voidzero-dev/vite-plus:pr-3670 2>/dev/null; docker pull ghcr.io/voidzero-dev/vite-plus:pr-3670Quick check: docker run --rm ghcr.io/voidzero-dev/vite-plus:pr-3670 vp --versionSee docs/guide/docker.md for usage. |
Add an RFC for first-class `.env` support through varlock: a bundled `vp dotenv` command family (init, check, print, explain, scan, exec), automatic Vite/Vitest plugin injection when `.env.schema` exists, create/migrate scaffolding, and opt-in `vp run` task injection. Add the user guide and config reference that describe the intended end-user experience, with sidebar entries and cross-links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Phase 1 of rfcs/varlock-integration.md: - `vp dotenv init|check|print|explain|scan|exec`, parsed by clap in the native binding and run through the bundled varlock CLI script. - Load `@varlock/vite-integration` from `defineConfig` when the project root has `.env.schema`, with a resolve plugin for `varlock/*` imports and a client build-output scan. The new `dotenv` config key controls it. - `vite-plus/env` re-exports `varlock/env`. - Pin varlock and its Vite integration, and report varlock in the toolchain and version output. - Keep `.env.schema` tracked in the `vp create` .gitignore default. - Align the RFC and docs with varlock's actual CLI and plugin behavior. Not done yet: pnpm-lock.yaml does not include varlock, the native binding and global CLI are not compiled, the hand-edited binding index files are unchecked against napi output, and the affected CLI snapshots are not re-recorded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `vp dotenv` waits on SIGINT and forwards SIGTERM and SIGHUP to varlock, so `exec` no longer orphans the child under a supervisor. - `vp dotenv exec` rejects unknown options before the command instead of running them as the command. - Gate every dotenv plugin with `apply`: the first group claims each config resolution, so composed configs do not load varlock twice, and the merged config's `dotenv` options apply. - Change PATH and the telemetry default only while the varlock Vite integration is imported; the integration keeps its own copy of the env. - Report a scan spawn error or signal separately from scan findings. - Skip non-JSON lines before the `varlock load` output, and quote masked `env` values with single quotes so `$` is not expanded. - Add `vp dotenv init --no-interactive` (`varlock init --agent`). - Reuse `pkgRoot` and resolve varlock from vite-plus's manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Mark varlock as `noExternal` in server environments. Vite resolves an externalized dependency again from the importer, which skipped the resolve bridge, so SSR dev under pnpm could not load `varlock/env`. - Resolve `vite-plus/env` to `varlock/env`, so each environment has one varlock runtime, the one that the SSR init code initializes. - Fail every `vp dotenv` subcommand except `init` when the directory has no `.env.schema` and no `varlock.loadPath`, so `check` and `scan` cannot pass without checking anything. - Tolerate extra stdout lines after the `varlock load` JSON. - Document how tasks pass `APP_ENV` and secrets through to varlock, and show `--reveal` for `eval` of `vp dotenv print --format shell`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`dotenv.schema: true` without a schema rejected the plugin promise, and Vite awaits plugin promises before it calls `apply`, so a later `dotenv.schema: false` from `mergeConfig` could not win. A separate `vite-plus:dotenv-require-schema` plugin now fails in its `config` hook, and only when the merged config still sets `true`. Document in the RFC that the integration's import-time load runs in the working directory, and that its `config` hook loads again from the Vite root and clears the earlier error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Stop recommending `vp remove varlock` after `varlock init`. TypeScript resolves the generated `varlock/env` augmentation from the project, so the direct dependency is needed under pnpm; package managers share one copy when it matches the bundled version, which the reminder now names. - Print masked `vp dotenv print` output through the terminal `log` helper, which ignores a closed pipe, instead of a raw stdout write that threw EPIPE for `vp dotenv print | head -n 1`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add pnpm-lock.yaml entries for varlock 1.23.0 and @varlock/vite-integration 1.5.4, including the catalog entries, the vite-plus importer, and varlock's optional native helper packages, so frozen installs accept the manifest changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add varlock to the global CLI's `vp --version` tool list, which is separate from the JS list, and add the `dotenv` row to the local CLI's `vp -h`, so both CLIs show the same commands and tools. - With `dotenv.schema: true`, fail with an error that names a schema found only in a root given on the command line, instead of claiming that no schema exists. - Fix type-aware lint errors in the dotenv module and its tests. - Add the command_dotenv snapshot fixture (help on both flavors, the error paths, and a real schema run with a masked secret), and re-record the help, version, toolchain, and create snapshots that the new command, tool, and .gitignore entry change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The varlock runtime snapshots process.env when `varlock/env` first loads and writes the snapshot back on every reload. It first loaded inside the integration import, while vite-plus's bin directory was on PATH, so a dev restart or a root that differs from the working directory restored that PATH for the rest of the process. Load `varlock/env` before changing the environment, so the snapshot holds the user's own PATH. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Fail a Vitest run in `configureVitest` when the env config is invalid. Vitest resolves its config with `command: 'serve'`, for which the integration only installs a dev error page, so tests ran anyway. - Apply the integration's plugins only in resolutions with the group's first root. An inherited inline Vitest project with its own `root` reloaded the integration's module-wide state and dropped the root schema's env for every project. - Add the dotenv entry as a tagged thenable that imports the integration only when Vite awaits it, and drop wrapped configs' entries in `defineConfig`, so an outer `dotenv.schema: false` never starts the first `varlock load`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rocess - Run the Vitest validation guard in `configResolved` instead of `configureVitest`. Vitest calls `configureVitest` for runnable projects only, so a root config that only lists file-based projects skipped the check. The guard detects Vitest through the `__vitest__` environment, so `vp dev` keeps the integration's error page. - Pin the integration to one schema root per process instead of per plugin group. The integration and varlock's runtime keep one loaded env per process, so a second project config with a different schema mixed the two schemas' values. It now fails with an error that names both schema roots; inherited projects still keep the root's env. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pass `rootDir` to the varlock Vite integration instead of gating its plugins on the final Vite root. The integration reloads only when `rootDir ?? config.root` changes, and Vitest changes `root` in ways `defineConfig` cannot see: it evaluates the parent config again for an inline project, and sets the root of a file-based project in a config hook. The root pin wrongly rejected the re-evaluated config, missed the file-based project's reload, and dropped `ENV` transforms and init code from inherited browser projects. Key the one-schema-per-process check on the schema root, so a config evaluated again for the same schema passes, and run the build-output scan in the schema root, where `varlock scan` resolves the schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Remove the keys that the schema marks @sensitive from Vite's `config.env` in `configResolved`. varlock writes every resolved value into `process.env`, and Vite's `loadEnv` copies each `VITE_*` key from there into `import.meta.env`, so decrypted or secret-manager values reached browser code in `vp dev`. A warning names the removed keys. - Stop `vp preview` when the env config is invalid. Vite resolves preview as `serve`, and the integration's error page lives in `configureServer`, which preview never calls. The guard, now `vite-plus:dotenv-validation`, covers Vitest and preview. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Independent Vitest projects (`defineProject` files and inline projects with `extends: false` or a config file) get their own Vite server without the root plugins. Give each one a follower entry that installs the resolver, the varlock transforms, and the client env filter for the claimed schema. Validation and the build-output scan stay with the root. - When merged configs bring two different schema roots into one resolution, fail with the conflict error instead of keeping the first schema silently. - Load the schema root right after the integration import. With `_VARLOCK_ENV_KEY` preset, the integration skipped its preload and did not set the restart flag when the root differed from the working directory, so the first dev restart was lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- @varlock/vite-integration 1.5.6 fixes the stale first dev restart when the root is not the working directory. Remove the early schema-root load that worked around it. - A dev restart now loads env again only when an env file changed. Document that values from a secret manager or `exec()` refresh only when the dev server starts again. - varlock 1.25.0 names the failing keys on the last line of an invalid config. Record the new schema snapshot. - RFC: describe 1.5.6 and mark the restart request as resolved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Describe `vp dotenv` in the global and local `vp --help` and in the READMEs as "Validate and inspect project environment variables using .env.schema". "Manage .env files" suggested a file editor. - Add "For project environment variables, see vp dotenv." to the global `vp env --help`, for users who try `vp env` first. - Start `vp dotenv --help` with "Validate project environment variables against .env.schema, including values supplied by CI", so it is clear that the check covers the values in effect. - Record the `help_background_job` snapshot, which was missing the `dotenv` row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
….env types - Keep the direct `varlock` dependency when TypeScript code reads `ENV`. `ENV` gets its keys only from the generated types, which extend `varlock/env`, and with pnpm the bundled copy is not visible from the project, so every `ENV` property is a type error. Explain why its version must match the bundled one, and when it can be removed. - Use `@generateTsTypes(path='env.d.ts', importMetaEnv=none)` in the examples, and tell users to add the option after `vp dotenv init`. By default the generated types add every variable to `import.meta.env`, sensitive ones included, but Vite exposes only `VITE_*` variables there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…llow the new lint preset - `vp dotenv init` pins the `varlock` dependency that `varlock init` adds to the bundled version, then runs `vp install`. `varlock init` runs `<package manager> add varlock`, which saves the latest release with a range. - Rename the `vite-plus/env` export to `vite-plus/dotenv`. The name matches `vp dotenv` and does not suggest a link to `vp env`, which manages runtimes. - Follow the Cloudflare Oxlint preset from #3562: read JSON as `JsonObject` instead of `any`, type the lazy plugin entry as a promise, and remove unsafe type assertions. Keep `utils/json.ts` out of the config graph that `defineConfig` loads, because the CommonJS build cannot bundle `jsonc-parser`. - Add the `varlock` row to the new `cwd_flag` snapshot. - RFC: record that the generated types can augment `vite-plus/dotenv` through the re-export, and link the upstream request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`varlock init` runs `<package manager> add varlock`, which installs the latest release with a range. Instead of pinning it afterwards with a second install, `vp dotenv init` writes `varlock` at the bundled version into `dependencies` before `varlock init` runs. `varlock init` skips its install when the dependency exists, so `vp dotenv init` runs `vp install` once. When the init fails or is cancelled (varlock exits with code 0 on a cancelled prompt), it restores `package.json`. Remove `hasVarlockDependency`, which nothing uses now, and link the upstream request for a skip option from the RFC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lock dependency The generated types augment `varlock/env`, which TypeScript resolves from the project, so `ENV` needed a direct `varlock` dependency. Ship a varlock plugin in `vite-plus` (the `./plugin` export that varlock requires) that registers `@generateVitePlusTypes`. It runs varlock's own TypeScript generator and adds the same augmentation for `vite-plus/dotenv`, so varlock writes the final file itself on every load. The plugin is one CommonJS file: varlock runs `.cjs` plugins with its own `varlock/plugin-lib`, so it works with the varlock copy that loads it. `vp dotenv init` now leaves `package.json` unchanged. It writes the dependency only so that `varlock init` skips its own install, restores the file, switches the new schema to `@plugin(vite-plus) @generateVitePlusTypes(..., importMetaEnv=none)`, and runs one load to write the types. A project that already depends on `varlock`, or has no `vite-plus` in node_modules, keeps the plain `varlock init` behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
….config.ts
A config file runs before Vite+ adds the varlock integration, so `ENV`
threw "varlock ENV not initialized" there. Under the `node` export
condition, `vite-plus/dotenv` now loads the integration with `require()`
on the first read. The integration's own load then serves the config file
and the Vite command, the integration copies `process.env` before varlock
injects values into it, and an invalid env still stops `vp build`. After a
failed load, reads return no values with varlock's warning instead of
throwing. Each read checks the env files at most once per synchronous
turn, so a `vp dev` restart gives the config the new values.
varlock picks `.env.[env]` files from `@currentEnv`, not from Vite's mode,
and its values override the ones Vite reads from `.env.[mode]`. `vp dev`,
`vp build`, `vp preview`, and `vp test` now warn when a mode other than
the default mode of the command does not match the `@currentEnv` value,
and name the command to run, such as `APP_ENV=staging vp build`.
`vp dotenv init` also replaces `@defaultSensitive=false` with
`@defaultSensitive=inferFromPrefix('VITE_')`, so that only `VITE_*`
variables are public by default, as in Vite. The client env warning now
says that a variable that the schema does not declare is sensitive too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
varlock selects `.env.[env]` files from `@currentEnv`, and without it only from its `--env` option, so `vp build` ignored `.env.production`, which plain Vite loads, and printed no warning. The local CLI now sets `VP_VITE_MODE` for `vp dev`, `vp build`, `vp preview`, and `vp test`: the `--mode` value, or else the default mode of the command. `vp run` passes it to cached tasks, because the arguments in the cache key decide it. The vite-plus varlock plugin adds `viteMode()`, so a schema can follow the mode with `APP_ENV=fallback(viteMode(), development)`. The mode is the lowest-priority source: the process environment, env files, and earlier `fallback()` values still win, and `vp build` loads the same files as `vp build --mode production`. `vp dotenv init` adds `@currentEnv=$APP_ENV` and that item when the schema has no `@currentEnv`. `vp dotenv check`, `print`, `explain`, `scan`, and `exec` take `--mode`. The mode warning now also covers the default mode when `.env.[mode]` exists, and names why the environment does not follow the mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vite+ bundles varlock and its Vite integration and adds them for `.env.schema`, so a project that registers `varlockVitePlugin()` itself would run two integrations. `vp migrate` now detects `@varlock/vite-integration` in package.json or vite.config, asks in interactive mode (default yes), and migrates in non-interactive mode. On a project that already uses Vite+, it runs with `--full`, like the other tool migrations. The migration removes `varlockVitePlugin()` calls without options and their import, and an emptied `plugins` property. It switches `@generateTsTypes(...)` in `.env.schema` to `@plugin(vite-plus) @generateVitePlusTypes(...)` with the same options, and keeps `@defaultSensitive` and `@currentEnv`, so the project loads the same values. It removes `@varlock/vite-integration`, and `varlock` when no source import, script, CI workflow, git hook, varlock plugin, or other schema plugin uses it. A call with options and a used dependency stay, with a warning. Imports from `varlock/env` stay, because server code that Vite does not bundle would then need `vite-plus` at run time. The RFC now states when pnpm 12 asks to approve varlock's agent skill: only for a direct dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6b4945c to
cc78061
Compare
…ntal
varlock encrypts secrets with a key stored on the device (Secure Enclave,
TPM, or a key file) as `varlock("local:...")`, and every command that
loads the schema already decrypts them. Projects without a direct
`varlock` dependency had no command to create those values, though.
`vp dotenv encrypt` runs `varlock encrypt` with the terminal attached: it
reads a value from stdin or a prompt, or encrypts the sensitive plaintext
values of a file with `--file`. `vp dotenv lock` runs `varlock lock`,
which ends the biometric session. Neither needs a schema, except
`encrypt --file`.
The guide gets a local encryption section: which commands decrypt, where
varlock keeps the key, that only the encrypting device can decrypt, and
that `varlock(prompt)` asks only through `vp dotenv exec`. The guide, the
`dotenv` config reference, the varlock migration rules, and the README
command lists now say that `vp dotenv` and the `.env.schema` support are
experimental.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`keychain()` already reads secrets from the macOS Keychain in every command that loads the schema, but projects without a direct `varlock` dependency had no command to store or manage those items. `vp dotenv keychain` passes every argument, `--help` included, to `varlock keychain` (`set`, `import`, `fix-access`, or `list`) with the terminal attached. Vite+ does not declare the subcommands and options again, so it does not have to follow their changes. varlock reports the platform error outside macOS, and `keychain import` checks for its schema itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On cnpmcore, a server with about 80 optional variables and none set,
`vp dotenv check` printed `Found no errors in 0 config items`, because it
counted only the values in `load --format json`. It now reads the full
graph (`json-full --agent`, so sensitive values stay redacted) and prints
both numbers: `Found no errors in 80 config items (0 have a value)`.
`vp dotenv init` also assumed a Vite app. `inferFromPrefix('VITE_')`
made every variable of a server sensitive, and the `viteMode()` item had
no Vite command to follow. init now reads the package.json scripts and
`index.html`: only a project that serves or builds a client app with Vite
gets the prefix rule, and only one whose scripts run Vite or Vitest gets
the `APP_ENV` item. A server keeps `@defaultSensitive=false`.
The guide also notes that output redaction in `vp dotenv exec` masks every
occurrence of a sensitive value, so a short value such as `postgres`
masks the same word in unrelated output.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds first-class
.envsupport to Vite+ through varlock. A project commits a.env.schemathat declares each variable, its type, and whether it is sensitive. Real values stay in git-ignored files such as.env.local. Vite+ bundles varlock and its Vite integration, so the project does not install or register anything.The feature ships as experimental: the Env Files guide, the
dotenvconfig reference, the varlock migration rules, and the README command lists say so, and commands, options, and the schema setup thatvp dotenv initwrites may change.Design:
rfcs/varlock-integration.md. User guide:docs/guide/dotenv.md. Config reference:docs/config/dotenv.md.vp dotenvcommandsvp dotenv init [--no-interactive].env.schemafrom the existing.envfiles and code, adds!.env.schemato.gitignorewhen needed, and sets up theENVtypes without avarlockdependency. A project that serves or builds a client app with Vite gets@defaultSensitive=inferFromPrefix('VITE_'), and a project whose scripts run Vite or Vitest gets anAPP_ENVthat follows the Vite mode. A server without a client bundle keeps@defaultSensitive=falsevp dotenv check [--mode <name>] [--env <name>]pass:line with the number of config items and how many have a valuevp dotenv print [--mode <name>] [--format env|json|shell] [--reveal]--revealis givenvp dotenv explain [KEY] [--mode <name>]vp dotenv scan [--mode <name>] [--staged] [--include-ignored] [paths...]vp dotenv exec [--mode <name>] -- <command>vp dotenv encrypt [--file <file>]varlock("local:...")with a key stored on the device, or the sensitive plaintext values of a filevp dotenv lockvp dotenv keychain [args...]keychain()reads. Every argument,--helpincluded, goes tovarlock keychain(set,import,fix-access,list)--modegivesviteMode()the same value asvp build --mode <name>, so CI can check the values of one mode. Every subcommand that loads the config fails when the directory has no.env.schemaand novarlock.loadPath, so a check in the wrong directory cannot pass.init,lock,keychain, andencryptwithout--filedo not load it.vp dotenvis available from both the global and the local CLI, andvp --versionlists the bundled varlock version. The globalvp env --helppoints tovp dotenvfor project environment variables.Vite and Vitest integration
When the config root has a
.env.schema,defineConfigadds the varlock plugins. Projects without a schema get no new plugins, and their plugin list does not change.vp devvalidates before it serves the app and shows varlock's error page when the env is invalid.vp buildandvp previewstop with exit code 1 on invalid env.vp testfails before any test runs.ENVfromvite-plus/dotenv(orvarlock/env) is typed and coerced. Public values are inlined at build time, and sensitive values are never inlined into client code.vite.config.tscan readENV. The first read loads the schema, and the Vite command uses the same load. An invalid env still stopsvp build, and avp devrestart after an env file change gives the config the new values..env.[env]files from the@currentEnvvariable, andviteMode()from@plugin(vite-plus)returns the mode ofvp dev,vp build,vp preview, orvp test(the--modevalue, or else the default mode of the command). WithAPP_ENV=fallback(viteMode(), development),vp buildloads.env.productionas in Vite,vp build --mode stagingloads.env.staging, andvp testloads.env.test. The mode is the lowest-priority source, soAPP_ENVfrom the environment or an env file still wins. This also holds when avp runtask runs the command.--modevalue, and for the default mode when.env.[mode]exists. The warning names the cause, such as a schema withoutviteMode()or a value with higher priority.vite-plus/pluginis a varlock plugin. In the schema,@plugin(vite-plus) @generateVitePlusTypes(path=env.d.ts, importMetaEnv=none)writes varlock's TypeScript types and also applies them toENVfromvite-plus/dotenv, so a project needs no directvarlockdependency.vp dotenv initsets this up and leavespackage.jsonunchanged.VITE_*variable from the process environment intoimport.meta.env. Vite+ removes the keys that varlock treats as sensitive and prints a warning that names them. varlock treats a variable that the schema does not declare as sensitive, so publicVITE_*variables must be in the schema.varlock("local:...")), and macOS Keychain references (keychain(...)), resolve in every command that loads the schema.varlock(prompt)asks for a value only throughvp dotenv exec, because the other commands do not give varlock a terminal.varlock scanon the output and fails the build if a sensitive value appears there.dotenv.scanBuildOutput: falseturns this off.varlockat run time.defineProjectfiles and projects withextends: false) use the root config's schema.dotenv.schema: falsekeeps the file but skips loading.dotenv.schema: truefails when no schema is found.vp createadds!.env.schemato the default.gitignore.vp migratefor existing varlock setupsA project that registers
@varlock/vite-integrationitself would run two integrations after it adopts Vite+.vp migratedetects the integration inpackage.jsonorvite.config.*, asks in interactive mode (default yes), and migrates in non-interactive mode. On a project that already uses Vite+, it runs with--full, like the other tool migrations.varlockVitePlugin()without options leaves the Vite config, with its import and an emptiedpluginsproperty.@generateTsTypes(...)in.env.schemabecomes@plugin(vite-plus) @generateVitePlusTypes(...)with the same options.@defaultSensitiveand@currentEnvstay, so the project loads the same values.@varlock/vite-integrationis removed.varlockis removed when no source import, script, CI workflow, git hook, varlock plugin, or other schema plugin uses it.varlock/envstay, because server code that Vite does not bundle would then needvite-plusat run time.Dependencies
vite-plusnow depends onvarlock@1.25.0and@varlock/vite-integration@1.5.6, kept in lockstep in the catalog. They add about 5.7 MB unpacked (varlock5.4 MB, the integration 0.24 MB), plus one native helper for the platform (0.5 MB on Windows x64, 1.0 MB on macOS, 1.8 MB on Linux x64).@varlock/vite-integration@1.5.6fixes a stale env on the first dev server restart when Vite's root is not the working directory.Limits
vpprocess loads one schema. Configs with different.env.schemafiles in one resolution or onevp testrun fail with an error instead of mixing values.rootfromvite.config.ts, or else in the working directory. A root given only on the command line (vp dev ./app) is not detected. Withdotenv.schema: true, the command fails and names that schema.ENVinvite.config.tsreads the schema in the working directory, not in arootthat the config sets. Other commands that run the config file, such asvp lint, then load the schema too.viteMode()comes from thevpcommand line.modeinvite.config.tsdoes not change it, and it returns nothing when a script runsvite builddirectly. Vite+ warns in both cases.vp runtask starts in a clean environment. To give a task the schema environment, run its command throughvp dotenv exec.ENVfromvarlock/envneeds a directvarlockdependency at the bundled version.ENVfromvite-plus/dotenvdoes not.varlockis a direct dependency, so a project that depends only onvite-plussees no prompt. This repository and projects that addvarlockthemselves see it until they approve or deny it (pnpm approve '!varlock').vp dotenv execreplaces every occurrence of a sensitive value, so a short or common value, such as a database passwordpostgres, also masks the same word in unrelated output.vp pack(tsdown) does not load the schema.🤖 Generated with Claude Code