fix(cli): follow .env.example ordering and comments when writing .env.local - #3100
Merged
jorgemoya merged 2 commits intoJul 14, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 30b0a05 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 |
Contributor
Bundle Size ReportComparing against baseline from No bundle size changes detected. |
Contributor
Unlighthouse Performance Comparison — VercelComparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores. Summary ScoreAggregate score across all categories as reported by Unlighthouse.
Category Scores
Core Web Vitals
|
jorgemoya
marked this pull request as ready for review
July 14, 2026 16:36
jorgemoya
force-pushed
the
jorgemoya/ltrac-974-follow-envexample-when-setting-new-environment-variables
branch
from
July 14, 2026 16:36
f3a30d0 to
9ae6f0d
Compare
chanceaclark
approved these changes
Jul 14, 2026
….local writeEnv previously emitted a flat, unordered list of KEY=VALUE pairs, ignoring core/.env.example — the file that documents every variable with comments, ordering, and sensible defaults. Generated .env.local files were therefore inconsistent and undocumented, and channel link/create clobbered any values the user had already set. writeEnv now reads the project's own .env.example as the source of truth for shape. It reproduces the documented ordering and per-key comment blocks, substitutes CLI-supplied values in place, and leaves documented-but-unsupplied keys as their example line (blank or default) so users still see what's expected. CLI-only variables (e.g. access tokens not in .env.example) are appended in a clearly separated trailing section. Existing .env.local files are reconciled rather than overwritten: user-set values are preserved unless the CLI explicitly supplies a new one, and newly documented keys are added in their canonical position without disturbing the ordering of unknown keys. Falls back to a flat merge when no .env.example is present. Refs LTRAC-974 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…mpty `catalyst channel link` inlined its own .env.local dump instead of going through writeEnv, so it skipped the .env.example ordering/comments and overwrote the file rather than reconciling it. Route it through writeEnv like `channel create --link`. Also stop empty CLI-supplied values from clobbering existing on-disk values: the channel init API returns blank placeholders for keys it does not own (e.g. MAKESWIFT_SITE_API_KEY), which were wiping the user's real value on re-run. An empty supplied value now falls back to the existing .env.local value. Refs LTRAC-974 Co-Authored-By: Claude <noreply@anthropic.com>
jorgemoya
force-pushed
the
jorgemoya/ltrac-974-follow-envexample-when-setting-new-environment-variables
branch
from
July 14, 2026 17:27
e97863c to
30b0a05
Compare
jorgemoya
enabled auto-merge
July 14, 2026 17:30
jorgemoya
deleted the
jorgemoya/ltrac-974-follow-envexample-when-setting-new-environment-variables
branch
July 14, 2026 17:45
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.
Linear: LTRAC-974
What/Why?
writeEnvemitted a flat, unordered list ofKEY=VALUEpairs that looked nothing like the documentedcore/.env.example— no comments, arbitrary order, no signal about what still needs filling in. This uses.env.exampleas the source of truth for shape and ordering: keys are emitted in their documented order with each key's leading comment block preserved; documented-but-unset keys render as blank active keys (KEY=); and CLI-supplied keys not in the example are appended in a clearly separated trailing section. Existing.env.localvalues are preserved and reconciled against.env.exampleon re-runs (newly documented keys get added in canonical position without disturbing existing values).Out of scope: deployment secrets in
.bigcommerce/project.json/catalyst env add(tracked in LTRAC-975).Testing
write-env.spec.ts(7 tests): ordering, comment preservation, blank-key rendering for missing keys, unknown-key passthrough, and the re-sync path.typecheckandlintpass.Migration
None.