Skip to content

Commit be701f2

Browse files
committed
update a bunch of stuff, remove some legacy packages
1 parent f6d5571 commit be701f2

File tree

7 files changed

+2095
-1441
lines changed

7 files changed

+2095
-1441
lines changed

biome.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.4.4/schema.json",
33
"files": {
4-
"include": ["src/**/*.ts", "src/**/*.tsx", "next.config.mjs"]
4+
"includes": ["**/src/**/*.ts", "**/src/**/*.tsx", "**/next.config.mjs"]
55
},
66
"formatter": {
77
"enabled": true,
88
"indentStyle": "space",
99
"indentWidth": 2
1010
},
11-
"organizeImports": {
12-
"enabled": false
13-
},
11+
"assist": { "actions": { "source": { "organizeImports": "off" } } },
1412
"linter": {
1513
"enabled": true,
1614
"rules": {

package-lock.json

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

package.json

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,31 @@
1212
"dependencies": {
1313
"@r4ai/remark-callout": "^0.6.2",
1414
"classnames": "^2.5.1",
15+
"fast-xml-parser": "^5.3.7",
1516
"gray-matter": "^4.0.3",
16-
"klaw-sync": "^6.0.0",
17-
"lucide-react": "^0.424.0",
18-
"mermaid": "^11.9.0",
17+
"lucide-react": "^0.575.0",
18+
"mermaid": "^11.12.3",
1919
"next": "^16.1.6",
2020
"next-mdx-remote": "^6.0.0",
2121
"postcss-flexbugs-fixes": "^5.0.2",
22-
"postcss-preset-env": "^9.6.0",
23-
"react": "19.2.3",
24-
"react-dom": "19.2.3",
25-
"react-intersection-observer": "^9.14.0",
26-
"rehype-highlight": "^7.0.1",
27-
"remark-gfm": "^4.0.0",
22+
"postcss-preset-env": "^11.2.0",
23+
"react": "19.2.4",
24+
"react-dom": "19.2.4",
25+
"react-intersection-observer": "^10.0.3",
26+
"rehype-highlight": "^7.0.2",
27+
"remark-gfm": "^4.0.1",
2828
"slugify": "^1.6.6",
29-
"xml2js": "^0.6.2",
30-
"zustand": "^5.0.2"
29+
"zustand": "^5.0.11"
3130
},
3231
"devDependencies": {
33-
"@biomejs/biome": "^1.9.4",
34-
"@types/klaw-sync": "^6.0.5",
35-
"@types/node": "20.14.13",
36-
"@types/react": "19.2.3",
32+
"@biomejs/biome": "^2.4.4",
33+
"@types/node": "^25.3.0",
34+
"@types/react": "19.2.14",
3735
"@types/react-dom": "19.2.3",
38-
"@types/xml2js": "^0.4.14",
39-
"typescript": "5.5.4"
36+
"typescript": "^5.9.3"
4037
},
4138
"overrides": {
42-
"@types/react": "19.2.3",
39+
"@types/react": "19.2.14",
4340
"@types/react-dom": "19.2.3"
4441
}
4542
}

src/lib/fetch-docs.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import remarkCallout, {
22
type Options as RemarkCalloutOptions,
33
} from "@r4ai/remark-callout";
4+
import { promises as fs } from "node:fs";
45
import matter from "gray-matter";
5-
import recurse, { type Item } from "klaw-sync";
66
import type { Root } from "mdast";
77
import type { MDXRemoteSerializeResult } from "next-mdx-remote";
88
import { serialize } from "next-mdx-remote/serialize";
@@ -209,15 +209,9 @@ function parseAnchorLinks({
209209
export async function loadAllDocsPageSlugs(
210210
docsDirectory: string,
211211
): Promise<Array<string>> {
212-
const allPaths = recurse(docsDirectory, {
213-
nodir: true,
214-
filter: (file: Item): boolean => {
215-
return file.path.endsWith(MDX_EXTENSION);
216-
},
217-
traverseAll: true,
218-
}).map((item: recurse.Item) => {
219-
return item.path;
220-
});
212+
const allPaths = (await collectAllFilesRecursively(docsDirectory)).filter(
213+
(path) => path.endsWith(MDX_EXTENSION),
214+
);
221215
const docsPageSlugs: Set<string> = new Set();
222216
for (let i = 0; i < allPaths.length; i++) {
223217
const path = allPaths[i];
@@ -253,3 +247,19 @@ function slugFromRelativeFilePath(relativeFilePath: string): string {
253247
.replaceAll(/\/index$/gi, "")
254248
);
255249
}
250+
251+
async function collectAllFilesRecursively(root: string): Promise<string[]> {
252+
const files: string[] = [];
253+
const entries = await fs.readdir(root, { withFileTypes: true });
254+
255+
for (const entry of entries) {
256+
const fullPath = nodePath.join(root, entry.name);
257+
if (entry.isDirectory()) {
258+
files.push(...(await collectAllFilesRecursively(fullPath)));
259+
continue;
260+
}
261+
files.push(fullPath);
262+
}
263+
264+
return files;
265+
}

src/lib/fetch-latest-ghostty-version.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
import { parseStringPromise } from "xml2js";
1+
import { XMLParser } from "fast-xml-parser";
2+
3+
type AppcastItem = {
4+
"sparkle:version": string;
5+
"sparkle:shortVersionString": string;
6+
};
7+
8+
type Appcast = {
9+
rss?: {
10+
channel?: {
11+
item?: AppcastItem | AppcastItem[];
12+
};
13+
};
14+
};
215

316
export async function fetchLatestGhosttyVersion(): Promise<string> {
417
// Use the same appcast we use for Sparkle updates to get the
@@ -10,12 +23,15 @@ export async function fetchLatestGhosttyVersion(): Promise<string> {
1023
}
1124

1225
const xmlContent = await response.text();
13-
const parsedXml = await parseStringPromise(xmlContent, {
14-
explicitArray: false,
26+
const parser = new XMLParser({
27+
ignoreAttributes: false,
1528
});
29+
const parsedXml = parser.parse(xmlContent) as Appcast;
1630

17-
// Extract items
18-
const items = parsedXml.rss.channel.item;
31+
const items = parsedXml.rss?.channel?.item;
32+
if (!items) {
33+
throw new Error("Failed to parse appcast XML: no items found");
34+
}
1935

2036
// Convert items to an array if it's not already
2137
const itemsArray = Array.isArray(items) ? items : [items];

src/lib/fetch-terminal-content.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { promises as fs } from "node:fs";
2-
import recurse, { type Item } from "klaw-sync";
32
const nodePath = require("node:path");
43

54
const TERMINALS_DIRECTORY = "./terminals";
@@ -10,15 +9,9 @@ export type TerminalsMap = { [k: string]: string[] };
109
export async function loadAllTerminalFiles(
1110
subdirectory?: string,
1211
): Promise<TerminalsMap> {
13-
const allPaths = recurse(`${TERMINALS_DIRECTORY}${subdirectory}`, {
14-
nodir: true,
15-
filter: (file: Item): boolean => {
16-
return file.path.endsWith(TERMINAL_CONTENT_FILE_EXTENSION);
17-
},
18-
traverseAll: true,
19-
}).map((item: recurse.Item) => {
20-
return item.path;
21-
});
12+
const allPaths = (
13+
await collectAllFilesRecursively(`${TERMINALS_DIRECTORY}${subdirectory}`)
14+
).filter((path) => path.endsWith(TERMINAL_CONTENT_FILE_EXTENSION));
2215

2316
const map: Map<string, Array<string>> = new Map<string, Array<string>>();
2417
for (const path of allPaths) {
@@ -35,3 +28,19 @@ export async function loadAllTerminalFiles(
3528
}
3629
return Object.fromEntries(map);
3730
}
31+
32+
async function collectAllFilesRecursively(root: string): Promise<string[]> {
33+
const files: string[] = [];
34+
const entries = await fs.readdir(root, { withFileTypes: true });
35+
36+
for (const entry of entries) {
37+
const fullPath = nodePath.join(root, entry.name);
38+
if (entry.isDirectory()) {
39+
files.push(...(await collectAllFilesRecursively(fullPath)));
40+
continue;
41+
}
42+
files.push(fullPath);
43+
}
44+
45+
return files;
46+
}

src/lib/nav-tree-to-breadcrumbs.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ export function navTreeToBreadcrumbs(
2424

2525
// Go through each URL segment & determine the breadcrumb to push to our array
2626
while (segments.length) {
27-
const currentSegment = segments[0];
28-
2927
// Find the Node which represents the URL segment we're on
3028
const nextNode: FolderNode | LinkNode | undefined = currentNavTree.find(
3129
(node) => {
@@ -39,7 +37,7 @@ export function navTreeToBreadcrumbs(
3937
) as FolderNode | LinkNode | undefined;
4038

4139
if (typeof nextNode === "undefined") {
42-
segments.map((name) => {
40+
segments.forEach((name) => {
4341
accumulatedPath += `/${name}`; // Accumulate the path with the current segment
4442
breadcrumbs.push({
4543
text: name, // Use segment (file name) as the breadcrumb title

0 commit comments

Comments
 (0)