diff --git a/.github/workflows/deploy-script.yml b/.github/workflows/deploy-script.yml index 38045f4..04ca6cf 100644 --- a/.github/workflows/deploy-script.yml +++ b/.github/workflows/deploy-script.yml @@ -25,7 +25,7 @@ on: jobs: script: name: Script - runs-on: ubuntu-latest + runs-on: self-hosted environment: ${{ inputs.environment }} steps: - uses: appleboy/ssh-action@v1.0.3 diff --git a/biome.json b/biome.json index 11d1c49..e8c5dd7 100644 --- a/biome.json +++ b/biome.json @@ -11,6 +11,9 @@ "enabled": true, "rules": { "recommended": true, + "a11y": { + "useSemanticElements": "off" + }, "nursery": { "useSortedClasses": { "level": "warn", diff --git a/bun.lockb b/bun.lockb index c4e9ff5..68cb166 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/global.d.ts b/global.d.ts index 9ce5fc0..977f992 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1,5 +1,3 @@ // Use type safe message keys with `next-intl` -// eslint-disable-next-line @typescript-eslint/consistent-type-imports type Messages = typeof import('./messages/en.json'); -// eslint-disable-next-line @typescript-eslint/no-empty-interface declare interface IntlMessages extends Messages {} diff --git a/lefthook.yml b/lefthook.yml index cf9b74e..b05d112 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -1,6 +1,6 @@ pre-commit: commands: check: - glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}" + glob: "*.{js,ts,tsx,json}" stage_fixed: true run: bunx @biomejs/biome check --write --no-errors-on-unmatched --files-ignore-unknown=true --colors=off {staged_files} diff --git a/lighthouserc.cjs b/lighthouserc.cjs new file mode 100644 index 0000000..210334c --- /dev/null +++ b/lighthouserc.cjs @@ -0,0 +1,66 @@ +const PAGES_EXCLUDED = ['news', 'storage']; + +// Do not convert into an ES6 export. +// lighthouse-ci (as of 0.14.0) uses require() to import, and this is not supported with ES6 modules. +module.exports = { + ci: { + collect: { + url: [ + 'http://localhost:3000/en/', // Trailing slash required, else the regex for default lighthouse rules won't catch this one + 'http://localhost:3000/en/about', + 'http://localhost:3000/en/events', + 'http://localhost:3000/en/news', + 'http://localhost:3000/en/news/1', + 'http://localhost:3000/en/storage', + 'http://localhost:3000/en/storage/shopping-cart', + ], + startServerCommand: 'bun run start', + }, + upload: { + target: 'lhci', + serverBaseUrl: 'https://lhci.hackerspace-ntnu.no', // build token is set by the GH Action + }, + assert: { + assertMatrix: [ + { + matchingUrlPattern: `http://.*/en/(?!${PAGES_EXCLUDED.join('|')}).*`, // match all routes, except for pages with special rules. See https://github.com/GoogleChrome/lighthouse-ci/issues/511 and https://github.com/GoogleChrome/lighthouse-ci/issues/208#issuecomment-784501105 + preset: 'lighthouse:recommended', + assertions: { + 'bf-cache': 'off', + 'color-contrast': 'off', + 'heading-order': 'off', + 'largest-contentful-paint': 'off', + 'render-blocking-resources': 'off', + }, + }, + { + matchingUrlPattern: 'http://.*/en/news.*', + preset: 'lighthouse:recommended', + assertions: { + 'bf-cache': 'off', + 'color-contrast': 'off', + 'heading-order': 'off', + 'largest-contentful-paint': 'off', + 'render-blocking-resources': 'off', + interactive: 'off', + 'uses-responsive-images': 'off', // Should be removed when we obtain images from backend + }, + }, + { + matchingUrlPattern: 'http://.*/en/storage.*', + preset: 'lighthouse:recommended', + assertions: { + 'bf-cache': 'off', + 'color-contrast': 'off', + 'heading-order': 'off', + 'largest-contentful-paint': 'off', + 'render-blocking-resources': 'off', + 'unused-javascript': 'off', + 'cumulative-layout-shift': 'off', // We don't always know how many items are in the cart, which can lead to layout shifts when loading completes + 'max-potential-fid': 'off', + }, + }, + ], + }, + }, +}; diff --git a/lighthouserc.yml b/lighthouserc.yml deleted file mode 100644 index 5c8c3e1..0000000 --- a/lighthouserc.yml +++ /dev/null @@ -1,48 +0,0 @@ -ci: - collect: - url: - - 'http://localhost:3000/en' - - 'http://localhost:3000/en/events' - - 'http://localhost:3000/en/news' - - 'http://localhost:3000/en/news/1' - - 'http://localhost:3000/en/about' - - 'http://localhost:3000/en/storage' - - 'http://localhost:3000/en/storage/shopping-cart' - startServerCommand: 'bun run start' - upload: - target: 'lhci' - serverBaseUrl: 'https://lhci.hackerspace-ntnu.no' # build token is set by the GH Action - assert: - assertMatrix: - - matchingUrlPattern: '.*' - preset: 'lighthouse:recommended' - assertions: - first-contentful-paint: - - error - - maxNumericValue: 2000 - aggregationMethod: optimistic - interactive: - - error - - maxNumericValue: 5000 - aggregationMethod: optimistic - bf-cache: 'off' - csp-xss: 'off' - identical-links-same-purpose: 'off' - total-byte-weight: 'off' - color-contrast: 'off' - heading-order: 'off' - mainthread-work-breakdown: 'off' - bootup-time: 'off' - largest-contentful-paint: 'off' - dom-size: 'off' - render-blocking-resources: 'off' - server-response-time: 'off' - uses-responsive-images: 'off' - maskable-icon: 'off' - installable-manifest: 'off' - - matchingUrlPattern: 'http://[^/]+/storage.*' - preset: 'lighthouse:recommended' - assertions: - unused-javascript: 'off' - cumulative-layout-shift: 'off' - max-potential-fid: 'off' diff --git a/next.config.js b/next.config.js index 69a418a..819aad4 100644 --- a/next.config.js +++ b/next.config.js @@ -1,11 +1,7 @@ import nextIntl from 'next-intl/plugin'; - -/** - * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful - * for Docker builds. - */ await import('./src/env.js'); -const withNextIntl = nextIntl('./src/lib/locale/i18n.ts'); + +const withNextIntl = nextIntl('./src/lib/locale/request.ts'); /** @type {import("next").NextConfig} */ const config = { diff --git a/package.json b/package.json index 4640edb..43e37e9 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,6 @@ "@trpc/client": "^11.0.0-rc.490", "@trpc/react-query": "^11.0.0-rc.490", "@trpc/server": "^11.0.0-rc.490", - "autoprefixer": "^10.4.19", - "client-only": "^0.0.1", "cmdk": "1.0.0", "country-flag-icons": "^1.5.12", "cva": "^1.0.0-beta.1", @@ -47,7 +45,6 @@ "lucide-react": "^0.396.0", "next": "^14.2.10", "next-intl": "^3.18.1", - "next-sitemap": "^4.2.3", "next-themes": "^0.3.0", "nuqs": "^1.17.4", "postgres": "^3.4.4", @@ -56,25 +53,29 @@ "react-dom": "^18.3.1", "react-hook-form": "^7.53.0", "reading-time": "^1.5.0", - "server-only": "^0.0.1", "sharp": "^0.33.4", "superjson": "^2.2.1", "tailwind-merge": "^2.5.2", "zod": "^3.23.8" }, "devDependencies": { - "@biomejs/biome": "1.8.3", + "@biomejs/biome": "^1.9.1", "@fluid-tailwind/tailwind-merge": "^0.0.2", "@types/node": "^20.14.8", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", + "autoprefixer": "^10.4.20", + "client-only": "^0.0.1", "drizzle-kit": "^0.24.1", "fluid-tailwind": "^1.0.3", "lefthook": "^1.7.14", + "next-sitemap": "^4.2.3", "postcss": "^8.4.38", + "server-only": "^0.0.1", "tailwind-scrollbar": "^3.1.0", "tailwindcss": "^3.4.4", "tailwindcss-animate": "^1.0.7", + "tailwindcss-radix": "^3.0.5", "typescript": "^5.5.0" }, "packageManager": "bun@1.1.12" diff --git a/postcss.config.cjs b/postcss.config.js similarity index 52% rename from postcss.config.cjs rename to postcss.config.js index e305dd9..2ef30fc 100644 --- a/postcss.config.cjs +++ b/postcss.config.js @@ -1,3 +1,4 @@ +/** @type {import('postcss-load-config').Config} */ const config = { plugins: { tailwindcss: {}, @@ -5,4 +6,4 @@ const config = { }, }; -module.exports = config; +export default config; diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 5dd6846..17d77be 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -1,10 +1,11 @@ 'use client'; +import { routing } from '@/lib/locale'; import NextError from 'next/error'; export default function NotFoundPage() { return ( - +