Skip to content

Generalize wrangler deploy positional argument from [script] to [path]#14153

Merged
dario-piotrowicz merged 6 commits into
mainfrom
dario/DEVX-2333-wrangler-deploy-positional-arg-path
Jun 3, 2026
Merged

Generalize wrangler deploy positional argument from [script] to [path]#14153
dario-piotrowicz merged 6 commits into
mainfrom
dario/DEVX-2333-wrangler-deploy-positional-arg-path

Conversation

@dario-piotrowicz

@dario-piotrowicz dario-piotrowicz commented Jun 2, 2026

Copy link
Copy Markdown
Member

Fixes https://jira.cfdata.org/browse/DEVX-2333

The wrangler deploy command now accepts a generic [path] positional argument that can point to either a Worker entry-point file or a directory of static assets. The type is auto-detected:

  • File: wrangler deploy ./src/index.ts deploys a Worker (same as before)
  • Directory: wrangler deploy ./public deploys a static assets site (no interactive confirmation prompt)

The --script named option is now hidden and deprecated for the deploy command. It continues to work for backwards compatibility but only accepts file paths. Passing a directory to --script now produces a clear error message suggesting the positional path argument or --assets flag instead.


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

@changeset-bot

changeset-bot Bot commented Jun 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 657490b

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

This PR includes changesets to release 4 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch
@cloudflare/wrangler-bundler 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

@ask-bonk

ask-bonk Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

This test (deploy --assets ./assets, no positional path) confirms the suggestion uses --assets ./assets. Since args.path is undefined here, !args.path && args.assets → includes --assets. Correct. This test passes.

Now consider the case where a user runs wrangler deploy ./assets (positional directory). args.path = "./assets", validateArgs sets args.assets = "./assets", args.path stays "./assets". The suggestion: pathPart = "./assets ", and !args.path && args.assets → false (path is set), so --assets is omitted. Result: wrangler deploy ./assets --name ... --compatibility-date .... That's correct and clean — the positional covers the assets dir.

This logic is actually well-designed. My concern #1 about the --script named case dropping the entry-point in the suggestion is the only real (minor) issue, and --script is deprecated.

Let me reconsider severity. Since --script is now hidden/deprecated and this only affects a non-functional suggestion message in the autoconfig interactive flow (which itself requires --x-autoconfig), this is very low priority. It's borderline whether to flag it.

Let me do a final check — verify the path positional doesn't break the versions upload command or other commands that share sharedDeployVersionsArgs. The change is isolated to deploy/index.ts, so versions upload still uses script positional. Good.

Overall assessment: The PR is well-constructed. The directory-as-assets resolution is moved to validateArgs (correct timing, before config read), handles CI environments, and the suggestion-message logic is correctly adapted for the positional path. The one minor observation (suggestion drops entry-point for the deprecated --script named option) is too minor and edge-case to be actionable, and concerns a deprecated path.

Let me verify there are no remaining concerns with the statSync being called twice on the same path potentially (path then script) — no, they're mutually guarded.

I've completed a thorough review. The PR correctly:

  • Adds [path] positional with file/directory auto-detection in validateArgs (runs before config read, line 163 vs 201 in register-yargs-command.ts)
  • Handles CI/non-interactive cases (directory→assets now works without prompt)
  • Adapts the autoconfig suggestion message logic cleanly (positional path covers assets; --assets only suggested when no positional)
  • Updates maybeRunAutoConfig to respect args.path
  • Removes now-unused promptForMissingAssetFlag and its imports without leaving dead imports
  • Updates help-text snapshots and the directory-error test consistently

The only minor observation is that in the interactive autoconfig flow, the "You should run..." suggestion drops the entry-point path when the deprecated --script named option is used (instead of the positional). This is non-functional, affects only a deprecated/hidden option, and isn't worth flagging as actionable.

LGTM

github run

@pkg-pr-new

pkg-pr-new Bot commented Jun 2, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/cloudflare/workers-sdk/create-cloudflare@14153

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/deploy-helpers@14153

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/kv-asset-handler@14153

miniflare

npm i https://pkg.pr.new/cloudflare/workers-sdk/miniflare@14153

@cloudflare/pages-shared

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/pages-shared@14153

@cloudflare/unenv-preset

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/unenv-preset@14153

@cloudflare/vite-plugin

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/vite-plugin@14153

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/workers-auth@14153

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/workers-utils@14153

wrangler

npm i https://pkg.pr.new/cloudflare/workers-sdk/wrangler@14153

@cloudflare/wrangler-bundler

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/wrangler-bundler@14153

commit: 657490b

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

✅ All changesets look good

@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review June 2, 2026 11:03
@workers-devprod workers-devprod requested review from a team and edmundhung and removed request for a team June 2, 2026 11:03
@workers-devprod

workers-devprod commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2333-wrangler-deploy-positional-arg-path branch 2 times, most recently from 591c399 to 99859f5 Compare June 2, 2026 13:59
devin-ai-integration[bot]

This comment was marked as resolved.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2333-wrangler-deploy-positional-arg-path branch from 99859f5 to b3ee161 Compare June 2, 2026 14:24
Comment thread packages/wrangler/src/deploy/index.ts Outdated
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2333-wrangler-deploy-positional-arg-path branch from dce9d14 to b9f397e Compare June 2, 2026 23:33
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Comment thread .changeset/deploy-path-positional.md Outdated
Comment thread packages/wrangler/src/deploy/autoconfig.ts Outdated

@workers-devprod workers-devprod left a comment

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.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Jun 3, 2026
dario-piotrowicz and others added 2 commits June 3, 2026 14:28
Co-authored-by: emily-shen <69125074+emily-shen@users.noreply.github.com>
@dario-piotrowicz dario-piotrowicz merged commit 7a6b1a4 into main Jun 3, 2026
56 checks passed
@dario-piotrowicz dario-piotrowicz deleted the dario/DEVX-2333-wrangler-deploy-positional-arg-path branch June 3, 2026 14:06
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Jun 3, 2026
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