@brightsideoy/kama 0.1.0-alpha.142 → 0.1.0-alpha.143

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
@@ -291,19 +291,13 @@ import customSchemas from './workspace-schemas.js';
291
291
 
292
292
  export default {
293
293
  async fetch(request, env, ctx) {
294
- // 🎯 FIX 1: Safely unwrap the ESM default export so the Engine sees local schemas
295
294
  const resolvedSchemas = customSchemas.default || customSchemas;
296
-
297
- // 🎯 FIX 2: Mutate the Cloudflare env directly instead of spreading it!
298
- // Spreading {...env} breaks Cloudflare D1/R2 proxy bindings.
299
295
  env.BUNDLED_DEFINITIONS = resolvedSchemas;
300
296
 
301
- // Execute the Hono app fetch handler
302
297
  if (kamaWorker && typeof kamaWorker.fetch === 'function') {
303
298
  return kamaWorker.fetch(request, env, ctx);
304
299
  }
305
300
 
306
- // Fallback just in case the export structure changes
307
301
  if (kamaWorker && kamaWorker.app && typeof kamaWorker.app.fetch === 'function') {
308
302
  return kamaWorker.app.fetch(request, env, ctx);
309
303
  }
@@ -315,7 +309,6 @@ export default {
315
309
 
316
310
  writeFileSync(join(cmsDir, 'index.js'), cmsWorkerIndexContent);
317
311
 
318
- // 🎯 THE FINAL FIX: Automatically run `npx kama bundle` before Dev or Deploy inside the worker!
319
312
  writeFileSync(
320
313
  join(cmsDir, 'package.json'),
321
314
  JSON.stringify({
@@ -437,7 +430,6 @@ async function createNewSiteOnly() {
437
430
  const envChoice = await rl.question('\nChoice [1/2]: ');
438
431
  const isCloudflare = envChoice.trim() === '2';
439
432
 
440
- // 🎯 FIX: Default to 'kama-starter'
441
433
  const siteFolder = (await rl.question('Astro package/folder name (e.g., my-new-site) [kama-starter]: ')).trim() || 'kama-starter';
442
434
 
443
435
  let siteDomain = 'localhost:4321';
@@ -461,7 +453,13 @@ async function createNewSiteOnly() {
461
453
  * Reads YAML from workspace and builds a static module for the worker
462
454
  */
463
455
  async function bundleWorkspaceSchemas(targetRootDir) {
464
- const rootDir = targetRootDir || process.cwd();
456
+ let rootDir = targetRootDir || process.cwd();
457
+
458
+ // Fix directory target if executed directly inside the worker package
459
+ if (basename(rootDir) === 'kama-worker') {
460
+ rootDir = resolve(rootDir, '..');
461
+ }
462
+
465
463
  const defsDir = join(rootDir, 'content', 'definitions');
466
464
  const workerDir = join(rootDir, 'kama-worker');
467
465
 
@@ -636,14 +634,12 @@ async function generateAstroSite(rootDir, siteFolder, siteDomain, cmsFullUrl, wo
636
634
  writeFileSync(wranglerPath, wranglerStr);
637
635
  }
638
636
 
639
- // 🎯 FIX: Smart capitalization for dynamic site labels
640
637
  const siteLabel = siteFolder.split(/[-_]/).map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
641
638
  const safeSiteLabel = siteLabel.replace(/'/g, "''");
642
639
 
643
640
  const channelKey = siteFolder.replace(/[^a-z0-9_-]/gi, '-').toLowerCase();
644
641
  const treeKey = `${channelKey}-nav`;
645
642
 
646
- // 🎯 FIX: Inject `safeSiteLabel` into the logoText, titleSuffix, and titles!
647
643
  const seedSql = `
648
644
  -- Seed data for site: ${safeSiteLabel}
649
645
  INSERT OR IGNORE INTO channels (key, label, channelType, defaultLanguage, isHidden, dataJson)
@@ -680,7 +676,6 @@ VALUES (
680
676
  appendFileSync(seedPath, seedSql);
681
677
  }
682
678
 
683
- // 🎯 FIX: Expose the title-cased name to Astro ENV vars as well
684
679
  const envContent = [
685
680
  `PUBLIC_CMS_URL="${cmsFullUrl}"`,
686
681
  `PUBLIC_API_URL="${cmsFullUrl}"`,