Skip to content

Conversation

@CarmenPopoviciu
Copy link
Contributor

@CarmenPopoviciu CarmenPopoviciu commented Feb 25, 2025

Original PR is here #7994. This PR was created from a fork, but required a couple of adjustments.

I tried creating a PR with the required changes to the fork, but it didn't get reviewed. Opening a new PR instead so we can get this over the finish line

---- from original PR

This PR adds -C, --cwd global argument to the wrangler CLI to allow changing the current working directory before running any command.

This feature is used in most of CLI tools that depend on right working directory but different names. I have chosen -C, --cwd following with pnpm (-C) + yarn (--cwd), but open to ideas changing it to anything else.

This allows better DX of using wrangler commands from any working directory to another (where project is).

$ wrangler --help

GLOBAL FLAGS
  -c, --config   Path to Wrangler configuration file  [string]
  -C, --cwd      Run as if wrangler was started in <path> instead of the current working directory  [string]
  -e, --env      Environment to use for operations, and for selecting .env and .dev.vars files  [string]
  -h, --help     Show help  [boolean]
  -v, --version  Show version number  [boolean]

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • Wrangler E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because: effect of global arg has unit test
  • Public documentation

@CarmenPopoviciu CarmenPopoviciu requested review from a team as code owners February 25, 2025 12:19
@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2025

🦋 Changeset detected

Latest commit: af6e4d0

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

This PR includes changesets to release 2 packages
Name Type
wrangler Minor
@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

@CarmenPopoviciu
Copy link
Contributor Author

on a second thought...I don't think we can support this for Pages, because I think Pages assumed the process is always running at the root? I need to double check this...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 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/13521568897/npm-package-wrangler-8253

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8253/npm-package-wrangler-8253

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13521568897/npm-package-wrangler-8253 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

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

create-cloudflare:

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

@cloudflare/kv-asset-handler:

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

miniflare:

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

@cloudflare/pages-shared:

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

@cloudflare/unenv-preset:

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

@cloudflare/vite-plugin:

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

@cloudflare/vitest-pool-workers:

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

@cloudflare/workers-editor-shared:

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

@cloudflare/workers-shared:

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

@cloudflare/workflows-shared:

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

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


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20250214.0
workerd 1.20250214.0 1.20250214.0
workerd --version 1.20250214.0 2025-02-14

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

This commit adds the `--cwd` global argument to the `wrangler`
CLI to allow changing the current working directory before
running any command.
@petebacondarwin
Copy link
Contributor

petebacondarwin commented Feb 25, 2025

on a second thought...I don't think we can support this for Pages, because I think Pages assumed the process is always running at the root? I need to double check this...

Why not support this for Pages? It is no different to cd-ing into that directory and running wrangler pages ..., right?

For example, in the workers-sdk root:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13521568897/npm-package-wrangler-8253 pages dev --cwd fixtures/pages-functions-app public 

works fine

Copy link
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.

LGTM

@CarmenPopoviciu CarmenPopoviciu added the skip-pr-description-validation Skip validation of the required PR description format label Feb 25, 2025
@CarmenPopoviciu CarmenPopoviciu merged commit 6dd1e23 into main Feb 25, 2025
23 of 24 checks passed
@CarmenPopoviciu CarmenPopoviciu deleted the pr/pi0/7994 branch February 25, 2025 14:43
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-pr-description-validation Skip validation of the required PR description format

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants