You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: ensure newline separator when appending to files - #396
Appending to a file without a final newline can join ignore patterns or environment sections. This adds the missing separator in both Node and edge template generation, preserves existing spacing and keeps raw file appends unchanged.
AI review notes:
The missing-newline regression failed in disk, Node memory and edge memory environments before the fix. All 27 cases now pass, covering missing and empty targets, existing separators, empty appends and CRLF.
The normal pre-commit build, unit and blocking e2e gates passed. A real Sentry/PostHog app was also generated outside the monorepo without installation or provider calls, and its environment sections are separate.
The original trailing-newline fixes and contributor history are retained.
Summary by CodeRabbit
Bug Fixes
Generated add-on files now append on a separate line when the existing file has content but no final newline. Existing newlines and intentional blank lines are preserved, and empty appends do not add extra separators. This behavior is consistent across disk-based, Node-memory, and edge-generation workflows.
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).
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
Heads up: #501 removes memfs from the published runtime and routes the Node memory environment through edge-environment.ts. If #501 lands first, the append separator change here should move to packages/create/src/edge-environment.ts; environment.ts will only adapt Node path resolution.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
Walkthrough
The Node and edge template append paths now insert a newline when existing nonempty file content lacks a final newline and appended content does not begin with one. Parameterized tests cover disk and memory environments, and a patch changeset records the update.
Changes: Append separator handling
Layer / File(s)
Summary
Append paths and validation packages/create/src/template-file.ts, packages/create/src/edge-template-file.ts, packages/create/tests/append-separators.test.ts, .changeset/append-separators.md, packages/create/src/frameworks/{react,solid}/add-ons/*/assets/*.append
Both append paths conditionally prepend a newline before appending. Tests cover missing or empty targets, newline combinations, blank lines, empty appends, and CRLF. The changeset describes the update. The listed add-on asset entries are unchanged.
Template appends preserve existing separators and keep sections separate. No merge-blocking risk was found.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: adding a newline separator when appending content to files.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 3 files. (5 skipped: 5 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
packages/create/tests/append-separators.test.ts
Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/create/tests/append-separators.test.ts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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
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.
Appending to a file without a final newline can join ignore patterns or environment sections. This adds the missing separator in both Node and edge template generation, preserves existing spacing and keeps raw file appends unchanged.
Summary by CodeRabbit