launchbase 1.0.6 → 1.0.7

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.
Files changed (2) hide show
  1. package/bin/launchbase.js +25 -23
  2. package/package.json +1 -1
package/bin/launchbase.js CHANGED
@@ -7,7 +7,7 @@ const crypto = require('crypto');
7
7
  const fs = require('fs-extra');
8
8
  const { execSync, spawn } = require('child_process');
9
9
 
10
- const VERSION = '1.0.6';
10
+ const VERSION = '1.0.7';
11
11
  const program = new Command();
12
12
 
13
13
  function findAvailablePort(startPort = 5432, maxAttempts = 100) {
@@ -296,32 +296,34 @@ async function startDatabase(projectDir) {
296
296
 
297
297
  console.log('🐳 Starting database with Docker Compose...\n');
298
298
 
299
- try {
300
- // Check if containers are already running
301
- const psOutput = execSync('docker compose ps -q', {
302
- cwd: projectDir,
303
- stdio: 'pipe',
304
- encoding: 'utf8'
305
- }).trim();
306
-
307
- if (psOutput) {
308
- console.log('✅ Database containers already running\n');
309
- return true;
310
- }
311
- } catch {
312
- // Containers not running, proceed to start
313
- }
299
+ // Get project name from directory
300
+ const projectName = path.basename(projectDir);
314
301
 
315
302
  try {
316
- // Stop any existing containers first to avoid port conflicts
303
+ // First, stop any containers with this project name (from previous runs)
317
304
  try {
318
- execSync('docker compose down', {
305
+ execSync(`docker compose -p ${projectName} down --remove-orphans`, {
319
306
  cwd: projectDir,
320
307
  stdio: 'pipe'
321
308
  });
322
309
  } catch {}
323
310
 
324
- execSync('docker compose up -d --wait', {
311
+ // Also try to remove any containers with similar names
312
+ try {
313
+ const containers = execSync('docker ps -a --format "{{.Names}}"', {
314
+ stdio: 'pipe',
315
+ encoding: 'utf8'
316
+ });
317
+ const containerList = containers.trim().split('\n').filter(c => c.includes(projectName));
318
+ for (const container of containerList) {
319
+ try {
320
+ execSync(`docker rm -f ${container}`, { stdio: 'pipe' });
321
+ } catch {}
322
+ }
323
+ } catch {}
324
+
325
+ // Start fresh containers with explicit project name
326
+ execSync(`docker compose -p ${projectName} up -d --wait --force-recreate`, {
325
327
  cwd: projectDir,
326
328
  stdio: 'inherit'
327
329
  });
@@ -333,10 +335,10 @@ async function startDatabase(projectDir) {
333
335
 
334
336
  // Check for port conflict
335
337
  if (error.message && error.message.includes('port is already allocated')) {
336
- console.log(' Port conflict detected. Another PostgreSQL may be running.\n');
337
- console.log('💡 Solutions:');
338
- console.log(' 1. Stop the other PostgreSQL: docker stop <container>');
339
- console.log(' 2. Or change the port in docker-compose.yml\n');
338
+ console.log(' Port conflict detected. Another service is using this port.\n');
339
+ console.log('💡 Try stopping other databases:');
340
+ console.log(' docker ps # list running containers');
341
+ console.log(' docker stop <container_id> # stop the conflicting container\n');
340
342
  } else {
341
343
  console.log(' Check Docker logs: docker compose logs\n');
342
344
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "launchbase",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Generate production-ready NestJS backends with authentication, multi-tenancy, billing, and deployment in minutes",
5
5
  "author": "LaunchBase",
6
6
  "keywords": [