Skip to content

Commit 54a4a7b

Browse files
committed
Enhance preflight checks in CLI to ensure Shadcn is installed; update default settings to include UI type; refactor better-auth template paths and imports for consistency.
1 parent f52c3dd commit 54a4a7b

File tree

12 files changed

+52
-27
lines changed

12 files changed

+52
-27
lines changed

packages/cli/src/cli/add/registry/preflight.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
import fs from "fs-extra";
2+
import path from "path";
13
import { stealthInit } from "~/helpers/stealth-init.js";
4+
import { state } from "~/state.js";
25

36
export async function preflightAddCommand() {
7+
const cwd = state.projectDir ?? process.cwd();
48
// make sure shadcn is installed, throw if not
9+
const shadcnInstalled = await fs.pathExists(path.join(cwd, "components.json"));
10+
if (!shadcnInstalled) {
11+
throw new Error("Shadcn is not installed. Please run `pnpm dlx shadcn@latest init` to install it.");
12+
}
513

614
// if proofkit is not inited, try to stealth init
715
await stealthInit();

packages/cli/src/helpers/stealth-init.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@ export async function stealthInit() {
1919
}
2020

2121
// create proofkit.json
22-
await fs.writeJson("proofkit.json", defaultSettings
23-
24-
);
22+
await fs.writeJson("proofkit.json", defaultSettings);
2523
}

packages/cli/src/utils/parseSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const settingsSchema = z.object({
6868
registryTemplates: z.array(z.string()).default([]),
6969
});
7070

71-
export const defaultSettings = settingsSchema.parse({ auth: { type: "none" } });
71+
export const defaultSettings = settingsSchema.parse({ auth: { type: "none" },ui:"shadcn" });
7272

7373
let settings: Settings | undefined;
7474
export const getSettings = () => {

packages/registry/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export async function getStaticComponent(
191191
path: file.sourceFileName,
192192
type: file.type,
193193
content,
194-
target: file.destinationPath ?? file.sourceFileName,
194+
target: file.destinationPath!
195195
};
196196

197197
return shadcnFile;

packages/registry/templates/better-auth/AuthUIProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { AuthUIProvider as BetterAuthUIProvider } from "@daveyplate/better-auth-ui";
4-
import { authClient } from "@/auth-client";
4+
import { authClient } from "@/registry/lib/auth-client";
55
import { useRouter } from "next/navigation";
66
import Link from "next/link";
77

packages/registry/templates/better-auth/_meta.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const meta: TemplateMetadata = {
1212
"@proofkit/better-auth",
1313
],
1414
registryDependencies: [
15+
"{proofkit}/r/utils/t3-env",
1516
"{proofkit}/r/react-email",
1617
"{proofkit}/r/email/generic",
1718
],
@@ -34,22 +35,15 @@ export const meta: TemplateMetadata = {
3435
},
3536
{
3637
sourceFileName: "auth.ts",
37-
destinationPath: "src/auth.ts",
38-
type: "registry:file",
38+
type: "registry:lib",
3939
},
4040
{
4141
sourceFileName: "auth-client.ts",
42-
destinationPath: "src/auth-client.ts",
43-
type: "registry:file",
44-
},
45-
{
46-
sourceFileName: "auth/[pathname]/page.tsx",
47-
// destinationPath: "src/app/auth/[pathname]/page.tsx",
48-
type: "registry:page",
42+
type: "registry:lib",
4943
},
5044
{
51-
sourceFileName: "view.tsx",
52-
destinationPath: "src/app/auth/[pathname]/view.tsx",
45+
sourceFileName: "page.tsx",
46+
destinationPath: "src/app/auth/[pathname]/page.tsx",
5347
type: "registry:file",
5448
},
5549
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { auth } from "@/auth";
1+
import { auth } from "@/registry/lib/auth";
22
import { toNextJsHandler } from "better-auth/next-js";
33

44
export const { GET, POST } = toNextJsHandler(auth.handler);

packages/registry/templates/better-auth/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FileMakerAdapter } from "@proofkit/better-auth";
22
import { betterAuth } from "better-auth";
33
import { nextCookies } from "better-auth/next-js";
4-
import { env } from "@/config/env";
4+
import { env } from "@/registry/lib/env";
55
import { render } from "@react-email/components";
66
import { GenericEmail } from "@/emails/generic";
77

packages/registry/templates/better-auth/auth/[pathname]/page.tsx renamed to packages/registry/templates/better-auth/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { AuthView } from "@daveyplate/better-auth-ui";
12
import { authViewPaths } from "@daveyplate/better-auth-ui/server";
2-
import { AuthView } from "../../view";
33

44
export function generateStaticParams() {
55
return Object.values(authViewPaths).map((pathname) => ({ pathname }));

packages/registry/templates/better-auth/view.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)