@brightsideoy/kama 0.1.0-alpha.61 → 0.1.0-alpha.62

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
@@ -32,8 +32,8 @@ async function main() {
32
32
  */
33
33
  async function createFullWorkspace() {
34
34
  const projName = (await rl.question('Project folder name [kama-workspace]: ')) || 'kama-workspace';
35
- const cmsDomain = (await rl.question('CMS Admin Domain (e.g., cms.example.com): ')) || 'cms.example.com';
36
- const siteDomain = (await rl.question('First Website Domain (e.g., www.example.com): ')) || 'www.example.com';
35
+ const cmsDomain = (await rl.question('CMS Admin Domain (e.g., admin.t3cloud.eu): ')) || 'admin.t3cloud.eu';
36
+ const siteDomain = (await rl.question('First Website Domain (e.g., kama.t3cloud.eu): ')) || 'kama.t3cloud.eu';
37
37
 
38
38
  const rootDir = join(process.cwd(), projName);
39
39
 
@@ -171,6 +171,7 @@ async function createFullWorkspace() {
171
171
  }, null, 2)
172
172
  );
173
173
 
174
+ // 🎯 Fixed CMS wrangler.json (Added PUBLIC_FRONTEND_URL & CLOUDFLARE_ZONE_ID to public vars)
174
175
  writeFileSync(
175
176
  join(cmsDir, 'wrangler.json'),
176
177
  JSON.stringify({
@@ -184,7 +185,11 @@ async function createFullWorkspace() {
184
185
  binding: 'ASSETS'
185
186
  },
186
187
  routes: [{ pattern: cmsDomain, custom_domain: true }],
187
- vars: { CDN_DOMAIN: cmsDomain },
188
+ vars: {
189
+ CDN_DOMAIN: cmsDomain,
190
+ PUBLIC_FRONTEND_URL: `https://${siteDomain}`,
191
+ CLOUDFLARE_ZONE_ID: "REPLACE_WITH_YOUR_32_CHAR_ZONE_ID"
192
+ },
188
193
  d1_databases: [{
189
194
  binding: 'DB',
190
195
  database_name: dbName,
@@ -197,10 +202,10 @@ async function createFullWorkspace() {
197
202
  }, null, 2)
198
203
  );
199
204
 
200
- // 🎯 Generate backend .dev.vars template for Cloudflare Cache Purging
205
+ // 🎯 Fixed .dev.vars (Only contains API token for local dev, not public Zone ID)
201
206
  writeFileSync(
202
207
  join(cmsDir, '.dev.vars'),
203
- `# Cloudflare Edge Cache Purging Secrets\nCLOUDFLARE_ZONE_ID=\nCLOUDFLARE_API_TOKEN=\nPUBLIC_FRONTEND_URL=https://${siteDomain}\n`
208
+ `# Cloudflare Edge Cache Purging Secrets\nCLOUDFLARE_API_TOKEN=cfut_YOUR_CUSTOM_PURGE_TOKEN\n`
204
209
  );
205
210
 
206
211
  // 🎯 3. Setup First Astro Site tied to target workerName
@@ -211,11 +216,11 @@ async function createFullWorkspace() {
211
216
  console.log(` 1. cd ${projName}`);
212
217
  console.log(` 2. npm install`);
213
218
  if (d1DatabaseId === 'REPLACE_WITH_YOUR_D1_ID') {
214
- console.log(` 3. Run 'npx wrangler login', create a D1 database, and update cms-worker/wrangler.json`);
215
- } else {
216
- console.log(` 3. Fill in your API tokens in cms-worker/.dev.vars`);
217
- console.log(` 4. Run 'npm run dev:cms' from the workspace root to start the backend.`);
219
+ console.log(` 3. Run 'npx wrangler login' and create a D1 database.`);
218
220
  }
221
+ console.log(` 4. Update CLOUDFLARE_ZONE_ID in cms-worker/wrangler.json with your actual Zone ID`);
222
+ console.log(` 5. Securely store your purge token: cd cms-worker && npx wrangler secret put CLOUDFLARE_API_TOKEN`);
223
+ console.log(` 6. Run 'npm run dev:cms' from the workspace root to start the backend.`);
219
224
  }
220
225
 
221
226
  /**
@@ -229,7 +234,6 @@ async function createNewSiteOnly() {
229
234
  return;
230
235
  }
231
236
 
232
- // Try reading cms-worker/wrangler.json to determine workerName dynamically
233
237
  let targetWorkerName = 'kama-worker';
234
238
  const cmsWranglerPath = join(rootDir, 'cms-worker', 'wrangler.json');
235
239
  if (existsSync(cmsWranglerPath)) {
@@ -241,7 +245,7 @@ async function createNewSiteOnly() {
241
245
 
242
246
  const siteFolder = await rl.question('Site folder name (e.g., my-new-site): ');
243
247
  const siteDomain = await rl.question('Website Domain (e.g., brand.com): ');
244
- const cmsDomain = (await rl.question('CMS API Domain (e.g., cms.example.com): ')) || 'cms.example.com';
248
+ const cmsDomain = (await rl.question('CMS API Domain (e.g., admin.t3cloud.eu): ')) || 'admin.t3cloud.eu';
245
249
 
246
250
  await generateAstroSite(rootDir, siteFolder, siteDomain, cmsDomain.replace(/^https?:\/\//, ''), targetWorkerName);
247
251
 
@@ -282,7 +286,7 @@ async function generateAstroSite(rootDir, siteFolder, siteDomain, cmsDomain, wor
282
286
  }, null, 2)
283
287
  );
284
288
 
285
- // 🎯 Changed output directory to ./dist/client for Astro SSR output
289
+ // 🎯 Fixed Astro wrangler.json: Added `run_worker_first: true` to prevent media routing 404s on Edge
286
290
  writeFileSync(
287
291
  join(siteDir, 'wrangler.json'),
288
292
  JSON.stringify({
@@ -295,6 +299,7 @@ async function generateAstroSite(rootDir, siteFolder, siteDomain, cmsDomain, wor
295
299
  binding: 'ASSETS',
296
300
  html_handling: 'drop-trailing-slash',
297
301
  not_found_handling: '404-page',
302
+ run_worker_first: true
298
303
  },
299
304
  services: [{ binding: 'CMS_WORKER', service: workerName }],
300
305
  routes: [{ pattern: siteDomain, custom_domain: true }],
@@ -305,7 +310,6 @@ async function generateAstroSite(rootDir, siteFolder, siteDomain, cmsDomain, wor
305
310
  }, null, 2)
306
311
  );
307
312
 
308
- // 🎯 Changed output mode to 'server' to support Service Bindings
309
313
  const astroConfig = `import { defineConfig } from 'astro/config';
310
314
  import cloudflare from '@astrojs/cloudflare';
311
315