Skip to content

feat: run project setup when migrating a Wrangler project - #817

Open
edmundhung wants to merge 3 commits into
mainfrom
edmundhung/migrate-with-autoconfig
Open

edmundhung wants to merge 3 commits into
mainfrom
edmundhung/migrate-with-autoconfig

Conversation

@edmundhung

@edmundhung edmundhung commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

cf migrate, and the migration offer in cf dev, cf build and cf deploy, now run four steps: detect the project, migrate its Worker settings to cloudflare.config.ts, run project setup with autoconfig, then migrate its build settings for the bundler that setup chose. Setup's bundler wins over --bundler, with a warning, and --no-install skips setup.

cf no longer depends on @cloudflare/codemods.

@edmundhung
edmundhung force-pushed the edmundhung/migrate-with-autoconfig branch from 1bab04b to 0f88aaf Compare November 27, 2026 18:43
@pkg-pr-new

pkg-pr-new Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/cf@817

commit: 3805905

@ask-bonk

ask-bonk Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

cf --help startup

mean stddev min max
PR 283.0 ms 4.7 ms 277.4 ms 294.5 ms
base 282.7 ms 3.5 ms 277.2 ms 290.5 ms

Δ (PR vs base): — +0.3 ms (+0.1%)

Measured with hyperfine on ubuntu-latest (3 warmup runs, 20 timed runs). CI numbers carry ±a few ms of runner jitter; treat small deltas as noise.

@ask-bonk

ask-bonk Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@ask-bonk

ask-bonk Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.
Posted 1 inline suggestion.

github run

@ask-bonk

ask-bonk Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@ask-bonk

ask-bonk Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@edmundhung
edmundhung force-pushed the edmundhung/migrate-with-autoconfig branch from e4e65b5 to 5d62120 Compare November 30, 2026 16:06
@ask-bonk

ask-bonk Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

  • Warning packages/cli/src/lib/wrangler-migration.ts:196: setup failures leave a partial cloudflare.config.ts that blocks retries. Preflight setup before writing migration settings.

github run

@ask-bonk

ask-bonk Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🤖 I've done a thorough review of your PR.

cf migrate now integrates framework setup via autoconfig.

  1. Posted 1 inline warning on conflicting wrangler.config.ts creation.

github run

@edmundhung
edmundhung force-pushed the edmundhung/migrate-with-autoconfig branch from ae746fc to 1f7bcec Compare December 1, 2026 15:31
@ask-bonk

ask-bonk Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

Posted 1 inline finding.

github run

@ask-bonk

ask-bonk Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@ask-bonk

ask-bonk Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@ask-bonk

ask-bonk Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

Posted 1 inline warning.

github run

@ask-bonk

ask-bonk Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

cf migrate, and the migration that cf dev, cf build and cf deploy offer, now
detect the project, migrate its Worker settings to cloudflare.config.ts, run
project setup, then migrate its build settings for the bundler that setup chose.
cf no longer depends on @cloudflare/codemods.
Autoconfig reads a named Wrangler config itself.
Autoconfig only asks about a Wrangler assets directory that Vite won't deploy.
@edmundhung
edmundhung force-pushed the edmundhung/migrate-with-autoconfig branch from 411e583 to 3805905 Compare December 1, 2026 19:46
@edmundhung edmundhung changed the title feat: set up the framework in cf migrate feat: run project setup when migrating a Wrangler project Dec 1, 2026
@ask-bonk

ask-bonk Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@edmundhung
edmundhung marked this pull request as ready for review December 1, 2026 22:58
@edmundhung
edmundhung requested a review from a team as a code owner December 1, 2026 22:58

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💬 Approved with comments — The four-step migration flow works as described. One WARNING: if project setup or the bundler step fails after cloudflare.config.ts has been written, the project is left half-migrated, and later cf dev/cf build/cf deploy runs skip setup.

Findings: 1 warning (1 is an inline comment on the diff)

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 #817.

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] If `configureProject` or `migrateBundler` throws after `migrateWranglerConfig` has written `cloudflare.config.ts`, the project is left half-migrated, and `prepareProject` then treats it as configured and skips setup.
- **File:** packages/cli/src/lib/wrangler-migration.ts:204

📋 Code Quality: ⚠️ 1 warning

The move to autoconfig's step-by-step migration is sound overall. A failure partway through can leave the project half-migrated.

Recommendation: 📝 Minor Comments

  • [WARNING] If configureProject or migrateBundler throws after migrateWranglerConfig has written cloudflare.config.ts, the project is left half-migrated, and prepareProject then treats it as configured and skips setup. (packages/cli/src/lib/wrangler-migration.ts:204)
View full review

A failure partway through leaves the project half-migrated (packages/cli/src/lib/wrangler-migration.ts:196-231)

  • migrateWranglerConfig writes cloudflare.config.ts before configureProject and migrateBundler run. The old codemod did all of this in a single call.
  • configureProject installs packages, so it can throw on an install failure or a cancelled prompt. migrateBundler can also reject. Either way, cloudflare.config.ts stays on disk but setup and the build migration never happen.
  • On the next cf dev, cf build or cf deploy, prepareProject (packages/cli/src/lib/autoconfig.ts:173-176) sees details.configured and returns early. It skips both framework setup and the migration offer, so the project is never finished.
  • Possible fixes: catch failures after step 2 and tell the user which steps finished and how to resume, or make the later steps safe to retry. A test where configureProject rejects would cover this.

Checks that found no issue: how --bundler and setup's bundler interact (warning, then setup wins); --no-install falling back to declared-plugin detection; no framework detected and the static framework skipping setup; changedFiles deduplication and merging of followUps and status; removal of @cloudflare/codemods from package.json and the lockfile; agreement between meta.ts and the regenerated commands.json and hand-written-commands.json.


✅ All other checks passed

🚀 Release: ✅ LGTM

The changeset is present and suits a user-facing feature.


🔒 Security: ✅ LGTM

No security concerns in this change.


📖 AGENTS.md: ✅ LGTM

No issues in the files this pull request changes.


📝 Documentation: ✅ LGTM

The changeset and the regenerated command metadata match the new behaviour.


Reviewed commit: 38059051

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.

1 participant