Skip to content

Deduplicate codemod logic in C3 and autoconfig by moving it to its own @cloudflare/codemod package#13102

Merged
dario-piotrowicz merged 4 commits intomainfrom
dario/DEVX-2380/2/graduate-codemod
Mar 30, 2026
Merged

Deduplicate codemod logic in C3 and autoconfig by moving it to its own @cloudflare/codemod package#13102
dario-piotrowicz merged 4 commits intomainfrom
dario/DEVX-2380/2/graduate-codemod

Conversation

@dario-piotrowicz
Copy link
Copy Markdown
Member

@dario-piotrowicz dario-piotrowicz commented Mar 27, 2026

Fixes partially https://jira.cfdata.org/browse/DEVX-2380


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: this PR just moves pre-existing (and test covered) code around
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal change

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


Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 27, 2026

🦋 Changeset detected

Latest commit: 6b1aa34

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

@github-actions

This comment was marked as outdated.

@dario-piotrowicz dario-piotrowicz changed the title Deduplicate codemod logic in C3 and autoconfig by moving it its own @cloudflare/codemod package Deduplicate codemod logic in C3 and autoconfig by moving it to its own @cloudflare/codemod package Mar 27, 2026
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2380/2/graduate-codemod branch from 7302596 to d23326b Compare March 27, 2026 23:57
ask-bonk[bot]

This comment was marked as outdated.

@ask-bonk

This comment was marked as outdated.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2380/2/graduate-codemod branch 2 times, most recently from ef7fce4 to 1bbbf97 Compare March 28, 2026 00:01
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 28, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 6b1aa34

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2380/2/graduate-codemod branch 4 times, most recently from 3eb6c10 to d004659 Compare March 28, 2026 00:54
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review March 28, 2026 01:17
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner March 28, 2026 01:17
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 28, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

Copy link
Copy Markdown
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: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Comment thread packages/codemod/tsup.config.ts
Comment thread packages/codemod/src/dev.ts Outdated
Comment thread packages/codemod/src/dev.ts
Comment thread .changeset/add-codemod-package.md Outdated
Comment thread packages/codemod/src/index.ts
Comment thread packages/codemod/tests/index.test.ts Outdated
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Mar 30, 2026
@petebacondarwin
Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

This PR extracts shared codemod utilities into a new @cloudflare/codemod package, deduplicating code between C3 and wrangler's autoconfig. The overall structure and approach look good.

One issue found:

  1. Stale/incorrect file paths in create-cloudflare/tsconfig.json (lines 7-9) — The three ../codemod/... include entries reference files that don't exist (codemod.test.ts, codemod.ts, codemodDev.ts). The actual files in the new package are named index.test.ts, index.ts, and dev.ts. Additionally, these cross-package includes are unnecessary since @cloudflare/codemod has its own tsconfig. I posted a suggestion comment to remove them.

github run

Does this need addressing @dario-piotrowicz ?

@dario-piotrowicz
Copy link
Copy Markdown
Member Author

Does this need addressing @dario-piotrowicz ?

It's already been addressed 🙂

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2380/2/graduate-codemod branch from 36f3ea8 to 90091b3 Compare March 30, 2026 11:48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

⚠️ Issues found

File: .changeset/add-codemod-package.md

  1. Weak title: The title "First release of new package" is not a meaningful imperative description of the change. Per the README guidelines, the title should be a single imperative sentence describing what the change is (e.g., "Add @cloudflare/codemod package with AST-based codemod utilities"). "First release of new package" tells users nothing about what the package does or why it exists.

  2. Redundant structure: The changeset has a weak one-liner title followed by a body that actually contains the useful information. The title and body should together form a coherent entry — ideally the title stands on its own as a useful changelog heading, with the body providing additional detail.

Suggested fix:

---
"@cloudflare/codemod": minor
---

Add `@cloudflare/codemod` package with internal AST-based codemod utilities

Introduces the `@cloudflare/codemod` package, providing AST-based codemod utilities (`parseJs`, `parseTs`, `parseFile`, `transformFile`, `mergeObjectProperties`) built on `recast`.

The minor version bump is appropriate for a new package's first release.

This changeset is kind of fine but we can still stick to the rules.
@dario-piotrowicz dario-piotrowicz merged commit e200179 into main Mar 30, 2026
48 checks passed
@dario-piotrowicz dario-piotrowicz deleted the dario/DEVX-2380/2/graduate-codemod branch March 30, 2026 13:14
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Mar 30, 2026
NuroDev pushed a commit that referenced this pull request Mar 30, 2026
…n `@cloudflare/codemod` package (#13102)

Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
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.

3 participants