From cf94d4b3cf83610e077920cda21d56f50653bbc4 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 14 May 2025 21:40:25 -0700 Subject: [PATCH 1/8] Clean up env vars --- .env | 8 ++------ .env.local.sample | 1 - .env.production | 33 --------------------------------- .github/workflows/CI.yml | 27 ++++++++++++++++++++++++++- src/lib/server/env.ts | 11 +---------- vitest-setup.ts | 3 --- 6 files changed, 29 insertions(+), 54 deletions(-) delete mode 100644 .env.production diff --git a/.env b/.env index bedfcf9eea..d090f6a723 100644 --- a/.env +++ b/.env @@ -1,5 +1,3 @@ -BILLING_PLAN_ENV=dev - VSCODE_EXTENSION_BASE_URL=vscode://RooVeterinaryInc.roo-cline CURSOR_EXTENSION_BASE_URL=cursor://RooVeterinaryInc.roo-cline @@ -14,7 +12,5 @@ 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_USERNAME=default diff --git a/.env.local.sample b/.env.local.sample index 14fbf342b2..3430599d24 100644 --- a/.env.local.sample +++ b/.env.local.sample @@ -1,5 +1,4 @@ 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..4784af22c7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,8 +11,33 @@ env: PNPM_VERSION: 10.8.1 jobs: + 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: - name: Run all tests runs-on: ubuntu-latest steps: 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/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'; From eb9163f95ac146b0228682612b6d46bb8ff3c6e4 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 14 May 2025 21:41:46 -0700 Subject: [PATCH 2/8] Ignore .next in tsconfig --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 28ee215a16..6c434db78f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -56,6 +56,7 @@ "exclude": [ "./out/**/*", "./node_modules/**/*", + ".next/**/*", "**/*.spec.ts", "**/*.e2e.ts" ], @@ -64,7 +65,6 @@ "**/*.ts", "**/*.tsx", ".storybook/*.ts", - ".next/types/**/*.ts", "**/*.mts" ] } From 2c52904e0e1a5151a4035857da4f8334cf8322d3 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 14 May 2025 21:42:20 -0700 Subject: [PATCH 3/8] Organize includes --- tsconfig.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 6c434db78f..802fabeb83 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -61,10 +61,10 @@ "**/*.e2e.ts" ], "include": [ - "next-env.d.ts", "**/*.ts", "**/*.tsx", - ".storybook/*.ts", - "**/*.mts" + "**/*.mts", + "next-env.d.ts", + ".storybook/*.ts" ] } From 56c7f2250371652738a86f3fea59ea880ac94576 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 14 May 2025 21:58:28 -0700 Subject: [PATCH 4/8] Debug middleware --- src/middleware.ts | 24 ++++++++++++++++++------ tsconfig.json | 22 ++++------------------ 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/middleware.ts b/src/middleware.ts index e66a85c015..c7d3ebcb86 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: true }, +); // 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 802fabeb83..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,39 +17,26 @@ "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/**/*", @@ -61,10 +46,11 @@ "**/*.e2e.ts" ], "include": [ + "**/*.mts", "**/*.ts", "**/*.tsx", - "**/*.mts", + ".storybook/*.ts", "next-env.d.ts", - ".storybook/*.ts" + ".next/types/**/*.ts" ] } From 61cdd7928da89168444d1d7128edab6ca5f0f431 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 14 May 2025 22:08:39 -0700 Subject: [PATCH 5/8] More env var fixes --- .env | 13 +++++++++++-- .env.local.sample | 4 ---- 2 files changed, 11 insertions(+), 6 deletions(-) delete mode 100644 .env.local.sample diff --git a/.env b/.env index d090f6a723..8cb18db3b6 100644 --- a/.env +++ b/.env @@ -1,7 +1,16 @@ +# 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 @@ -9,8 +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 # ClickHouse +CLICKHOUSE_URL=your_clickhouse_url CLICKHOUSE_USERNAME=default +CLICKHOUSE_PASSWORD=fake-your_clickhouse_password diff --git a/.env.local.sample b/.env.local.sample deleted file mode 100644 index 3430599d24..0000000000 --- a/.env.local.sample +++ /dev/null @@ -1,4 +0,0 @@ -CLERK_SECRET_KEY=your_clerk_secret_key - -CLICKHOUSE_URL=your_clickhouse_url -CLICKHOUSE_PASSWORD=fake-your_clickhouse_password From 3127b69bfb8c2a17d8a994ac8c65271cf9864e89 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 14 May 2025 22:09:36 -0700 Subject: [PATCH 6/8] Add `check` job --- .github/workflows/CI.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4784af22c7..9d42706c6e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -97,3 +97,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." From bbffb234af5eceed9ed9e55b204fe8019951ec81 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 14 May 2025 22:14:00 -0700 Subject: [PATCH 7/8] Fix props --- .env | 2 +- .github/workflows/CI.yml | 2 -- src/app/extension/sign-in/page.tsx | 10 ++++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 8cb18db3b6..d9be82d68e 100644 --- a/.env +++ b/.env @@ -20,6 +20,6 @@ NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/dashboard NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/dashboard # ClickHouse -CLICKHOUSE_URL=your_clickhouse_url +CLICKHOUSE_URL=https://fake.us-west-2.aws.clickhouse.cloud:1234 CLICKHOUSE_USERNAME=default CLICKHOUSE_PASSWORD=fake-your_clickhouse_password diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9d42706c6e..f9a4e73a15 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,6 @@ env: jobs: build: runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v4 @@ -39,7 +38,6 @@ jobs: test: runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v4 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`); From 7c89c68a12b2435c517b0523006407359dc4c317 Mon Sep 17 00:00:00 2001 From: Chris Estreich Date: Wed, 14 May 2025 22:14:39 -0700 Subject: [PATCH 8/8] Update src/middleware.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- src/middleware.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware.ts b/src/middleware.ts index c7d3ebcb86..f42a360e78 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -12,7 +12,7 @@ export default clerkMiddleware( await auth.protect(); } }, - { debug: true }, + { debug: process.env.NODE_ENV !== "production" }, ); // Also exclude tunnelRoute used in Sentry from the matcher.