@brightsideoy/kama 0.1.0-alpha.151 → 0.1.0-alpha.153

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/cli.js CHANGED
@@ -311,7 +311,7 @@ export default {
311
311
  "schema:remote": `wrangler d1 execute ${dbName} --remote --file=../node_modules/@brightsideoy/kama/schema.sql`,
312
312
  "seed:local": `wrangler d1 execute ${dbName} --local --file=seed.sql > /dev/null 2>&1`,
313
313
  "seed:remote": `wrangler d1 execute ${dbName} --remote --file=seed.sql`,
314
- "dev": "npm run schema:local && npm run seed:local && wrangler dev --remote --log-level warn --inspector-port=9230",
314
+ "dev": "npm run schema:local && npm run seed:local && wrangler dev --port 8787 --inspector-port 9239",
315
315
  "deploy": "npm run schema:remote && npm run seed:remote && wrangler deploy"
316
316
  },
317
317
  dependencies: {
@@ -359,7 +359,14 @@ export default {
359
359
  };
360
360
 
361
361
  writeFileSync(join(cmsDir, 'wrangler.json'), JSON.stringify(cmsWranglerConfig, null, 2));
362
- writeFileSync(join(cmsDir, '.dev.vars'), `# Cloudflare Edge Cache Purging Secrets\nCLOUDFLARE_API_TOKEN=cfut_YOUR_CUSTOM_PURGE_TOKEN\n`);
362
+
363
+ writeFileSync(join(cmsDir, '.dev.vars'), `# Cloudflare Edge Cache Purging Secrets
364
+ CLOUDFLARE_API_TOKEN=cfut_YOUR_CUSTOM_PURGE_TOKEN
365
+
366
+ # Local Development Overrides (Takes precedence over wrangler.json vars during local dev)
367
+ CDN_DOMAIN=http://localhost:8787
368
+ PUBLIC_FRONTEND_URL=http://localhost:4321
369
+ `);
363
370
  } else {
364
371
  const nodeServerContent = `import { serve } from '@hono/node-server';
365
372
  import { serveStatic } from '@hono/node-server/serve-static';
@@ -408,11 +415,13 @@ if (distPath) {
408
415
  });
409
416
  }
410
417
 
411
- const port = process.env.PORT || 8787;
412
- console.log(\`šŸ”„ Kama Node Server & Admin UI running on http://localhost:\${port}\`);
413
- if (distPath) console.log(\`šŸ‘‰ Serving Admin UI from: \${distPath}\`);
418
+ const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 8787;
414
419
 
415
- serve({ fetch: kamaApp.fetch, port });
420
+ serve({ fetch: kamaApp.fetch, port }, (info) => {
421
+ console.log(\`\\nšŸ”„ KAMA CMS Node Server is running!\`);
422
+ console.log(\`ā”ƒ Local http://localhost:\${info.port}/\`);
423
+ if (distPath) console.log(\`ā”ƒ Admin UI Serving from: \${distPath}\\n\`);
424
+ });
416
425
  `;
417
426
  writeFileSync(join(cmsDir, 'server.js'), nodeServerContent);
418
427
 
@@ -441,13 +450,14 @@ serve({ fetch: kamaApp.fetch, port });
441
450
  }, null, 2)
442
451
  );
443
452
 
453
+ // For Node mode, localhost is explicitly used
444
454
  writeFileSync(join(cmsDir, '.env'), `PORT=8787
445
455
  KAMA_RUNTIME=node
446
456
  DB_PATH=./kama.db
447
457
  LOCAL_MEDIA_PATH=./public/media
448
- PUBLIC_CMS_URL=${cmsFullUrl}
449
- PUBLIC_API_URL=${cmsFullUrl}
450
- PUBLIC_FRONTEND_URL=${shouldCreateSite ? `http://${siteDomain}` : 'http://localhost:4321'}
458
+ PUBLIC_CMS_URL=http://localhost:8787
459
+ PUBLIC_API_URL=http://localhost:8787
460
+ PUBLIC_FRONTEND_URL=http://localhost:4321
451
461
  `);
452
462
  }
453
463
 
@@ -692,6 +702,7 @@ async function generateAstroSite(rootDir, siteFolder, siteDomain, cmsFullUrl, wo
692
702
  run_worker_first: true
693
703
  };
694
704
 
705
+ // These are production variables used on Cloudflare!
695
706
  configObj.vars = configObj.vars || {};
696
707
  configObj.vars.PUBLIC_CMS_URL = cmsFullUrl;
697
708
  configObj.vars.PUBLIC_API_URL = cmsFullUrl;
@@ -720,6 +731,7 @@ async function generateAstroSite(rootDir, siteFolder, siteDomain, cmsFullUrl, wo
720
731
  const channelKey = siteFolder.replace(/[^a-z0-9_-]/gi, '-').toLowerCase();
721
732
  const treeKey = 'main-tree';
722
733
 
734
+ // šŸŽÆ FIX: 'navigation' is properly set as the treeType so it resolves correctly
723
735
  const seedSql = `
724
736
  -- Seed data for site: ${safeSiteLabel}
725
737
 
@@ -729,7 +741,7 @@ VALUES ('${channelKey}', '${safeSiteLabel}', 'website', 'en', 0, '{}');
729
741
 
730
742
  -- 2. Create the Tree and link it to the Channel
731
743
  INSERT OR IGNORE INTO trees (key, label, treeType, channelId, isHidden, dataJson)
732
- VALUES ('${treeKey}', 'Main Tree', 'main-navigation', (SELECT id FROM channels WHERE key = '${channelKey}'), 0, '{}');
744
+ VALUES ('${treeKey}', 'Main Tree', 'navigation', (SELECT id FROM channels WHERE key = '${channelKey}'), 0, '{}');
733
745
 
734
746
  INSERT OR IGNORE INTO channel_trees (channelId, treeId, key)
735
747
  VALUES ((SELECT id FROM channels WHERE key = '${channelKey}'), (SELECT id FROM trees WHERE key = '${treeKey}'), 'main');
@@ -762,9 +774,11 @@ VALUES (
762
774
  appendFileSync(seedPath, seedSql);
763
775
  }
764
776
 
777
+ // Local Development Overrides
765
778
  const envContent = [
766
- `PUBLIC_CMS_URL="${cmsFullUrl}"`,
767
- `PUBLIC_API_URL="${cmsFullUrl}"`,
779
+ `# Local Development Overrides (Production uses wrangler.json vars)`,
780
+ `PUBLIC_CMS_URL="http://localhost:8787"`,
781
+ `PUBLIC_API_URL="http://localhost:8787"`,
768
782
  `PUBLIC_CHANNEL_ID="${channelKey}"`,
769
783
  `PUBLIC_TREE_ID="${treeKey}"`,
770
784
  `PUBLIC_HOME_SLUG="home"`,