Skip to content

fix: ensure newline separator when appending to files#396

Open
Ktsierra wants to merge 1 commit intoTanStack:mainfrom
Ktsierra:fix/append-file-missing-newline
Open

fix: ensure newline separator when appending to files#396
Ktsierra wants to merge 1 commit intoTanStack:mainfrom
Ktsierra:fix/append-file-missing-newline

Conversation

@Ktsierra
Copy link

Summary

  • When multiple add-ons append to the same file (e.g. .env.local), the content from
    the second add-on gets concatenated directly onto the last line of the first add-on's
    content if it doesn't end with a newline. For example, selecting both Sentry and PostHog
    produces SENTRY_AUTH_TOKEN=# PostHog configuration... instead of two separate lines.
  • Add a newline guard in both the real fs and memfs appendFile implementations that
    ensures a blank line between appended sections for readability.
  • Add missing trailing newlines to 4 .append files: Sentry (react), Strapi (react + solid),
    and MCP gitignore (react).
  • Update test assertions to reflect the new blank-line separator behavior.

Test plan

  • pnpm build passes
  • pnpm test passes (271 tests across 3 packages)
  • Manually verified: node ./cli/packages/cli/dist/bin.js create test-app --framework react --add-ons sentry,posthog produces a valid .env.local with each
    add-on's variables separated by a blank line

appendFile concatenated content without checking for a trailing
  newline, causing malformed output when multiple add-ons append to the
  same file (e.g. .env.local with sentry + posthog).

  Add newline guard in both fs and memfs appendFile implementations.
  Fix 4 .append files missing trailing newlines (sentry, strapi, mcp).
Copilot AI review requested due to automatic review settings February 25, 2026 19:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a content concatenation issue where multiple add-ons appending to the same file (e.g., .env.local) would have their content directly concatenated without proper separation. The fix ensures proper formatting by automatically inserting blank line separators between appended sections.

Changes:

  • Modified appendFile implementations in both real fs and memfs to automatically add a blank line separator when appending to existing files
  • Added missing trailing newlines to 4 .append template files (Sentry, Strapi for React and Solid, MCP gitignore)
  • Updated test assertions to reflect the new blank-line separator behavior

Reviewed changes

Copilot reviewed 4 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/create/src/environment.ts Added logic to automatically insert blank line separators (1 or 2 newlines depending on existing content) when appending to files in both real fs and memfs implementations
packages/create/src/frameworks/react/add-ons/sentry/assets/_dot_env.local.append Added missing trailing newline to Sentry environment config
packages/create/src/frameworks/react/add-ons/strapi/assets/_dot_env.local.append Added missing trailing newline to Strapi environment config for React
packages/create/src/frameworks/solid/add-ons/strapi/assets/_dot_env.local.append Added missing trailing newline to Strapi environment config for Solid
packages/create/src/frameworks/react/add-ons/mcp/assets/_dot_gitignore.append Added missing trailing newline to MCP gitignore
packages/create/tests/template-file.test.ts Updated test assertion to expect blank line separator between appended content
packages/create/tests/filename-processing.test.ts Updated test assertion to account for the blank line separator behavior
packages/create/tests/environment.test.ts Updated test assertion to verify blank line separator in appendFile operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants