diff --git a/.changeset/khaki-years-act.md b/.changeset/khaki-years-act.md new file mode 100644 index 000000000000..6bee3895973b --- /dev/null +++ b/.changeset/khaki-years-act.md @@ -0,0 +1,5 @@ +--- +"wrangler": minor +--- + +Add `--cwd` global argument to the `wrangler` CLI to allow changing the current working directory before running any command. diff --git a/packages/wrangler/src/__tests__/ai.test.ts b/packages/wrangler/src/__tests__/ai.test.ts index 13cb23e2a078..916a1d21c0f3 100644 --- a/packages/wrangler/src/__tests__/ai.test.ts +++ b/packages/wrangler/src/__tests__/ai.test.ts @@ -27,6 +27,7 @@ describe("ai help", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -55,6 +56,7 @@ describe("ai help", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/cert.test.ts b/packages/wrangler/src/__tests__/cert.test.ts index 396f9793ec0e..c3424a13d14d 100644 --- a/packages/wrangler/src/__tests__/cert.test.ts +++ b/packages/wrangler/src/__tests__/cert.test.ts @@ -440,6 +440,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/cloudchamber/create.test.ts b/packages/wrangler/src/__tests__/cloudchamber/create.test.ts index d9475ad8fe0d..0c0023def4c8 100644 --- a/packages/wrangler/src/__tests__/cloudchamber/create.test.ts +++ b/packages/wrangler/src/__tests__/cloudchamber/create.test.ts @@ -87,6 +87,7 @@ describe("cloudchamber create", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/cloudchamber/curl.test.ts b/packages/wrangler/src/__tests__/cloudchamber/curl.test.ts index 5856bb590b56..fa735f2c58b7 100644 --- a/packages/wrangler/src/__tests__/cloudchamber/curl.test.ts +++ b/packages/wrangler/src/__tests__/cloudchamber/curl.test.ts @@ -40,6 +40,7 @@ describe("cloudchamber curl", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/cloudchamber/delete.test.ts b/packages/wrangler/src/__tests__/cloudchamber/delete.test.ts index 10193cfeeeb4..0785b0ac48ec 100644 --- a/packages/wrangler/src/__tests__/cloudchamber/delete.test.ts +++ b/packages/wrangler/src/__tests__/cloudchamber/delete.test.ts @@ -36,6 +36,7 @@ describe("cloudchamber delete", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/cloudchamber/images.test.ts b/packages/wrangler/src/__tests__/cloudchamber/images.test.ts index 6bfe4ad9c572..facfbaa1381c 100644 --- a/packages/wrangler/src/__tests__/cloudchamber/images.test.ts +++ b/packages/wrangler/src/__tests__/cloudchamber/images.test.ts @@ -37,6 +37,7 @@ describe("cloudchamber image", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/cloudchamber/list.test.ts b/packages/wrangler/src/__tests__/cloudchamber/list.test.ts index cd9af2a35702..b62706f018c3 100644 --- a/packages/wrangler/src/__tests__/cloudchamber/list.test.ts +++ b/packages/wrangler/src/__tests__/cloudchamber/list.test.ts @@ -37,6 +37,7 @@ describe("cloudchamber list", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/cloudchamber/modify.test.ts b/packages/wrangler/src/__tests__/cloudchamber/modify.test.ts index 83a06ce3e00d..ce528f48621f 100644 --- a/packages/wrangler/src/__tests__/cloudchamber/modify.test.ts +++ b/packages/wrangler/src/__tests__/cloudchamber/modify.test.ts @@ -72,6 +72,7 @@ describe("cloudchamber modify", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/d1/d1.test.ts b/packages/wrangler/src/__tests__/d1/d1.test.ts index 8be9b0ecc892..23fb7802ff9e 100644 --- a/packages/wrangler/src/__tests__/d1/d1.test.ts +++ b/packages/wrangler/src/__tests__/d1/d1.test.ts @@ -30,6 +30,7 @@ describe("d1", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -66,6 +67,7 @@ describe("d1", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -95,6 +97,7 @@ describe("d1", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -123,6 +126,7 @@ describe("d1", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/deployments.test.ts b/packages/wrangler/src/__tests__/deployments.test.ts index 3f29eb0a32fa..6db305daeba0 100644 --- a/packages/wrangler/src/__tests__/deployments.test.ts +++ b/packages/wrangler/src/__tests__/deployments.test.ts @@ -66,6 +66,7 @@ describe("deployments", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/docs.test.ts b/packages/wrangler/src/__tests__/docs.test.ts index 240e410504aa..346768925ef3 100644 --- a/packages/wrangler/src/__tests__/docs.test.ts +++ b/packages/wrangler/src/__tests__/docs.test.ts @@ -58,6 +58,7 @@ describe("wrangler docs", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/hyperdrive.test.ts b/packages/wrangler/src/__tests__/hyperdrive.test.ts index 85873cee789a..6b044809abaf 100644 --- a/packages/wrangler/src/__tests__/hyperdrive.test.ts +++ b/packages/wrangler/src/__tests__/hyperdrive.test.ts @@ -38,6 +38,7 @@ describe("hyperdrive help", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -69,6 +70,7 @@ describe("hyperdrive help", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/index.test.ts b/packages/wrangler/src/__tests__/index.test.ts index eca91504038d..d21f4bf64081 100644 --- a/packages/wrangler/src/__tests__/index.test.ts +++ b/packages/wrangler/src/__tests__/index.test.ts @@ -69,6 +69,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -126,6 +127,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -154,6 +156,14 @@ describe("wrangler", () => { `[Error: The argument "--config" expects a single value, but received multiple: ["wrangler.toml","example"].]` ); }); + + it("should change cwd with --cwd", async () => { + const spy = vi.spyOn(process, "chdir").mockImplementation(() => {}); + await runWrangler("--cwd /path"); + expect(process.chdir).toHaveBeenCalledTimes(1); + expect(process.chdir).toHaveBeenCalledWith("/path"); + spy.mockRestore(); + }); }); describe("preview", () => { @@ -192,6 +202,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -213,6 +224,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -235,6 +247,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -255,6 +268,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -275,6 +289,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/kv.test.ts b/packages/wrangler/src/__tests__/kv.test.ts index 187e559258ea..14bff8689104 100644 --- a/packages/wrangler/src/__tests__/kv.test.ts +++ b/packages/wrangler/src/__tests__/kv.test.ts @@ -48,6 +48,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -69,6 +70,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -97,6 +99,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -141,6 +144,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -172,6 +176,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -623,6 +628,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -664,6 +670,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -705,6 +712,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -746,6 +754,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -787,6 +796,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -1156,6 +1166,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -1192,6 +1203,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -1229,6 +1241,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -1800,6 +1813,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -1820,6 +1834,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -1838,6 +1853,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/mtls-certificates.test.ts b/packages/wrangler/src/__tests__/mtls-certificates.test.ts index 15b03f6bf00f..03f898c15f23 100644 --- a/packages/wrangler/src/__tests__/mtls-certificates.test.ts +++ b/packages/wrangler/src/__tests__/mtls-certificates.test.ts @@ -366,6 +366,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/pages/deploy.test.ts b/packages/wrangler/src/__tests__/pages/deploy.test.ts index dedefe5d4069..cb1532f02ee8 100644 --- a/packages/wrangler/src/__tests__/pages/deploy.test.ts +++ b/packages/wrangler/src/__tests__/pages/deploy.test.ts @@ -63,6 +63,7 @@ describe("pages deploy", () => { directory The directory of static files to upload [string] GLOBAL FLAGS + --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean] diff --git a/packages/wrangler/src/__tests__/pages/pages.test.ts b/packages/wrangler/src/__tests__/pages/pages.test.ts index e8bdb2cdeeb3..4f780db9880c 100644 --- a/packages/wrangler/src/__tests__/pages/pages.test.ts +++ b/packages/wrangler/src/__tests__/pages/pages.test.ts @@ -31,6 +31,7 @@ describe("pages", () => { wrangler pages download Download settings from your project GLOBAL FLAGS + --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]" `); @@ -50,6 +51,7 @@ describe("pages", () => { command The proxy command to run [deprecated] [string] GLOBAL FLAGS + --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean] @@ -97,6 +99,7 @@ describe("pages", () => { wrangler pages project delete [project-name] Delete a Cloudflare Pages project GLOBAL FLAGS + --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]" `); @@ -117,6 +120,7 @@ describe("pages", () => { wrangler pages deployment tail [deployment] Start a tailing session for a project's deployment and livestream logs from your Functions GLOBAL FLAGS + --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]" `); @@ -135,6 +139,7 @@ describe("pages", () => { directory The directory of static files to upload [string] GLOBAL FLAGS + --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean] @@ -166,6 +171,7 @@ describe("pages", () => { wrangler pages secret list List all secrets for a Pages project GLOBAL FLAGS + --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]" `); @@ -184,6 +190,7 @@ describe("pages", () => { wrangler pages download config [projectName] Experimental: Download your Pages project config as a Wrangler configuration file GLOBAL FLAGS + --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]" `); diff --git a/packages/wrangler/src/__tests__/pipelines.test.ts b/packages/wrangler/src/__tests__/pipelines.test.ts index 557653c67ea5..2dd1d2cc7301 100644 --- a/packages/wrangler/src/__tests__/pipelines.test.ts +++ b/packages/wrangler/src/__tests__/pipelines.test.ts @@ -264,6 +264,7 @@ describe("pipelines", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -309,6 +310,7 @@ describe("pipelines", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/pubsub.test.ts b/packages/wrangler/src/__tests__/pubsub.test.ts index d76a11bc191b..0efc740ddc83 100644 --- a/packages/wrangler/src/__tests__/pubsub.test.ts +++ b/packages/wrangler/src/__tests__/pubsub.test.ts @@ -36,6 +36,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -68,6 +69,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -195,6 +197,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/queues.test.ts b/packages/wrangler/src/__tests__/queues.test.ts index eaf5d21db3a9..1bc43d89e49d 100644 --- a/packages/wrangler/src/__tests__/queues.test.ts +++ b/packages/wrangler/src/__tests__/queues.test.ts @@ -36,6 +36,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -109,6 +110,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -256,6 +258,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -509,23 +512,24 @@ describe("wrangler", () => { await runWrangler("queues update --help"); expect(std.err).toMatchInlineSnapshot(`""`); expect(std.out).toMatchInlineSnapshot(` - "wrangler queues update + "wrangler queues update - Update a Queue + Update a Queue - POSITIONALS - name The name of the queue [string] [required] + POSITIONALS + name The name of the queue [string] [required] - GLOBAL FLAGS - -c, --config Path to Wrangler configuration file [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] + GLOBAL FLAGS + -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] - OPTIONS - --delivery-delay-secs How long a published message should be delayed for, in seconds. Must be between 0 and 42300 [number] - --message-retention-period-secs How long to retain a message in the queue, in seconds. Must be between 60 and 1209600 [number]" - `); + OPTIONS + --delivery-delay-secs How long a published message should be delayed for, in seconds. Must be between 0 and 42300 [number] + --message-retention-period-secs How long to retain a message in the queue, in seconds. Must be between 60 and 1209600 [number]" + `); }); it("should update a queue with new message retention period and preserve old delivery delay", async () => { @@ -671,6 +675,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -739,6 +744,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -786,6 +792,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -1107,6 +1114,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -1494,6 +1502,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -1540,6 +1549,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -1670,6 +1680,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -1757,6 +1768,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/r2.test.ts b/packages/wrangler/src/__tests__/r2.test.ts index 4385bb97caf3..e832628e4de7 100644 --- a/packages/wrangler/src/__tests__/r2.test.ts +++ b/packages/wrangler/src/__tests__/r2.test.ts @@ -38,6 +38,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -66,6 +67,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -99,6 +101,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -137,6 +140,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -244,6 +248,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -277,6 +282,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -399,6 +405,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -428,6 +435,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -493,6 +501,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -556,6 +565,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -623,6 +633,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -714,6 +725,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -757,6 +769,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -808,6 +821,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -989,6 +1003,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -1349,6 +1364,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -1507,6 +1523,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -2295,6 +2312,7 @@ describe("r2", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/secret.test.ts b/packages/wrangler/src/__tests__/secret.test.ts index fc7264313bc1..6b205040e0ed 100644 --- a/packages/wrangler/src/__tests__/secret.test.ts +++ b/packages/wrangler/src/__tests__/secret.test.ts @@ -1222,6 +1222,7 @@ describe("wrangler secret", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/vectorize/vectorize.test.ts b/packages/wrangler/src/__tests__/vectorize/vectorize.test.ts index 2edc6a3e3e98..8e1005533124 100644 --- a/packages/wrangler/src/__tests__/vectorize/vectorize.test.ts +++ b/packages/wrangler/src/__tests__/vectorize/vectorize.test.ts @@ -40,6 +40,7 @@ describe("vectorize help", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -88,6 +89,7 @@ describe("vectorize help", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -124,6 +126,7 @@ describe("vectorize help", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] @@ -164,6 +167,7 @@ describe("vectorize help", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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] diff --git a/packages/wrangler/src/__tests__/versions/versions.help.test.ts b/packages/wrangler/src/__tests__/versions/versions.help.test.ts index c64a31356f77..8bacadf8879a 100644 --- a/packages/wrangler/src/__tests__/versions/versions.help.test.ts +++ b/packages/wrangler/src/__tests__/versions/versions.help.test.ts @@ -24,6 +24,7 @@ describe("versions --help", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -54,6 +55,7 @@ describe("versions subhelp", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/worker-namespace.test.ts b/packages/wrangler/src/__tests__/worker-namespace.test.ts index 8b1a6bcab1de..540101d51456 100644 --- a/packages/wrangler/src/__tests__/worker-namespace.test.ts +++ b/packages/wrangler/src/__tests__/worker-namespace.test.ts @@ -43,6 +43,7 @@ describe("dispatch-namespace", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]", @@ -95,6 +96,7 @@ describe("dispatch-namespace", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -145,6 +147,7 @@ describe("dispatch-namespace", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -204,6 +207,7 @@ describe("dispatch-namespace", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -314,6 +318,7 @@ describe("dispatch-namespace", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 5d7b3d706de6..90434e47e7d5 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -74,6 +74,7 @@ describe("wrangler workflows", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" @@ -104,6 +105,7 @@ describe("wrangler workflows", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + --cwd Run as if Wrangler was started in the specified directory 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]" diff --git a/packages/wrangler/src/api/dev.ts b/packages/wrangler/src/api/dev.ts index 407fd113a4a1..a6685f461896 100644 --- a/packages/wrangler/src/api/dev.ts +++ b/packages/wrangler/src/api/dev.ts @@ -185,6 +185,7 @@ export async function unstable_dev( ip: "127.0.0.1", inspectorPort: options?.inspectorPort ?? 0, v: undefined, + cwd: undefined, localProtocol: options?.localProtocol, httpsKeyPath: options?.httpsKeyPath, httpsCertPath: options?.httpsCertPath, diff --git a/packages/wrangler/src/generate/index.ts b/packages/wrangler/src/generate/index.ts index 301512335f18..240a49fb57e0 100644 --- a/packages/wrangler/src/generate/index.ts +++ b/packages/wrangler/src/generate/index.ts @@ -53,6 +53,7 @@ export async function generateHandler(args: GenerateArgs) { delegateC3: false, v: undefined, config: undefined, + cwd: undefined, env: undefined, type: undefined, _: args._, diff --git a/packages/wrangler/src/index.ts b/packages/wrangler/src/index.ts index 6dea08b67e73..269a1c994ed5 100644 --- a/packages/wrangler/src/index.ts +++ b/packages/wrangler/src/index.ts @@ -231,6 +231,18 @@ export function createCLIParser(argv: string[]) { alias: "version", type: "boolean", }) + .option("cwd", { + describe: + "Run as if Wrangler was started in the specified directory instead of the current working directory", + type: "string", + requiresArg: true, + }) + .check(demandSingleValue("cwd")) + .middleware((_argv) => { + if (_argv.cwd) { + process.chdir(_argv.cwd); + } + }) .option("config", { alias: "c", describe: "Path to Wrangler configuration file", @@ -309,7 +321,7 @@ export function createCLIParser(argv: string[]) { "Examples:": `${chalk.bold("EXAMPLES")}`, }); wrangler.group( - ["config", "env", "help", "version"], + ["config", "cwd", "env", "help", "version"], `${chalk.bold("GLOBAL FLAGS")}` ); wrangler.help("help", "Show help").alias("h", "help"); diff --git a/packages/wrangler/src/pages/dev.ts b/packages/wrangler/src/pages/dev.ts index 8332ee8c85cf..3b324034cceb 100644 --- a/packages/wrangler/src/pages/dev.ts +++ b/packages/wrangler/src/pages/dev.ts @@ -901,6 +901,7 @@ export const Handler = async (args: PagesDevArguments) => { processEntrypoint: true, additionalModules: modules, v: undefined, + cwd: undefined, assets: undefined, name: undefined, noBundle: false, diff --git a/packages/wrangler/src/yargs-types.ts b/packages/wrangler/src/yargs-types.ts index edb7b63e51c3..2f28b4d9d477 100644 --- a/packages/wrangler/src/yargs-types.ts +++ b/packages/wrangler/src/yargs-types.ts @@ -6,6 +6,7 @@ import type { ArgumentsCamelCase, Argv, CommandModule } from "yargs"; */ export interface CommonYargsOptions { v: boolean | undefined; + cwd: string | undefined; config: string | undefined; env: string | undefined; "experimental-provision": boolean | undefined;