Skip to content

polish autoconfig newlines on created files#12548

Merged
dario-piotrowicz merged 3 commits intomainfrom
dario/DEVX-2462/polish-autoconfig-newlines
Feb 13, 2026
Merged

polish autoconfig newlines on created files#12548
dario-piotrowicz merged 3 commits intomainfrom
dario/DEVX-2462/polish-autoconfig-newlines

Conversation

@dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Feb 12, 2026

Fixes https://jira.cfdata.org/browse/DEVX-2462

When autoconfig creates files it can add extra empty lines (in gitignre files) or miss ending newlines (in package.json and wrangler.jsonc files), this PR simply polishes these small shortcomings


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bugfix/expected behavior

A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@claude
Copy link
Contributor

claude bot commented Feb 12, 2026

Claude finished @dario-piotrowicz's task —— View job


Changeset Review

Todo List:

  • Read changeset guidelines
  • Review .changeset/hot-walls-act.md
  • Review .changeset/spicy-eggs-fail.md
  • Review .changeset/thin-ears-sip.md
  • Check for cute animal image
  • Post final review results

All changesets look good

All three changesets are properly formatted:

  • hot-walls-act.md: Fixes .assetsignore formatting - patch version ✓
  • spicy-eggs-fail.md: Adds trailing newlines to generated files - patch version ✓
  • thin-ears-sip.md: Fixes .gitignore formatting - patch version ✓

Each changeset:

  • ✓ Uses appropriate patch version (bug fixes)
  • ✓ Has meaningful descriptions explaining the problem and fix
  • ✓ Contains no h1/h2/h3 headers
  • ✓ Follows the recommended format

@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2026

🦋 Changeset detected

Latest commit: 65d091a

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

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 12, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12548

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12548

miniflare

npm i https://pkg.pr.new/miniflare@12548

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12548

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12548

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12548

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12548

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12548

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12548

wrangler

npm i https://pkg.pr.new/wrangler@12548

commit: 65d091a

@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review February 12, 2026 17:18
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner February 12, 2026 17:18
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

⚠️ 1 issue in files not directly in the diff

⚠️ .assetsignore has the same leading empty lines bug that was fixed for .gitignore but was not updated (packages/wrangler/src/autoconfig/add-wrangler-assetsignore.ts:75-78)

When addWranglerToAssetsIgnore creates a new .assetsignore file, it produces unnecessary leading empty lines — the exact same cosmetic bug that this PR fixes for .gitignore.

Root Cause

In packages/wrangler/src/autoconfig/add-wrangler-assetsignore.ts:75-78, the linesToAppend array always starts with ["", ""] when the file is newly created (empty content), because:

const linesToAppend = [
    "",
    ...(!existingAssetsIgnoreContent.match(/\n\s*$/) ? [""] : []),
];

When existingAssetsIgnoreContent is "" (newly created file), "".match(/\n\s*$/) returns null, so the spread adds an extra "". This produces "\n\n# wrangler files\n..." — two leading empty lines in the output.

The .gitignore version of this code (packages/wrangler/src/autoconfig/c3-vendor/add-wrangler-gitignore.ts:96-98) was fixed in this PR to conditionally skip the leading lines when the file is newly created via the gitIgnorePreExisted check, but the identical pattern in .assetsignore was not updated.

The test at packages/wrangler/src/__tests__/autoconfig/run.test.ts:483-493 confirms the current (buggy) behavior with the output starting with "\n\n# wrangler files".

Impact: Newly created .assetsignore files have unnecessary leading empty lines, which is a cosmetic inconsistency with the fix applied to .gitignore in this same PR.

View 4 additional findings in Devin Review.

Open in Devin Review

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2462/polish-autoconfig-newlines branch from e697e93 to 65d091a Compare February 13, 2026 14:51
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Feb 13, 2026
@dario-piotrowicz dario-piotrowicz merged commit 5cc7158 into main Feb 13, 2026
45 of 47 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Feb 13, 2026
@dario-piotrowicz dario-piotrowicz deleted the dario/DEVX-2462/polish-autoconfig-newlines branch February 13, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants