@digilogiclabs/create-saas-app 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.
Files changed (199) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/index.js +45 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/templates/web/base/template/package.json +20 -10
  6. package/dist/templates/web/base/template/src/app/error.tsx +97 -0
  7. package/dist/templates/web/base/template/src/app/layout.tsx +8 -2
  8. package/dist/templates/web/base/template/src/app/loading.tsx +34 -0
  9. package/dist/templates/web/base/template/src/components/__tests__/example.test.tsx +49 -0
  10. package/dist/templates/web/base/template/src/components/providers/app-providers.tsx +6 -2
  11. package/dist/templates/web/base/template/src/components/providers/theme-provider.tsx +94 -0
  12. package/dist/templates/web/base/template/src/components/shared/footer.tsx +36 -0
  13. package/dist/templates/web/base/template/src/components/shared/header.tsx +2 -0
  14. package/dist/templates/web/base/template/src/components/ui/theme-toggle.tsx +34 -0
  15. package/dist/templates/web/base/template/src/lib/auth-server.ts +177 -0
  16. package/dist/templates/web/base/template/src/lib/env.ts +46 -0
  17. package/dist/templates/web/base/template/src/lib/utils.ts +133 -0
  18. package/dist/templates/web/base/template/src/test/setup.ts +79 -0
  19. package/dist/templates/web/base/template/vitest.config.ts +17 -0
  20. package/dist/templates/web/ui-auth/template/package.json +14 -4
  21. package/dist/templates/web/ui-auth/template/src/app/error.tsx +67 -0
  22. package/dist/templates/web/ui-auth/template/src/app/layout.tsx +6 -2
  23. package/dist/templates/web/ui-auth/template/src/app/loading.tsx +20 -0
  24. package/dist/templates/web/ui-auth/template/src/components/__tests__/example.test.tsx +49 -0
  25. package/dist/templates/web/ui-auth/template/src/components/providers/app-providers.tsx +6 -2
  26. package/dist/templates/web/ui-auth/template/src/components/providers/theme-provider.tsx +94 -0
  27. package/dist/templates/web/ui-auth/template/src/components/shared/footer.tsx +36 -0
  28. package/dist/templates/web/ui-auth/template/src/components/shared/header.tsx +2 -0
  29. package/dist/templates/web/ui-auth/template/src/components/ui/theme-toggle.tsx +34 -0
  30. package/dist/templates/web/ui-auth/template/src/lib/env.ts +49 -0
  31. package/dist/templates/web/ui-auth/template/src/lib/utils.ts +133 -0
  32. package/dist/templates/web/ui-auth/template/src/test/setup.ts +79 -0
  33. package/dist/templates/web/ui-auth/template/vitest.config.ts +17 -0
  34. package/dist/templates/web/ui-auth-payments/template/middleware.ts +68 -0
  35. package/dist/templates/web/ui-auth-payments/template/package.json +14 -4
  36. package/dist/templates/web/ui-auth-payments/template/src/app/dashboard/layout.tsx +22 -0
  37. package/dist/templates/web/ui-auth-payments/template/src/app/dashboard/page.tsx +183 -0
  38. package/dist/templates/web/ui-auth-payments/template/src/app/error.tsx +67 -0
  39. package/dist/templates/web/ui-auth-payments/template/src/app/layout.tsx +6 -2
  40. package/dist/templates/web/ui-auth-payments/template/src/app/loading.tsx +20 -0
  41. package/dist/templates/web/ui-auth-payments/template/src/app/login/loading.tsx +38 -0
  42. package/dist/templates/web/ui-auth-payments/template/src/app/signup/loading.tsx +50 -0
  43. package/dist/templates/web/ui-auth-payments/template/src/components/__tests__/example.test.tsx +49 -0
  44. package/dist/templates/web/ui-auth-payments/template/src/components/client/auth-status.tsx +52 -0
  45. package/dist/templates/web/ui-auth-payments/template/src/components/client/login-form.tsx +144 -0
  46. package/dist/templates/web/ui-auth-payments/template/src/components/client/newsletter-signup.tsx +68 -0
  47. package/dist/templates/web/ui-auth-payments/template/src/components/client/signup-form.tsx +185 -0
  48. package/dist/templates/web/ui-auth-payments/template/src/components/providers/app-providers.tsx +6 -2
  49. package/dist/templates/web/ui-auth-payments/template/src/components/providers/theme-provider.tsx +94 -0
  50. package/dist/templates/web/ui-auth-payments/template/src/components/shared/footer.tsx +36 -0
  51. package/dist/templates/web/ui-auth-payments/template/src/components/shared/header.tsx +2 -0
  52. package/dist/templates/web/ui-auth-payments/template/src/components/ui/theme-toggle.tsx +34 -0
  53. package/dist/templates/web/ui-auth-payments/template/src/lib/actions/auth.ts +246 -0
  54. package/dist/templates/web/ui-auth-payments/template/src/lib/actions/index.ts +340 -0
  55. package/dist/templates/web/ui-auth-payments/template/src/lib/auth-server.ts +177 -0
  56. package/dist/templates/web/ui-auth-payments/template/src/lib/env.ts +49 -0
  57. package/dist/templates/web/ui-auth-payments/template/src/lib/utils.ts +133 -0
  58. package/dist/templates/web/ui-auth-payments/template/src/test/setup.ts +79 -0
  59. package/dist/templates/web/ui-auth-payments/template/vitest.config.ts +17 -0
  60. package/dist/templates/web/ui-auth-payments-audio/template/package.json +14 -4
  61. package/dist/templates/web/ui-auth-payments-audio/template/src/app/error.tsx +67 -0
  62. package/dist/templates/web/ui-auth-payments-audio/template/src/app/layout.tsx +8 -2
  63. package/dist/templates/web/ui-auth-payments-audio/template/src/app/loading.tsx +20 -0
  64. package/dist/templates/web/ui-auth-payments-audio/template/src/components/__tests__/example.test.tsx +49 -0
  65. package/dist/templates/web/ui-auth-payments-audio/template/src/components/providers/app-providers.tsx +6 -2
  66. package/dist/templates/web/ui-auth-payments-audio/template/src/components/providers/theme-provider.tsx +94 -0
  67. package/dist/templates/web/ui-auth-payments-audio/template/src/components/shared/footer.tsx +36 -0
  68. package/dist/templates/web/ui-auth-payments-audio/template/src/components/shared/header.tsx +2 -0
  69. package/dist/templates/web/ui-auth-payments-audio/template/src/components/ui/theme-toggle.tsx +34 -0
  70. package/dist/templates/web/ui-auth-payments-audio/template/src/lib/env.ts +49 -0
  71. package/dist/templates/web/ui-auth-payments-audio/template/src/lib/utils.ts +133 -0
  72. package/dist/templates/web/ui-auth-payments-audio/template/src/test/setup.ts +79 -0
  73. package/dist/templates/web/ui-auth-payments-audio/template/vitest.config.ts +17 -0
  74. package/dist/templates/web/ui-auth-payments-video/template/package.json +14 -4
  75. package/dist/templates/web/ui-auth-payments-video/template/src/app/error.tsx +67 -0
  76. package/dist/templates/web/ui-auth-payments-video/template/src/app/layout.tsx +6 -2
  77. package/dist/templates/web/ui-auth-payments-video/template/src/app/loading.tsx +20 -0
  78. package/dist/templates/web/ui-auth-payments-video/template/src/components/__tests__/example.test.tsx +49 -0
  79. package/dist/templates/web/ui-auth-payments-video/template/src/components/providers/app-providers.tsx +6 -2
  80. package/dist/templates/web/ui-auth-payments-video/template/src/components/providers/theme-provider.tsx +94 -0
  81. package/dist/templates/web/ui-auth-payments-video/template/src/components/shared/footer.tsx +36 -0
  82. package/dist/templates/web/ui-auth-payments-video/template/src/components/shared/header.tsx +2 -0
  83. package/dist/templates/web/ui-auth-payments-video/template/src/components/ui/theme-toggle.tsx +34 -0
  84. package/dist/templates/web/ui-auth-payments-video/template/src/lib/env.ts +49 -0
  85. package/dist/templates/web/ui-auth-payments-video/template/src/lib/utils.ts +133 -0
  86. package/dist/templates/web/ui-auth-payments-video/template/src/test/setup.ts +79 -0
  87. package/dist/templates/web/ui-auth-payments-video/template/vitest.config.ts +17 -0
  88. package/dist/templates/web/ui-only/template/package.json +14 -4
  89. package/dist/templates/web/ui-only/template/src/app/error.tsx +67 -0
  90. package/dist/templates/web/ui-only/template/src/app/layout.tsx +6 -2
  91. package/dist/templates/web/ui-only/template/src/app/loading.tsx +20 -0
  92. package/dist/templates/web/ui-only/template/src/components/__tests__/example.test.tsx +49 -0
  93. package/dist/templates/web/ui-only/template/src/components/providers/app-providers.tsx +6 -2
  94. package/dist/templates/web/ui-only/template/src/components/providers/theme-provider.tsx +94 -0
  95. package/dist/templates/web/ui-only/template/src/components/shared/footer.tsx +36 -0
  96. package/dist/templates/web/ui-only/template/src/components/shared/header.tsx +2 -0
  97. package/dist/templates/web/ui-only/template/src/components/ui/theme-toggle.tsx +34 -0
  98. package/dist/templates/web/ui-only/template/src/lib/env.ts +49 -0
  99. package/dist/templates/web/ui-only/template/src/lib/utils.ts +133 -0
  100. package/dist/templates/web/ui-only/template/src/test/setup.ts +79 -0
  101. package/dist/templates/web/ui-only/template/vitest.config.ts +17 -0
  102. package/package.json +1 -1
  103. package/src/templates/web/base/template/package.json +20 -10
  104. package/src/templates/web/base/template/src/app/error.tsx +97 -0
  105. package/src/templates/web/base/template/src/app/layout.tsx +8 -2
  106. package/src/templates/web/base/template/src/app/loading.tsx +34 -0
  107. package/src/templates/web/base/template/src/components/__tests__/example.test.tsx +49 -0
  108. package/src/templates/web/base/template/src/components/providers/app-providers.tsx +6 -2
  109. package/src/templates/web/base/template/src/components/providers/theme-provider.tsx +94 -0
  110. package/src/templates/web/base/template/src/components/shared/footer.tsx +36 -0
  111. package/src/templates/web/base/template/src/components/shared/header.tsx +2 -0
  112. package/src/templates/web/base/template/src/components/ui/theme-toggle.tsx +34 -0
  113. package/src/templates/web/base/template/src/lib/auth-server.ts +177 -0
  114. package/src/templates/web/base/template/src/lib/env.ts +46 -0
  115. package/src/templates/web/base/template/src/lib/utils.ts +133 -0
  116. package/src/templates/web/base/template/src/test/setup.ts +79 -0
  117. package/src/templates/web/base/template/vitest.config.ts +17 -0
  118. package/src/templates/web/ui-auth/template/package.json +14 -4
  119. package/src/templates/web/ui-auth/template/src/app/error.tsx +67 -0
  120. package/src/templates/web/ui-auth/template/src/app/layout.tsx +6 -2
  121. package/src/templates/web/ui-auth/template/src/app/loading.tsx +20 -0
  122. package/src/templates/web/ui-auth/template/src/components/__tests__/example.test.tsx +49 -0
  123. package/src/templates/web/ui-auth/template/src/components/providers/app-providers.tsx +6 -2
  124. package/src/templates/web/ui-auth/template/src/components/providers/theme-provider.tsx +94 -0
  125. package/src/templates/web/ui-auth/template/src/components/shared/footer.tsx +36 -0
  126. package/src/templates/web/ui-auth/template/src/components/shared/header.tsx +2 -0
  127. package/src/templates/web/ui-auth/template/src/components/ui/theme-toggle.tsx +34 -0
  128. package/src/templates/web/ui-auth/template/src/lib/env.ts +49 -0
  129. package/src/templates/web/ui-auth/template/src/lib/utils.ts +133 -0
  130. package/src/templates/web/ui-auth/template/src/test/setup.ts +79 -0
  131. package/src/templates/web/ui-auth/template/vitest.config.ts +17 -0
  132. package/src/templates/web/ui-auth-payments/template/middleware.ts +68 -0
  133. package/src/templates/web/ui-auth-payments/template/package.json +14 -4
  134. package/src/templates/web/ui-auth-payments/template/src/app/dashboard/layout.tsx +22 -0
  135. package/src/templates/web/ui-auth-payments/template/src/app/dashboard/page.tsx +183 -0
  136. package/src/templates/web/ui-auth-payments/template/src/app/error.tsx +67 -0
  137. package/src/templates/web/ui-auth-payments/template/src/app/layout.tsx +6 -2
  138. package/src/templates/web/ui-auth-payments/template/src/app/loading.tsx +20 -0
  139. package/src/templates/web/ui-auth-payments/template/src/app/login/loading.tsx +38 -0
  140. package/src/templates/web/ui-auth-payments/template/src/app/signup/loading.tsx +50 -0
  141. package/src/templates/web/ui-auth-payments/template/src/components/__tests__/example.test.tsx +49 -0
  142. package/src/templates/web/ui-auth-payments/template/src/components/client/auth-status.tsx +52 -0
  143. package/src/templates/web/ui-auth-payments/template/src/components/client/login-form.tsx +144 -0
  144. package/src/templates/web/ui-auth-payments/template/src/components/client/newsletter-signup.tsx +68 -0
  145. package/src/templates/web/ui-auth-payments/template/src/components/client/signup-form.tsx +185 -0
  146. package/src/templates/web/ui-auth-payments/template/src/components/providers/app-providers.tsx +6 -2
  147. package/src/templates/web/ui-auth-payments/template/src/components/providers/theme-provider.tsx +94 -0
  148. package/src/templates/web/ui-auth-payments/template/src/components/shared/footer.tsx +36 -0
  149. package/src/templates/web/ui-auth-payments/template/src/components/shared/header.tsx +2 -0
  150. package/src/templates/web/ui-auth-payments/template/src/components/ui/theme-toggle.tsx +34 -0
  151. package/src/templates/web/ui-auth-payments/template/src/lib/actions/auth.ts +246 -0
  152. package/src/templates/web/ui-auth-payments/template/src/lib/actions/index.ts +340 -0
  153. package/src/templates/web/ui-auth-payments/template/src/lib/auth-server.ts +177 -0
  154. package/src/templates/web/ui-auth-payments/template/src/lib/env.ts +49 -0
  155. package/src/templates/web/ui-auth-payments/template/src/lib/utils.ts +133 -0
  156. package/src/templates/web/ui-auth-payments/template/src/test/setup.ts +79 -0
  157. package/src/templates/web/ui-auth-payments/template/vitest.config.ts +17 -0
  158. package/src/templates/web/ui-auth-payments-audio/template/package.json +14 -4
  159. package/src/templates/web/ui-auth-payments-audio/template/src/app/error.tsx +67 -0
  160. package/src/templates/web/ui-auth-payments-audio/template/src/app/layout.tsx +8 -2
  161. package/src/templates/web/ui-auth-payments-audio/template/src/app/loading.tsx +20 -0
  162. package/src/templates/web/ui-auth-payments-audio/template/src/components/__tests__/example.test.tsx +49 -0
  163. package/src/templates/web/ui-auth-payments-audio/template/src/components/providers/app-providers.tsx +6 -2
  164. package/src/templates/web/ui-auth-payments-audio/template/src/components/providers/theme-provider.tsx +94 -0
  165. package/src/templates/web/ui-auth-payments-audio/template/src/components/shared/footer.tsx +36 -0
  166. package/src/templates/web/ui-auth-payments-audio/template/src/components/shared/header.tsx +2 -0
  167. package/src/templates/web/ui-auth-payments-audio/template/src/components/ui/theme-toggle.tsx +34 -0
  168. package/src/templates/web/ui-auth-payments-audio/template/src/lib/env.ts +49 -0
  169. package/src/templates/web/ui-auth-payments-audio/template/src/lib/utils.ts +133 -0
  170. package/src/templates/web/ui-auth-payments-audio/template/src/test/setup.ts +79 -0
  171. package/src/templates/web/ui-auth-payments-audio/template/vitest.config.ts +17 -0
  172. package/src/templates/web/ui-auth-payments-video/template/package.json +14 -4
  173. package/src/templates/web/ui-auth-payments-video/template/src/app/error.tsx +67 -0
  174. package/src/templates/web/ui-auth-payments-video/template/src/app/layout.tsx +6 -2
  175. package/src/templates/web/ui-auth-payments-video/template/src/app/loading.tsx +20 -0
  176. package/src/templates/web/ui-auth-payments-video/template/src/components/__tests__/example.test.tsx +49 -0
  177. package/src/templates/web/ui-auth-payments-video/template/src/components/providers/app-providers.tsx +6 -2
  178. package/src/templates/web/ui-auth-payments-video/template/src/components/providers/theme-provider.tsx +94 -0
  179. package/src/templates/web/ui-auth-payments-video/template/src/components/shared/footer.tsx +36 -0
  180. package/src/templates/web/ui-auth-payments-video/template/src/components/shared/header.tsx +2 -0
  181. package/src/templates/web/ui-auth-payments-video/template/src/components/ui/theme-toggle.tsx +34 -0
  182. package/src/templates/web/ui-auth-payments-video/template/src/lib/env.ts +49 -0
  183. package/src/templates/web/ui-auth-payments-video/template/src/lib/utils.ts +133 -0
  184. package/src/templates/web/ui-auth-payments-video/template/src/test/setup.ts +79 -0
  185. package/src/templates/web/ui-auth-payments-video/template/vitest.config.ts +17 -0
  186. package/src/templates/web/ui-only/template/package.json +14 -4
  187. package/src/templates/web/ui-only/template/src/app/error.tsx +67 -0
  188. package/src/templates/web/ui-only/template/src/app/layout.tsx +6 -2
  189. package/src/templates/web/ui-only/template/src/app/loading.tsx +20 -0
  190. package/src/templates/web/ui-only/template/src/components/__tests__/example.test.tsx +49 -0
  191. package/src/templates/web/ui-only/template/src/components/providers/app-providers.tsx +6 -2
  192. package/src/templates/web/ui-only/template/src/components/providers/theme-provider.tsx +94 -0
  193. package/src/templates/web/ui-only/template/src/components/shared/footer.tsx +36 -0
  194. package/src/templates/web/ui-only/template/src/components/shared/header.tsx +2 -0
  195. package/src/templates/web/ui-only/template/src/components/ui/theme-toggle.tsx +34 -0
  196. package/src/templates/web/ui-only/template/src/lib/env.ts +49 -0
  197. package/src/templates/web/ui-only/template/src/lib/utils.ts +133 -0
  198. package/src/templates/web/ui-only/template/src/test/setup.ts +79 -0
  199. package/src/templates/web/ui-only/template/vitest.config.ts +17 -0
@@ -0,0 +1,34 @@
1
+ 'use client'
2
+
3
+ import * as React from "react"
4
+ import { Moon, Sun } from "lucide-react"
5
+ import { useTheme } from "next-themes"
6
+
7
+ import { Button } from "@digilogiclabs/saas-factory-ui"
8
+
9
+ export function ThemeToggle() {
10
+ const { theme, setTheme } = useTheme()
11
+
12
+ const toggleTheme = () => {
13
+ if (theme === 'light') {
14
+ setTheme('dark')
15
+ } else if (theme === 'dark') {
16
+ setTheme('system')
17
+ } else {
18
+ setTheme('light')
19
+ }
20
+ }
21
+
22
+ return (
23
+ <Button
24
+ variant="outline"
25
+ size="icon"
26
+ onClick={toggleTheme}
27
+ className="h-9 w-9"
28
+ >
29
+ <Sun className="h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
30
+ <Moon className="absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
31
+ <span className="sr-only">Toggle theme</span>
32
+ </Button>
33
+ )
34
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Optional Environment Configuration with Zod validation
3
+ *
4
+ * This provides type-safe environment variable validation.
5
+ * Usage is optional - existing templates will continue to work without this.
6
+ *
7
+ * To use: import { env } from '@/lib/env' instead of process.env
8
+ */
9
+
10
+ import { z } from 'zod'
11
+
12
+ const envSchema = z.object({
13
+ // Next.js built-in
14
+ NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
15
+
16
+ // App configuration
17
+ NEXT_PUBLIC_APP_URL: z.string().url().optional(),
18
+ NEXT_PUBLIC_APP_NAME: z.string().default('{{titleCaseName}}'),
19
+
20
+ // Auth configuration (if using server-side auth)
21
+ SUPABASE_URL: z.string().url().optional(),
22
+ SUPABASE_ANON_KEY: z.string().optional(),
23
+ SUPABASE_SERVICE_ROLE_KEY: z.string().optional(),
24
+
25
+ // Payment configuration
26
+ STRIPE_SECRET_KEY: z.string().optional(),
27
+ STRIPE_WEBHOOK_SECRET: z.string().optional(),
28
+
29
+ // Optional analytics
30
+ ANALYTICS_ID: z.string().optional(),
31
+ })
32
+
33
+ // Parse with fallback to process.env for backward compatibility
34
+ function parseEnv() {
35
+ try {
36
+ return envSchema.parse(process.env)
37
+ } catch (error) {
38
+ if (process.env.NODE_ENV === 'development') {
39
+ console.warn('Environment validation failed. Using process.env fallback:', error)
40
+ }
41
+ // Fallback to process.env for backward compatibility
42
+ return process.env as any
43
+ }
44
+ }
45
+
46
+ export const env = parseEnv()
47
+
48
+ // Type helper for environment variables
49
+ export type Env = z.infer<typeof envSchema>
@@ -1,7 +1,140 @@
1
+ /**
2
+ * Enhanced utility functions for {{titleCaseName}}
3
+ *
4
+ * This extends the basic utils with additional functionality while
5
+ * maintaining compatibility with existing templates.
6
+ */
7
+
1
8
  import { type ClassValue, clsx } from "clsx"
2
9
  import { twMerge } from "tailwind-merge"
3
10
 
11
+ // Core utility function (keeps existing functionality)
4
12
  export function cn(...inputs: ClassValue[]) {
5
13
  return twMerge(clsx(inputs))
6
14
  }
7
15
 
16
+ // Additional utilities for enhanced templates
17
+
18
+ /**
19
+ * Format currency with proper locale support
20
+ */
21
+ export function formatCurrency(
22
+ amount: number,
23
+ currency: string = 'USD',
24
+ locale: string = 'en-US'
25
+ ): string {
26
+ return new Intl.NumberFormat(locale, {
27
+ style: 'currency',
28
+ currency,
29
+ }).format(amount)
30
+ }
31
+
32
+ /**
33
+ * Format date with relative time support
34
+ */
35
+ export function formatDate(
36
+ date: Date | string,
37
+ options?: Intl.DateTimeFormatOptions
38
+ ): string {
39
+ const dateObj = typeof date === 'string' ? new Date(date) : date
40
+
41
+ const defaultOptions: Intl.DateTimeFormatOptions = {
42
+ year: 'numeric',
43
+ month: 'short',
44
+ day: 'numeric',
45
+ }
46
+
47
+ return new Intl.DateTimeFormat('en-US', options || defaultOptions).format(dateObj)
48
+ }
49
+
50
+ /**
51
+ * Get relative time string (e.g., "2 hours ago")
52
+ */
53
+ export function getRelativeTime(date: Date | string): string {
54
+ const dateObj = typeof date === 'string' ? new Date(date) : date
55
+ const now = new Date()
56
+ const diffInMs = now.getTime() - dateObj.getTime()
57
+ const diffInSeconds = Math.floor(diffInMs / 1000)
58
+ const diffInMinutes = Math.floor(diffInSeconds / 60)
59
+ const diffInHours = Math.floor(diffInMinutes / 60)
60
+ const diffInDays = Math.floor(diffInHours / 24)
61
+
62
+ if (diffInSeconds < 60) return 'just now'
63
+ if (diffInMinutes < 60) return `${diffInMinutes} minute${diffInMinutes > 1 ? 's' : ''} ago`
64
+ if (diffInHours < 24) return `${diffInHours} hour${diffInHours > 1 ? 's' : ''} ago`
65
+ if (diffInDays < 7) return `${diffInDays} day${diffInDays > 1 ? 's' : ''} ago`
66
+
67
+ return formatDate(dateObj)
68
+ }
69
+
70
+ /**
71
+ * Truncate text to specified length with ellipsis
72
+ */
73
+ export function truncate(text: string, length: number = 50): string {
74
+ if (text.length <= length) return text
75
+ return text.slice(0, length).trim() + '...'
76
+ }
77
+
78
+ /**
79
+ * Generate initials from a name
80
+ */
81
+ export function getInitials(name: string): string {
82
+ return name
83
+ .split(' ')
84
+ .map(word => word.charAt(0).toUpperCase())
85
+ .slice(0, 2)
86
+ .join('')
87
+ }
88
+
89
+ /**
90
+ * Validate email format
91
+ */
92
+ export function isValidEmail(email: string): boolean {
93
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
94
+ return emailRegex.test(email)
95
+ }
96
+
97
+ /**
98
+ * Generate a random ID
99
+ */
100
+ export function generateId(prefix: string = ''): string {
101
+ const timestamp = Date.now().toString(36)
102
+ const randomString = Math.random().toString(36).substring(2)
103
+ return prefix ? `${prefix}-${timestamp}-${randomString}` : `${timestamp}-${randomString}`
104
+ }
105
+
106
+ /**
107
+ * Debounce function
108
+ */
109
+ export function debounce<T extends (...args: any[]) => any>(
110
+ func: T,
111
+ delay: number
112
+ ): (...args: Parameters<T>) => void {
113
+ let timeoutId: NodeJS.Timeout | null = null
114
+
115
+ return (...args: Parameters<T>) => {
116
+ if (timeoutId !== null) {
117
+ clearTimeout(timeoutId)
118
+ }
119
+ timeoutId = setTimeout(() => func(...args), delay)
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Sleep/delay function for async operations
125
+ */
126
+ export function sleep(ms: number): Promise<void> {
127
+ return new Promise(resolve => setTimeout(resolve, ms))
128
+ }
129
+
130
+ /**
131
+ * Safe JSON parse with fallback
132
+ */
133
+ export function safeJsonParse<T>(json: string, fallback: T): T {
134
+ try {
135
+ return JSON.parse(json)
136
+ } catch {
137
+ return fallback
138
+ }
139
+ }
140
+
@@ -0,0 +1,79 @@
1
+ import '@testing-library/jest-dom'
2
+ import { vi } from 'vitest'
3
+
4
+ // Mock Next.js router
5
+ vi.mock('next/navigation', () => ({
6
+ useRouter: () => ({
7
+ push: vi.fn(),
8
+ back: vi.fn(),
9
+ forward: vi.fn(),
10
+ refresh: vi.fn(),
11
+ replace: vi.fn(),
12
+ prefetch: vi.fn(),
13
+ }),
14
+ useSearchParams: () => new URLSearchParams(),
15
+ usePathname: () => '/',
16
+ }))
17
+
18
+ // Mock SaaS Factory Auth (optional - only if testing auth components)
19
+ vi.mock('@digilogiclabs/saas-factory-auth', () => ({
20
+ useAuth: () => ({
21
+ user: null,
22
+ loading: false,
23
+ error: null,
24
+ signIn: vi.fn(),
25
+ signUp: vi.fn(),
26
+ signOut: vi.fn(),
27
+ signInWithOAuth: vi.fn(),
28
+ }),
29
+ AuthProvider: ({ children }: { children: React.ReactNode }) => children,
30
+ }))
31
+
32
+ // Mock SaaS Factory Payments (optional - only if testing payment components)
33
+ vi.mock('@digilogiclabs/saas-factory-payments', () => ({
34
+ usePayments: () => ({
35
+ createCheckoutSession: vi.fn(),
36
+ createPortalSession: vi.fn(),
37
+ subscription: null,
38
+ loading: false,
39
+ }),
40
+ PaymentsProvider: ({ children }: { children: React.ReactNode }) => children,
41
+ }))
42
+
43
+ // Global test utilities
44
+ global.ResizeObserver = vi.fn().mockImplementation(() => ({
45
+ observe: vi.fn(),
46
+ unobserve: vi.fn(),
47
+ disconnect: vi.fn(),
48
+ }))
49
+
50
+ // Suppress console warnings in tests unless needed
51
+ const originalConsoleError = console.error
52
+ const originalConsoleWarn = console.warn
53
+
54
+ beforeEach(() => {
55
+ console.error = (...args: any[]) => {
56
+ if (
57
+ typeof args[0] === 'string' &&
58
+ args[0].includes('Warning: ReactDOM.render is no longer supported')
59
+ ) {
60
+ return
61
+ }
62
+ originalConsoleError.call(console, ...args)
63
+ }
64
+
65
+ console.warn = (...args: any[]) => {
66
+ if (
67
+ typeof args[0] === 'string' &&
68
+ args[0].includes('useLayoutEffect does nothing on the server')
69
+ ) {
70
+ return
71
+ }
72
+ originalConsoleWarn.call(console, ...args)
73
+ }
74
+ })
75
+
76
+ afterAll(() => {
77
+ console.error = originalConsoleError
78
+ console.warn = originalConsoleWarn
79
+ })
@@ -0,0 +1,17 @@
1
+ import { defineConfig } from 'vitest/config'
2
+ import react from '@vitejs/plugin-react'
3
+ import path from 'path'
4
+
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ test: {
8
+ environment: 'jsdom',
9
+ setupFiles: ['./src/test/setup.ts'],
10
+ globals: true,
11
+ },
12
+ resolve: {
13
+ alias: {
14
+ '@': path.resolve(__dirname, './src'),
15
+ },
16
+ },
17
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digilogiclabs/create-saas-app",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Create modern SaaS applications with Digi Logic Labs packages",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -4,16 +4,19 @@
4
4
  "description": "{{description}}",
5
5
  "private": true,
6
6
  "scripts": {
7
- "dev": "next dev",
7
+ "dev": "next dev --turbo",
8
8
  "build": "next build",
9
9
  "start": "next start",
10
10
  "lint": "next lint",
11
- "type-check": "tsc --noEmit"
11
+ "type-check": "tsc --noEmit",
12
+ "test": "vitest",
13
+ "test:ui": "vitest --ui",
14
+ "test:run": "vitest run"
12
15
  },
13
16
  "dependencies": {
14
- "next": "^14.0.0",
15
- "react": "^18.0.0",
16
- "react-dom": "^18.0.0",
17
+ "next": "^15.0.0",
18
+ "react": "^19.0.0",
19
+ "react-dom": "^19.0.0",
17
20
  "@digilogiclabs/saas-factory-ui": "^0.7.2",
18
21
  "@digilogiclabs/saas-factory-auth": "^0.4.3",
19
22
  "@digilogiclabs/saas-factory-payments": "^0.2.0",
@@ -26,21 +29,28 @@
26
29
  "next-themes": "^0.2.1",
27
30
  "@radix-ui/react-slot": "^1.0.2",
28
31
  "tailwindcss-animate": "^1.0.7",
29
- "lucide-react": "^0.292.0",
32
+ "lucide-react": "^0.542.0",
33
+ "zod": "^3.22.4",
30
34
  "firebase": "^10.0.0",
31
35
  "@supabase/supabase-js": "^2.0.0"
32
36
  },
33
37
  "devDependencies": {
34
38
  "typescript": "^5.0.0",
35
39
  "@types/node": "^20.0.0",
36
- "@types/react": "^18.0.0",
37
- "@types/react-dom": "^18.0.0",
40
+ "@types/react": "^19.0.0",
41
+ "@types/react-dom": "^19.0.0",
38
42
  "eslint": "^8.0.0",
39
- "eslint-config-next": "^14.0.0",
43
+ "eslint-config-next": "^15.0.0",
40
44
  "@typescript-eslint/eslint-plugin": "^6.0.0",
41
45
  "@typescript-eslint/parser": "^6.0.0",
42
46
  "prettier": "^3.0.0",
43
- "prettier-plugin-tailwindcss": "^0.5.0"
47
+ "prettier-plugin-tailwindcss": "^0.5.0",
48
+ "vitest": "^1.0.0",
49
+ "@vitejs/plugin-react": "^4.0.0",
50
+ "@testing-library/react": "^14.0.0",
51
+ "@testing-library/jest-dom": "^6.0.0",
52
+ "@testing-library/user-event": "^14.0.0",
53
+ "jsdom": "^24.0.0"
44
54
  },
45
55
  "engines": {
46
56
  "node": ">=18.0.0"
@@ -0,0 +1,97 @@
1
+ 'use client'
2
+
3
+ import { useEffect } from 'react'
4
+ import { Button, Card } from '@digilogiclabs/saas-factory-ui'
5
+ import { AlertTriangle, RefreshCw, Home } from 'lucide-react'
6
+ import Link from 'next/link'
7
+
8
+ interface ErrorProps {
9
+ error: Error & { digest?: string }
10
+ reset: () => void
11
+ }
12
+
13
+ export default function Error({ error, reset }: ErrorProps) {
14
+ useEffect(() => {
15
+ // Log error to error reporting service
16
+ console.error('Application error:', error)
17
+ }, [error])
18
+
19
+ return (
20
+ <div className="min-h-screen bg-gradient-to-br from-red-50 to-orange-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center p-4">
21
+ <Card className="p-8 max-w-lg w-full">
22
+ <div className="flex flex-col items-center space-y-6 text-center">
23
+ {/* Error icon */}
24
+ <div className="w-16 h-16 bg-red-100 dark:bg-red-900 rounded-full flex items-center justify-center">
25
+ <AlertTriangle className="w-8 h-8 text-red-600 dark:text-red-400" />
26
+ </div>
27
+
28
+ {/* Error content */}
29
+ <div>
30
+ <h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-2">
31
+ Something went wrong!
32
+ </h1>
33
+ <p className="text-gray-600 dark:text-gray-300 mb-4">
34
+ We encountered an unexpected error. This has been logged and our team will look into it.
35
+ </p>
36
+
37
+ {/* Error details in development */}
38
+ {process.env.NODE_ENV === 'development' && (
39
+ <details className="mt-4 text-left">
40
+ <summary className="cursor-pointer text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200">
41
+ Error details (development only)
42
+ </summary>
43
+ <div className="mt-2 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs font-mono text-gray-700 dark:text-gray-300 overflow-auto max-h-40">
44
+ <div className="mb-2">
45
+ <strong>Message:</strong> {error.message}
46
+ </div>
47
+ {error.digest && (
48
+ <div className="mb-2">
49
+ <strong>Digest:</strong> {error.digest}
50
+ </div>
51
+ )}
52
+ {error.stack && (
53
+ <div>
54
+ <strong>Stack:</strong>
55
+ <pre className="whitespace-pre-wrap mt-1">{error.stack}</pre>
56
+ </div>
57
+ )}
58
+ </div>
59
+ </details>
60
+ )}
61
+ </div>
62
+
63
+ {/* Action buttons */}
64
+ <div className="flex flex-col sm:flex-row gap-3 w-full">
65
+ <Button
66
+ onClick={reset}
67
+ className="flex-1"
68
+ size="lg"
69
+ >
70
+ <RefreshCw className="w-4 h-4 mr-2" />
71
+ Try again
72
+ </Button>
73
+
74
+ <Link href="/" className="flex-1">
75
+ <Button
76
+ variant="outline"
77
+ className="w-full"
78
+ size="lg"
79
+ >
80
+ <Home className="w-4 h-4 mr-2" />
81
+ Go home
82
+ </Button>
83
+ </Link>
84
+ </div>
85
+
86
+ {/* Help text */}
87
+ <p className="text-sm text-gray-500 dark:text-gray-400">
88
+ If this problem persists, please{' '}
89
+ <Link href="/contact" className="text-blue-600 hover:underline dark:text-blue-400">
90
+ contact support
91
+ </Link>
92
+ </p>
93
+ </div>
94
+ </Card>
95
+ </div>
96
+ )
97
+ }
@@ -3,6 +3,7 @@ import { Inter } from 'next/font/google'
3
3
  import './globals.css'
4
4
  import { AppProviders } from '@/components/providers/app-providers'
5
5
  import { Header } from '@/components/shared/header'
6
+ import { Footer } from '@/components/shared/footer'
6
7
 
7
8
  const inter = Inter({ subsets: ['latin'] })
8
9
 
@@ -20,8 +21,13 @@ export default function RootLayout({
20
21
  <html lang="en" suppressHydrationWarning>
21
22
  <body className={inter.className}>
22
23
  <AppProviders>
23
- <Header />
24
- {children}
24
+ <div className="min-h-screen flex flex-col">
25
+ <Header />
26
+ <main className="flex-1">
27
+ {children}
28
+ </main>
29
+ <Footer />
30
+ </div>
25
31
  </AppProviders>
26
32
  </body>
27
33
  </html>
@@ -0,0 +1,34 @@
1
+ import { Card } from '@digilogiclabs/saas-factory-ui'
2
+
3
+ export default function Loading() {
4
+ return (
5
+ <div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center">
6
+ <Card className="p-8 max-w-sm w-full mx-4">
7
+ <div className="flex flex-col items-center space-y-4">
8
+ {/* Animated spinner */}
9
+ <div className="relative">
10
+ <div className="w-12 h-12 border-4 border-gray-200 dark:border-gray-700 rounded-full animate-spin"></div>
11
+ <div className="absolute top-0 left-0 w-12 h-12 border-4 border-blue-600 border-t-transparent rounded-full animate-spin"></div>
12
+ </div>
13
+
14
+ {/* Loading text */}
15
+ <div className="text-center">
16
+ <h2 className="text-lg font-semibold text-gray-900 dark:text-white mb-2">
17
+ Loading...
18
+ </h2>
19
+ <p className="text-sm text-gray-600 dark:text-gray-300">
20
+ Please wait while we prepare your content
21
+ </p>
22
+ </div>
23
+
24
+ {/* Pulsing dots */}
25
+ <div className="flex space-x-1">
26
+ <div className="w-2 h-2 bg-blue-600 rounded-full animate-pulse"></div>
27
+ <div className="w-2 h-2 bg-blue-600 rounded-full animate-pulse" style={{ animationDelay: '0.2s' }}></div>
28
+ <div className="w-2 h-2 bg-blue-600 rounded-full animate-pulse" style={{ animationDelay: '0.4s' }}></div>
29
+ </div>
30
+ </div>
31
+ </Card>
32
+ </div>
33
+ )
34
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Example test file demonstrating testing patterns for SaaS Factory components
3
+ *
4
+ * This is optional and serves as a reference for testing your components.
5
+ * You can delete this file if you don't need example tests.
6
+ */
7
+
8
+ import { render, screen } from '@testing-library/react'
9
+ import { Button } from '@digilogiclabs/saas-factory-ui'
10
+
11
+ // Example: Testing UI components
12
+ describe('UI Components', () => {
13
+ it('renders button with correct text', () => {
14
+ render(<Button>Click me</Button>)
15
+ expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument()
16
+ })
17
+
18
+ it('button can be disabled', () => {
19
+ render(<Button disabled>Disabled button</Button>)
20
+ expect(screen.getByRole('button')).toBeDisabled()
21
+ })
22
+ })
23
+
24
+ // Example: Testing custom components
25
+ function MockComponent({ title }: { title: string }) {
26
+ return <h1>{title}</h1>
27
+ }
28
+
29
+ describe('Custom Components', () => {
30
+ it('renders with correct title', () => {
31
+ render(<MockComponent title="Test Title" />)
32
+ expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Test Title')
33
+ })
34
+ })
35
+
36
+ // Example: Testing utilities
37
+ function formatCurrency(amount: number): string {
38
+ return new Intl.NumberFormat('en-US', {
39
+ style: 'currency',
40
+ currency: 'USD',
41
+ }).format(amount)
42
+ }
43
+
44
+ describe('Utilities', () => {
45
+ it('formats currency correctly', () => {
46
+ expect(formatCurrency(1000)).toBe('$1,000.00')
47
+ expect(formatCurrency(0)).toBe('$0.00')
48
+ })
49
+ })
@@ -4,6 +4,7 @@ import React from 'react'
4
4
  import { AuthProvider } from '@digilogiclabs/saas-factory-auth'
5
5
  import { ThemeProvider } from 'next-themes'
6
6
  import { StripeProvider } from '@digilogiclabs/saas-factory-payments'
7
+ import { AppThemeProvider } from './theme-provider'
7
8
 
8
9
  interface AppProvidersProps {
9
10
  children: React.ReactNode
@@ -17,11 +18,14 @@ export function AppProviders({ children }: AppProvidersProps) {
17
18
  >
18
19
  <ThemeProvider
19
20
  attribute="class"
20
- defaultTheme="system"
21
+ defaultTheme="{{defaultTheme}}"
21
22
  enableSystem
22
23
  disableTransitionOnChange
24
+ storageKey="{{packageName}}-theme"
23
25
  >
24
- {children}
26
+ <AppThemeProvider themeColor="{{themeColor}}">
27
+ {children}
28
+ </AppThemeProvider>
25
29
  </ThemeProvider>
26
30
  </StripeProvider>
27
31
  </AuthProvider>