From 2a654a7e35bd599735e49f83113a098b1ed8d1da Mon Sep 17 00:00:00 2001 From: Alan Alickovic Date: Sun, 25 Aug 2024 23:33:18 +0200 Subject: [PATCH] update --- .github/workflows/nextjs-app-ci.yml | 62 +++++++++++++++++++ .husky/pre-commit | 2 +- apps/nextjs-app/src/app/app/layout.tsx | 6 +- apps/nextjs-app/src/app/auth/layout.tsx | 6 +- apps/nextjs-app/src/app/layout.tsx | 6 +- apps/nextjs-app/src/app/page.tsx | 2 +- .../src/components/layouts/auth-layout.tsx | 45 +++++++++----- package.json | 2 +- 8 files changed, 106 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/nextjs-app-ci.yml diff --git a/.github/workflows/nextjs-app-ci.yml b/.github/workflows/nextjs-app-ci.yml new file mode 100644 index 00000000..3d641fca --- /dev/null +++ b/.github/workflows/nextjs-app-ci.yml @@ -0,0 +1,62 @@ +name: Next.js App CI +on: + push: + branches: ["*"] + paths-ignore: + - "README.md" + - "docs/**" + pull_request: + branches: [master] + paths-ignore: + - "README.md" + - "docs/**" +jobs: + all-cli-checks: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./apps/nextjs-app + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Set environment variables + run: mv .env.example .env + - name: Install dependencies + run: yarn install + - name: Build application + run: yarn build + - name: Run tests + run: yarn test + - name: Run linter + run: yarn lint + - name: Check types + run: yarn check-types + e2e: + timeout-minutes: 60 + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./apps/nextjs-app + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Set environment variables + run: mv .env.example-e2e .env + - name: Install dependencies + run: npm install -g yarn && yarn + - name: Install Playwright Browsers + run: yarn playwright install --with-deps + - name: Run Playwright tests + run: yarn test-e2e + - uses: actions/upload-artifact@v4 + if: always() + with: + name: playwright-report + path: | + playwright-report/ + mocked-db.json + retention-days: 30 diff --git a/.husky/pre-commit b/.husky/pre-commit index 6bf5f594..f85512a0 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1 @@ -yarn --cwd apps/react-vite lint-staged && yarn --cwd apps/nextjs-pages lint-staged \ No newline at end of file +yarn --cwd apps/nextjs-app lint-staged && yarn --cwd apps/nextjs-pages lint-staged && yarn --cwd apps/react-vite lint-staged \ No newline at end of file diff --git a/apps/nextjs-app/src/app/app/layout.tsx b/apps/nextjs-app/src/app/app/layout.tsx index 152c90da..c4c1eb24 100644 --- a/apps/nextjs-app/src/app/app/layout.tsx +++ b/apps/nextjs-app/src/app/app/layout.tsx @@ -2,6 +2,8 @@ import { ReactNode } from 'react'; import { DashboardLayout } from '@/components/layouts'; -export default function AppLayout({ children }: { children: ReactNode }) { +const AppLayout = ({ children }: { children: ReactNode }) => { return {children}; -} +}; + +export default AppLayout; diff --git a/apps/nextjs-app/src/app/auth/layout.tsx b/apps/nextjs-app/src/app/auth/layout.tsx index 830e0fe8..896f83f1 100644 --- a/apps/nextjs-app/src/app/auth/layout.tsx +++ b/apps/nextjs-app/src/app/auth/layout.tsx @@ -5,7 +5,7 @@ import { ReactNode } from 'react'; import { AuthLayout as AuthLayoutComponent } from '@/components/layouts/auth-layout'; -export default function AuthLayout({ children }: { children: ReactNode }) { +const AuthLayout = ({ children }: { children: ReactNode }) => { const pathname = usePathname(); const isLoginPage = pathname === '/auth/login'; const title = isLoginPage @@ -13,4 +13,6 @@ export default function AuthLayout({ children }: { children: ReactNode }) { : 'Register your account'; return {children}; -} +}; + +export default AuthLayout; diff --git a/apps/nextjs-app/src/app/layout.tsx b/apps/nextjs-app/src/app/layout.tsx index f55b4141..3ec2d211 100644 --- a/apps/nextjs-app/src/app/layout.tsx +++ b/apps/nextjs-app/src/app/layout.tsx @@ -4,7 +4,7 @@ import { AppProvider } from '@/app/provider'; import '@/styles/globals.css'; -export default function RootLayout({ children }: { children: ReactNode }) { +const RootLayout = ({ children }: { children: ReactNode }) => { return ( @@ -12,4 +12,6 @@ export default function RootLayout({ children }: { children: ReactNode }) { ); -} +}; + +export default RootLayout; diff --git a/apps/nextjs-app/src/app/page.tsx b/apps/nextjs-app/src/app/page.tsx index 5cfc008a..d322cbd0 100644 --- a/apps/nextjs-app/src/app/page.tsx +++ b/apps/nextjs-app/src/app/page.tsx @@ -9,7 +9,7 @@ import { useUser } from '@/lib/auth'; // description: 'Welcome to bulletproof react', // }; -export const HomePage = () => { +const HomePage = () => { const router = useRouter(); const user = useUser(); diff --git a/apps/nextjs-app/src/components/layouts/auth-layout.tsx b/apps/nextjs-app/src/components/layouts/auth-layout.tsx index 95997b38..3d81801d 100644 --- a/apps/nextjs-app/src/components/layouts/auth-layout.tsx +++ b/apps/nextjs-app/src/components/layouts/auth-layout.tsx @@ -1,10 +1,12 @@ 'use client'; -import { useRouter } from 'next/navigation'; +import { useRouter, usePathname } from 'next/navigation'; import * as React from 'react'; import { useEffect } from 'react'; +import { ErrorBoundary } from 'react-error-boundary'; import { Link } from '@/components/ui/link'; +import { Spinner } from '@/components/ui/spinner'; import { useUser } from '@/lib/auth'; type LayoutProps = { @@ -21,6 +23,7 @@ export const AuthLayout = ({ children, title }: LayoutProps) => { const user = useUser(); const router = useRouter(); + const pathname = usePathname(); useEffect(() => { if (user.data) { @@ -29,24 +32,34 @@ export const AuthLayout = ({ children, title }: LayoutProps) => { }, [user.data, router]); return ( -
-
-
- - Workflow - + +
+ } + > + Something went wrong!
}> +
+
+
+ + Workflow + +
-

- {title} -

-
+

+ {title} +

+
-
-
- {children} +
+
+ {children} +
+
-
-
+ + ); }; diff --git a/package.json b/package.json index 6c858d66..d30f79d1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "description": "A simple, scalable, and powerful architecture for building production ready React applications.", "scripts": { - "prepare": "cd ./apps/nextjs-pages && yarn && cd ../react-vite && yarn" + "prepare": "cd ./apps/nextjs-app && yarn && cd ../nextjs-pages && yarn && cd ../react-vite && yarn" }, "author": "alan2207", "license": "MIT"