From b75dba67dd9cf4f4f22dbc43f71420f66136a113 Mon Sep 17 00:00:00 2001 From: Pahan Sarathchandra Date: Mon, 20 May 2024 19:23:04 +0300 Subject: [PATCH] Move lib out of app directory --- src/app/[slug]/(read)/page.tsx | 2 +- src/app/admin/page.tsx | 2 +- src/app/layout.tsx | 2 +- src/components/app/edit-post/edit-post.tsx | 4 ++-- src/components/app/posts-list/posts-list.test.tsx | 4 ++-- src/components/app/posts-list/posts-list.tsx | 2 +- src/components/app/posts-table/actions-cell.tsx | 4 ++-- src/components/app/posts-table/index.tsx | 2 +- src/components/app/posts-table/posts-table.tsx | 2 +- src/components/app/read-post/index.tsx | 2 +- src/components/app/read-post/read-post.tsx | 2 +- src/components/{app => ui}/theme-provider/index.ts | 0 src/components/{app => ui}/theme-provider/theme-provider.tsx | 0 src/{app => }/lib/actions.ts | 2 +- src/{app => }/lib/data.ts | 0 src/{app => }/lib/definitions.ts | 0 src/{app => }/lib/kysely.ts | 0 17 files changed, 15 insertions(+), 15 deletions(-) rename src/components/{app => ui}/theme-provider/index.ts (100%) rename src/components/{app => ui}/theme-provider/theme-provider.tsx (100%) rename src/{app => }/lib/actions.ts (97%) rename src/{app => }/lib/data.ts (100%) rename src/{app => }/lib/definitions.ts (100%) rename src/{app => }/lib/kysely.ts (100%) diff --git a/src/app/[slug]/(read)/page.tsx b/src/app/[slug]/(read)/page.tsx index 5b47501..6384411 100644 --- a/src/app/[slug]/(read)/page.tsx +++ b/src/app/[slug]/(read)/page.tsx @@ -1,4 +1,4 @@ -import { fetchPost } from "@/app/lib/data"; +import { fetchPost } from "@/lib/data"; import { ReadPost, ReadPostSkeleton } from "@/components/app/read-post"; import { notFound } from "next/navigation"; import { Suspense } from "react"; diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index cb984f7..27469ee 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -1,5 +1,5 @@ import { EditPost } from "@/components/app/edit-post"; -import { fetchPost } from "@/app/lib/data"; +import { fetchPost } from "@/lib/data"; import { PostsTable } from "@/components/app/posts-table"; import { Suspense } from "react"; import { PostsTableSkeleton } from "@/components/app/posts-table/skeleton"; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index baca37d..9dcccb5 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,7 +1,7 @@ import { cn } from "@/lib/utils"; import type { Metadata } from "next"; import { Header } from "@/components/app/header"; -import { ThemeProvider } from "@/components/app/theme-provider"; +import { ThemeProvider } from "@/components/ui/theme-provider"; import { fontSans } from "./fonts"; import "./globals.css"; diff --git a/src/components/app/edit-post/edit-post.tsx b/src/components/app/edit-post/edit-post.tsx index 00901a5..3d23d75 100644 --- a/src/components/app/edit-post/edit-post.tsx +++ b/src/components/app/edit-post/edit-post.tsx @@ -1,6 +1,6 @@ "use client"; -import { createOrUpdatePost } from "@/app/lib/actions"; -import { BlogPost } from "@/app/lib/definitions"; +import { createOrUpdatePost } from "@/lib/actions"; +import { BlogPost } from "@/lib/definitions"; import { Button } from "@/components/ui/button"; import { Dialog, diff --git a/src/components/app/posts-list/posts-list.test.tsx b/src/components/app/posts-list/posts-list.test.tsx index 7db57c2..9c6bbb5 100644 --- a/src/components/app/posts-list/posts-list.test.tsx +++ b/src/components/app/posts-list/posts-list.test.tsx @@ -1,6 +1,6 @@ import { render, screen } from "@testing-library/react"; import { PostsList } from "."; -import { BlogPost } from "@/app/lib/definitions"; +import { BlogPost } from "@/lib/definitions"; const posts: BlogPost[] = [ { @@ -17,7 +17,7 @@ const posts: BlogPost[] = [ }, ]; -jest.mock("@/app/lib/data", () => ({ +jest.mock("@/lib/data", () => ({ fetchAllPosts: () => { return Promise.resolve(posts); }, diff --git a/src/components/app/posts-list/posts-list.tsx b/src/components/app/posts-list/posts-list.tsx index bfb7b76..c8ea2d3 100644 --- a/src/components/app/posts-list/posts-list.tsx +++ b/src/components/app/posts-list/posts-list.tsx @@ -1,5 +1,5 @@ import { Separator } from "@/components/ui/separator"; -import { fetchAllPosts } from "@/app/lib/data"; +import { fetchAllPosts } from "@/lib/data"; import Link from "next/link"; interface PostsListProps {} diff --git a/src/components/app/posts-table/actions-cell.tsx b/src/components/app/posts-table/actions-cell.tsx index 0f66d30..81c73ea 100644 --- a/src/components/app/posts-table/actions-cell.tsx +++ b/src/components/app/posts-table/actions-cell.tsx @@ -3,8 +3,8 @@ import { Edit as EditIcon } from "lucide-react"; import { usePathname, useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; -import { deletePost } from "@/app/lib/actions"; -import { BlogPost } from "@/app/lib/definitions"; +import { deletePost } from "@/lib/actions"; +import { BlogPost } from "@/lib/definitions"; import { ConfirmDeleteDialog } from "./confirm-delete-dialog"; import { useCallback } from "react"; diff --git a/src/components/app/posts-table/index.tsx b/src/components/app/posts-table/index.tsx index 291bc1d..7890eb5 100644 --- a/src/components/app/posts-table/index.tsx +++ b/src/components/app/posts-table/index.tsx @@ -1,4 +1,4 @@ -import { fetchAllPosts } from "@/app/lib/data"; +import { fetchAllPosts } from "@/lib/data"; import { PostsTable as PostsTableClient } from "./posts-table"; export const PostsTable: React.FC = async () => { diff --git a/src/components/app/posts-table/posts-table.tsx b/src/components/app/posts-table/posts-table.tsx index a4688d4..a114cce 100644 --- a/src/components/app/posts-table/posts-table.tsx +++ b/src/components/app/posts-table/posts-table.tsx @@ -1,7 +1,7 @@ "use client"; import { ColumnDef } from "@tanstack/react-table"; -import { BlogPost } from "@/app/lib/definitions"; +import { BlogPost } from "@/lib/definitions"; import { DataTable } from "./data-table"; import { ActionsCell } from "./actions-cell"; diff --git a/src/components/app/read-post/index.tsx b/src/components/app/read-post/index.tsx index e786017..3fefa1e 100644 --- a/src/components/app/read-post/index.tsx +++ b/src/components/app/read-post/index.tsx @@ -1,4 +1,4 @@ -import { fetchPost } from "@/app/lib/data"; +import { fetchPost } from "@/lib/data"; import { ReadPost as ReadPostClient } from "./read-post"; import { notFound } from "next/navigation"; diff --git a/src/components/app/read-post/read-post.tsx b/src/components/app/read-post/read-post.tsx index 5f6a5af..044247e 100644 --- a/src/components/app/read-post/read-post.tsx +++ b/src/components/app/read-post/read-post.tsx @@ -1,6 +1,6 @@ "use client"; -import { BlogPost } from "@/app/lib/definitions"; +import { BlogPost } from "@/lib/definitions"; interface ReadPostProps { post: BlogPost; diff --git a/src/components/app/theme-provider/index.ts b/src/components/ui/theme-provider/index.ts similarity index 100% rename from src/components/app/theme-provider/index.ts rename to src/components/ui/theme-provider/index.ts diff --git a/src/components/app/theme-provider/theme-provider.tsx b/src/components/ui/theme-provider/theme-provider.tsx similarity index 100% rename from src/components/app/theme-provider/theme-provider.tsx rename to src/components/ui/theme-provider/theme-provider.tsx diff --git a/src/app/lib/actions.ts b/src/lib/actions.ts similarity index 97% rename from src/app/lib/actions.ts rename to src/lib/actions.ts index df1cb16..89d8e1c 100644 --- a/src/app/lib/actions.ts +++ b/src/lib/actions.ts @@ -1,6 +1,6 @@ "use server"; -import { db } from "@/app/lib/kysely"; +import { db } from "@/lib/kysely"; import { z } from "zod"; import { redirect } from "next/navigation"; import { revalidatePath } from "next/cache"; diff --git a/src/app/lib/data.ts b/src/lib/data.ts similarity index 100% rename from src/app/lib/data.ts rename to src/lib/data.ts diff --git a/src/app/lib/definitions.ts b/src/lib/definitions.ts similarity index 100% rename from src/app/lib/definitions.ts rename to src/lib/definitions.ts diff --git a/src/app/lib/kysely.ts b/src/lib/kysely.ts similarity index 100% rename from src/app/lib/kysely.ts rename to src/lib/kysely.ts