Skip to content

Commit

Permalink
Address feedback (leerob#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
leerob authored Sep 16, 2024
2 parents a3d3968 + 3c42c7c commit 2952c19
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Fun fact: the majority of the UI for this application was built with [v0](https:
git clone https://github.com/leerob/next-saas-starter
pnpm install
pnpm db:setup
pnpm db:migrate
pnpm db:seed
```

Expand Down
1 change: 1 addition & 0 deletions app/(dashboard)/terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function Terminal() {
'git clone https://github.com/leerob/next-saas-starter',
'pnpm install',
'pnpm db:setup',
'pnpm db:migrate',
'pnpm db:seed',
'pnpm dev 🎉',
];
Expand Down
10 changes: 9 additions & 1 deletion lib/db/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@ async function seed() {
await createStripeProducts();
}

seed().catch(console.error);
seed()
.catch((error) => {
console.error('Seed process failed:', error);
process.exit(1);
})
.finally(() => {
console.log('Seed process finished. Exiting...');
process.exit(0);
});
39 changes: 37 additions & 2 deletions lib/db/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,43 @@ function question(query: string): Promise<string> {
}

async function checkStripeCLI() {
console.log('Step 1: Checking if Stripe CLI is installed...');
console.log(
'Step 1: Checking if Stripe CLI is installed and authenticated...'
);
try {
await execAsync('stripe --version');
console.log('Stripe CLI is installed.');

// Check if Stripe CLI is authenticated
try {
await execAsync('stripe config --list');
console.log('Stripe CLI is authenticated.');
} catch (error) {
console.log(
'Stripe CLI is not authenticated or the authentication has expired.'
);
console.log('Please run: stripe login');
const answer = await question(
'Have you completed the authentication? (y/n): '
);
if (answer.toLowerCase() !== 'y') {
console.log(
'Please authenticate with Stripe CLI and run this script again.'
);
process.exit(1);
}

// Verify authentication after user confirms login
try {
await execAsync('stripe config --list');
console.log('Stripe CLI authentication confirmed.');
} catch (error) {
console.error(
'Failed to verify Stripe CLI authentication. Please try again.'
);
process.exit(1);
}
}
} catch (error) {
console.error(
'Stripe CLI is not installed. Please install it and try again.'
Expand All @@ -36,7 +69,9 @@ async function checkStripeCLI() {
'2. Download and install the Stripe CLI for your operating system'
);
console.log('3. After installation, run: stripe login');
console.log('After installation, please run this setup script again.');
console.log(
'After installation and authentication, please run this setup script again.'
);
process.exit(1);
}
}
Expand Down

0 comments on commit 2952c19

Please sign in to comment.