fix(varlock): scope audit/init env scanning in monorepos#830
Open
theoephraim wants to merge 2 commits into
Open
fix(varlock): scope audit/init env scanning in monorepos#830theoephraim wants to merge 2 commits into
theoephraim wants to merge 2 commits into
Conversation
Scanning no longer descends into child packages (any subdir with its own package.json or .env.schema is treated as a separate package), and well-known platform/runtime/CI vars (NODE_ENV, CI, PATH, npm_*, GitHub Actions context, etc.) are no longer reported as missing or added to inferred schemas.
Contributor
|
The changes in this PR will be included in the next version bump.
|
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| 🔵 In progress View logs |
varlock-website | 31bee74 | Jun 25 2026, 06:41 AM |
commit: |
…plumbing only Only ignore pure shell/OS/node-launch/npm plumbing (PATH, NODE_OPTIONS, npm_*, ...). App-meaningful vars like NODE_ENV, the CI flag, and GitHub Actions/hosting vars are still reported so users can decide whether to declare them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What & why
Running
varlock audit(and the source scan invarlock init) in a monorepo erroneously pulled in env var references from every child package, producing a large list of spurious "missing in schema" findings — most noticeable duringinit— and it was slow.Changes
1. Respect package boundaries when scanning
discoverSourceFilesnow walks manually and stops descending into any subdirectory that is its own project — detected by the presence of apackage.jsonor.env.schema.package.jsoncovers JS workspace packages regardless of package manager, and works in a fresh monorepo where child packages haven't runvarlock inityet;.env.schemacovers already-initialized and non-JS projects. The scan root itself is always exempt. Ignored dirs (node_modules, etc.) are pruned up front rather than globbed-then-filtered.2. Ignore pure execution-environment plumbing
New
well-known-env-keys.ts/isWellKnownEnvKey(). Variables that are an artifact of where/how the process runs — shell/OS (PATH,HOME,SHELL, …), node launch flags (NODE_OPTIONS,NODE_PATH, …), and package-manager lifecycle (npm_*) — are read fromprocess.envin normal code but are never declared in a schema, so:auditno longer reports them as "missing in schema"initno longer adds them to inferred schemasThe list is intentionally narrow. It deliberately does not include semantically meaningful vars an app or its CI may depend on —
NODE_ENV, theCIflag, GitHub Actions / GitLab context vars, hosting markers likeVERCEL. Those keep showing up in audit so you can decide whether to declare them or suppress them with@auditIgnore. It also never matches anything that could be config or a secret (noPORT/HOST/DATABASE_URL, noGITHUB_prefix-match).Impact (auditing this repo's root)
The remaining findings are genuine project-specific vars (GitHub Actions context vars used in CI scripts,
RELEASE_*) — real signal, surfaced on purpose.Notes
@auditIgnore/@auditIgnorePaths/--ignoreescape hatches are unchanged;isWellKnownEnvKeyis structured so a user-extensible config layer can compose on top later if needed.package.json(e.g. a bundled demo/examplesapp) is now skipped during the parent's audit. That's almost always desired, but it is a change.Tests
isWellKnownEnvKey(incl. that NODE_ENV / CI / GitHub vars are still tracked), plus audit-command tests for both filtered-and-not cases. Fullvarlocksuite passes.