Repository navigation
[autoconfig] Keep existing files when setting up a migrated project - #17238
Conversation
🦋 Changeset detectedLatest commit: 917feaa The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
|
I'm Bonk, and I've done a quick review of your PR. Keeps migrated config and React Router files while reporting Astro's Vite build tool.
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/cli-shared-helpers
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/test-server
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
fba6bb9 to
ba456dc
Compare
0d33269 to
1202002
Compare
Bumps the workers-sdk previews to cloudflare/workers-sdk#17238 at 284d481, which reads a named Wrangler config itself.
Bumps the workers-sdk previews to cloudflare/workers-sdk#17238 at 284d481, which reads a named Wrangler config itself.
Bumps the workers-sdk previews to cloudflare/workers-sdk#17238 at 098e110, which only asks about a Wrangler assets directory that Vite won't deploy.
The summary now only lists the Worker configuration setup writes, and the changeset is split into the fixes and the new buildTool field.
Check for an existing cloudflare.config.ts when saving it, instead of adjusting the setup summary.
…ngler config Detection now reports the project's own Wrangler config, and setup passes it to the framework. React Router skips workers/app.ts, app/entry.server.tsx and the isbot install when it's set, instead of keeping an existing workers/app.ts.
…etup React Router skips its own Worker entry only when the Wrangler config names one, and points the generated config at it. Detection also reports the Wrangler config for projects already configured for Wrangler.
getDetailsForAutoConfig takes the Wrangler config the caller passes, or reads the one in the project folder, and reports it as wranglerConfig. Setup passes it to the framework, so React Router reads main from it instead of a path.
Use workers-utils' isPagesConfig, which checks that the field is set, as Wrangler does, rather than that it's non-empty.
Setup keeps the cloudflare.config.ts that the migration writes first, so pointing the result at the Wrangler config's main had no effect.
Both Pages checks in detection now agree on an empty pages_build_output_dir.
getDetailsForAutoConfig takes a wranglerConfigPath. Without a wranglerConfig, detection reads that file, or else the one in the project folder, so a caller like cf migrate no longer has to read the config itself.
Matches outputDir, and documents it.
…ploy Vite deploys its build output and public folder, so a Wrangler assets directory there, or inside the build output folder that detection reports, needs no TODO. migrateBundler takes that folder as outputDir.
A folder inside the build output would be deployed under a URL prefix, so only the build output folder itself needs no TODO.
The Cloudflare Vite plugin writes client assets to the client folder inside the build output by default, so a Wrangler assets directory there keeps its URLs.
Detection reports each framework's default folder rather than reading the project's config, so the docs for outputDir and the assets check say so.
Only Vite's default public folder and the build output folder that detection reports skip the TODO, as agreed.
8350b3d to
7c49a9f
Compare
There was a problem hiding this comment.
Superseded by the review of
917feaae.
This review, of 7c49a9fc
💬 Approved with comments — One WARNING carries over from the last review: React Router setup can write a cloudflare.config.ts whose entrypoint is ./workers/app.ts, a file it skipped creating. The changes since that review (the assets TODO check, outputDir, resolving wranglerConfigPath, and the guard that keeps an existing config) need no fixes.
Findings: 1 warning
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #17238.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] React Router skips writing `workers/app.ts` when the Wrangler config sets `main`, but still returns `entrypoint: "./workers/app.ts"`, so setup can write a `cloudflare.config.ts` pointing at a missing file. Kept: @edmundhung [author] deferred the fix, and the returned entrypoint at lines 529-532 is unchanged.
- **File:** packages/autoconfig/src/frameworks/react-router.ts:499
📋 Code Quality: ⚠️ 1 warning
One earlier WARNING is still open: React Router returns an entrypoint for a file it skipped writing.
Recommendation: 📝 Minor Comments
- [WARNING] React Router skips writing
workers/app.tswhen the Wrangler config setsmain, but still returnsentrypoint: "./workers/app.ts", so setup can write acloudflare.config.tspointing at a missing file. Kept: @edmundhung [author] deferred the fix, and the returned entrypoint at lines 529-532 is unchanged. (packages/autoconfig/src/frameworks/react-router.ts:499)
View full review
React Router returns an entrypoint it no longer writes (packages/autoconfig/src/frameworks/react-router.ts:498-533)
- When
wranglerConfig?.mainis set,configureskips creatingworkers/app.tsandapp/entry.server.tsx, and skips installingisbot. - It still always returns
workerConfig: { entrypoint: "./workers/app.ts" }(lines 529-532). - Detection now reads any
wrangler.json,wrangler.jsoncorwrangler.tomlin the project folder. That meansmaincan reachconfigurein a project that has nocloudflare.config.tsyet. - In that case
saveCloudflareConfigfinds no existing file and writes a new one that points at a file that doesn't exist.
The author replied that a project with a Wrangler config is treated as already set up and that this will be improved later. That explains why the files are skipped, but the returned entrypoint is unchanged, so this stays at WARNING. Possible fixes: return entrypoint: wranglerConfig.main when main is set, or leave the entrypoint out in that case.
The other changes since the last review need no fixes: the isDeployedByVite assets check, outputDir in migrateBundler, resolving wranglerConfigPath in detection, and the existsSync guard in saveCloudflareConfig.
✅ All other checks passed
🚀 Release: ✅ LGTM
The changesets cover the detection, setup and migration changes. The React Router entrypoint concern is tracked in the Code Quality section. The patch bump on .changeset/vite-assets-directory-follow-up.md was raised before and the author acknowledged it, so it is not repeated.
🔒 Security: ✅ LGTM
The new inputs (the Wrangler config's main and assets.directory, plus the outputDir and wranglerConfigPath options) come from the project's own files or from the caller. They only reach path comparisons and message text, never a shell command. saveCloudflareConfig now leaves an existing cloudflare.config.ts in place instead of overwriting it.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
⚡ Performance: ✅ LGTM
Each detection run adds one small config read and a few existsSync checks, and none of them are on a hot path.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 7c49a9fc
There was a problem hiding this comment.
💬 Approved with comments — One WARNING carries over: when the Wrangler config sets main, React Router setup still returns ./workers/app.ts as the entrypoint even though it skipped writing that file. The changes since the last review need no fixes.
Findings: 1 warning
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #17238.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] React Router skips writing `workers/app.ts` when the Wrangler config sets `main`, but still returns `entrypoint: "./workers/app.ts"`. Setup can then write a `cloudflare.config.ts` that points at a missing file. Kept: @edmundhung [author] deferred the fix, and the returned entrypoint at lines 528-533 is unchanged.
- **File:** packages/autoconfig/src/frameworks/react-router.ts:499
📋 Code Quality: ⚠️ 1 warning
One WARNING carries over: React Router returns an entrypoint it skipped writing.
Recommendation: 📝 Minor Comments
- [WARNING] React Router skips writing
workers/app.tswhen the Wrangler config setsmain, but still returnsentrypoint: "./workers/app.ts". Setup can then write acloudflare.config.tsthat points at a missing file. Kept: @edmundhung [author] deferred the fix, and the returned entrypoint at lines 528-533 is unchanged. (packages/autoconfig/src/frameworks/react-router.ts:499)
View full review
React Router returns an entrypoint it did not write (packages/autoconfig/src/frameworks/react-router.ts:498-533)
- When
wranglerConfig?.mainis set,configureskips three things: creatingworkers/app.ts, writingapp/entry.server.tsxand installingisbot. - It still always returns
workerConfig: { entrypoint: "./workers/app.ts" }(lines 530-532). - Detection now reads a
wrangler.json,wrangler.jsoncorwrangler.tomlfrom the project folder, somaincan be set in a project that has nocloudflare.config.tsyet. - In that case
saveCloudflareConfigfinds no existing file and writes a new one whose entrypoint does not exist.
Kept at WARNING: @edmundhung [author] said a project with a Wrangler config is treated as already set up and that this will be improved later. That explains why the files are skipped. It does not explain returning a path that was never written, and lines 528-533 are unchanged at this commit.
Possible fixes: return entrypoint: wranglerConfig.main when main is set, or leave the entrypoint out in that case.
The changes since the last review need no fixes: the isDeployedByVite assets check, passing outputDir through migrateBundler and convertWranglerBuild, and the existsSync guard in saveCloudflareConfig.
✅ All other checks passed
🚀 Release: ✅ LGTM
The changesets cover the detection, setup, Pages detection and assets-directory changes. The patch bump on .changeset/vite-assets-directory-follow-up.md was raised before and the author acknowledged it, so it is not repeated here.
🔒 Security: ✅ LGTM
The new inputs come from the project's own files or from the caller: the Wrangler config, the wranglerConfigPath option and outputDir. They are used only in path comparisons, file reads and message text, and none of them reaches a shell command. Setup now leaves an existing cloudflare.config.ts in place instead of overwriting it.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
⚡ Performance: ✅ LGTM
Each detection run adds one small config read and a few existence checks. None of them runs on a hot path.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 917feaae
Bumps the workers-sdk previews to cloudflare/workers-sdk#17238 at 284d481, which reads a named Wrangler config itself.
Bumps the workers-sdk previews to cloudflare/workers-sdk#17238 at 098e110, which only asks about a Wrangler assets directory that Vite won't deploy.
Part of RM-31810. Stacked on #17222.
Gets setup ready to run on a project whose Wrangler config was just migrated to
cloudflare.config.ts:runAutoConfigkeeps an existingcloudflare.config.tsinstead of overwriting it, and its summary reports the build tool the framework set up. Astro now reportsvite, since its adapter builds with the Cloudflare Vite plugin.getDetailsForAutoConfigreports the project's Wrangler config aswranglerConfig: the one the caller passes, or else the one in the project folder. Setup passes it to the framework. When it names a Worker entry, React Router leavesworkers/app.ts,app/entry.server.tsxandisbotalone.pages_build_output_dir, so setup stops on it instead of setting it up as a new Worker.