launchbase 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/launchbase.js CHANGED
@@ -6,7 +6,7 @@ const crypto = require('crypto');
6
6
  const fs = require('fs-extra');
7
7
  const { execSync, spawn } = require('child_process');
8
8
 
9
- const VERSION = '1.0.4';
9
+ const VERSION = '1.0.5';
10
10
  const program = new Command();
11
11
 
12
12
  function replaceInFile(filePath, replacements) {
@@ -281,34 +281,34 @@ async function startDatabase(projectDir) {
281
281
  }
282
282
 
283
283
  try {
284
- execSync('docker compose up -d', {
284
+ // Stop any existing containers first to avoid port conflicts
285
+ try {
286
+ execSync('docker compose down', {
287
+ cwd: projectDir,
288
+ stdio: 'pipe'
289
+ });
290
+ } catch {}
291
+
292
+ execSync('docker compose up -d --wait', {
285
293
  cwd: projectDir,
286
294
  stdio: 'inherit'
287
295
  });
288
296
 
289
- console.log('\n Waiting for database to be ready...');
297
+ console.log('\n Database is ready!\n');
298
+ return true;
299
+ } catch (error) {
300
+ console.log('\n❌ Failed to start database.');
290
301
 
291
- // Wait for database to be ready
292
- let retries = 30;
293
- while (retries > 0) {
294
- try {
295
- execSync('docker compose exec -T db pg_isready -U postgres', {
296
- cwd: projectDir,
297
- stdio: 'pipe'
298
- });
299
- console.log('✅ Database is ready!\n');
300
- return true;
301
- } catch {
302
- process.stdout.write('.');
303
- await new Promise(r => setTimeout(r, 1000));
304
- retries--;
305
- }
302
+ // Check for port conflict
303
+ if (error.message && error.message.includes('port is already allocated')) {
304
+ console.log(' Port conflict detected. Another PostgreSQL may be running.\n');
305
+ console.log('💡 Solutions:');
306
+ console.log(' 1. Stop the other PostgreSQL: docker stop <container>');
307
+ console.log(' 2. Or change the port in docker-compose.yml\n');
308
+ } else {
309
+ console.log(' Check Docker logs: docker compose logs\n');
306
310
  }
307
311
 
308
- console.log('\n⚠️ Database may not be ready yet. Check logs: docker compose logs\n');
309
- return true;
310
- } catch (error) {
311
- console.log('\n❌ Failed to start database. Check Docker logs.\n');
312
312
  return false;
313
313
  }
314
314
  }
@@ -420,6 +420,7 @@ program
420
420
  }
421
421
 
422
422
  // Setup Docker and database
423
+ let dbReady = false;
423
424
  if (!options.noDocker) {
424
425
  console.log('\n🐳 Setting up database...\n');
425
426
 
@@ -431,10 +432,15 @@ program
431
432
  // Run migrations
432
433
  console.log('📄 Running database migrations...\n');
433
434
  runCommand('npx prisma migrate dev --name init', { cwd: targetDir });
435
+ dbReady = true;
434
436
  }
435
437
  }
436
438
  }
437
439
 
440
+ // Generate Prisma client before starting dev server
441
+ console.log('📦 Generating Prisma client...\n');
442
+ runCommand('npx prisma generate', { cwd: targetDir });
443
+
438
444
  // Start dev server
439
445
  console.log('\n🚀 Starting development server...\n');
440
446
  console.log('━'.repeat(50));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "launchbase",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Generate production-ready NestJS backends with authentication, multi-tenancy, billing, and deployment in minutes",
5
5
  "author": "LaunchBase",
6
6
  "keywords": [
@@ -15,7 +15,7 @@ FRONTEND_URL=http://localhost:5173
15
15
  # Database
16
16
  # ===========================================
17
17
  # Local PostgreSQL (with Docker)
18
- DATABASE_URL=postgresql://postgres:postgres@localhost:5432/__APP_NAME__?schema=public
18
+ DATABASE_URL=postgresql://postgres:postgres@localhost:5433/__APP_NAME__?schema=public
19
19
  # SQLite (for simple local dev)
20
20
  # DATABASE_URL="file:./dev.db"
21
21
 
@@ -7,9 +7,14 @@ services:
7
7
  POSTGRES_PASSWORD: postgres
8
8
  POSTGRES_DB: launchbase
9
9
  ports:
10
- - "5432:5432"
10
+ - "5433:5432"
11
11
  volumes:
12
12
  - db_data:/var/lib/postgresql/data
13
+ healthcheck:
14
+ test: ["CMD-SHELL", "pg_isready -U postgres"]
15
+ interval: 5s
16
+ timeout: 5s
17
+ retries: 5
13
18
 
14
19
  api:
15
20
  build: .
@@ -21,7 +26,8 @@ services:
21
26
  ports:
22
27
  - "3000:3000"
23
28
  depends_on:
24
- - db
29
+ db:
30
+ condition: service_healthy
25
31
 
26
32
  volumes:
27
33
  db_data: