Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wrangler): support -C, --cwd cli argument #7994

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pi0
Copy link
Contributor

@pi0 pi0 commented Jan 31, 2025

Fixes #7993 (/cc @petebacondarwin)

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      The directory to run the command in  [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: It is generic CLI behavior (is it needed?)
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because: It is generic CLI behavior
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because:

Copy link

changeset-bot bot commented Jan 31, 2025

🦋 Changeset detected

Latest commit: 2230d66

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

Copy link
Contributor

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/13079674354/npm-package-wrangler-7994

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

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

Or you can use npx with this latest build directly:

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

cloudflare-workers-bindings-extension:

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

create-cloudflare:

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

@cloudflare/kv-asset-handler:

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

miniflare:

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

@cloudflare/pages-shared:

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

@cloudflare/unenv-preset:

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

@cloudflare/vite-plugin:

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

@cloudflare/vitest-pool-workers:

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

@cloudflare/workers-editor-shared:

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

@cloudflare/workers-shared:

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

@cloudflare/workflows-shared:

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

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.20250129.0
workerd 1.20250129.0 1.20250129.0
workerd --version 1.20250129.0 2025-01-29

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

@pi0 pi0 changed the title feat(wrangler): support -C, --cwd cli argument feat(wrangler): support -C, --dir cli argument Jan 31, 2025
@pi0 pi0 changed the title feat(wrangler): support -C, --dir cli argument feat(wrangler): support -C, --cwd cli argument Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: Support argument for wrangler to run in different working directory
1 participant