refactor(wrangler): organize command files as a tree in src/commands#12349
Draft
refactor(wrangler): organize command files as a tree in src/commands#12349
src/commands#12349Conversation
Move standalone commands and simple namespaces into the new src/commands/ directory structure. This is the first step in reorganizing wrangler's command files to mirror the CLI hierarchy. Commands moved: - docs, init, dev, deploy, delete, setup, tail, complete - types (from type-generation) - user (login, logout, whoami, auth) - telemetry (from metrics/commands) - secret, triggers - versions (with deployments, rollback, secrets sub-namespaces) No logic changes - only file moves and import updates. All 2827 tests pass.
Move KV namespace commands into the src/commands/ directory structure. Files moved: - src/kv/index.ts → src/commands/kv/index.ts - src/kv/helpers.ts → src/commands/kv/helpers.ts Imports updated in: - src/index.ts - src/sites.ts - src/deployment-bundle/bindings.ts - src/commands/delete.ts - src/__tests__/kv/*.test.ts - src/__tests__/delete.test.ts - src/__tests__/helpers/mock-kv.ts No logic changes - only file moves and import updates. All 2827 tests pass.
Move D1 database commands into the src/commands/ directory structure. Files moved (26 files): - src/d1/*.ts → src/commands/d1/*.ts - src/d1/migrations/*.ts → src/commands/d1/migrations/*.ts - src/d1/timeTravel/*.ts → src/commands/d1/timeTravel/*.ts Imports updated in: - src/index.ts - src/cli.ts - src/deployment-bundle/bindings.ts - src/__tests__/d1/*.ts - src/__tests__/provision.test.ts No logic changes - only file moves and import updates. All 2827 tests pass.
Move R2 storage commands into the src/commands/ directory structure. Files moved (23 files): - src/r2/*.ts → src/commands/r2/*.ts - src/r2/helpers/*.ts → src/commands/r2/helpers/*.ts Imports updated in: - src/index.ts - src/deployment-bundle/bindings.ts - src/pipelines/client.ts - src/__tests__/r2/*.ts No logic changes - only file moves and import updates. All 2827 tests pass.
Moved: ai, build, cert, check, cloudchamber, containers, hello-world, hyperdrive, mtls-certificate, pipelines, secrets-store, vpc, workflows
|
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: it took me > 10s (like way longer) to find in what file a command was implemented. We need to fix this.
Still in draft while being discussed
Commands are central to
wranglerand should be grouped in a logical way so that it's easy to find where they are implemented. The current status is that command files are not well organized and mixed with utility code.IMO the commands and utility code should be well separated, commands should be organized as a tree.
Note that this PR is a first step in that direction and we decide that's something we want to pursue, I'll follow up with more PR.
As
wranglergrows in scope, I believe the change proposed here will become more relevant.I believe have enough tests to have confidence we're not breaking too many things 😰
I worked on a plan with Claude. They then implemented the changes.
Summary
Reorganize wrangler's command files from scattered src// locations into a structured src/commands/ directory that mirrors the CLI hierarchy, making commands easy to find by name.
For example: wrangler r2 bucket create → src/commands/r2/bucket/index.ts
File Moves
Phase 1: Standalone Commands
Phase 2: Feature Namespaces
What's NOT Changing
A picture of a cute animal (not mandatory, but encouraged)