diff --git a/.changeset/khaki-years-act.md b/.changeset/khaki-years-act.md new file mode 100644 index 0000000000000..ae7e4c36c608b --- /dev/null +++ b/.changeset/khaki-years-act.md @@ -0,0 +1,5 @@ +--- +"wrangler": minor +--- + +Add `-C, --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 13cb23e2a0780..a417890484dc7 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 396f9793ec0ea..dc5b0487aaffa 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 d9475ad8fe0d9..dfb49d9c97e74 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 5856bb590b561..57f74470e86ea 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 10193cfeeeb46..b2202580dc0f4 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 6bfe4ad9c5725..aa0f6dafb4e30 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 cd9af2a35702d..3453abcb06dc0 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 83a06ce3e00da..013caca23a2b7 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 8be9b0ecc8928..b06a55136c63f 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 3f29eb0a32fab..861294a034f98 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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__/dev.test.ts b/packages/wrangler/src/__tests__/dev.test.ts index 5cbce0f5ecb10..3a44f918049d5 100644 --- a/packages/wrangler/src/__tests__/dev.test.ts +++ b/packages/wrangler/src/__tests__/dev.test.ts @@ -1364,6 +1364,7 @@ describe.sequential("wrangler dev", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 240e410504aa4..d0f83e215fe31 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 85873cee789a0..c3d8675497ac6 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 8bfc0b45bb160..f3d751f17ed9b 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 -C, --cwd", async () => { + const spy = vi.spyOn(process, "chdir").mockImplementation(() => {}); + await Promise.all([runWrangler("-C /path"), runWrangler("--cwd /path")]); + expect(process.chdir).toHaveBeenCalledTimes(2); + 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 187e559258ead..21abd9009441b 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 15b03f6bf00f6..d70791e3952fa 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 806f692195609..301bc15a9dd9f 100644 --- a/packages/wrangler/src/__tests__/pages/deploy.test.ts +++ b/packages/wrangler/src/__tests__/pages/deploy.test.ts @@ -61,6 +61,7 @@ describe("pages deploy", () => { directory The directory of static files to upload [string] GLOBAL FLAGS + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 f8fedd5add508..6b73da058d9ba 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 + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean] @@ -96,6 +98,7 @@ describe("pages", () => { wrangler pages project delete [project-name] Delete a Cloudflare Pages project GLOBAL FLAGS + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]" `); @@ -116,6 +119,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 + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]" `); @@ -134,6 +138,7 @@ describe("pages", () => { directory The directory of static files to upload [string] GLOBAL FLAGS + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean] @@ -165,6 +170,7 @@ describe("pages", () => { wrangler pages secret list List all secrets for a Pages project GLOBAL FLAGS + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory instead of the current working directory [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]" `); @@ -183,6 +189,7 @@ describe("pages", () => { wrangler pages download config [projectName] Experimental: Download your Pages project config as a Wrangler configuration file GLOBAL FLAGS + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 335dc28149f37..ac7e831391200 100644 --- a/packages/wrangler/src/__tests__/pipelines.test.ts +++ b/packages/wrangler/src/__tests__/pipelines.test.ts @@ -263,6 +263,7 @@ describe("pipelines", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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]" @@ -285,6 +286,7 @@ describe("pipelines", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 d76a11bc191b2..dec8286ef55da 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 e69a3ab20b6c3..226ce504288e7 100644 --- a/packages/wrangler/src/__tests__/queues.test.ts +++ b/packages/wrangler/src/__tests__/queues.test.ts @@ -35,6 +35,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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]" @@ -108,6 +109,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 +246,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] @@ -366,6 +369,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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]" @@ -434,6 +438,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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]" @@ -481,6 +486,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] @@ -802,6 +808,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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]" @@ -1189,6 +1196,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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]" @@ -1235,6 +1243,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] @@ -1365,6 +1374,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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]" @@ -1452,6 +1462,7 @@ describe("wrangler", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 4385bb97caf35..485034973220b 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 9b11085d6bca2..bb6225e80695f 100644 --- a/packages/wrangler/src/__tests__/secret.test.ts +++ b/packages/wrangler/src/__tests__/secret.test.ts @@ -1091,6 +1091,7 @@ describe("wrangler secret", () => { GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 2edc6a3e3e98c..237eda3357345 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 c64a31356f779..7b7dded354026 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 8b1a6bcab1dec..44b1f5ebd8e12 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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 5d7b3d706de62..10fe68bf2d6a2 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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] + -C, --cwd Run as if Wrangler was started in the specified directory instead of the current working 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/index.ts b/packages/wrangler/src/index.ts index 8df47f8fb316c..48cbb41697c3b 100644 --- a/packages/wrangler/src/index.ts +++ b/packages/wrangler/src/index.ts @@ -225,15 +225,15 @@ export function createCLIParser(argv: string[]) { }) .option("cwd", { describe: - "Run as if wrangler was started in instead of the current working directory.", + "Run as if Wrangler was started in the specified directory instead of the current working directory instead of the current working directory", alias: "C", type: "string", requiresArg: true, }) .check(demandSingleValue("cwd")) - .middleware((argv) => { - if (argv.cwd) { - process.chdir(argv.cwd); + .middleware((_argv) => { + if (_argv.cwd) { + process.chdir(_argv.cwd); } }) .option("config", {