Skip to content

Commit

Permalink
refactor: Moving --legacy-env out of global (#957)
Browse files Browse the repository at this point in the history
The `--legacy-env` flag was in global scope, which only certain commands
utilize the flag for functionality, and doesnt do anything for the other commands.

resolves #933
  • Loading branch information
JacobMGEvans authored May 10, 2022
1 parent 1caa5f7 commit e0a0509
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 146 deletions.
9 changes: 9 additions & 0 deletions .changeset/hungry-bugs-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"wrangler": patch
---

refactor: Moving `--legacy-env` out of global
The `--legacy-env` flag was in global scope, which only certain commands
utilize the flag for functionality, and doesnt do anything for the other commands.

resolves #933
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions packages/wrangler/src/__tests__/dev.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,9 @@ describe("wrangler dev", () => {
script The path to an entry point for your worker [string]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--name Name of the worker [string]
Expand Down
107 changes: 50 additions & 57 deletions packages/wrangler/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ describe("wrangler", () => {
wrangler whoami 🕵️ Retrieve your user info and test your auth config
Flags:
-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]"
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
`);

expect(std.err).toMatchInlineSnapshot(`""`);
Expand Down Expand Up @@ -85,10 +84,9 @@ describe("wrangler", () => {
wrangler whoami 🕵️ Retrieve your user info and test your auth config
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
X [ERROR] Unknown argument: invalid-command
"
Expand Down Expand Up @@ -133,92 +131,87 @@ describe("wrangler", () => {
wrangler secret list List all secrets for a script
Flags:
-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]"
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
`);
});

it("no subcommand 'kv:namespace' should display a list of available subcommands", async () => {
await runWrangler("kv:namespace");
await endEventLoop();
expect(std.out).toMatchInlineSnapshot(`
"wrangler kv:namespace
"wrangler kv:namespace
🗂️ Interact with your Workers KV Namespaces
🗂️ Interact with your Workers KV Namespaces
Commands:
wrangler kv:namespace create <namespace> Create a new namespace
wrangler kv:namespace list Outputs a list of all KV namespaces associated with your account id.
wrangler kv:namespace delete Deletes a given namespace.
Commands:
wrangler kv:namespace create <namespace> Create a new namespace
wrangler kv:namespace list Outputs a list of all KV namespaces associated with your account id.
wrangler kv:namespace delete Deletes a given namespace.
Flags:
-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]"
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
`);
});

it("no subcommand 'kv:key' should display a list of available subcommands", async () => {
await runWrangler("kv:key");
await endEventLoop();
expect(std.out).toMatchInlineSnapshot(`
"wrangler kv:key
"wrangler kv:key
🔑 Individually manage Workers KV key-value pairs
🔑 Individually manage Workers KV key-value pairs
Commands:
wrangler kv:key put <key> [value] Writes a single key/value pair to the given namespace.
wrangler kv:key list Outputs a list of all keys in a given namespace.
wrangler kv:key get <key> Reads a single value by key from the given namespace.
wrangler kv:key delete <key> Removes a single key value pair from the given namespace.
Commands:
wrangler kv:key put <key> [value] Writes a single key/value pair to the given namespace.
wrangler kv:key list Outputs a list of all keys in a given namespace.
wrangler kv:key get <key> Reads a single value by key from the given namespace.
wrangler kv:key delete <key> Removes a single key value pair from the given namespace.
Flags:
-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]"
`);
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
`);
});

it("no subcommand 'kv:bulk' should display a list of available subcommands", async () => {
await runWrangler("kv:bulk");
await endEventLoop();
expect(std.out).toMatchInlineSnapshot(`
"wrangler kv:bulk
"wrangler kv:bulk
💪 Interact with multiple Workers KV key-value pairs at once
💪 Interact with multiple Workers KV key-value pairs at once
Commands:
wrangler kv:bulk put <filename> Upload multiple key-value pairs to a namespace
wrangler kv:bulk delete <filename> Delete multiple key-value pairs from a namespace
Commands:
wrangler kv:bulk put <filename> Upload multiple key-value pairs to a namespace
wrangler kv:bulk delete <filename> Delete multiple key-value pairs from a namespace
Flags:
-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]"
`);
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
`);
});
it("no subcommand 'r2' should display a list of available subcommands", async () => {
await runWrangler("r2");
await endEventLoop();
expect(std.out).toMatchInlineSnapshot(`
"wrangler r2
"wrangler r2
📦 Interact with an R2 store
📦 Interact with an R2 store
Commands:
wrangler r2 bucket Manage R2 buckets
Commands:
wrangler r2 bucket Manage R2 buckets
Flags:
-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]"
`);
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
`);
});
});
describe("Deprecated commands", () => {
Expand Down
84 changes: 36 additions & 48 deletions packages/wrangler/src/__tests__/kv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ describe("wrangler", () => {
namespace The name of the new namespace [string] [required]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
-e, --env Perform on a specific environment [string]
Expand Down Expand Up @@ -92,10 +91,9 @@ describe("wrangler", () => {
namespace The name of the new namespace [string] [required]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
-e, --env Perform on a specific environment [string]
Expand Down Expand Up @@ -126,10 +124,9 @@ describe("wrangler", () => {
namespace The name of the new namespace [string] [required]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
-e, --env Perform on a specific environment [string]
Expand Down Expand Up @@ -291,10 +288,9 @@ describe("wrangler", () => {
Deletes a given namespace.
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--binding The name of the namespace to delete [string]
Expand Down Expand Up @@ -490,10 +486,9 @@ describe("wrangler", () => {
value The value to write [string]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--binding The binding of the namespace to write to [string]
Expand Down Expand Up @@ -530,10 +525,9 @@ describe("wrangler", () => {
value The value to write [string]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--binding The binding of the namespace to write to [string]
Expand Down Expand Up @@ -570,10 +564,9 @@ describe("wrangler", () => {
value The value to write [string]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--binding The binding of the namespace to write to [string]
Expand Down Expand Up @@ -610,10 +603,9 @@ describe("wrangler", () => {
value The value to write [string]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--binding The binding of the namespace to write to [string]
Expand Down Expand Up @@ -650,10 +642,9 @@ describe("wrangler", () => {
value The value to write [string]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--binding The binding of the namespace to write to [string]
Expand Down Expand Up @@ -956,10 +947,9 @@ describe("wrangler", () => {
key The key value to get. [string] [required]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--binding The name of the namespace to get from [string]
Expand Down Expand Up @@ -991,10 +981,9 @@ describe("wrangler", () => {
key The key value to get. [string] [required]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--binding The name of the namespace to get from [string]
Expand Down Expand Up @@ -1027,10 +1016,9 @@ describe("wrangler", () => {
key The key value to get. [string] [required]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--binding The name of the namespace to get from [string]
Expand Down
14 changes: 6 additions & 8 deletions packages/wrangler/src/__tests__/pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ describe("pages", () => {
wrangler pages publish [directory] 🆙 Publish a directory of static assets as a Pages deployment
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose"
`);
Expand Down Expand Up @@ -261,10 +260,9 @@ describe("pages", () => {
directory The directory of static files to upload [string]
Flags:
-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]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--project-name The name of the project you want to deploy to [string]
Expand Down
Loading

0 comments on commit e0a0509

Please sign in to comment.