Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spruce up the dashboard #689

Merged
merged 6 commits into from Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tender-brooms-own.md
@@ -0,0 +1,5 @@
---
"counterfact": minor
---

Until now the dashboard hasn't gotten much attention. Added a logo and took some baby steps toward the planned design. https://excalidraw.com/#json=THGkyuKCGr_69fFqUrghd,ecIPAvDtoAOajwZ9G4m3sg
5 changes: 5 additions & 0 deletions .changeset/twelve-ducks-reflect.md
@@ -0,0 +1,5 @@
---
"counterfact": patch
---

fix links to open in VSCode
162 changes: 144 additions & 18 deletions src/client/index.html.hbs

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions src/server/module-tree.ts
@@ -1,5 +1,10 @@
import type { Module } from "./registry.js";

interface Route {
methods: { [key: string]: string };
path: string;
}

interface File {
isWildcard: boolean;
module: Module;
Expand Down Expand Up @@ -206,16 +211,23 @@ export class ModuleTree {
);
}

public get routes(): string[] {
const routes: string[] = [];
public get routes(): Route[] {
const routes: Route[] = [];

function traverse(directory: Directory, path: string) {
Object.values(directory.directories).forEach((subdirectory) => {
traverse(subdirectory, `${path}/${subdirectory.rawName}`);
});

Object.values(directory.files).forEach((file) => {
routes.push(`${path}/${file.rawName}`);
const methods: [string, string][] = Object.entries(file.module).map(
([method, implementation]) => [method, String(implementation)],
);

routes.push({
methods: Object.fromEntries(methods),
path: `${path}/${file.rawName}`,
});
});
}

Expand All @@ -228,7 +240,7 @@ export class ModuleTree {

// eslint-disable-next-line etc/no-assign-mutated-array
return routes.sort((first, second) =>
stripBrackets(first).localeCompare(stripBrackets(second)),
stripBrackets(first.path).localeCompare(stripBrackets(second.path)),
);
}
}
7 changes: 6 additions & 1 deletion test/server/module-tree.test.ts
Expand Up @@ -106,6 +106,11 @@ it("has all of the routes", () => {
add(moduleTree, "/a/b", "b");
add(moduleTree, "/a/{b}", "b");
add(moduleTree, "/c", "c");
expect(moduleTree.routes).toEqual(["/a", "/a/b", "/a/{b}", "/c"]);
expect(moduleTree.routes.map((route) => route.path)).toEqual([
"/a",
"/a/b",
"/a/{b}",
"/c",
]);
});
export default ModuleTree;
2 changes: 1 addition & 1 deletion test/server/registry.test.ts
Expand Up @@ -143,7 +143,7 @@ describe("a registry", () => {
registry.add("/c/{b}", {});
registry.add("/c/c", {});

expect(registry.routes).toStrictEqual([
expect(registry.routes.map((route) => route.path)).toStrictEqual([
"/a",
"/a/in/order",
"/b",
Expand Down