diff --git a/apps/epic-react/package.json b/apps/epic-react/package.json index 4df0fb855f..9a17d3206f 100644 --- a/apps/epic-react/package.json +++ b/apps/epic-react/package.json @@ -4,7 +4,7 @@ "scripts": { "dev": "next dev -p 3024", "dev:sanity": "sanity dev", - "dev:stripe": "stripe listen --forward-to localhost:3024/api/skill/webhook/stripe", + "dev:stripe": "./scripts/check-stripe && stripe listen --forward-to localhost:3024/api/skill/webhook/stripe", "build": "next build", "postbuild": "NODE_ENV=production next-sitemap", "start": "next start -p 3024", diff --git a/apps/epic-react/scripts/check-stripe b/apps/epic-react/scripts/check-stripe new file mode 100755 index 0000000000..df9c0cf768 --- /dev/null +++ b/apps/epic-react/scripts/check-stripe @@ -0,0 +1,17 @@ +#!/bin/bash + +# Expected stripe display name +EXPECTED_STRING="KCD Training" + +# Currently connected stripe display name +COMMAND_OUTPUT=$( + stripe config --list | grep '^display_name' | awk -F'=' '{print $2}' | xargs +) + +# Compare the expected string with the command output +if [ "$EXPECTED_STRING" = "$COMMAND_OUTPUT" ]; then + exit 0 # exit with status 0, indicating success/match +else + echo "Mismatched Stripe accounts, expected $EXPECTED_STRING, got $COMMAND_OUTPUT." + exit 1 # exit with status 1, indicating failure/no match +fi diff --git a/apps/epic-web/package.json b/apps/epic-web/package.json index e247c804eb..4e7ace85f3 100644 --- a/apps/epic-web/package.json +++ b/apps/epic-web/package.json @@ -8,7 +8,7 @@ "db:schema": "prisma migrate dev --create-only", "db:start": "docker compose up -d", "db:studio": "prisma studio", - "dev:stripe": "stripe listen --forward-to localhost:3021/api/skill/webhook/stripe", + "dev:stripe": "./scripts/check-stripe && stripe listen --forward-to localhost:3021/api/skill/webhook/stripe", "dev": "concurrently \"npm:dev:*\"", "dev:next": "next dev -p 3021", "dev:inngest": "pnpx inngest-cli@latest dev -u http://localhost:3021/api/inngest", diff --git a/apps/epic-web/scripts/check-stripe b/apps/epic-web/scripts/check-stripe new file mode 100755 index 0000000000..df9c0cf768 --- /dev/null +++ b/apps/epic-web/scripts/check-stripe @@ -0,0 +1,17 @@ +#!/bin/bash + +# Expected stripe display name +EXPECTED_STRING="KCD Training" + +# Currently connected stripe display name +COMMAND_OUTPUT=$( + stripe config --list | grep '^display_name' | awk -F'=' '{print $2}' | xargs +) + +# Compare the expected string with the command output +if [ "$EXPECTED_STRING" = "$COMMAND_OUTPUT" ]; then + exit 0 # exit with status 0, indicating success/match +else + echo "Mismatched Stripe accounts, expected $EXPECTED_STRING, got $COMMAND_OUTPUT." + exit 1 # exit with status 1, indicating failure/no match +fi diff --git a/apps/total-typescript/package.json b/apps/total-typescript/package.json index c7a9181042..399c6cd25b 100644 --- a/apps/total-typescript/package.json +++ b/apps/total-typescript/package.json @@ -13,7 +13,7 @@ "dev": "next dev -p 3016", "dev:sanity": "sanity dev", "dev:setup": "vercel env pull .env.local && sed -i.bak '/^VERCEL/d' .env.local", - "dev:stripe": "stripe listen --forward-to localhost:3016/api/skill/webhook/stripe", + "dev:stripe": "./scripts/check-stripe && stripe listen --forward-to localhost:3016/api/skill/webhook/stripe", "lint": "eslint src/**/*.{ts,tsx} --fix && tsc --noEmit", "start": "next start -p 3016", "test": "jest" diff --git a/apps/total-typescript/scripts/check-stripe b/apps/total-typescript/scripts/check-stripe new file mode 100755 index 0000000000..9c91988824 --- /dev/null +++ b/apps/total-typescript/scripts/check-stripe @@ -0,0 +1,17 @@ +#!/bin/bash + +# Expected stripe display name +EXPECTED_STRING="Total TypeScript" + +# Currently connected stripe display name +COMMAND_OUTPUT=$( + stripe config --list | grep '^display_name' | awk -F'=' '{print $2}' | xargs +) + +# Compare the expected string with the command output +if [ "$EXPECTED_STRING" = "$COMMAND_OUTPUT" ]; then + exit 0 # exit with status 0, indicating success/match +else + echo "Mismatched Stripe accounts, expected $EXPECTED_STRING, got $COMMAND_OUTPUT." + exit 1 # exit with status 1, indicating failure/no match +fi