From 2cf030c1fe55093866974d7ae061645d401e1df5 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 8 Mar 2024 11:53:26 -0600 Subject: [PATCH] feat: add stripe-checks for other kcd products --- apps/epic-react/package.json | 2 +- apps/epic-react/scripts/check-stripe | 17 +++++++++++++++++ apps/epic-web/package.json | 2 +- apps/epic-web/scripts/check-stripe | 17 +++++++++++++++++ apps/total-typescript/package.json | 2 +- apps/total-typescript/scripts/check-stripe | 17 +++++++++++++++++ 6 files changed, 54 insertions(+), 3 deletions(-) create mode 100755 apps/epic-react/scripts/check-stripe create mode 100755 apps/epic-web/scripts/check-stripe create mode 100755 apps/total-typescript/scripts/check-stripe diff --git a/apps/epic-react/package.json b/apps/epic-react/package.json index 4df0fb855..9a17d3206 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 000000000..df9c0cf76 --- /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 e247c804e..4e7ace85f 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 000000000..df9c0cf76 --- /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 c7a918104..399c6cd25 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 000000000..9c9198882 --- /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