Skip to content

Commit 9a8dca9

Browse files
authored
[Docs Site] Implement WranglerCommand feedback (#24563)
* [Docs Site] Implement WranglerCommand feedback * logging * ignore _ var names in eslint * ignore _ var names in eslint
1 parent 8cec7c9 commit 9a8dca9

File tree

3 files changed

+53
-28
lines changed

3 files changed

+53
-28
lines changed

eslint.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ export default [
3434
"@typescript-eslint/no-explicit-any": "off",
3535
"@typescript-eslint/no-unused-vars": [
3636
"error",
37-
{ ignoreRestSiblings: true },
37+
{
38+
ignoreRestSiblings: true,
39+
argsIgnorePattern: "^_",
40+
varsIgnorePattern: "^_",
41+
caughtErrorsIgnorePattern: "^_",
42+
destructuredArrayIgnorePattern: "^_",
43+
},
3844
],
3945
},
4046
},

src/components/WranglerCommand.astro

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,58 @@ if (!definition.args) {
3939
throw new Error(`[WranglerCommand] "${command}" has no arguments`);
4040
}
4141
42-
const positionals = definition.positionalArgs;
43-
44-
if (positionals && positionals.length > 0) {
45-
const display = positionals.map((p) => `[${p.toUpperCase()}]`).join(" ");
46-
47-
command = command.concat(" ".concat(display));
48-
}
42+
const positionals = definition.positionalArgs
43+
?.map((p) => `[${p.toUpperCase()}]`)
44+
.join(" ");
4945
---
5046

51-
<AnchorHeading depth={2} title={definition.command} />
47+
<AnchorHeading depth={2} title={command} />
5248

53-
<p>{definition.metadata?.description}</p>
54-
55-
<PackageManagers pkg="wrangler" type="exec" args={command} />
49+
<PackageManagers
50+
pkg="wrangler"
51+
type="exec"
52+
args={positionals ? command.concat(` ${positionals}`) : command}
53+
/>
5654

5755
<AnchorHeading
5856
depth={3}
5957
title="Arguments"
60-
slug={`${definition.command.replaceAll(" ", "-")}-arguments`}
58+
slug={`${command.replaceAll(" ", "-")}-arguments`}
6159
/>
6260

6361
<ul>
6462
{
65-
Object.entries(definition.args).map(([key, value]) => {
66-
const required = value.demandOption;
67-
const defaultValue = value.default;
68-
69-
return (
70-
<li>
71-
<code>{key}</code> <Type text={value.type} />{" "}
72-
{required && <MetaInfo text="required" />}
73-
{defaultValue !== undefined && (
74-
<MetaInfo text={`default: ${defaultValue}`} />
75-
)}
76-
<p>{value.description}</p>
77-
</li>
78-
);
79-
})
63+
Object.entries(definition.args)
64+
.filter(([_, value]) => !value.hidden)
65+
.map(([key, value]) => {
66+
const description = value.description ?? value.describe;
67+
const required = value.demandOption;
68+
const defaultValue = value.default;
69+
const alias = value.alias;
70+
const positional = definition.positionalArgs?.includes(key);
71+
72+
const name = positional ? `[${key.toUpperCase()}]` : `--${key}`;
73+
74+
let aliasText;
75+
if (alias) {
76+
if (Array.isArray(alias)) {
77+
aliasText = `aliases: --${alias.join(", --")}`;
78+
} else {
79+
aliasText = `alias: --${alias}`;
80+
}
81+
}
82+
83+
return (
84+
<li>
85+
<code>{name}</code> <Type text={value.type} />{" "}
86+
{aliasText && <MetaInfo text={aliasText} />}
87+
{required && <MetaInfo text="required" />}
88+
{defaultValue !== undefined && (
89+
<MetaInfo text={`default: ${defaultValue}`} />
90+
)}
91+
<p>{description}</p>
92+
</li>
93+
);
94+
})
8095
}
8196
</ul>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ styleGuide:
66

77
The `WranglerCommand` component documents the available options for a given command.
88

9+
This is generated using the Wrangler version in the [`cloudflare-docs` repository](https://github.com/cloudflare/cloudflare-docs/blob/production/package.json).
10+
911
## Import
1012

1113
```mdx
@@ -17,5 +19,7 @@ import { WranglerCommand } from "~/components";
1719
```mdx live
1820
import { WranglerCommand } from "~/components";
1921

22+
<WranglerCommand command="deploy" />
23+
2024
<WranglerCommand command="d1 execute" />
2125
```

0 commit comments

Comments
 (0)