polish autoconfig newlines on created files#12548
Conversation
|
Claude finished @dario-piotrowicz's task —— View job Changeset ReviewTodo List:
✅ All changesets look good All three changesets are properly formatted:
Each changeset:
|
🦋 Changeset detectedLatest 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 |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
There was a problem hiding this comment.
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.
e697e93 to
65d091a
Compare
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
A picture of a cute animal (not mandatory, but encouraged)