Skip to content

Commit 4d9d0e9

Browse files
committed
Refactor template page and CLI command components for improved clarity and functionality. Update installation command to use dynamic CLI versioning and streamline template content display. Enhance error handling in tests for better resilience against undefined values.
1 parent d88124c commit 4d9d0e9

File tree

11 files changed

+35
-48
lines changed

11 files changed

+35
-48
lines changed

.changeset/quick-ends-drop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@proofkit/typegen": patch
3+
---
4+
5+
Add type import to the `InferZodPortals` import

apps/docs/src/app/docs/templates/[...slug]/page.tsx

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { getAllTemplates, getTemplateByName } from "@/lib/templates";
22
import { notFound } from "next/navigation";
3-
import Link from "next/link";
4-
import { ArrowLeft, Package, ExternalLink } from "lucide-react";
53
import type { Metadata } from "next";
64
import { CliCommand } from "@/components/CliCommand";
75
import { getCategoryConfig } from "../category-config";
@@ -86,32 +84,7 @@ export default async function TemplatePage({ params }: TemplatePageProps) {
8684
{/* Installation command */}
8785
<div className="not-prose mb-8">
8886
<h2 className="text-lg font-semibold mb-4">Installation</h2>
89-
<CliCommand
90-
command={`add ${template.name}`}
91-
exec
92-
execPackage="proofkit@latest"
93-
/>
94-
</div>
95-
96-
{/* Template content */}
97-
<div className="prose prose-neutral dark:prose-invert max-w-none">
98-
{/* Placeholder content - you can expand this later */}
99-
<div className="border border-border rounded-lg p-6">
100-
<h2 className="text-xl font-semibold mb-4">About this template</h2>
101-
<p className="text-muted-foreground mb-4">
102-
This template provides{" "}
103-
{template.description?.toLowerCase() ||
104-
"functionality for your ProofKit application"}
105-
.
106-
</p>
107-
108-
<div className="bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-4">
109-
<p className="text-sm text-blue-800 dark:text-blue-200">
110-
<strong>Coming soon:</strong> Detailed documentation, code
111-
examples, and usage guides will be available here.
112-
</p>
113-
</div>
114-
</div>
87+
<CliCommand command={`add ${template.name}`} exec />
11588
</div>
11689
</div>
11790
);

apps/docs/src/components/CliCommand.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
"use client";
12
import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock";
23
import { Tabs, Tab } from "fumadocs-ui/components/tabs";
4+
import { cliVersion } from "@/lib/constants";
35

46
const MANAGERS = [
57
{
@@ -31,7 +33,7 @@ const MANAGERS = [
3133
export function CliCommand({
3234
command,
3335
exec,
34-
execPackage = "@proofkit/cli",
36+
execPackage = `@proofkit/cli@${cliVersion}`,
3537
}: {
3638
command: string;
3739
exec?: boolean;

apps/docs/src/components/InitCommand.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock";
22
import { Tabs, Tab } from "fumadocs-ui/components/tabs";
3+
import { cliVersion } from "@/lib/constants";
34

45
const MANAGERS = [
5-
{ key: "pnpm", label: "pnpm", command: "pnpm create proofkit@latest" },
6-
{ key: "npm", label: "npm", command: "npx create-proofkit@latest" },
7-
{ key: "yarn", label: "yarn", command: "yarn create proofkit@latest" },
6+
{ key: "pnpm", label: "pnpm", command: `pnpm create proofkit@${cliVersion}` },
7+
{ key: "npm", label: "npm", command: `npx create-proofkit@${cliVersion}` },
8+
{ key: "yarn", label: "yarn", command: `yarn create proofkit@${cliVersion}` },
89
];
910

1011
export function InitCommand() {

apps/docs/src/lib/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// which version of the CLI to use in the docs
2+
export const cliVersion: "latest" | "beta" = "beta";

packages/fmdapi/tests/client-methods.test.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ describe("sort methods", () => {
1919
sort: { fieldName: "recordId", sortOrder: "descend" },
2020
});
2121
expect(resp.data.length).toBe(3);
22-
const firstRecord = parseInt(resp.data[0].fieldData.recordId as string);
23-
const secondRecord = parseInt(resp.data[1].fieldData.recordId as string);
22+
const firstRecord = parseInt(resp.data[0]?.fieldData.recordId as string);
23+
const secondRecord = parseInt(resp.data[1]?.fieldData.recordId as string);
2424
expect(firstRecord).toBeGreaterThan(secondRecord);
2525
});
2626
test("should sort ascending by default", async () => {
2727
const resp = await layoutClient.list({
2828
sort: { fieldName: "recordId" },
2929
});
3030

31-
const firstRecord = parseInt(resp.data[0].fieldData.recordId as string);
32-
const secondRecord = parseInt(resp.data[1].fieldData.recordId as string);
31+
const firstRecord = parseInt(resp.data[0]?.fieldData.recordId as string);
32+
const secondRecord = parseInt(resp.data[1]?.fieldData.recordId as string);
3333
expect(secondRecord).toBeGreaterThan(firstRecord);
3434
});
3535
});
@@ -48,6 +48,7 @@ describe("find methods", () => {
4848
const resp = await client.find({
4949
query: { anything: "anything" },
5050
});
51+
5152
expect(Array.isArray(resp.data)).toBe(true);
5253
});
5354
test("successful findFirst with multiple return", async () => {
@@ -75,18 +76,18 @@ describe("portal methods", () => {
7576
const result = await layoutClient.list({
7677
limit: 1,
7778
});
78-
expect(result.data[0].portalData.test.length).toBe(50); // default portal limit is 50
79+
expect(result.data[0]?.portalData?.test?.length).toBe(50); // default portal limit is 50
7980

8081
const { data } = await layoutClient.list({
8182
limit: 1,
8283
portalRanges: { test: { limit: 1, offset: 2 } },
8384
});
8485
expect(data.length).toBe(1);
8586

86-
const portalData = data[0].portalData;
87-
const testPortal = portalData.test;
88-
expect(testPortal.length).toBe(1);
89-
expect(testPortal[0]["related::related_field"]).toContain("2"); // we should get the 2nd record
87+
const portalData = data[0]?.portalData;
88+
const testPortal = portalData?.test;
89+
expect(testPortal?.length).toBe(1);
90+
expect(testPortal?.[0]?.["related::related_field"]).toContain("2"); // we should get the 2nd record
9091
});
9192
it("should update portal data", async () => {
9293
await layoutClient.update({
@@ -106,13 +107,13 @@ describe("portal methods", () => {
106107
});
107108

108109
expect(
109-
"long_and_strange.portalName#forTesting" in data[0].portalData,
110+
"long_and_strange.portalName#forTesting" in (data?.[0]?.portalData ?? {}),
110111
).toBeTruthy();
111112

112113
const portalData =
113-
data[0].portalData["long_and_strange.portalName#forTesting"];
114+
data[0]?.portalData["long_and_strange.portalName#forTesting"];
114115

115-
expect(portalData.length).toBeGreaterThan(50);
116+
expect(portalData?.length).toBeGreaterThan(50);
116117
});
117118
});
118119

packages/fmdapi/tests/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"compilerOptions": {
44
"noEmit": true,
55
"types": ["vitest", "node"],
6-
"isolatedModules": true
6+
"isolatedModules": true,
7+
"rootDir": "../"
78
},
89
"include": ["./**/*.ts"],
910
"exclude": ["../dist", "../schema"]

packages/typegen/src/buildSchema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function buildSchema(
3535
schemaFile.addImportDeclaration({
3636
moduleSpecifier: "@proofkit/fmdapi",
3737
namedImports: ["InferZodPortals"],
38+
isTypeOnly: true,
3839
});
3940
}
4041
}
@@ -349,6 +350,7 @@ export function buildOverrideFile(
349350
overrideFile.addImportDeclaration({
350351
moduleSpecifier: "@proofkit/fmdapi",
351352
namedImports: ["InferZodPortals"],
353+
isTypeOnly: true,
352354
});
353355
}
354356

packages/typegen/tests/__snapshots__/strict-numbers.snap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* DO NOT EDIT THIS FILE DIRECTLY. Changes may be overritten
55
*/
66
import { z } from "zod/v4";
7-
import { InferZodPortals } from "@proofkit/fmdapi";
7+
import type { InferZodPortals } from "@proofkit/fmdapi";
88

99
// @generated
1010
// prettier-ignore

packages/typegen/tests/__snapshots__/zod-layout-client.snap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* DO NOT EDIT THIS FILE DIRECTLY. Changes may be overritten
55
*/
66
import { z } from "zod";
7-
import { InferZodPortals } from "@proofkit/fmdapi";
7+
import type { InferZodPortals } from "@proofkit/fmdapi";
88

99
// @generated
1010
// prettier-ignore

0 commit comments

Comments
 (0)