Skip to content

Commit

Permalink
feat: --local mode only applies in wrangler dev
Browse files Browse the repository at this point in the history
We'd originally planned for `--local` mode to be a thing across all wrangler commands. In hindsight, that didn't make much sense, since every command other than `wrangler dev` assumes some interaction with cloudflare and their API. The only command other than dev where this "worked" was `kv`, but even that didn't make sense because wrangler dev wouldn't even read from it. We also have `--experimental-enable-local-persistence` there anyway.

So this moves the `--local` flag to only apply for `wrangler dev` and removes any trace from other commands.
  • Loading branch information
threepointone committed Mar 3, 2022
1 parent 046b17d commit 6c44274
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 522 deletions.
9 changes: 9 additions & 0 deletions .changeset/gentle-islands-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"wrangler": patch
---

feat: `--local` mode only applies in `wrangler dev`

We'd originally planned for `--local` mode to be a thing across all wrangler commands. In hindsight, that didn't make much sense, since every command other than `wrangler dev` assumes some interaction with cloudflare and their API. The only command other than dev where this "worked" was `kv`, but even that didn't make sense because wrangler dev wouldn't even read from it. We also have `--experimental-enable-local-persistence` there anyway.

So this moves the `--local` flag to only apply for `wrangler dev` and removes any trace from other commands.
8 changes: 1 addition & 7 deletions packages/wrangler/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ describe("wrangler", () => {
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]"
--legacy-env Use legacy environments [boolean]"
`);

expect(std.err).toMatchInlineSnapshot(`""`);
Expand Down Expand Up @@ -89,9 +86,6 @@ describe("wrangler", () => {
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Unknown command: invalid-command."
`);
});
Expand Down
12 changes: 0 additions & 12 deletions packages/wrangler/src/__tests__/kv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--env Perform on a specific environment [string]
--preview Interact with a preview namespace [boolean]
Expand Down Expand Up @@ -89,7 +88,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--env Perform on a specific environment [string]
--preview Interact with a preview namespace [boolean]
Expand Down Expand Up @@ -120,7 +118,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--env Perform on a specific environment [string]
--preview Interact with a preview namespace [boolean]
Expand Down Expand Up @@ -285,7 +282,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The name of the namespace to delete [string]
--namespace-id The id of the namespace to delete [string]
--env Perform on a specific environment [string]
Expand Down Expand Up @@ -481,7 +477,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
Expand Down Expand Up @@ -518,7 +513,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
Expand Down Expand Up @@ -555,7 +549,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
Expand Down Expand Up @@ -592,7 +585,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
Expand Down Expand Up @@ -629,7 +621,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
Expand Down Expand Up @@ -955,7 +946,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The name of the namespace to get from [string]
--namespace-id The id of the namespace to get from [string]
--env Perform on a specific environment [string]
Expand Down Expand Up @@ -987,7 +977,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The name of the namespace to get from [string]
--namespace-id The id of the namespace to get from [string]
--env Perform on a specific environment [string]
Expand Down Expand Up @@ -1020,7 +1009,6 @@ describe("wrangler", () => {
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The name of the namespace to get from [string]
--namespace-id The id of the namespace to get from [string]
--env Perform on a specific environment [string]
Expand Down
12 changes: 0 additions & 12 deletions packages/wrangler/src/__tests__/r2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ describe("wrangler", () => {
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Not enough non-option arguments: got 0, need at least 1"
`);
});
Expand All @@ -110,9 +107,6 @@ describe("wrangler", () => {
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Unexpected additional positional arguments \\"def ghi\\"."
`);
});
Expand Down Expand Up @@ -164,9 +158,6 @@ describe("wrangler", () => {
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Not enough non-option arguments: got 0, need at least 1"
`);
});
Expand All @@ -192,9 +183,6 @@ describe("wrangler", () => {
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Unexpected additional positional arguments \\"def ghi\\"."
`);
});
Expand Down
40 changes: 0 additions & 40 deletions packages/wrangler/src/__tests__/secret.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,6 @@ describe("wrangler secret", () => {
`);
expect(error).toMatchInlineSnapshot(`[Error: Missing script name]`);
});

it("warns about being a no-op in local mode", async () => {
mockPrompt({
text: "Enter a secret value:",
type: "password",
result: "the-secret",
});

mockPutRequest({ name: "the-secret-name", text: "the-secret" });
await runWrangler("secret put the-key --name script-name --local");
expect(std.out).toMatchInlineSnapshot(`""`);
expect(std.err).toMatchInlineSnapshot(`""`);
expect(std.warn).toMatchInlineSnapshot(
`"\`wrangler secret put\` is a no-op in --local mode"`
);
});
});

describe("delete", () => {
Expand Down Expand Up @@ -244,21 +228,6 @@ describe("wrangler secret", () => {
`);
expect(error).toMatchInlineSnapshot(`[Error: Missing script name]`);
});

it("warns about being a no-op in local mode", async () => {
mockConfirm({
text: "Are you sure you want to permanently delete the variable the-key on the script script-name?",
result: true,
});
await runWrangler("secret delete the-key --name script-name --local");
expect(std.out).toMatchInlineSnapshot(
`"🌀 Deleting the secret the-key on script script-name"`
);
expect(std.err).toMatchInlineSnapshot(`""`);
expect(std.warn).toMatchInlineSnapshot(
`"\`wrangler secret delete\` is a no-op in --local mode"`
);
});
});

describe("list", () => {
Expand Down Expand Up @@ -353,14 +322,5 @@ describe("wrangler secret", () => {
`);
expect(error).toMatchInlineSnapshot(`[Error: Missing script name]`);
});

it("warns about being a no-op in local mode", async () => {
await runWrangler("secret list --name script-name --local");
expect(std.out).toMatchInlineSnapshot(`""`);
expect(std.err).toMatchInlineSnapshot(`""`);
expect(std.warn).toMatchInlineSnapshot(
`"\`wrangler secret list\` is a no-op in --local mode"`
);
});
});
});
Loading

0 comments on commit 6c44274

Please sign in to comment.