launchbase 1.0.9 → 1.1.0
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 +16 -23
- package/package.json +1 -1
- package/template/.env.example +1 -1
- package/template/docker-compose.yml +1 -14
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
|
|
10
|
+
const VERSION = '1.1.0';
|
|
11
11
|
const program = new Command();
|
|
12
12
|
|
|
13
13
|
function findAvailablePort(startPort = 5432, maxAttempts = 100) {
|
|
@@ -422,20 +422,12 @@ program
|
|
|
422
422
|
// Replace placeholders with dynamic ports
|
|
423
423
|
const replacements = {
|
|
424
424
|
'__APP_NAME__': appName,
|
|
425
|
+
'__DB_PORT__': dbPort.toString(),
|
|
425
426
|
'"name": "launchbase-template"': `"name": "${appName}"`,
|
|
426
|
-
'"PORT=3000"': `"PORT=${apiPort}"`,
|
|
427
|
-
'PORT=3000': `PORT=${apiPort}`,
|
|
428
|
-
'localhost:3000': `localhost:${apiPort}`,
|
|
429
|
-
'localhost:5173': `localhost:${frontendPort}`,
|
|
430
|
-
'localhost:5433': `localhost:${dbPort}`,
|
|
431
|
-
'localhost:5432': `localhost:${dbPort}`,
|
|
432
|
-
'"5433:5432"': `"${dbPort}:5432"`,
|
|
433
|
-
'"5432:5432"': `"${dbPort}:5432"`,
|
|
434
|
-
'"3000:3000"': `"${apiPort}:3000"`,
|
|
435
427
|
};
|
|
436
428
|
|
|
437
429
|
// Update files with port replacements
|
|
438
|
-
const filesToReplace = ['package.json', '.env.example', 'README.md', 'docker-compose.yml'
|
|
430
|
+
const filesToReplace = ['package.json', '.env.example', 'README.md', 'docker-compose.yml'];
|
|
439
431
|
for (const rel of filesToReplace) {
|
|
440
432
|
const fp = path.join(targetDir, rel);
|
|
441
433
|
if (await fs.pathExists(fp)) {
|
|
@@ -443,30 +435,31 @@ program
|
|
|
443
435
|
}
|
|
444
436
|
}
|
|
445
437
|
|
|
446
|
-
// Generate .env with secrets
|
|
438
|
+
// Generate .env with secrets and correct ports
|
|
447
439
|
const envExamplePath = path.join(targetDir, '.env.example');
|
|
448
440
|
const envPath = path.join(targetDir, '.env');
|
|
449
441
|
|
|
450
442
|
if (await fs.pathExists(envExamplePath)) {
|
|
451
443
|
let env = await fs.readFile(envExamplePath, 'utf8');
|
|
444
|
+
// Replace app name
|
|
445
|
+
env = env.replace(/__APP_NAME__/g, appName);
|
|
446
|
+
// Replace secrets
|
|
452
447
|
env = env.replace('JWT_ACCESS_SECRET=__CHANGE_ME__', `JWT_ACCESS_SECRET=${randomSecret(32)}`);
|
|
453
448
|
env = env.replace('JWT_REFRESH_SECRET=__CHANGE_ME__', `JWT_REFRESH_SECRET=${randomSecret(32)}`);
|
|
454
|
-
//
|
|
449
|
+
// Replace ports
|
|
455
450
|
env = env.replace(/PORT=\d+/, `PORT=${apiPort}`);
|
|
456
|
-
env = env.replace(/localhost:\d
|
|
451
|
+
env = env.replace(/localhost:\d+\/__APP_NAME__/g, `localhost:${dbPort}/${appName}`);
|
|
452
|
+
env = env.replace(/localhost:5433/g, `localhost:${dbPort}`);
|
|
453
|
+
env = env.replace(/localhost:5432/g, `localhost:${dbPort}`);
|
|
454
|
+
env = env.replace(/localhost:3000/g, `localhost:${apiPort}`);
|
|
455
|
+
env = env.replace(/localhost:5173/g, `localhost:${frontendPort}`);
|
|
457
456
|
await fs.writeFile(envPath, env, 'utf8');
|
|
458
457
|
}
|
|
459
458
|
|
|
460
|
-
// Update docker-compose.yml with correct ports
|
|
461
|
-
const dockerComposePath = path.join(targetDir, 'docker-compose.yml');
|
|
462
|
-
if (await fs.pathExists(dockerComposePath)) {
|
|
463
|
-
let compose = await fs.readFile(dockerComposePath, 'utf8');
|
|
464
|
-
compose = compose.replace(/"(\d+):5432"/, `"${dbPort}:5432"`);
|
|
465
|
-
compose = compose.replace(/"(\d+):3000"/, `"${apiPort}:3000"`);
|
|
466
|
-
await fs.writeFile(dockerComposePath, compose, 'utf8');
|
|
467
|
-
}
|
|
468
|
-
|
|
469
459
|
console.log('✅ Project files created\n');
|
|
460
|
+
console.log(` Database port: ${dbPort}`);
|
|
461
|
+
console.log(` API port: ${apiPort}`);
|
|
462
|
+
console.log(` Frontend port: ${frontendPort}\n`);
|
|
470
463
|
|
|
471
464
|
// Install dependencies
|
|
472
465
|
console.log('📦 Installing dependencies...\n');
|
package/package.json
CHANGED
package/template/.env.example
CHANGED
|
@@ -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:
|
|
18
|
+
DATABASE_URL=postgresql://postgres:postgres@localhost:__DB_PORT__/__APP_NAME__?schema=public
|
|
19
19
|
# SQLite (for simple local dev)
|
|
20
20
|
# DATABASE_URL="file:./dev.db"
|
|
21
21
|
|
|
@@ -7,7 +7,7 @@ services:
|
|
|
7
7
|
POSTGRES_PASSWORD: postgres
|
|
8
8
|
POSTGRES_DB: launchbase
|
|
9
9
|
ports:
|
|
10
|
-
- "
|
|
10
|
+
- "__DB_PORT__:5432"
|
|
11
11
|
volumes:
|
|
12
12
|
- db_data:/var/lib/postgresql/data
|
|
13
13
|
healthcheck:
|
|
@@ -16,18 +16,5 @@ services:
|
|
|
16
16
|
timeout: 5s
|
|
17
17
|
retries: 5
|
|
18
18
|
|
|
19
|
-
api:
|
|
20
|
-
build: .
|
|
21
|
-
restart: unless-stopped
|
|
22
|
-
env_file:
|
|
23
|
-
- .env
|
|
24
|
-
environment:
|
|
25
|
-
DATABASE_URL: ${DATABASE_URL}
|
|
26
|
-
ports:
|
|
27
|
-
- "3000:3000"
|
|
28
|
-
depends_on:
|
|
29
|
-
db:
|
|
30
|
-
condition: service_healthy
|
|
31
|
-
|
|
32
19
|
volumes:
|
|
33
20
|
db_data:
|