Skip to content

Commit 59b20b8

Browse files
committed
Merge branch 'production' into ranbel/tunnel-onoma
merge in latest changes
2 parents 9d3bec6 + ae2c927 commit 59b20b8

File tree

125 files changed

+1454
-502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1454
-502
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@expressive-code/plugin-line-numbers": "0.41.3",
4343
"@floating-ui/react": "0.27.16",
4444
"@iarna/toml": "2.2.5",
45-
"@lottiefiles/dotlottie-react": "0.16.0",
45+
"@lottiefiles/dotlottie-react": "0.16.1",
4646
"@marsidev/react-turnstile": "1.3.0",
4747
"@microsoft/fetch-event-source": "2.0.1",
4848
"@nanostores/react": "1.0.0",
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
diff --git a/node_modules/@astrojs/starlight-docsearch/DocSearch.astro b/node_modules/@astrojs/starlight-docsearch/DocSearch.astro
2+
index f50c208..5309557 100644
3+
--- a/node_modules/@astrojs/starlight-docsearch/DocSearch.astro
4+
+++ b/node_modules/@astrojs/starlight-docsearch/DocSearch.astro
5+
@@ -109,15 +109,20 @@ const docsearchTranslations: DocSearchTranslationProps = {
6+
.DocSearch-Button-Keys {
7+
margin-inline-start: auto;
8+
}
9+
- .DocSearch-Button-Keys::before {
10+
- content: '';
11+
- width: 1em;
12+
- height: 1em;
13+
- -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17 2H7a5 5 0 0 0-5 5v10a5 5 0 0 0 5 5h10a5 5 0 0 0 5-5V7a5 5 0 0 0-5-5Zm3 15a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3v10Z'%3E%3C/path%3E%3Cpath d='M15.293 6.707a1 1 0 1 1 1.414 1.414l-8.485 8.486a1 1 0 0 1-1.414-1.415l8.485-8.485Z'%3E%3C/path%3E%3C/svg%3E");
14+
- mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17 2H7a5 5 0 0 0-5 5v10a5 5 0 0 0 5 5h10a5 5 0 0 0 5-5V7a5 5 0 0 0-5-5Zm3 15a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3v10Z'%3E%3C/path%3E%3Cpath d='M15.293 6.707a1 1 0 1 1 1.414 1.414l-8.485 8.486a1 1 0 0 1-1.414-1.415l8.485-8.485Z'%3E%3C/path%3E%3C/svg%3E");
15+
- -webkit-mask-size: 100%;
16+
- mask-size: 100%;
17+
- background-color: currentColor;
18+
+ .DocSearch-Button-Key:first-child {
19+
+ margin-right: 0.4em;
20+
+ }
21+
+ .DocSearch-Button-Key {
22+
+ display: inline-block;
23+
+ font-size: 0.75em;
24+
+ font-weight: 600;
25+
+ opacity: 0.8;
26+
+ border: 1px solid var(--sl-color-gray-4);
27+
+ border-radius: 0.25rem;
28+
+ padding: 0.125rem 0.375rem;
29+
+ background-color: var(--sl-color-gray-6);
30+
+ color: var(--sl-color-gray-1);
31+
+ line-height: 1;
32+
}
33+
}
34+
</style>
35+
@@ -128,6 +133,7 @@ const docsearchTranslations: DocSearchTranslationProps = {
36+
class StarlightDocSearch extends HTMLElement {
37+
constructor() {
38+
super();
39+
+
40+
window.addEventListener('DOMContentLoaded', async () => {
41+
const { default: docsearch } = await import('@docsearch/js');
42+
const options = { ...config, container: 'sl-doc-search' };
43+
@@ -136,6 +142,27 @@ const docsearchTranslations: DocSearchTranslationProps = {
44+
Object.assign(options, translations);
45+
} catch {}
46+
docsearch(options);
47+
+
48+
+ const keyboardShortcuts = options.keyboardShortcuts ?? {};
49+
+ const slashEnabled = keyboardShortcuts?.['/'] !== false;
50+
+ const ctrlCmdKEnabled = keyboardShortcuts?.['Ctrl/Cmd+K'] !== false;
51+
+
52+
+ if (slashEnabled && !ctrlCmdKEnabled) {
53+
+ const styleContainer = document.createElement('style');
54+
+ styleContainer.innerHTML = `
55+
+ .DocSearch-Button-Keys::before {
56+
+ content: '';
57+
+ width: 1em;
58+
+ height: 1em;
59+
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17 2H7a5 5 0 0 0-5 5v10a5 5 0 0 0 5 5h10a5 5 0 0 0 5-5V7a5 5 0 0 0-5-5Zm3 15a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3v10Z'%3E%3C/path%3E%3Cpath d='M15.293 6.707a1 1 0 1 1 1.414 1.414l-8.485 8.486a1 1 0 0 1-1.414-1.415l8.485-8.485Z'%3E%3C/path%3E%3C/svg%3E");
60+
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17 2H7a5 5 0 0 0-5 5v10a5 5 0 0 0 5 5h10a5 5 0 0 0 5-5V7a5 5 0 0 0-5-5Zm3 15a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3v10Z'%3E%3C/path%3E%3Cpath d='M15.293 6.707a1 1 0 1 1 1.414 1.414l-8.485 8.486a1 1 0 0 1-1.414-1.415l8.485-8.485Z'%3E%3C/path%3E%3C/svg%3E");
61+
+ -webkit-mask-size: 100%;
62+
+ mask-size: 100%;
63+
+ background-color: currentColor;
64+
+ }
65+
+ `;
66+
+ document.head.appendChild(styleContainer);
67+
+ }
68+
});
69+
}
70+
}
71+
diff --git a/node_modules/@astrojs/starlight-docsearch/index.ts b/node_modules/@astrojs/starlight-docsearch/index.ts
72+
index e8cc7e5..6c88e07 100644
73+
--- a/node_modules/@astrojs/starlight-docsearch/index.ts
74+
+++ b/node_modules/@astrojs/starlight-docsearch/index.ts
75+
@@ -43,6 +43,18 @@ const DocSearchConfigSchema = z
76+
* @see https://www.algolia.com/doc/api-reference/search-api-parameters/
77+
*/
78+
searchParameters: z.custom<SearchOptions>(),
79+
+ /**
80+
+ * Configuration for keyboard shortcuts that trigger the DocSearch modal.
81+
+ * @see https://docsearch.algolia.com/docs/api/#keyboardshortcuts
82+
+ */
83+
+ keyboardShortcuts: z
84+
+ .object({
85+
+ /** Enable/disable Ctrl/Cmd+K shortcut. @default true */
86+
+ 'Ctrl/Cmd+K': z.boolean().optional(),
87+
+ /** Enable/disable / shortcut. @default true */
88+
+ '/': z.boolean().optional(),
89+
+ })
90+
+ .optional(),
91+
})
92+
.strict()
93+
.or(

patches/@docsearch+js+3.8.2.patch

Lines changed: 38 additions & 0 deletions
Large diffs are not rendered by default.

src/components/404.astro

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,37 @@
1010

1111
<script>
1212
import { track } from "~/util/zaraz";
13+
import { openGlobalSearch } from "~/util/search";
1314

1415
const { pathname } = window.location;
1516

1617
const anchor = document.getElementById("404-search-link");
18+
const pretty = decodeURIComponent(
19+
pathname.replaceAll("/", " ").replaceAll("-", " ").trim(),
20+
);
1721

1822
if (anchor) {
19-
const pretty = pathname.replaceAll("/", " ").replaceAll("-", " ").trim();
20-
2123
anchor.setAttribute("href", `/search/?q=${encodeURIComponent(pretty)}`);
2224
anchor.addEventListener("click", () => {
2325
track("serp from location", { value: "404", query: pretty });
2426
});
2527
}
28+
29+
document.addEventListener(
30+
"keydown",
31+
(keyboardEvent) => {
32+
if (
33+
(keyboardEvent.metaKey || keyboardEvent.ctrlKey) &&
34+
keyboardEvent.key === "k"
35+
) {
36+
keyboardEvent.preventDefault();
37+
keyboardEvent.stopPropagation();
38+
39+
openGlobalSearch(pretty);
40+
}
41+
},
42+
{
43+
capture: true,
44+
},
45+
);
2646
</script>

src/components/WranglerCLI.astro

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
import { z } from "astro:schema";
3+
import { PackageManagers } from "starlight-package-managers";
4+
import { commands, getCommand } from "~/util/wrangler";
5+
import WranglerArg from "./WranglerArg.astro";
6+
import Details from "./Details.astro";
7+
8+
function validateArg(value: any, expected: string): boolean {
9+
if (Array.isArray(expected)) {
10+
for (const choice of expected) {
11+
if (value === choice) {
12+
return true;
13+
}
14+
}
15+
16+
return false;
17+
}
18+
19+
return typeof value === expected;
20+
}
21+
22+
type Props = z.input<typeof props>;
23+
24+
const props = z.object({
25+
command: z.string(),
26+
positionals: z.array(z.string()).optional(),
27+
flags: z.record(z.string(), z.any()).optional(),
28+
showArgs: z.boolean().default(false),
29+
});
30+
31+
const { command, positionals, flags, showArgs } = props.parse(Astro.props);
32+
33+
const definition = getCommand(command);
34+
35+
const { globalFlags } = commands;
36+
37+
let args = [];
38+
39+
if (flags) {
40+
for (const [key, value] of Object.entries(flags)) {
41+
const flagDef = definition.args?.[key];
42+
43+
if (!flagDef) {
44+
throw new Error(
45+
`[WranglerCLI] Received "${key}" for "${command}" but no such arg exists`,
46+
);
47+
}
48+
49+
const type = flagDef.type ?? flagDef.choices;
50+
const valid = validateArg(value, type);
51+
52+
if (!valid) {
53+
throw new Error(
54+
`[WranglerCLI] Expected "${type}" for "${key}" but got "${typeof value}"`,
55+
);
56+
}
57+
58+
args.push(...[`--${key}`, value]);
59+
}
60+
}
61+
62+
if (positionals) {
63+
const positionalsDef = definition.positionalArgs ?? [];
64+
65+
if (positionalsDef.length === 0) {
66+
throw new Error(
67+
`[WranglerCLI] Expected 0 positional arguments for "${command}" but received ${positionals.length}`,
68+
);
69+
}
70+
71+
args.push(...positionals);
72+
}
73+
---
74+
75+
<PackageManagers
76+
pkg="wrangler"
77+
type="exec"
78+
args={`${command} ${args.join(" ")}`}
79+
/>
80+
81+
{
82+
showArgs && definition.args && (
83+
<Details header="Arguments">
84+
<p>
85+
<strong>Command flags</strong>
86+
</p>
87+
<ul>
88+
{Object.entries(definition.args)
89+
.filter(([_, value]) => !value.hidden)
90+
.map(([key, value]) => {
91+
return <WranglerArg key={key} definition={value} />;
92+
})}
93+
</ul>
94+
95+
<p>
96+
<strong>Global flags</strong>
97+
</p>
98+
<ul>
99+
{Object.entries(globalFlags).map(([key, value]) => {
100+
return <WranglerArg key={key} definition={value} />;
101+
})}
102+
</ul>
103+
</Details>
104+
)
105+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { experimental_AstroContainer as AstroContainer } from "astro/container";
2+
import { expect, test, describe } from "vitest";
3+
import WranglerCLI from "./WranglerCLI.astro";
4+
5+
type Options = Parameters<(typeof container)["renderToString"]>[1];
6+
7+
const container = await AstroContainer.create();
8+
9+
const renderWithOptions = (options?: Options) => {
10+
return container.renderToString(WranglerCLI, options);
11+
};
12+
13+
describe("WranglerCLI", () => {
14+
test("succeeds with valid input", async () => {
15+
await expect(
16+
renderWithOptions({
17+
props: {
18+
command: "deploy",
19+
},
20+
}),
21+
).resolves.toContain("pnpm wrangler deploy");
22+
});
23+
24+
test("errors with no props", async () => {
25+
await expect(renderWithOptions()).rejects
26+
.toThrowErrorMatchingInlineSnapshot(`
27+
[ZodError: [
28+
{
29+
"code": "invalid_type",
30+
"expected": "string",
31+
"received": "undefined",
32+
"path": [
33+
"command"
34+
],
35+
"message": "Required"
36+
}
37+
]]
38+
`);
39+
});
40+
41+
test("errors with non-existent command", async () => {
42+
await expect(
43+
renderWithOptions({
44+
props: {
45+
command: "not-a-valid-command",
46+
},
47+
}),
48+
).rejects.toThrowErrorMatchingInlineSnapshot(
49+
`[Error: [wrangler.ts] Command "not-a-valid-command" not found]`,
50+
);
51+
});
52+
53+
test("errors with bad flags for 'deploy'", async () => {
54+
await expect(
55+
renderWithOptions({
56+
props: {
57+
command: "deploy",
58+
flags: {
59+
foo: "bar",
60+
},
61+
},
62+
}),
63+
).rejects.toThrowErrorMatchingInlineSnapshot(
64+
`[Error: [WranglerCLI] Received "foo" for "deploy" but no such arg exists]`,
65+
);
66+
});
67+
68+
test("errors with bad value for 'container-rollout' flag", async () => {
69+
await expect(
70+
renderWithOptions({
71+
props: {
72+
command: "deploy",
73+
flags: {
74+
"containers-rollout": "not-a-valid-option",
75+
},
76+
},
77+
}),
78+
).rejects.toThrowErrorMatchingInlineSnapshot(
79+
`[Error: [WranglerCLI] Expected "immediate,gradual" for "containers-rollout" but got "string"]`,
80+
);
81+
});
82+
});

0 commit comments

Comments
 (0)