Skip to content

fix(cli): follow .env.example ordering and comments when writing .env.local#3100

Draft
jorgemoya wants to merge 1 commit into
canaryfrom
jorgemoya/ltrac-974-follow-envexample-when-setting-new-environment-variables
Draft

fix(cli): follow .env.example ordering and comments when writing .env.local#3100
jorgemoya wants to merge 1 commit into
canaryfrom
jorgemoya/ltrac-974-follow-envexample-when-setting-new-environment-variables

Conversation

@jorgemoya

Copy link
Copy Markdown
Contributor

Linear: LTRAC-974

What/Why?

writeEnv emitted a flat, unordered list of KEY=VALUE pairs that looked nothing like the documented core/.env.example — no comments, arbitrary order, no signal about what still needs filling in. This uses .env.example as 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.local values are preserved and reconciled against .env.example on 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.
  • typecheck and lint pass.

Migration

None.

….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>
@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
catalyst Ready Ready Preview, Comment Jul 10, 2026 3:54pm

Request Review

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f3a30d0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst Patch

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

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Report

Comparing against baseline from 8d9f9a9 (2026-07-10).

No bundle size changes detected.

@github-actions

Copy link
Copy Markdown
Contributor

Unlighthouse Performance Comparison — Vercel

Comparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores.

Summary Score

Aggregate score across all categories as reported by Unlighthouse.

Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Score 89 92 92 94

Category Scores

Category Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Performance 78 85 76 79
Accessibility 95 92 95 98
Best Practices 100 100 100 100
SEO 88 100 100 100

Core Web Vitals

Metric Prod Desktop Prod Mobile Preview Desktop Preview Mobile
LCP 3.6 s 4.2 s 3.7 s 5.7 s
CLS 0.001 0 0.001 0.011
FCP 1.1 s 1.2 s 1.2 s 1.2 s
TBT 0 ms 30 ms 0 ms 0 ms
Max Potential FID 40 ms 120 ms 40 ms 50 ms
Time to Interactive 3.6 s 4.6 s 3.7 s 5.7 s

Full Unlighthouse report →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant