Skip to content

Commit 81143ee

Browse files
kodster28nevikashah
authored andcommitted
[Wrangler] Migrate a few commands to component + add optional description input (#24804)
* [Wrangler] Migrate a few commands to component * re-add init * remove the vectorize page since we're not replacing yet
1 parent 45cbadb commit 81143ee

File tree

4 files changed

+14
-57
lines changed

4 files changed

+14
-57
lines changed

src/components/WranglerCommand.astro

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ function getCommand(path: string) {
2929
3030
const props = z.object({
3131
command: z.string(),
32-
headingLevel: z.number().default(2)
32+
headingLevel: z.number().default(2),
33+
description: z.string().optional(),
3334
});
3435
35-
let { command, headingLevel } = props.parse(Astro.props);
36+
let { command, headingLevel, description } = props.parse(Astro.props);
3637
3738
const definition = getCommand(command);
3839
@@ -45,11 +46,12 @@ const { globalFlags } = experimental_getWranglerCommands();
4546
const positionals = definition.positionalArgs
4647
?.map((p) => `[${p.toUpperCase()}]`)
4748
.join(" ");
48-
4949
---
5050

5151
<AnchorHeading depth={headingLevel} title={command} />
5252

53+
<p>{description ? description : definition.metadata.description}</p>
54+
5355
<PackageManagers
5456
pkg="wrangler"
5557
type="exec"

src/content/docs/style-guide/components/wrangler-command.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ import { WranglerCommand } from "~/components";
3131
- `command` <Type text="string" /> <MetaInfo text="required" />
3232
- The name of the command, i.e `d1 execute`.
3333
- `headingLevel` <Type text="boolean" /> <MetaInfo text="(default: 2) optional" />
34-
- The heading level that the command name should be added at on the page, i.e `2` for a `h2`.
34+
- The heading level that the command name should be added at on the page, i.e `2` for a `h2`.
35+
- `description` <Type text="string" /> <MetaInfo text="optional" />
36+
- A description to render below the command heading. If not set, defaults to the value specified in the Wrangler help API.

src/content/docs/workers/wrangler/commands.mdx

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Type,
1515
MetaInfo,
1616
WranglerConfig,
17+
WranglerCommand,
1718
WranglerNamespace,
1819
PackageManagers,
1920
} from "~/components";
@@ -99,18 +100,9 @@ You can then run them using your package manager of choice:
99100

100101
---
101102

102-
## `docs`
103+
<WranglerCommand command="docs" description="Open the Cloudflare developer documentation in your default browser." />
103104

104-
Open the Cloudflare developer documentation in your default browser.
105-
106-
```txt
107-
wrangler docs [<COMMAND>]
108-
```
109-
110-
- `COMMAND` <Type text="string" /> <MetaInfo text="optional" />
111-
- The Wrangler command you want to learn more about. This opens your default browser to the section of the documentation that describes the command.
112-
113-
<Render file="wrangler-commands/global-flags" product="workers" />
105+
---
114106

115107
## `init`
116108

@@ -898,34 +890,7 @@ wrangler workflows trigger <WORKFLOW_NAME> <PARAMS> [OPTIONS]
898890
wrangler workflows trigger my-workflow '{"hello":"world"}'
899891
```
900892

901-
## `tail`
902-
903-
Start a session to livestream logs from a deployed Worker.
904-
905-
```txt
906-
wrangler tail <WORKER> [OPTIONS]
907-
```
908-
909-
- `WORKER` <Type text="string" /> <MetaInfo text="required" />
910-
- The name of your Worker or the route the Worker is running on.
911-
- `--format` <Type text="'json'|'pretty'" /> <MetaInfo text="optional" />
912-
- The format of the log entries.
913-
- `--status` <Type text="'ok'|'error'|'canceled'" /> <MetaInfo text="optional" />
914-
- Filter by invocation status.
915-
- `--header` <Type text="string" /> <MetaInfo text="optional" />
916-
- Filter by HTTP header.
917-
- `--method` <Type text="string" /> <MetaInfo text="optional" />
918-
- Filter by HTTP method.
919-
- `--sampling-rate` <Type text="number" /> <MetaInfo text="optional" />
920-
- Add a fraction of requests to log sampling rate (between `0` and `1`).
921-
- `--search` <Type text="string" /> <MetaInfo text="optional" />
922-
- Filter by a text match in `console.log` messages.
923-
- `--ip` <Type text="(string|'self')\[]" />" <MetaInfo text="optional" />
924-
- Filter by the IP address the request originates from. Use `"self"` to show only messages from your own IP.
925-
- `--version-id` <Type text="string" /> <MetaInfo text="optional" />
926-
- Filter by Worker version.
927-
928-
<Render file="wrangler-commands/global-flags" product="workers" />
893+
<WranglerCommand command="tail" />
929894

930895
After starting `wrangler tail`, you will receive a live feed of console and exception logs for each request your Worker receives.
931896

@@ -1299,15 +1264,7 @@ If you are using `CLOUDFLARE_API_TOKEN` instead of OAuth, and you can logout by
12991264

13001265
---
13011266

1302-
## `whoami`
1303-
1304-
Retrieve your user information and test your authentication configuration.
1305-
1306-
```txt
1307-
wrangler whoami
1308-
```
1309-
1310-
<Render file="wrangler-commands/global-flags" product="workers" />
1267+
<WranglerCommand command="whoami" />
13111268

13121269
---
13131270

src/content/partials/workers/wrangler-commands/kv.mdx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,4 @@ Since version 3.60.0, Wrangler supports the `kv ...` syntax. If you are using ve
6262

6363
<WranglerCommand command="kv bulk put" />
6464

65-
<WranglerCommand command="kv bulk delete" />
66-
67-
## Global flags
68-
69-
<Render file="wrangler-commands/global-flags" product="workers" />
65+
<WranglerCommand command="kv bulk delete" />

0 commit comments

Comments
 (0)