kempo 4.2.14 → 4.2.15

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/cli.js +27 -5
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -31,7 +31,7 @@ const projectName = basename(projectDir);
31
31
  */
32
32
 
33
33
  const generatePassword = () => {
34
- const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789!@#$%&*';
34
+ const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789-_';
35
35
  return Array.from(
36
36
  { length: 16 },
37
37
  () => chars[crypto.randomInt(chars.length)]
@@ -404,6 +404,21 @@ execSync('npm install kempo', { cwd: projectDir, stdio: 'inherit' });
404
404
  console.log('\n--- Starting database ---\n');
405
405
 
406
406
  if(containerMode === 'new'){
407
+ const volumeName = `${dbName}_postgres_data`;
408
+
409
+ try {
410
+ execSync(`docker stop ${containerName}`, { stdio: 'ignore' });
411
+ execSync(`docker rm ${containerName}`, { stdio: 'ignore' });
412
+ } catch {
413
+ // Container doesn't exist, that's fine
414
+ }
415
+
416
+ try {
417
+ execSync(`docker volume rm ${volumeName}`, { stdio: 'ignore' });
418
+ } catch {
419
+ // Volume doesn't exist, that's fine
420
+ }
421
+
407
422
  const compose = spawnSync('docker', ['compose', 'up', '-d'], {
408
423
  cwd: projectDir,
409
424
  stdio: 'inherit',
@@ -429,8 +444,8 @@ if(containerMode === 'new'){
429
444
 
430
445
  console.log('\n--- Initializing database ---\n');
431
446
 
432
- // Give database a moment to initialize
433
- await new Promise(r => setTimeout(r, 2000));
447
+ // Give database plenty of time to fully initialize
448
+ await new Promise(r => setTimeout(r, 30000));
434
449
 
435
450
  // Clear migration snapshots so drizzle-kit push compares against the live DB only
436
451
  const migrationDir = join(projectDir, 'server', 'db', 'migrations');
@@ -438,8 +453,15 @@ if(existsSync(migrationDir)){
438
453
  rmSync(migrationDir, { recursive: true, force: true });
439
454
  }
440
455
 
441
- execSync('npx drizzle-kit push --force', { cwd: projectDir, stdio: 'inherit' });
442
- execSync('node node_modules/kempo/scripts/init-db.js', { cwd: projectDir, stdio: 'inherit' });
456
+ const drizzleResult = spawnSync('npx', ['drizzle-kit', 'push', '--force'], { cwd: projectDir, stdio: 'inherit', env: { ...process.env, DATABASE_URL: databaseUrl }, shell: true });
457
+ if(drizzleResult.status !== 0){
458
+ console.error('\n❌ Drizzle push failed. DATABASE_URL: ' + databaseUrl);
459
+ console.error('Container: ' + containerName);
460
+ console.error('Check: docker logs ' + containerName + '\n');
461
+ process.exit(1);
462
+ }
463
+
464
+ execSync('node node_modules/kempo/scripts/init-db.js', { cwd: projectDir, stdio: 'inherit', env: { ...process.env, DATABASE_URL: databaseUrl } });
443
465
 
444
466
  /*
445
467
  Step 8: Create admin user
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kempo",
3
- "version": "4.2.14",
3
+ "version": "4.2.15",
4
4
  "type": "module",
5
5
  "description": "A fullstack CMS framework for creating websites with user authentication",
6
6
  "scripts": {