fix(cli): follow .env.example ordering and comments when writing .env.local#3100
Draft
jorgemoya wants to merge 1 commit into
Draft
Conversation
….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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: f3a30d0 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
|
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.