diff --git a/.env b/.env index bedfcf9eea..d9be82d68e 100644 --- a/.env +++ b/.env @@ -1,9 +1,16 @@ -BILLING_PLAN_ENV=dev +# NOTE: Sensitive ENV vars are overridden with their real values in .env.local +# for local development and in the "Environment Variables" setting on Vercel +# for production (https://vercel.com/roo-code/roo-code-cloud/settings/environment-variables). +# Deep Links VSCODE_EXTENSION_BASE_URL=vscode://RooVeterinaryInc.roo-cline CURSOR_EXTENSION_BASE_URL=cursor://RooVeterinaryInc.roo-cline # Clerk +CLERK_SECRET_KEY=your_clerk_secret_key +NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_ZXBpYy1jaGFtb2lzLTg1LmNsZXJrLmFjY291bnRzLmRldiQ +NEXT_PUBLIC_CLERK_FRONTEND_API=https://epic-chamois-85.clerk.accounts.dev + # https://clerk.com/docs/deployments/clerk-environment-variables#sign-in-and-sign-up-redirects NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up @@ -11,10 +18,8 @@ NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL=/dashboard NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL=/dashboard NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/dashboard NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/dashboard -NEXT_PUBLIC_CLERK_FRONTEND_API=https://epic-chamois-85.clerk.accounts.dev -NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_ZXBpYy1jaGFtb2lzLTg1LmNsZXJrLmFjY291bnRzLmRldiQ -# Stripe -NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51PNk4fKOp3DEwzQle6Cx1j3IW1Lze5nFKZ4JBX0gLpNQ3hjFbMiT25gw7LEr369ge7JIsVA2qRhdKQm1NAmVehXl00FQxwRfh1 -STRIPE_SECRET_KEY=your_stripe_secret_key -STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret +# ClickHouse +CLICKHOUSE_URL=https://fake.us-west-2.aws.clickhouse.cloud:1234 +CLICKHOUSE_USERNAME=default +CLICKHOUSE_PASSWORD=fake-your_clickhouse_password diff --git a/.env.local.sample b/.env.local.sample deleted file mode 100644 index 14fbf342b2..0000000000 --- a/.env.local.sample +++ /dev/null @@ -1,5 +0,0 @@ -CLERK_SECRET_KEY=your_clerk_secret_key - -CLICKHOUSE_URL=your_clickhouse_url -CLICKHOUSE_USERNAME=your_clickhouse_username -CLICKHOUSE_PASSWORD=fake-your_clickhouse_password diff --git a/.env.production b/.env.production deleted file mode 100644 index 21038485b9..0000000000 --- a/.env.production +++ /dev/null @@ -1,33 +0,0 @@ -# FIXME: Configure environment variables for production - -# Hosting -# Replace by your domain name -# NEXT_PUBLIC_APP_URL=https://example.com - -# Sentry DSN -NEXT_PUBLIC_SENTRY_DSN= - -# Stripe -# If you need a real Stripe subscription payment with checkout page, customer portal, webhook, etc. -# You can check out the Next.js Boilerplate Pro: https://nextjs-boilerplate.com/pro-saas-starter-kit -NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live -# Use Stripe test mode price id or production price id -BILLING_PLAN_ENV=prod - -######## [BEGIN] SENSITIVE DATA ######## For security reason, don't update the following variables (secret key) directly in this file. -######## Please create a new file named `.env.production.local`, all environment files ending with `.local` won't be tracked by Git. -######## After creating the file, you can add the following variables. -# Database -# Using an incorrect DATABASE_URL value, Next.js build will timeout and you will get the following error: "because it took more than 60 seconds" -# DATABASE_URL=postgresql://postgres@localhost:5432/postgres - -# Stripe -STRIPE_SECRET_KEY=your_stripe_secret_key -STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret - -# Error monitoring -# SENTRY_AUTH_TOKEN= - -# Logging ingestion -# LOGTAIL_SOURCE_TOKEN= -######## [END] SENSITIVE DATA diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 791fee1573..f9a4e73a15 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,10 +11,33 @@ env: PNPM_VERSION: 10.8.1 jobs: - test: - name: Run all tests + build: runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: ${{ env.PNPM_VERSION }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Build Next.js + run: pnpm build + + test: + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 @@ -72,3 +95,10 @@ jobs: # name: test-results # path: test-results/ # retention-days: 7 + + check: + needs: [build, test] + runs-on: ubuntu-latest + steps: + - name: NO-OP + run: echo "All checks passed." diff --git a/src/app/extension/sign-in/page.tsx b/src/app/extension/sign-in/page.tsx index 5f7e1fd52d..3063d7620f 100644 --- a/src/app/extension/sign-in/page.tsx +++ b/src/app/extension/sign-in/page.tsx @@ -6,10 +6,12 @@ import { Env } from '@/lib/server/env'; import { DeepLink } from './DeepLink'; -export default async function Page(params: { - searchParams: { state?: string }; -}) { - const { state } = await params.searchParams; +type Props = { + searchParams: Promise<{ state?: string }>; +}; + +export default async function Page(props: Props) { + const { state } = await props.searchParams; if (!state) { redirect(`/sign-in`); diff --git a/src/lib/server/env.ts b/src/lib/server/env.ts index 82d02b9506..513e73d9fd 100644 --- a/src/lib/server/env.ts +++ b/src/lib/server/env.ts @@ -6,9 +6,6 @@ export const Env = createEnv({ CLERK_SECRET_KEY: z.string().min(1), DATABASE_URL: z.string().optional(), LOGTAIL_SOURCE_TOKEN: z.string().optional(), - STRIPE_SECRET_KEY: z.string().min(1), - STRIPE_WEBHOOK_SECRET: z.string().min(1), - BILLING_PLAN_ENV: z.enum(['dev', 'test', 'prod']), VSCODE_EXTENSION_BASE_URL: z.string().min(1), CURSOR_EXTENSION_BASE_URL: z.string().min(1), CLICKHOUSE_URL: z.string().min(1), @@ -24,19 +21,15 @@ export const Env = createEnv({ NEXT_PUBLIC_CLERK_SIGN_UP_URL: z.string().min(1), NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL: z.string().min(1), NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL: z.string().min(1), - NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string().min(1), }, shared: { NODE_ENV: z.enum(['test', 'development', 'production']).optional(), }, - // You need to destructure all the keys manually + // You need to destructure all the keys manually. runtimeEnv: { CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY, DATABASE_URL: process.env.DATABASE_URL, LOGTAIL_SOURCE_TOKEN: process.env.LOGTAIL_SOURCE_TOKEN, - STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY, - STRIPE_WEBHOOK_SECRET: process.env.STRIPE_WEBHOOK_SECRET, - BILLING_PLAN_ENV: process.env.BILLING_PLAN_ENV, VSCODE_EXTENSION_BASE_URL: process.env.VSCODE_EXTENSION_BASE_URL, CURSOR_EXTENSION_BASE_URL: process.env.CURSOR_EXTENSION_BASE_URL, NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL, @@ -52,8 +45,6 @@ export const Env = createEnv({ process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL, NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL, - NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: - process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY, NODE_ENV: process.env.NODE_ENV, CLICKHOUSE_URL: process.env.CLICKHOUSE_URL, CLICKHOUSE_USERNAME: process.env.CLICKHOUSE_USERNAME, diff --git a/src/middleware.ts b/src/middleware.ts index e66a85c015..f42a360e78 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -6,13 +6,25 @@ const isProtectedRoute = createRouteMatcher([ '/api(.*)', ]); -export default clerkMiddleware(async (auth, req) => { - if (isProtectedRoute(req)) { - await auth.protect(); - } -}); +export default clerkMiddleware( + async (auth, req) => { + if (isProtectedRoute(req)) { + await auth.protect(); + } + }, + { debug: process.env.NODE_ENV !== "production" }, +); // Also exclude tunnelRoute used in Sentry from the matcher. +// export const config = { +// matcher: ['/((?!.+\\.[\\w]+$|_next|monitoring).*)', '/', '/(api|trpc)(.*)'], +// }; + export const config = { - matcher: ['/((?!.+\\.[\\w]+$|_next|monitoring).*)', '/', '/(api|trpc)(.*)'], + matcher: [ + // Skip Next.js internals and all static files, unless found in search params. + '/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)', + // Always run for API routes. + '/(api|trpc)(.*)', + ], }; diff --git a/tsconfig.json b/tsconfig.json index 28ee215a16..7d1121766e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,3 @@ -/* eslint-disable jsonc/sort-keys */ { "compilerOptions": { "lib": ["dom", "dom.iterable", "esnext"], @@ -11,7 +10,6 @@ "alwaysStrict": true, "strictNullChecks": true, "noUncheckedIndexedAccess": true, - "noImplicitAny": true, "noImplicitReturns": true, "noImplicitThis": true, @@ -19,52 +17,40 @@ "noUnusedParameters": true, "allowUnreachableCode": false, "noFallthroughCasesInSwitch": true, - "target": "es2017", "outDir": "out", "sourceMap": true, - "esModuleInterop": true, "allowSyntheticDefaultImports": true, "allowJs": true, "checkJs": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, - "jsx": "preserve", "noEmit": true, "isolatedModules": true, "incremental": true, - - // Load types "types": ["vitest/globals"], - - // Path aliases "baseUrl": ".", "paths": { "@/*": ["./src/*"], "@/public/*": ["./public/*"] }, - - // Editor support - "plugins": [ - { - "name": "next" - } - ] + "plugins": [{ "name": "next" }] }, "exclude": [ "./out/**/*", "./node_modules/**/*", + ".next/**/*", "**/*.spec.ts", "**/*.e2e.ts" ], "include": [ - "next-env.d.ts", + "**/*.mts", "**/*.ts", "**/*.tsx", ".storybook/*.ts", - ".next/types/**/*.ts", - "**/*.mts" + "next-env.d.ts", + ".next/types/**/*.ts" ] } diff --git a/vitest-setup.ts b/vitest-setup.ts index 528108d270..84135d937d 100644 --- a/vitest-setup.ts +++ b/vitest-setup.ts @@ -9,6 +9,3 @@ failOnConsole({ shouldFailOnLog: true, shouldFailOnWarn: true, }); - -// Set up environment variables for testing -process.env.BILLING_PLAN_ENV = 'test';