vercel / nextjs-subscription-payments

Clone, deploy, and fully customize a SaaS subscription application with Next.js.
https://subscription-payments.vercel.app/
MIT License
5.77k stars 1.18k forks source link

Add script to seed stripe products and prices #319

Open ChrisGambrell opened 3 months ago

ChrisGambrell commented 3 months ago

This change adds a script to seed products and prices from Stripe.

This change will benefits developers working in a shared development environment by allowing them to work with the same products and prices.

The script is ran with the following command: pnpm stripe:seed.

vercel[bot] commented 3 months ago

@ChrisGambrell is attempting to deploy a commit to the Vercel Solutions Team on Vercel.

A member of the Team first needs to authorize it.

olivernettinger commented 3 months ago

Hi @ChrisGambrell that is a useful addon. How would you trigger script execution? I don't see an updated package.json to include the stripe:seed command, so this command is not found.

I tried with npx ts-node scripts/seed-stripe.ts, but this results in: Error: Cannot find module 'tsconfig-paths/register'. Then I pnpm install -D tsconfig-paths, which allowed ts-node to run, but I get error: if (!supabaseUrl) throw new Error('supabaseUrl is required.') Error: supabaseUrl is required.

Update: so I guess I got it now with: npx ts-node -r scripts/dotenv.config.ts scripts/seed-stripe.ts

ChrisGambrell commented 2 months ago

Hi @ChrisGambrell that is a useful addon. How would you trigger script execution? I don't see an updated package.json to include the stripe:seed command, so this command is not found.

I tried with npx ts-node scripts/seed-stripe.ts, but this results in: Error: Cannot find module 'tsconfig-paths/register'. Then I pnpm install -D tsconfig-paths, which allowed ts-node to run, but I get error: if (!supabaseUrl) throw new Error('supabaseUrl is required.') Error: supabaseUrl is required.

Update: so I guess I got it now with: npx ts-node -r scripts/dotenv.config.ts scripts/seed-stripe.ts

Apologies- I forgot to include the command to run! This should be updated now. You can seed products and prices from stripe with the command pnpm stripe:seed