create-nextblock 0.9.95 → 0.9.99

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 (42) hide show
  1. package/package.json +1 -1
  2. package/templates/nextblock-template/app/[slug]/page.tsx +9 -2
  3. package/templates/nextblock-template/app/actions/package-actions.ts +9 -4
  4. package/templates/nextblock-template/app/api/cron/reset-sandbox/route.ts +3 -2
  5. package/templates/nextblock-template/app/api/cron/sync-currencies/route.ts +5 -1
  6. package/templates/nextblock-template/app/api/draft/route.ts +5 -1
  7. package/templates/nextblock-template/app/api/media/library/route.ts +6 -2
  8. package/templates/nextblock-template/app/api/process-image/route.ts +58 -43
  9. package/templates/nextblock-template/app/api/revalidate/route.ts +21 -18
  10. package/templates/nextblock-template/app/api/upload/presigned-url/route.ts +20 -8
  11. package/templates/nextblock-template/app/api/upload/proxy/route.ts +34 -28
  12. package/templates/nextblock-template/app/article/[slug]/page.tsx +4 -13
  13. package/templates/nextblock-template/app/checkout/success/actions.ts +3 -2
  14. package/templates/nextblock-template/app/cms/media/actions.ts +47 -31
  15. package/templates/nextblock-template/app/cms/orders/actions.ts +29 -29
  16. package/templates/nextblock-template/app/cms/users/[id]/edit/page.tsx +28 -28
  17. package/templates/nextblock-template/app/cms/users/actions.ts +119 -118
  18. package/templates/nextblock-template/app/cms/users/page.tsx +3 -3
  19. package/templates/nextblock-template/app/layout.tsx +10 -7
  20. package/templates/nextblock-template/app/lib/site-settings.ts +7 -4
  21. package/templates/nextblock-template/app/page.tsx +2 -1
  22. package/templates/nextblock-template/app/product/[slug]/page.tsx +9 -2
  23. package/templates/nextblock-template/app/robots.txt/route.ts +6 -3
  24. package/templates/nextblock-template/app/setup/SetupWizard.tsx +55 -8
  25. package/templates/nextblock-template/app/setup/page.tsx +17 -1
  26. package/templates/nextblock-template/app/sitemap.ts +5 -3
  27. package/templates/nextblock-template/context/language-rest-client.ts +3 -2
  28. package/templates/nextblock-template/docs/12-VERCEL-DEPLOYMENT.md +125 -32
  29. package/templates/nextblock-template/lib/app-secrets.ts +39 -0
  30. package/templates/nextblock-template/lib/auth/crypto.ts +4 -1
  31. package/templates/nextblock-template/lib/custom-block-r2-upload.ts +23 -3
  32. package/templates/nextblock-template/lib/setup/actions.ts +16 -0
  33. package/templates/nextblock-template/lib/setup/env-status.ts +44 -5
  34. package/templates/nextblock-template/lib/setup/migrations-bundle.ts +172 -0
  35. package/templates/nextblock-template/lib/setup/schema-apply.ts +23 -7
  36. package/templates/nextblock-template/lib/site-url.ts +48 -0
  37. package/templates/nextblock-template/lib/storage/provider.ts +66 -0
  38. package/templates/nextblock-template/lib/storage/supabase-storage.ts +103 -0
  39. package/templates/nextblock-template/lib/visual-editing/draft-content.ts +1 -1
  40. package/templates/nextblock-template/next.config.js +37 -2
  41. package/templates/nextblock-template/package.json +1 -1
  42. package/templates/nextblock-template/proxy.ts +39 -4
@@ -12,15 +12,54 @@
12
12
 
13
13
  export type DeployChannel = 'docker' | 'vercel' | 'local';
14
14
 
15
+ // --- Supabase env-var resolution (naming-tolerant) ---------------------------
16
+ //
17
+ // NextBlock's own vars are NEXT_PUBLIC_SUPABASE_URL / _ANON_KEY and
18
+ // SUPABASE_SERVICE_ROLE_KEY. But the Supabase Vercel Marketplace integration
19
+ // (the one-click `stores` deploy flow) injects a DIFFERENT set of names:
20
+ // - URL: SUPABASE_URL / NEXT_PUBLIC_SUPABASE_URL
21
+ // - anon: SUPABASE_PUBLISHABLE_KEY / NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
22
+ // - service: SUPABASE_SECRET_KEY
23
+ // (the new `sb_publishable_…` / `sb_secret_…` API keys, which supabase-js accepts
24
+ // in place of the legacy anon / service_role JWTs). Resolving every alias here is
25
+ // what makes auto-injected credentials work with zero manual entry. Keep the alias
26
+ // order identical anywhere this chain is duplicated (the published `libs/db`
27
+ // clients can't import this module, so they inline the same order).
28
+
29
+ /** The Supabase project URL, under either the prefixed or non-prefixed name. */
30
+ export function resolveSupabaseUrl(): string | undefined {
31
+ return (
32
+ process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL || undefined
33
+ );
34
+ }
35
+
36
+ /** The anon / publishable key — the RLS-respecting public key, under any alias. */
37
+ export function resolveSupabaseAnonKey(): string | undefined {
38
+ return (
39
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY ||
40
+ process.env.SUPABASE_ANON_KEY ||
41
+ process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY ||
42
+ process.env.SUPABASE_PUBLISHABLE_KEY ||
43
+ undefined
44
+ );
45
+ }
46
+
47
+ /** The service-role / secret key — the RLS-bypassing admin key, under either alias. */
48
+ export function resolveSupabaseServiceKey(): string | undefined {
49
+ return (
50
+ process.env.SUPABASE_SERVICE_ROLE_KEY ||
51
+ process.env.SUPABASE_SECRET_KEY ||
52
+ undefined
53
+ );
54
+ }
55
+
15
56
  /**
16
57
  * True when the public Supabase connection vars are present — enough to create an
17
58
  * anon client and reach the database. This is the single predicate the boot path,
18
59
  * the middleware gate, and the wizard all use to decide "is this instance wired up?".
19
60
  */
20
61
  export function isSupabaseConfigured(): boolean {
21
- return Boolean(
22
- process.env.NEXT_PUBLIC_SUPABASE_URL && process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
23
- );
62
+ return Boolean(resolveSupabaseUrl() && resolveSupabaseAnonKey());
24
63
  }
25
64
 
26
65
  /**
@@ -28,7 +67,7 @@ export function isSupabaseConfigured(): boolean {
28
67
  * schema). The wizard's first-admin step and schema-apply step require this.
29
68
  */
30
69
  export function isFullyConfigured(): boolean {
31
- return isSupabaseConfigured() && Boolean(process.env.SUPABASE_SERVICE_ROLE_KEY);
70
+ return isSupabaseConfigured() && Boolean(resolveSupabaseServiceKey());
32
71
  }
33
72
 
34
73
  /**
@@ -42,7 +81,7 @@ export function detectChannel(): DeployChannel {
42
81
  // Docker is identified by the internal Supabase gateway URL (Kong :8000) or the MinIO
43
82
  // storage marker the docker setup writes — NOT by NEXT_PUBLIC_IS_SANDBOX, which the
44
83
  // managed cloud sandbox also sets.
45
- const url = process.env.NEXT_PUBLIC_SUPABASE_URL ?? '';
84
+ const url = resolveSupabaseUrl() ?? '';
46
85
  if (
47
86
  url.includes('localhost:8000') ||
48
87
  url.includes('127.0.0.1:8000') ||