Skip to content

Continue createCommand migration with ✨AI✨ #8966

Merged
penalosa merged 21 commits intomainfrom
penalosa/create-command
Apr 23, 2025
Merged

Continue createCommand migration with ✨AI✨ #8966
penalosa merged 21 commits intomainfrom
penalosa/create-command

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

@penalosa penalosa commented Apr 15, 2025

This PR continues the createCommand migration for several new command families:

Halway through the migration I realised that this would be the perfect test case for something like Claude Code (pretty simple refactoring), and so tested out Claude code for hyperdrive, vectorize, d1, ai, and pages. It did surprisingly well! It halway blew up when doing pages, because more of that change was novel, I guess?


  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because: this should pass all existing tests
  • Wrangler / Vite E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal refactor
  • Wrangler V3 Backport
    • TODO (before merge)
    • Wrangler PR:
    • Not necessary because: no functionality change

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2025

🦋 Changeset detected

Latest commit: 59c5886

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

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

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-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Apr 15, 2025
@penalosa penalosa changed the title Continue createCommand migration Continue createCommand migration with ✨AI✨ Apr 15, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the v3-maintenance branch with your changes. Thank you for helping us keep Wrangler v3 supported!

Depending on your changes, running git rebase --onto v3-maintenance main penalosa/create-command might be a good starting point.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2025

A Wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-wrangler-8966
Prereleases for other packages:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-cloudflare-workers-bindings-extension-8966 -O ./cloudflare-workers-bindings-extension.0.0.0-v454b7082c.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v454b7082c.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-create-cloudflare-8966 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-cloudflare-kv-asset-handler-8966

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-miniflare-8966

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-cloudflare-pages-shared-8966

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-cloudflare-unenv-preset-8966

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-cloudflare-vite-plugin-8966

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-cloudflare-vitest-pool-workers-8966

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-cloudflare-workers-editor-shared-8966

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-cloudflare-workers-shared-8966

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14616902982/npm-package-cloudflare-workflows-shared-8966

Note that these links will no longer work once the GitHub Actions artifact expires.

@penalosa penalosa marked this pull request as ready for review April 16, 2025 14:07
@penalosa penalosa requested review from a team as code owners April 16, 2025 14:07
@irvinebroque
Copy link
Copy Markdown
Contributor

👏

Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Nice work Claude! Since it is such a big mechanical PR, we should have just got an AI to review if for us 😜 .

Fun to backport this one...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With createCommand, do we no longer get useful error messages saying what was wrong with the input?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We do, but this (and a few other similar places), shouldn't have been errors. This is the output from running d1 migrations, which now just shows the help text. Previously it also showed an error because you hadn't specified a subcommand list/create/apply, which isn't how other commands work

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this test case no longer supported?

Copy link
Copy Markdown
Contributor Author

@penalosa penalosa Apr 22, 2025

Choose a reason for hiding this comment

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

This case was never hit, as far as I can tell, since the API never returned that error. I tested on an account without queues enabled, and this message wasn't displayed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we still support the --depreacted-v1 flag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We do, but I've removed the vectorize GA banner that was printed at the end of all commands as an epilogue. Vectorize has been GA for a while, and no other GA commands follow this kind of pattern.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this a shortcoming in the createCommand definition options, that we can't say this is an array of numbers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's a bug in yargs, where if you pass array: true it's not reflected in the help text

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feels like this should be the default for all commands?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It should be. There was one command that used an argument called json for a different purpose, but we changed that in v4, so we should be able to make this printBanner option the default now. I can make that change in this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, that seems like it should be done in a followup

Comment on lines 108 to 112
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TODO (not in this PR): consolidate all the JSON logging aspects across the code base.

Comment on lines 54 to 55
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FUTURE: we should build this into the createCommand mechanism, so it doesn't need to be worked around in individual options/commands.

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Apr 22, 2025
@penalosa penalosa added the e2e Run wrangler + vite-plugin e2e tests on a PR label Apr 22, 2025
@penalosa penalosa force-pushed the penalosa/create-command branch from caca69f to a0971d5 Compare April 22, 2025 11:39
@penalosa penalosa force-pushed the penalosa/create-command branch from 40cd2db to 59c5886 Compare April 23, 2025 11:22
@penalosa penalosa merged commit 234afae into main Apr 23, 2025
17 of 18 checks passed
@penalosa penalosa deleted the penalosa/create-command branch April 23, 2025 13:47
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Apr 23, 2025
IRCody pushed a commit that referenced this pull request Apr 23, 2025
* wrangler init

* wrangler delete

* wrangler triggers

* halfway through wrangler queues

* complete queues migration

* wrangler d1

* wrangler ai

* hyperdrive & vectorize

* pages

* Fix AI code

* Create thirty-apples-invite.md

* more ai fixups

* mtls-certificate

* wrangler build

* wrangler pipelines

* wrangler dispatch-namespace

* fix check

* fix tests

* cleanup

* address comments

* fix lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e Run wrangler + vite-plugin e2e tests on a PR

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants