Compare commits

..

1 Commits

Author SHA1 Message Date
8c895aff12 fix(deps): update nextjs monorepo to v16
Some checks failed
Lint / Lint and Check (push) Failing after 17s
Lint / Lint and Check (pull_request) Failing after 17s
2025-11-08 03:18:27 +00:00
12 changed files with 957 additions and 895 deletions

View File

@@ -4,7 +4,7 @@ on:
pull_request: pull_request:
push: push:
branches: branches:
- '**' # matches every branch - "**" # matches every branch
jobs: jobs:
lint_and_check: lint_and_check:
@@ -22,10 +22,10 @@ jobs:
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6 uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with: with:
node-version: 24 node-version: 24
cache: 'pnpm' cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: pnpm install run: pnpm install
- name: Run check - name: Run check
run: pnpm run lint run: pnpm run check

View File

@@ -73,11 +73,11 @@ interface HabitResponse {
export default function Dashboard() { export default function Dashboard() {
const router = useRouter(); const router = useRouter();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const [userToken, setUserToken] = useState<string | null>(null);
const [showNewHabitDialog, setShowNewHabitDialog] = useState(false); const [showNewHabitDialog, setShowNewHabitDialog] = useState(false);
const [newHabitName, setNewHabitName] = useState(''); const [newHabitName, setNewHabitName] = useState('');
const [newHabitType, setNewHabitType] = useState<'positive' | 'neutral' | 'negative'>('neutral'); const [newHabitType, setNewHabitType] = useState<'positive' | 'neutral' | 'negative'>('neutral');
const [copiedToken, setCopiedToken] = useState(false); const [copiedToken, setCopiedToken] = useState(false);
const [currentTime, setCurrentTime] = useState(() => Date.now());
// Check authentication // Check authentication
const { data: authData, isLoading: authLoading } = useQuery<AuthData>({ const { data: authData, isLoading: authLoading } = useQuery<AuthData>({
@@ -92,15 +92,11 @@ export default function Dashboard() {
}, },
}); });
// Update current time periodically to avoid impure Date.now() calls during render
useEffect(() => { useEffect(() => {
const interval = setInterval(() => { if (authData?.token) {
setCurrentTime(Date.now()); setUserToken(authData.token);
}, 60000); // Update every minute }
return () => { }, [authData]);
clearInterval(interval);
};
}, []);
// Fetch habits // Fetch habits
const { data: habitsData, isLoading: habitsLoading } = useQuery<HabitsResponse>({ const { data: habitsData, isLoading: habitsLoading } = useQuery<HabitsResponse>({
@@ -158,8 +154,8 @@ export default function Dashboard() {
}; };
const copyToken = () => { const copyToken = () => {
if (authData?.token) { if (userToken) {
void navigator.clipboard.writeText(authData.token); void navigator.clipboard.writeText(userToken);
setCopiedToken(true); setCopiedToken(true);
setTimeout(() => { setTimeout(() => {
setCopiedToken(false); setCopiedToken(false);
@@ -203,7 +199,7 @@ export default function Dashboard() {
const getAverageFrequency = (habit: Habit) => { const getAverageFrequency = (habit: Habit) => {
const daysSinceCreation = Math.max( const daysSinceCreation = Math.max(
1, 1,
Math.floor((currentTime - new Date(habit.createdAt).getTime()) / (1000 * 60 * 60 * 24)), Math.floor((Date.now() - new Date(habit.createdAt).getTime()) / (1000 * 60 * 60 * 24)),
); );
if (daysSinceCreation <= 7) { if (daysSinceCreation <= 7) {
@@ -324,13 +320,13 @@ export default function Dashboard() {
</div> </div>
{/* Token Alert */} {/* Token Alert */}
{authData?.token && ( {userToken && (
<Alert className="border-zinc-800 bg-zinc-950"> <Alert className="border-zinc-800 bg-zinc-950">
<AlertDescription className="flex items-center justify-between"> <AlertDescription className="flex items-center justify-between">
<div className="space-y-1"> <div className="space-y-1">
<p className="text-sm text-zinc-400">Your access token:</p> <p className="text-sm text-zinc-400">Your access token:</p>
<code className="rounded bg-zinc-900 px-2 py-1 font-mono text-sm text-white"> <code className="rounded bg-zinc-900 px-2 py-1 font-mono text-sm text-white">
{authData.token} {userToken}
</code> </code>
</div> </div>
<TooltipProvider> <TooltipProvider>

View File

@@ -1,8 +1,7 @@
'use client'; 'use client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { useState } from 'react'; import { ReactNode, useState } from 'react';
import type { ReactNode } from 'react';
export function Providers({ children }: { children: ReactNode }) { export function Providers({ children }: { children: ReactNode }) {
const [queryClient] = useState( const [queryClient] = useState(

View File

@@ -1,5 +1,6 @@
import { defineConfig } from 'drizzle-kit'; import { defineConfig } from 'drizzle-kit';
import '@/lib/env-config'; import dotenv from 'dotenv';
dotenv.config({ path: ['.env.local', '.env'] });
const DATABASE_URL = process.env.POSTGRES_URL; const DATABASE_URL = process.env.POSTGRES_URL;
if (!DATABASE_URL) { if (!DATABASE_URL) {

View File

@@ -1,19 +1,29 @@
// @ts-check import js from '@eslint/js';
import { defineConfig, globalIgnores } from 'eslint/config';
import nextVitals from 'eslint-config-next/core-web-vitals';
import nextTs from 'eslint-config-next/typescript';
import tseslint from 'typescript-eslint'; import tseslint from 'typescript-eslint';
import nextPlugin from '@next/eslint-plugin-next';
const eslintConfig = defineConfig([ export default tseslint.config(
// Next.js core-web-vitals and TypeScript configs // Base recommended configs
...nextVitals, js.configs.recommended,
...nextTs,
// Add strict TypeScript rules on top // Next.js recommended configs
{
plugins: {
'@next/next': nextPlugin,
},
rules: {
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs['core-web-vitals'].rules,
},
},
// TypeScript configs
...tseslint.configs.recommended,
...tseslint.configs.strictTypeChecked, ...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked, ...tseslint.configs.stylisticTypeChecked,
// Configure TypeScript parser options
// Project-specific configuration
{ {
files: ['**/*.{ts,tsx}'],
languageOptions: { languageOptions: {
parserOptions: { parserOptions: {
projectService: true, projectService: true,
@@ -21,18 +31,30 @@ const eslintConfig = defineConfig([
}, },
}, },
}, },
// Override default ignores of eslint-config-next
globalIgnores([
// Default ignores of eslint-config-next:
'.next/**',
'out/**',
'build/**',
'next-env.d.ts',
// Additional ignores:
'*.mjs',
'tailwind.config.ts',
'eslint.config.js',
]),
]);
export default eslintConfig; // Next.js specific overrides
{
files: ['**/*.{js,jsx,ts,tsx}'],
rules: {
// Next.js already handles React imports
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
},
},
// Config files don't need strict type checking
{
files: ['**/*.config.{js,ts,mjs}', 'tailwind.config.{js,ts}'],
...tseslint.configs.disableTypeChecked,
},
// Ignore build outputs and dependencies
{
ignores: ['.next/**', 'node_modules/**', 'dist/**', 'build/**', 'drizzle/**/*.sql'],
},
);

View File

@@ -1,5 +1,4 @@
import { cookies } from 'next/headers'; import { cookies } from 'next/headers';
import '@/lib/env-config';
const TOKEN_COOKIE_NAME = 'habit-tracker-token'; const TOKEN_COOKIE_NAME = 'habit-tracker-token';
const TOKEN_COOKIE_OPTIONS = { const TOKEN_COOKIE_OPTIONS = {

View File

@@ -1,28 +1,14 @@
import { drizzle } from 'drizzle-orm/node-postgres'; import { drizzle } from 'drizzle-orm/node-postgres';
import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
import * as schema from './schema'; import * as schema from './schema';
import '@/lib/env-config'; import dotenv from 'dotenv';
dotenv.config({ path: ['.env.local', '.env'] });
let _db: NodePgDatabase<typeof schema> | null = null; const DATABASE_URL = process.env.POSTGRES_URL;
if (!DATABASE_URL) {
function getDb() {
if (!_db) {
const DATABASE_URL = process.env.POSTGRES_URL;
if (!DATABASE_URL) {
throw new Error('POSTGRES_URL environment variable is required'); throw new Error('POSTGRES_URL environment variable is required');
}
_db = drizzle(DATABASE_URL, { schema });
}
return _db;
} }
export const db = new Proxy({} as NodePgDatabase<typeof schema>, { export const db = drizzle(DATABASE_URL, { schema });
get(target, prop) {
const database = getDb();
const value = database[prop as keyof typeof database];
return typeof value === 'function' ? value.bind(database) : value;
},
});
// Re-export schema types for convenience // Re-export schema types for convenience
export * from './schema'; export * from './schema';

View File

@@ -1,4 +0,0 @@
import { loadEnvConfig } from '@next/env';
const projectDir = process.cwd();
loadEnvConfig(projectDir);

View File

@@ -1,7 +1,7 @@
import { NextResponse } from 'next/server'; import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server'; import type { NextRequest } from 'next/server';
export function proxy(request: NextRequest) { export function middleware(request: NextRequest) {
const token = request.cookies.get('habit-tracker-token'); const token = request.cookies.get('habit-tracker-token');
const isAuthPage = request.nextUrl.pathname === '/welcome'; const isAuthPage = request.nextUrl.pathname === '/welcome';
const isDashboard = request.nextUrl.pathname === '/dashboard'; const isDashboard = request.nextUrl.pathname === '/dashboard';

View File

@@ -7,7 +7,7 @@
"dev": "next dev --turbopack", "dev": "next dev --turbopack",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "next typegen && eslint . && npx tsc --noEmit", "check": "next lint && npx tsc --noEmit",
"db:generate": "drizzle-kit generate", "db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate", "db:migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push", "db:push": "drizzle-kit push",
@@ -16,55 +16,52 @@
"format:write": "prettier --write \"**/*.{ts,tsx,js,jsx,mdx}\" --cache" "format:write": "prettier --write \"**/*.{ts,tsx,js,jsx,mdx}\" --cache"
}, },
"dependencies": { "dependencies": {
"@next/env": "^16.0.3", "@radix-ui/react-dialog": "^1.1.14",
"@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-label": "^2.1.7",
"@radix-ui/react-label": "^2.1.8", "@radix-ui/react-select": "^2.2.5",
"@radix-ui/react-select": "^2.2.6", "@radix-ui/react-separator": "^1.1.7",
"@radix-ui/react-separator": "^1.1.8", "@radix-ui/react-slot": "^1.2.3",
"@radix-ui/react-slot": "^1.2.4", "@radix-ui/react-tooltip": "^1.2.7",
"@radix-ui/react-tooltip": "^1.2.8", "@tanstack/react-query": "^5.83.0",
"@tanstack/react-query": "^5.90.9",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"cssnano": "^7.1.2", "cssnano": "^7.1.0",
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"drizzle-orm": "^0.44.7", "dotenv": "^17.2.0",
"lucide-react": "^0.553.0", "drizzle-orm": "^0.44.3",
"nanoid": "^5.1.6", "lucide-react": "^0.552.0",
"next": "16.0.3", "nanoid": "^5.1.5",
"next-plausible": "^3.12.5", "next": "16.0.1",
"next-plausible": "^3.12.4",
"pg": "^8.16.3", "pg": "^8.16.3",
"pg-native": "^3.5.2", "pg-native": "^3.5.2",
"postcss-flexbugs-fixes": "^5.0.2", "postcss-flexbugs-fixes": "^5.0.2",
"postcss-preset-env": "^10.4.0", "postcss-preset-env": "^10.2.4",
"react": "19.2.0", "react": "19.2.0",
"react-dom": "19.2.0", "react-dom": "19.2.0",
"tailwind-merge": "^3.4.0", "tailwind-merge": "^3.3.1",
"tailwindcss-animate": "^1.0.7" "tailwindcss-animate": "^1.0.7"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "9.38.0",
"@next/eslint-plugin-next": "16.0.1",
"@tailwindcss/postcss": "4.1.17", "@tailwindcss/postcss": "4.1.17",
"@types/node": "24.10.1", "@types/node": "24.9.2",
"@types/pg": "8.15.6", "@types/pg": "8.15.6",
"@types/react": "19.2.5", "@types/react": "19.2.2",
"@types/react-dom": "19.2.3", "@types/react-dom": "19.2.2",
"drizzle-kit": "0.31.7", "@typescript-eslint/eslint-plugin": "8.46.2",
"eslint": "9.39.1", "@typescript-eslint/parser": "8.46.2",
"eslint-config-next": "16.0.3", "drizzle-kit": "0.31.6",
"eslint-config-prettier": "^10.1.8", "eslint": "9.38.0",
"eslint-config-next": "16.0.1",
"postcss": "8.5.6", "postcss": "8.5.6",
"prettier": "3.6.2", "prettier": "3.6.2",
"prettier-plugin-tailwindcss": "0.7.1", "prettier-plugin-tailwindcss": "0.7.1",
"tailwindcss": "4.1.17", "tailwindcss": "4.1.17",
"turbo": "2.6.1", "turbo": "2.6.0",
"typescript": "5.9.3", "typescript": "5.9.3",
"typescript-eslint": "8.46.4" "typescript-eslint": "8.46.2"
}, },
"packageManager": "pnpm@10.22.0", "packageManager": "pnpm@10.20.0"
"pnpm": {
"overrides": {
"@types/react": "19.2.5",
"@types/react-dom": "19.2.3"
}
}
} }

1628
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": false, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
"noEmit": true, "noEmit": true,
@@ -10,20 +10,18 @@
"moduleResolution": "bundler", "moduleResolution": "bundler",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "react-jsx", "jsx": "preserve",
"incremental": true, "incremental": true,
"baseUrl": ".", "plugins": [
{
"name": "next"
}
],
"paths": { "paths": {
"@/*": ["./*"] "@/*": ["./*"]
}, },
"target": "ES2022", "target": "ES2022"
"forceConsistentCasingInFileNames": true,
"verbatimModuleSyntax": true,
"noUncheckedIndexedAccess": false,
"exactOptionalPropertyTypes": false,
"noImplicitReturns": false,
"plugins": [{ "name": "next" }]
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", ".next/dev/types/**/*.ts"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }