@prenta/cli 1.4.0 → 1.5.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.
@@ -202,28 +202,45 @@ export function createDiagnosticReport(input) {
202
202
  });
203
203
  checks.push(rateLimitBackendCheck(input));
204
204
  const blobState = detectBlobLinkState(input.env, input.configContent);
205
- checks.push({
206
- id: 'blob-storage',
207
- label: 'Vercel Blob storage',
208
- status: blobState === 'partial' ? 'fail' : blobState === 'token-format' ? 'warn' : 'pass',
209
- message: blobState === 'partial'
210
- ? 'Vercel Blob appears configured (vercel-blob / webhook key) but BLOB_STORE_ID is missing. Media uploads will fail until the store is connected to this project.'
211
- : blobState === 'token-format'
212
- ? 'BLOB_READ_WRITE_TOKEN does not start with `vercel_blob_` — verify it is a real Vercel Blob read-write token.'
213
- : blobState === 'ok'
214
- ? input.env.BLOB_READ_WRITE_TOKEN
215
- ? 'BLOB_READ_WRITE_TOKEN is configured.'
216
- : 'Vercel Marketplace Blob is linked (BLOB_STORE_ID). Uploads use OIDC on Vercel; no read-write token required.'
217
- : 'No Vercel Blob storage configured (skipped).',
218
- fix: blobState === 'partial'
219
- ? 'Connect a Vercel Blob store to the project from the Storage tab, then `vercel env pull`. Validate with `prenta vercel:blob-link`.'
220
- : blobState === 'token-format'
221
- ? 'Re-copy the read-write token from the Vercel Blob store (Storage tab) and re-pull your environment.'
205
+ const blobRegistered = /createBlobAdapter\s*\(/.test(input.projectFiles?.apiRoute ?? '');
206
+ if (blobState === 'none' && blobRegistered) {
207
+ checks.push({
208
+ id: 'blob-storage',
209
+ label: 'Vercel Blob storage',
210
+ status: isProductionTarget(input) ? 'fail' : 'warn',
211
+ message: 'The CMS API route registers createBlobAdapter(), but no Blob store is linked (no BLOB_STORE_ID or BLOB_READ_WRITE_TOKEN). Media uploads will fail.',
212
+ fix: 'Connect a Vercel Blob store to the project from the Storage tab, then `vercel env pull`. Validate with `prenta vercel:blob-link`.',
213
+ docs: 'https://prentacms.dev/docs/deployment',
214
+ });
215
+ }
216
+ else
217
+ checks.push({
218
+ id: 'blob-storage',
219
+ label: 'Vercel Blob storage',
220
+ status: blobState === 'partial' ? 'fail' : blobState === 'token-format' ? 'warn' : 'pass',
221
+ message: blobState === 'partial'
222
+ ? 'Vercel Blob appears configured (vercel-blob / webhook key) but BLOB_STORE_ID is missing. Media uploads will fail until the store is connected to this project.'
223
+ : blobState === 'token-format'
224
+ ? 'BLOB_READ_WRITE_TOKEN does not start with `vercel_blob_` — verify it is a real Vercel Blob read-write token.'
225
+ : blobState === 'ok'
226
+ ? input.env.BLOB_READ_WRITE_TOKEN
227
+ ? 'BLOB_READ_WRITE_TOKEN is configured.'
228
+ : 'Vercel Marketplace Blob is linked (BLOB_STORE_ID). Uploads use OIDC on Vercel; no read-write token required.'
229
+ : 'No Vercel Blob storage configured, and the API route does not register a Blob adapter.',
230
+ fix: blobState === 'partial'
231
+ ? 'Connect a Vercel Blob store to the project from the Storage tab, then `vercel env pull`. Validate with `prenta vercel:blob-link`.'
232
+ : blobState === 'token-format'
233
+ ? 'Re-copy the read-write token from the Vercel Blob store (Storage tab) and re-pull your environment.'
234
+ : undefined,
235
+ docs: blobState === 'partial' || blobState === 'token-format'
236
+ ? 'https://prentacms.dev/docs/deployment'
222
237
  : undefined,
223
- docs: blobState === 'partial' || blobState === 'token-format'
224
- ? 'https://prentacms.dev/docs/deployment'
225
- : undefined,
226
- });
238
+ });
239
+ checks.push(envShapeCheck(input));
240
+ checks.push(cronSecretCheck(input));
241
+ const emailCheck = emailProviderCheck(input);
242
+ if (emailCheck)
243
+ checks.push(emailCheck);
227
244
  checks.push({
228
245
  id: 'package-manager',
229
246
  label: 'Package manager',
@@ -262,28 +279,44 @@ export function createDiagnosticReport(input) {
262
279
  : 'https://prentacms.dev/docs/prototype-to-production',
263
280
  });
264
281
  const seoSiteUrlOk = detectSeoSiteUrl(input.configContent, input.env);
265
- checks.push({
266
- id: 'seo-site-url',
267
- label: 'SEO site URL',
268
- status: seoSiteUrlOk ? 'pass' : 'warn',
269
- message: seoSiteUrlOk
270
- ? 'Production site URL is configured via NEXT_PUBLIC_SITE_URL and/or prenta.config.ts seo.siteUrl.'
271
- : 'Neither NEXT_PUBLIC_SITE_URL nor prenta.config.ts seo.siteUrl appears configured — canonical URLs, sitemaps, and JSON-LD may be wrong.',
272
- fix: seoSiteUrlOk
273
- ? undefined
274
- : 'Set NEXT_PUBLIC_SITE_URL to your production origin (no trailing slash) and align prenta.config.ts seo.siteUrl.',
275
- docs: seoSiteUrlOk ? undefined : 'https://prentacms.dev/docs/environment-variables',
276
- });
282
+ const siteUrlProblem = seoSiteUrlOk
283
+ ? productionOriginProblem(input.env.NEXT_PUBLIC_SITE_URL)
284
+ : null;
285
+ if (siteUrlProblem) {
286
+ checks.push({
287
+ id: 'seo-site-url',
288
+ label: 'SEO site URL',
289
+ status: isProductionTarget(input) ? 'fail' : 'warn',
290
+ message: `NEXT_PUBLIC_SITE_URL is ${siteUrlProblem}. In production, canonical URLs, sitemaps, feeds and JSON-LD would point there.`,
291
+ fix: 'Set NEXT_PUBLIC_SITE_URL to the public https origin (no trailing slash) in the production environment.',
292
+ docs: 'https://prentacms.dev/docs/environment-variables',
293
+ });
294
+ }
295
+ else
296
+ checks.push({
297
+ id: 'seo-site-url',
298
+ label: 'SEO site URL',
299
+ status: seoSiteUrlOk ? 'pass' : 'warn',
300
+ message: seoSiteUrlOk
301
+ ? 'Production site URL is configured via NEXT_PUBLIC_SITE_URL and/or prenta.config.ts seo.siteUrl.'
302
+ : 'Neither NEXT_PUBLIC_SITE_URL nor prenta.config.ts seo.siteUrl appears configured — canonical URLs, sitemaps, and JSON-LD may be wrong.',
303
+ fix: seoSiteUrlOk
304
+ ? undefined
305
+ : 'Set NEXT_PUBLIC_SITE_URL to your production origin (no trailing slash) and align prenta.config.ts seo.siteUrl.',
306
+ docs: seoSiteUrlOk ? undefined : 'https://prentacms.dev/docs/environment-variables',
307
+ });
277
308
  if (input.projectFiles) {
278
309
  const astroSplit = detectsAstroSplitSite(input.projectFiles);
310
+ const siteDir = input.projectFiles.siteLabel ?? 'site';
279
311
  if (astroSplit) {
280
312
  checks.push({
281
313
  id: 'astro-split-site',
282
314
  label: 'Astro public site (split)',
283
315
  status: 'pass',
284
- message: 'Detected an Astro public site (site/) using Prenta site helpers — CMS host should serve admin + /api/cms only.',
316
+ message: `Detected an Astro public site in ${siteDir}/. The CMS host serves the admin and /api/cms only.`,
285
317
  docs: 'https://prentacms.dev/docs/astro-public-site',
286
318
  });
319
+ checks.push(...astroSiteChecks(input, siteDir));
287
320
  const astroCmsOk = detectsAstroCmsHelpers(input.projectFiles);
288
321
  checks.push({
289
322
  id: 'astro-cms-helpers',
@@ -291,10 +324,10 @@ export function createDiagnosticReport(input) {
291
324
  status: astroCmsOk ? 'pass' : 'warn',
292
325
  message: astroCmsOk
293
326
  ? 'Astro site uses createAstroSiteHelpers / PRENTA_CMS_URL.'
294
- : 'Astro site/ is present but src/lib/cms.ts does not use createAstroSiteHelpers or PRENTA_CMS_URL.',
327
+ : `${siteDir}/src/lib/cms.ts does not use createAstroSiteHelpers or PRENTA_CMS_URL.`,
295
328
  fix: astroCmsOk
296
329
  ? undefined
297
- : 'In site/src/lib/cms.ts import createAstroSiteHelpers from @prenta/core/astro/site and set PRENTA_CMS_URL.',
330
+ : `In ${siteDir}/src/lib/cms.ts import createAstroSiteHelpers from @prenta/core/astro/site and set PRENTA_CMS_URL.`,
298
331
  docs: 'https://prentacms.dev/docs/astro-public-site',
299
332
  });
300
333
  }
@@ -315,62 +348,97 @@ export function createDiagnosticReport(input) {
315
348
  : 'Add app/llms.txt/route.ts, app/robots.txt/route.ts, and app/sitemap.xml/route.ts (or next.config rewrites) — see create-prenta scaffold. For Astro split, add site/src/pages proxies instead.',
316
349
  docs: seoOk ? undefined : 'https://prentacms.dev/docs/prototype-to-production',
317
350
  });
318
- const uncachedResolve = !astroSplit && detectsUncachedResolvePattern(input.projectFiles);
319
- checks.push({
320
- id: 'cached-resolve',
321
- label: 'Cached /resolve for ISR',
322
- status: uncachedResolve ? 'warn' : 'pass',
323
- message: uncachedResolve
324
- ? 'The public catch-all appears to call resolveDocument() directly for metadata and page renders without createNextSiteHelpers() caching — ISR may be blocked and /resolve may be hit twice per request.'
325
- : astroSplit
326
- ? 'Astro split deploy: use CMS CDN/runtime cache (layers 1–2); Next ISR helpers are optional on the CMS host.'
351
+ const hasCatchAll = Boolean(input.projectFiles.catchAllPage?.trim());
352
+ const noCatchAll = astroSplit
353
+ ? 'Astro split deploy: the public pages are on the Astro site, so this Next catch-all check does not apply.'
354
+ : 'No Next catch-all page (app/(site)/[[...path]]/page.tsx or app/[[...path]]/page.tsx) found, so this was not checked.';
355
+ const uncachedResolve = detectsUncachedResolvePattern(input.projectFiles);
356
+ if (astroSplit || !hasCatchAll) {
357
+ checks.push({
358
+ id: 'cached-resolve',
359
+ label: 'Cached /resolve for ISR',
360
+ status: 'skip',
361
+ message: noCatchAll,
362
+ }, {
363
+ id: 'public-sections-ssr',
364
+ label: 'Public sections SSR',
365
+ status: 'skip',
366
+ message: noCatchAll,
367
+ }, {
368
+ id: 'structured-data-html',
369
+ label: 'JSON-LD in page HTML',
370
+ status: 'skip',
371
+ message: noCatchAll,
372
+ });
373
+ }
374
+ else
375
+ checks.push({
376
+ id: 'cached-resolve',
377
+ label: 'Cached /resolve for ISR',
378
+ status: uncachedResolve ? 'warn' : 'pass',
379
+ message: uncachedResolve
380
+ ? 'The public catch-all appears to call resolveDocument() directly for metadata and page renders without createNextSiteHelpers() caching — ISR may be blocked and /resolve may be hit twice per request.'
327
381
  : 'Published pages use cached /resolve helpers suitable for ISR.',
328
- fix: uncachedResolve
329
- ? 'Adopt createNextSiteHelpers() from @prenta/core/next/site in lib/cms.ts and use getCachedPageMetadata / getCachedPublishedDocument in the catch-all (keep resolveDocument only for ?preview= drafts).'
330
- : undefined,
331
- docs: uncachedResolve ? 'https://prentacms.dev/docs/prototype-to-production' : undefined,
332
- });
333
- const clientSections = !astroSplit && detectsClientWrappedPublicSections(input.projectFiles);
334
- checks.push({
335
- id: 'public-sections-ssr',
336
- label: 'Public sections SSR',
337
- status: clientSections ? 'warn' : 'pass',
338
- message: clientSections
339
- ? "The public catch-all or its sections wrapper is marked 'use client' — keep <Sections> in a Server Component so HTML ships in the initial response."
340
- : astroSplit
341
- ? 'Astro split: render sections via @astrojs/react SSR (no client-only catch-all).'
382
+ fix: uncachedResolve
383
+ ? 'Adopt createNextSiteHelpers() from @prenta/core/next/site in lib/cms.ts and use getCachedPageMetadata / getCachedPublishedDocument in the catch-all (keep resolveDocument only for ?preview= drafts).'
384
+ : undefined,
385
+ docs: uncachedResolve ? 'https://prentacms.dev/docs/prototype-to-production' : undefined,
386
+ });
387
+ const clientSections = detectsClientWrappedPublicSections(input.projectFiles);
388
+ if (!astroSplit && hasCatchAll)
389
+ checks.push({
390
+ id: 'public-sections-ssr',
391
+ label: 'Public sections SSR',
392
+ status: clientSections ? 'warn' : 'pass',
393
+ message: clientSections
394
+ ? "The public catch-all or its sections wrapper is marked 'use client' — keep <Sections> in a Server Component so HTML ships in the initial response."
342
395
  : 'Public page sections render from a Server Component catch-all.',
343
- fix: clientSections
344
- ? "Remove 'use client' from the catch-all and any PageSections wrapper; register section renderers via a side-effect import in the site layout instead."
345
- : undefined,
346
- docs: clientSections ? 'https://prentacms.dev/docs/prototype-to-production' : undefined,
347
- });
396
+ fix: clientSections
397
+ ? "Remove 'use client' from the catch-all and any PageSections wrapper; register section renderers via a side-effect import in the site layout instead."
398
+ : undefined,
399
+ docs: clientSections ? 'https://prentacms.dev/docs/prototype-to-production' : undefined,
400
+ });
348
401
  const missingJsonLd = !astroSplit && detectsMissingJsonLdInCatchAll(input.projectFiles.catchAllPage);
349
- checks.push({
350
- id: 'structured-data-html',
351
- label: 'JSON-LD in page HTML',
352
- status: missingJsonLd ? 'warn' : 'pass',
353
- message: missingJsonLd
354
- ? 'The public catch-all does not render JSON-LD from /resolve — Rich Results and some AI crawlers expect structured data in the HTML body.'
355
- : 'Published pages inject JSON-LD from cms-core into the server-rendered HTML.',
356
- fix: missingJsonLd
357
- ? 'Render result.jsonLd as a <script type="application/ld+json"> in the catch-all (see create-prenta scaffold).'
358
- : undefined,
359
- docs: missingJsonLd ? 'https://prentacms.dev/docs/prototype-to-production' : undefined,
360
- });
402
+ if (!astroSplit && hasCatchAll)
403
+ checks.push({
404
+ id: 'structured-data-html',
405
+ label: 'JSON-LD in page HTML',
406
+ status: missingJsonLd ? 'warn' : 'pass',
407
+ message: missingJsonLd
408
+ ? 'The public catch-all does not render JSON-LD from /resolve — Rich Results and some AI crawlers expect structured data in the HTML body.'
409
+ : 'Published pages inject JSON-LD from cms-core into the server-rendered HTML.',
410
+ fix: missingJsonLd
411
+ ? 'Render result.jsonLd as a <script type="application/ld+json"> in the catch-all (see create-prenta scaffold).'
412
+ : undefined,
413
+ docs: missingJsonLd ? 'https://prentacms.dev/docs/prototype-to-production' : undefined,
414
+ });
361
415
  const missingApiCache = detectsMissingApiCacheWiring(input.projectFiles.apiRoute);
362
- checks.push({
363
- id: 'api-cache-invalidation',
364
- label: 'CMS API cache + invalidation',
365
- status: missingApiCache ? 'warn' : 'pass',
366
- message: missingApiCache
367
- ? 'The CMS API route is missing publicReads caching and/or onInvalidate → revalidateTag wiring — /resolve may hit Postgres every request and ISR may stay stale after publish.'
368
- : 'CMS public reads are CDN-cacheable and writes drain Next ISR via onInvalidate.',
369
- fix: missingApiCache
370
- ? 'Adopt the cache block from create-prenta app/api/cms/[[...cms]]/route.ts (publicReads + onInvalidate with revalidateTag).'
371
- : undefined,
372
- docs: missingApiCache ? 'https://prentacms.dev/docs/caching' : undefined,
373
- });
416
+ if (!input.projectFiles.apiRoute?.trim()) {
417
+ checks.push({
418
+ id: 'api-cache-invalidation',
419
+ label: 'CMS API cache + invalidation',
420
+ status: 'skip',
421
+ message: 'No CMS API route (app/api/cms/[[...cms]]/route.ts) found, so this was not checked.',
422
+ });
423
+ }
424
+ else
425
+ checks.push({
426
+ id: 'api-cache-invalidation',
427
+ label: 'CMS API cache + invalidation',
428
+ status: missingApiCache ? 'warn' : 'pass',
429
+ message: missingApiCache
430
+ ? 'The CMS API route is missing publicReads caching and/or onInvalidate → revalidateTag wiring — /resolve may hit Postgres every request and ISR may stay stale after publish.'
431
+ : 'CMS public reads are CDN-cacheable and writes drain Next ISR via onInvalidate.',
432
+ fix: missingApiCache
433
+ ? 'Adopt the cache block from create-prenta app/api/cms/[[...cms]]/route.ts (publicReads + onInvalidate with revalidateTag).'
434
+ : undefined,
435
+ docs: missingApiCache ? 'https://prentacms.dev/docs/caching' : undefined,
436
+ });
437
+ if (input.projectFiles.vercelJson) {
438
+ const cronCheck = vercelCronPlanCheck(input.projectFiles.vercelJson);
439
+ if (cronCheck)
440
+ checks.push(cronCheck);
441
+ }
374
442
  if (input.projectFiles.backupWorkflowPresent !== undefined) {
375
443
  checks.push(backupsCheck(Boolean(input.env.BACKUP_ENCRYPTION_KEY), input.projectFiles.backupWorkflowPresent));
376
444
  }
@@ -417,6 +485,222 @@ export function createDiagnosticReport(input) {
417
485
  : 'pass';
418
486
  return { status, checks };
419
487
  }
488
+ /**
489
+ * Why a site origin is not a production origin, or `null` when it is one:
490
+ * localhost, a loopback address, or plain http.
491
+ */
492
+ export function productionOriginProblem(value) {
493
+ const raw = value?.trim();
494
+ if (!raw)
495
+ return null;
496
+ let url;
497
+ try {
498
+ url = new URL(raw);
499
+ }
500
+ catch {
501
+ return `not a valid URL ("${raw}")`;
502
+ }
503
+ const host = url.hostname;
504
+ if (host === 'localhost' ||
505
+ host.endsWith('.localhost') ||
506
+ host === '127.0.0.1' ||
507
+ host === '[::1]' ||
508
+ host === '0.0.0.0') {
509
+ return `a local address (${url.origin})`;
510
+ }
511
+ if (url.protocol !== 'https:')
512
+ return `not https (${url.origin})`;
513
+ return null;
514
+ }
515
+ /** The env value rules /health applies, surfaced before deploy (#1263). */
516
+ function envShapeCheck(input) {
517
+ const label = 'Environment variable values';
518
+ const docs = 'https://prentacms.dev/docs/environment-variables';
519
+ if (!input.envShape) {
520
+ return {
521
+ id: 'env-shape',
522
+ label,
523
+ status: 'skip',
524
+ message: 'The installed @prenta/core has no @prenta/core/diagnostics entry, so only presence was checked. Update @prenta/core for value checks (secret length, key format, placeholders).',
525
+ };
526
+ }
527
+ // Variables another check owns, with context this one lacks: Blob (an OIDC
528
+ // store needs no token, and VERCEL_OIDC_TOKEN only exists at runtime on
529
+ // Vercel), the rate-limit store (either name pair), email (Settings > Email
530
+ // counts too), and plain presence (the `environment` check).
531
+ const ownedElsewhere = new Set([
532
+ 'BLOB_READ_WRITE_TOKEN',
533
+ 'UPSTASH_REDIS_REST_URL',
534
+ 'UPSTASH_REDIS_REST_TOKEN',
535
+ 'RESEND_API_KEY',
536
+ 'CRON_SECRET',
537
+ ]);
538
+ const relevant = input.envShape.checks.filter((c) => !ownedElsewhere.has(c.name));
539
+ // Malformed values only: a missing variable is the `environment` check's.
540
+ const errors = relevant.filter((c) => c.status === 'error');
541
+ if (errors.length > 0) {
542
+ return {
543
+ id: 'env-shape',
544
+ label,
545
+ // Like the other new checks: a failure for deploy:check and production,
546
+ // a warning while developing (a local dev key is normal there).
547
+ status: isProductionTarget(input) ? 'fail' : 'warn',
548
+ message: `Invalid environment variables: ${errors.map((c) => `${c.name} (${c.message})`).join('; ')}`,
549
+ fix: 'Fix each value. /api/cms/health reports these as unhealthy too.',
550
+ docs,
551
+ };
552
+ }
553
+ const warnings = relevant.filter((c) => c.status === 'warn');
554
+ if (warnings.length > 0) {
555
+ return {
556
+ id: 'env-shape',
557
+ label,
558
+ status: 'warn',
559
+ message: warnings.map((c) => `${c.name}: ${c.message}`).join('; '),
560
+ docs,
561
+ };
562
+ }
563
+ return {
564
+ id: 'env-shape',
565
+ label,
566
+ status: 'pass',
567
+ message: 'Environment variable values pass the checks /api/cms/health runs.',
568
+ };
569
+ }
570
+ /** Every /cron route answers 401 to everyone without CRON_SECRET, so nothing scheduled runs. */
571
+ function cronSecretCheck(input) {
572
+ const secret = input.env.CRON_SECRET?.trim() ?? '';
573
+ // Core's rules also catch a placeholder value; they own the wording for it.
574
+ const shapeError = input.envShape?.checks.find((c) => c.name === 'CRON_SECRET' && c.status === 'error');
575
+ if (secret && shapeError) {
576
+ return {
577
+ id: 'cron-secret',
578
+ label: 'Cron secret',
579
+ status: isProductionTarget(input) ? 'fail' : 'warn',
580
+ message: `CRON_SECRET: ${shapeError.message}`,
581
+ fix: 'Set CRON_SECRET to a random string of 16+ characters (for example `openssl rand -hex 32`).',
582
+ docs: 'https://prentacms.dev/docs/deployment',
583
+ };
584
+ }
585
+ if (secret.length >= 16) {
586
+ return {
587
+ id: 'cron-secret',
588
+ label: 'Cron secret',
589
+ status: 'pass',
590
+ message: 'CRON_SECRET is set.',
591
+ };
592
+ }
593
+ return {
594
+ id: 'cron-secret',
595
+ label: 'Cron secret',
596
+ status: isProductionTarget(input) ? 'fail' : 'warn',
597
+ message: secret
598
+ ? 'CRON_SECRET is shorter than 16 characters.'
599
+ : 'CRON_SECRET is not set. Every /api/cms/cron/* route then answers 401, so scheduled publishing, cleanup and SEO jobs never run.',
600
+ fix: 'Set CRON_SECRET to a random string of 16+ characters (for example `openssl rand -hex 32`) in the production environment. Vercel sends it to the crons automatically.',
601
+ docs: 'https://prentacms.dev/docs/deployment',
602
+ };
603
+ }
604
+ /** Without a provider, password-reset, invite and notification mail is skipped silently. */
605
+ function emailProviderCheck(input) {
606
+ if (!/emailPlugin\s*\(/.test(input.configContent ?? ''))
607
+ return null;
608
+ const env = input.env;
609
+ const provider = env.EMAIL_PROVIDER?.trim();
610
+ const configured = provider === 'smtp'
611
+ ? Boolean(env.SMTP_HOST)
612
+ : provider === 'ses'
613
+ ? Boolean(env.SES_REGION || env.AWS_REGION)
614
+ : provider === 'smtpcom'
615
+ ? Boolean(env.SMTPCOM_API_KEY || env.SMTP_KEY)
616
+ : provider === 'resend'
617
+ ? Boolean(env.RESEND_API_KEY)
618
+ : Boolean(env.SMTP_HOST || env.SMTPCOM_API_KEY || env.SMTP_KEY || env.RESEND_API_KEY);
619
+ if (configured) {
620
+ return {
621
+ id: 'email-provider',
622
+ label: 'Email provider',
623
+ status: 'pass',
624
+ message: 'A transactional email provider is configured.',
625
+ };
626
+ }
627
+ return {
628
+ id: 'email-provider',
629
+ label: 'Email provider',
630
+ status: 'warn',
631
+ message: 'emailPlugin() is registered but no provider is configured (RESEND_API_KEY, SMTP_HOST, SMTPCOM_API_KEY or EMAIL_PROVIDER=ses), so password-reset, invite and form-notification mail is skipped without an error. An admin can also set a provider in Settings > Email.',
632
+ fix: 'Set RESEND_API_KEY (or SMTP_HOST / EMAIL_PROVIDER) in the production environment, or configure Settings > Email after deploy.',
633
+ docs: 'https://prentacms.dev/docs/environment-variables',
634
+ };
635
+ }
636
+ function sameOrigin(a, b) {
637
+ try {
638
+ return new URL(a).origin === new URL(b).origin;
639
+ }
640
+ catch {
641
+ return false;
642
+ }
643
+ }
644
+ /** The Astro public site's deploy wiring (#1263). */
645
+ function astroSiteChecks(input, siteDir) {
646
+ const files = input.projectFiles ?? {};
647
+ const checks = [];
648
+ const docs = 'https://prentacms.dev/docs/astro-public-site';
649
+ if (files.siteVercelJson?.includes('CMS_HOST_ORIGIN')) {
650
+ checks.push({
651
+ id: 'astro-cms-host-origin',
652
+ label: 'Astro site rewrites',
653
+ status: isProductionTarget(input) ? 'fail' : 'warn',
654
+ message: `${siteDir}/vercel.json still rewrites /api/cms and the admin to the placeholder host CMS_HOST_ORIGIN, so on the public domain they go nowhere.`,
655
+ fix: `Replace CMS_HOST_ORIGIN in ${siteDir}/vercel.json with the deployed CMS host (for example cms-yourproject.vercel.app).`,
656
+ docs,
657
+ });
658
+ }
659
+ const siteEnv = files.siteEnv;
660
+ if (!siteEnv) {
661
+ checks.push({
662
+ id: 'astro-site-env',
663
+ label: 'Astro site environment',
664
+ status: 'skip',
665
+ message: `No .env in ${siteDir}/, so its environment was not checked. On its Vercel project, set SITE, PRENTA_CMS_URL, PRENTA_WEBHOOK_SECRET and CDN purge credentials (CLOUDFLARE_ZONE_ID + CLOUDFLARE_API_TOKEN, or VERCEL_DEPLOY_HOOK_URL).`,
666
+ docs,
667
+ });
668
+ return checks;
669
+ }
670
+ const missing = ['SITE', 'PRENTA_CMS_URL', 'PRENTA_WEBHOOK_SECRET'].filter((key) => !siteEnv[key]?.trim());
671
+ const hasPurge = Boolean((siteEnv.CLOUDFLARE_ZONE_ID && siteEnv.CLOUDFLARE_API_TOKEN) || siteEnv.VERCEL_DEPLOY_HOOK_URL);
672
+ if (!hasPurge) {
673
+ missing.push('CLOUDFLARE_ZONE_ID + CLOUDFLARE_API_TOKEN (or VERCEL_DEPLOY_HOOK_URL)');
674
+ }
675
+ checks.push({
676
+ id: 'astro-site-env',
677
+ label: 'Astro site environment',
678
+ status: missing.length === 0 ? 'pass' : 'warn',
679
+ message: missing.length === 0
680
+ ? `${siteDir}/.env sets SITE, PRENTA_CMS_URL, PRENTA_WEBHOOK_SECRET and CDN purge credentials.`
681
+ : `${siteDir}/.env is missing ${missing.join(', ')}. Without SITE the site falls back to the CMS origin; without the webhook secret or purge credentials, publishing does not refresh the site in production. Check the Astro project's Vercel environment too.`,
682
+ docs,
683
+ });
684
+ const site = siteEnv.SITE?.trim();
685
+ const cmsSiteUrl = input.env.NEXT_PUBLIC_SITE_URL?.trim();
686
+ if (site &&
687
+ cmsSiteUrl &&
688
+ !productionOriginProblem(site) &&
689
+ !productionOriginProblem(cmsSiteUrl)) {
690
+ const same = sameOrigin(site, cmsSiteUrl);
691
+ checks.push({
692
+ id: 'astro-site-url-match',
693
+ label: 'Public origin agreement',
694
+ status: same ? 'pass' : 'warn',
695
+ message: same
696
+ ? 'The CMS NEXT_PUBLIC_SITE_URL and the Astro SITE name the same public origin.'
697
+ : `The CMS NEXT_PUBLIC_SITE_URL (${cmsSiteUrl}) and the Astro SITE (${site}) differ, so canonical URLs, sitemaps and purges disagree about which domain is live.`,
698
+ fix: same ? undefined : 'Set both to the public apex origin.',
699
+ docs: same ? undefined : docs,
700
+ });
701
+ }
702
+ return checks;
703
+ }
420
704
  /** Off-platform database backups: encryption key + nightly workflow (spec 2026-09-18). */
421
705
  export function backupsCheck(hasKey, workflowPresent) {
422
706
  const problems = [];
@@ -440,6 +724,56 @@ export function backupsCheck(hasKey, workflowPresent) {
440
724
  docs: 'https://prentacms.dev/docs/backups',
441
725
  };
442
726
  }
727
+ /**
728
+ * True when a 5-field cron expression can fire more than once a day, which a
729
+ * Vercel Hobby project refuses to deploy. Only a single-number minute and hour
730
+ * guarantee at most one run a day; anything else (`*`, a step, list or range)
731
+ * is treated as sub-daily, which can only over-warn.
732
+ */
733
+ export function cronRunsMoreThanDaily(schedule) {
734
+ const fields = schedule.trim().split(/\s+/);
735
+ if (fields.length !== 5)
736
+ return true;
737
+ const single = /^\d+$/;
738
+ return !single.test(fields[0]) || !single.test(fields[1]);
739
+ }
740
+ /**
741
+ * Warn about crons Vercel Hobby rejects (#1262). Hobby allows crons at most
742
+ * once a day and fails the whole deployment otherwise. The CLI cannot see the
743
+ * plan, so this is a warning; Pro and Enterprise run them fine.
744
+ */
745
+ function vercelCronPlanCheck(vercelJson) {
746
+ let crons;
747
+ try {
748
+ crons = JSON.parse(vercelJson).crons;
749
+ }
750
+ catch {
751
+ return null;
752
+ }
753
+ if (!Array.isArray(crons) || crons.length === 0)
754
+ return null;
755
+ const subDaily = crons
756
+ .filter((c) => typeof c?.path === 'string' && typeof c?.schedule === 'string')
757
+ .filter((c) => cronRunsMoreThanDaily(c.schedule));
758
+ if (subDaily.length === 0) {
759
+ return {
760
+ id: 'vercel-cron-plan',
761
+ label: 'Vercel cron schedules',
762
+ status: 'pass',
763
+ message: 'Every cron in vercel.json runs at most once a day, which Vercel Hobby allows.',
764
+ };
765
+ }
766
+ return {
767
+ id: 'vercel-cron-plan',
768
+ label: 'Vercel cron schedules',
769
+ status: 'warn',
770
+ message: `vercel.json has crons that run more than once a day: ${subDaily
771
+ .map((c) => `${c.path} (${c.schedule})`)
772
+ .join(', ')}. Vercel Hobby fails the deployment for these; Pro and Enterprise run them.`,
773
+ fix: 'On Hobby, give each a daily schedule (for example the publish cron "0 1 * * *"; scheduled publishes then run once a day). On Pro, nothing to do.',
774
+ docs: 'https://prentacms.dev/docs/deployment#vercel-hobby',
775
+ };
776
+ }
443
777
  export function buildDeploymentManifest() {
444
778
  return {
445
779
  schemaVersion: 1,