Skip to content

Commit a4dd09c

Browse files
committed
[Wrangler] Migrate a few commands to component
1 parent 72f0335 commit a4dd09c

File tree

5 files changed

+20
-79
lines changed

5 files changed

+20
-79
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.
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
---
2-
pcx_content_type: navigation
32
title: Wrangler commands
4-
external_link: /workers/wrangler/commands/#vectorize
3+
pcx_content_type: reference
54
sidebar:
65
order: 19
7-
86
---
7+
8+
import { WranglerNamespace } from "~/components"
9+
10+
Vectorize uses the following Wrangler Commands.
11+
12+
<WranglerNamespace namespace="vectorize" />

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

Lines changed: 4 additions & 67 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,36 +100,7 @@ You can then run them using your package manager of choice:
99100

100101
---
101102

102-
## `docs`
103-
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" />
114-
115-
## `init`
116-
117-
Create a new project via the [create-cloudflare-cli (C3) tool](/workers/get-started/guide/#1-create-a-new-worker-project). A variety of web frameworks are available to choose from as well as templates. Dependencies are installed by default, with the option to deploy your project immediately.
118-
119-
```txt
120-
wrangler init [<NAME>] [OPTIONS]
121-
```
122-
123-
- `NAME` <Type text="string" /> <MetaInfo text="optional (default: name of working directory)" />
124-
- The name of the Workers project. This is both the directory name and `name` property in the generated [Wrangler configuration](/workers/wrangler/configuration/).
125-
- `--yes` <Type text="boolean" /> <MetaInfo text="optional" />
126-
- Answer yes to any prompts for new projects.
127-
- `--from-dash` <Type text="string" /> <MetaInfo text="optional" />
128-
- Fetch a Worker initialized from the dashboard. This is done by passing the flag and the Worker name. `wrangler init --from-dash <WORKER_NAME>`.
129-
- The `--from-dash` command will not automatically sync changes made to the dashboard after the command is used. Therefore, it is recommended that you continue using the CLI.
130-
131-
<Render file="wrangler-commands/global-flags" product="workers" />
103+
<WranglerCommand command="docs" description="Open the Cloudflare developer documentation in your default browser." />
132104

133105
---
134106

@@ -898,34 +870,7 @@ wrangler workflows trigger <WORKFLOW_NAME> <PARAMS> [OPTIONS]
898870
wrangler workflows trigger my-workflow '{"hello":"world"}'
899871
```
900872

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" />
873+
<WranglerCommand command="tail" />
929874

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

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

13001245
---
13011246

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" />
1247+
<WranglerCommand command="whoami" />
13111248

13121249
---
13131250

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)