create-mohit-next 0.0.0-stage → 2.0.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 (202) hide show
  1. package/README.md +139 -2
  2. package/index.js +399 -0
  3. package/lib/features.js +358 -0
  4. package/lib/scaffold.js +471 -0
  5. package/package.json +40 -4
  6. package/templates/common/_editorconfig +12 -0
  7. package/templates/common/_gitattributes +5 -0
  8. package/templates/common/_github/dependabot.yml +14 -0
  9. package/templates/common/_github/workflows/ci.yml +66 -0
  10. package/templates/common/_husky/commit-msg +1 -0
  11. package/templates/common/_husky/pre-commit +1 -0
  12. package/templates/common/_nvmrc +1 -0
  13. package/templates/common/_prettierignore +15 -0
  14. package/templates/common/commitlint.config.mjs +10 -0
  15. package/templates/next/AGENTS.md +9 -0
  16. package/templates/next/Dockerfile +48 -0
  17. package/templates/next/README.md +328 -0
  18. package/templates/next/_dockerignore +13 -0
  19. package/templates/next/_env.example +20 -0
  20. package/templates/next/_gitignore +50 -0
  21. package/templates/next/docker-compose.yml +33 -0
  22. package/templates/next/e2e/rbac.spec.ts +69 -0
  23. package/templates/next/e2e/server.mjs +35 -0
  24. package/templates/next/eslint.config.mjs +33 -0
  25. package/templates/next/next.config.ts +47 -0
  26. package/templates/next/package.json +68 -0
  27. package/templates/next/playwright.config.ts +30 -0
  28. package/templates/next/public/robots.txt +6 -0
  29. package/templates/next/scripts/seed.ts +111 -0
  30. package/templates/next/src/app/(app)/admin/audit/page.tsx +99 -0
  31. package/templates/next/src/app/(app)/admin/page.tsx +92 -0
  32. package/templates/next/src/app/(app)/dashboard/page.tsx +120 -0
  33. package/templates/next/src/app/(app)/error.tsx +28 -0
  34. package/templates/next/src/app/(app)/layout.tsx +58 -0
  35. package/templates/next/src/app/(app)/loading.tsx +5 -0
  36. package/templates/next/src/app/(app)/reports/page.tsx +128 -0
  37. package/templates/next/src/app/(app)/settings/page.tsx +66 -0
  38. package/templates/next/src/app/(auth)/forgot-password/page.tsx +17 -0
  39. package/templates/next/src/app/(auth)/layout.tsx +18 -0
  40. package/templates/next/src/app/(auth)/login/page.tsx +18 -0
  41. package/templates/next/src/app/(auth)/register/page.tsx +18 -0
  42. package/templates/next/src/app/(auth)/reset-password/page.tsx +18 -0
  43. package/templates/next/src/app/api/account/password/route.ts +45 -0
  44. package/templates/next/src/app/api/account/route.ts +25 -0
  45. package/templates/next/src/app/api/account/sessions/route.ts +12 -0
  46. package/templates/next/src/app/api/admin/audit/route.ts +13 -0
  47. package/templates/next/src/app/api/admin/users/[id]/route.ts +61 -0
  48. package/templates/next/src/app/api/admin/users/route.ts +18 -0
  49. package/templates/next/src/app/api/auth/forgot-password/route.ts +47 -0
  50. package/templates/next/src/app/api/auth/login/route.ts +43 -0
  51. package/templates/next/src/app/api/auth/logout/route.ts +21 -0
  52. package/templates/next/src/app/api/auth/me/route.ts +21 -0
  53. package/templates/next/src/app/api/auth/register/route.ts +74 -0
  54. package/templates/next/src/app/api/auth/resend-verification/route.ts +25 -0
  55. package/templates/next/src/app/api/auth/reset-password/route.ts +43 -0
  56. package/templates/next/src/app/api/auth/verify-email/route.ts +29 -0
  57. package/templates/next/src/app/api/health/route.ts +27 -0
  58. package/templates/next/src/app/favicon.ico +0 -0
  59. package/templates/next/src/app/forbidden/page.tsx +47 -0
  60. package/templates/next/src/app/layout.tsx +55 -0
  61. package/templates/next/src/app/not-found.tsx +20 -0
  62. package/templates/next/src/app/opengraph-image.tsx +49 -0
  63. package/templates/next/src/app/page.tsx +165 -0
  64. package/templates/next/src/app/robots.ts +15 -0
  65. package/templates/next/src/app/sitemap.ts +13 -0
  66. package/templates/next/src/app/verify-email/page.tsx +23 -0
  67. package/templates/next/src/components/admin/user-actions.tsx +124 -0
  68. package/templates/next/src/components/admin/users-data-table.tsx +221 -0
  69. package/templates/next/src/components/admin/users-table.tsx +67 -0
  70. package/templates/next/src/components/auth/auth-card.tsx +41 -0
  71. package/templates/next/src/components/auth/can.tsx +34 -0
  72. package/templates/next/src/components/auth/forgot-password-form.tsx +76 -0
  73. package/templates/next/src/components/auth/form-field.tsx +40 -0
  74. package/templates/next/src/components/auth/login-form.tsx +87 -0
  75. package/templates/next/src/components/auth/password-input.tsx +43 -0
  76. package/templates/next/src/components/auth/register-form.tsx +117 -0
  77. package/templates/next/src/components/auth/reset-password-form.tsx +80 -0
  78. package/templates/next/src/components/auth/session-refresher.tsx +44 -0
  79. package/templates/next/src/components/auth/verify-email-banner.tsx +43 -0
  80. package/templates/next/src/components/auth/verify-email-status.tsx +44 -0
  81. package/templates/next/src/components/layout/nav-links.tsx +37 -0
  82. package/templates/next/src/components/layout/navbar.tsx +27 -0
  83. package/templates/next/src/components/layout/page-header.tsx +21 -0
  84. package/templates/next/src/components/layout/sidebar.tsx +83 -0
  85. package/templates/next/src/components/layout/skeletons.tsx +57 -0
  86. package/templates/next/src/components/layout/user-menu.tsx +118 -0
  87. package/templates/next/src/components/logo.tsx +16 -0
  88. package/templates/next/src/components/motion/fade-in.tsx +19 -0
  89. package/templates/next/src/components/providers/user-provider.tsx +60 -0
  90. package/templates/next/src/components/reports/animated-bar.tsx +24 -0
  91. package/templates/next/src/components/reports/role-chart.tsx +61 -0
  92. package/templates/next/src/components/reports/signups-chart.tsx +64 -0
  93. package/templates/next/src/components/role-badge.tsx +11 -0
  94. package/templates/next/src/components/settings/password-form.tsx +80 -0
  95. package/templates/next/src/components/settings/profile-form.tsx +63 -0
  96. package/templates/next/src/components/settings/sessions-card.tsx +70 -0
  97. package/templates/next/src/components/theme-toggle.tsx +61 -0
  98. package/templates/next/src/config/rbac.test.ts +89 -0
  99. package/templates/next/src/config/rbac.ts +170 -0
  100. package/templates/next/src/config/site.ts +4 -0
  101. package/templates/next/src/lib/api.ts +179 -0
  102. package/templates/next/src/lib/audit.ts +66 -0
  103. package/templates/next/src/lib/auth.ts +50 -0
  104. package/templates/next/src/lib/dal.ts +63 -0
  105. package/templates/next/src/lib/db.ts +35 -0
  106. package/templates/next/src/lib/email-templates.ts +55 -0
  107. package/templates/next/src/lib/email.ts +53 -0
  108. package/templates/next/src/lib/env.ts +90 -0
  109. package/templates/next/src/lib/http.ts +57 -0
  110. package/templates/next/src/lib/password-strength.test.ts +20 -0
  111. package/templates/next/src/lib/password-strength.ts +24 -0
  112. package/templates/next/src/lib/rate-limit.test.ts +47 -0
  113. package/templates/next/src/lib/rate-limit.ts +70 -0
  114. package/templates/next/src/lib/redirect.test.ts +23 -0
  115. package/templates/next/src/lib/redirect.ts +21 -0
  116. package/templates/next/src/lib/session.ts +71 -0
  117. package/templates/next/src/lib/theme.ts +32 -0
  118. package/templates/next/src/lib/tokens.ts +63 -0
  119. package/templates/next/src/lib/users.ts +196 -0
  120. package/templates/next/src/lib/validations/account.ts +20 -0
  121. package/templates/next/src/lib/validations/auth.test.ts +39 -0
  122. package/templates/next/src/lib/validations/auth.ts +66 -0
  123. package/templates/next/src/lib/validations/user.ts +13 -0
  124. package/templates/next/src/models/audit-log.ts +33 -0
  125. package/templates/next/src/models/auth-token.ts +26 -0
  126. package/templates/next/src/models/user.ts +35 -0
  127. package/templates/next/src/proxy.ts +57 -0
  128. package/templates/next/src/styles/app.css +1092 -0
  129. package/templates/next/src/types/user.ts +13 -0
  130. package/templates/next/tsconfig.json +34 -0
  131. package/templates/next/vitest.config.mts +13 -0
  132. package/templates/styles/css.css +580 -0
  133. package/templates/styles/shadcn.css +142 -0
  134. package/templates/styles/tailwind.css +140 -0
  135. package/templates/ui/css/components/alert-dialog.tsx +172 -0
  136. package/templates/ui/css/components/avatar.tsx +17 -0
  137. package/templates/ui/css/components/badge.tsx +18 -0
  138. package/templates/ui/css/components/button.tsx +41 -0
  139. package/templates/ui/css/components/card.tsx +33 -0
  140. package/templates/ui/css/components/dropdown-menu.tsx +230 -0
  141. package/templates/ui/css/components/input.tsx +7 -0
  142. package/templates/ui/css/components/label.tsx +7 -0
  143. package/templates/ui/css/components/native-select.tsx +23 -0
  144. package/templates/ui/css/components/skeleton.tsx +7 -0
  145. package/templates/ui/css/components/slot.tsx +30 -0
  146. package/templates/ui/css/components/table.tsx +31 -0
  147. package/templates/ui/css/utils.ts +16 -0
  148. package/templates/ui/shadcn/components/alert-dialog.tsx +199 -0
  149. package/templates/ui/shadcn/components/avatar.tsx +111 -0
  150. package/templates/ui/shadcn/components/badge.tsx +44 -0
  151. package/templates/ui/shadcn/components/button.tsx +66 -0
  152. package/templates/ui/shadcn/components/card.tsx +87 -0
  153. package/templates/ui/shadcn/components/dropdown-menu.tsx +268 -0
  154. package/templates/ui/shadcn/components/input.tsx +18 -0
  155. package/templates/ui/shadcn/components/label.tsx +20 -0
  156. package/templates/ui/shadcn/components/native-select.tsx +54 -0
  157. package/templates/ui/shadcn/components/skeleton.tsx +13 -0
  158. package/templates/ui/shadcn/components/table.tsx +115 -0
  159. package/templates/ui/shadcn/utils.ts +1 -0
  160. package/templates/ui/tailwind/components/alert-dialog.tsx +177 -0
  161. package/templates/ui/tailwind/components/avatar.tsx +36 -0
  162. package/templates/ui/tailwind/components/badge.tsx +29 -0
  163. package/templates/ui/tailwind/components/button.tsx +65 -0
  164. package/templates/ui/tailwind/components/card.tsx +70 -0
  165. package/templates/ui/tailwind/components/dropdown-menu.tsx +236 -0
  166. package/templates/ui/tailwind/components/input.tsx +17 -0
  167. package/templates/ui/tailwind/components/label.tsx +16 -0
  168. package/templates/ui/tailwind/components/native-select.tsx +32 -0
  169. package/templates/ui/tailwind/components/skeleton.tsx +13 -0
  170. package/templates/ui/tailwind/components/slot.tsx +34 -0
  171. package/templates/ui/tailwind/components/table.tsx +56 -0
  172. package/templates/ui/tailwind/utils.ts +1 -0
  173. package/templates/vite/Dockerfile +29 -0
  174. package/templates/vite/README.md +142 -0
  175. package/templates/vite/_dockerignore +14 -0
  176. package/templates/vite/_env.example +8 -0
  177. package/templates/vite/_gitignore +37 -0
  178. package/templates/vite/e2e/app.spec.ts +41 -0
  179. package/templates/vite/index.html +32 -0
  180. package/templates/vite/nginx.conf +26 -0
  181. package/templates/vite/package.json +61 -0
  182. package/templates/vite/playwright.config.ts +27 -0
  183. package/templates/vite/public/favicon.svg +1 -0
  184. package/templates/vite/src/App.test.tsx +28 -0
  185. package/templates/vite/src/App.tsx +26 -0
  186. package/templates/vite/src/components/home.tsx +121 -0
  187. package/templates/vite/src/components/layout/root-layout.tsx +18 -0
  188. package/templates/vite/src/components/layout/site-footer.tsx +10 -0
  189. package/templates/vite/src/components/layout/site-header.tsx +49 -0
  190. package/templates/vite/src/components/theme-toggle.tsx +90 -0
  191. package/templates/vite/src/env.ts +36 -0
  192. package/templates/vite/src/lib/theme.ts +26 -0
  193. package/templates/vite/src/main.tsx +13 -0
  194. package/templates/vite/src/pages/about.tsx +52 -0
  195. package/templates/vite/src/pages/not-found.tsx +33 -0
  196. package/templates/vite/src/router.ts +24 -0
  197. package/templates/vite/src/styles/app.css +281 -0
  198. package/templates/vite/src/test/setup.ts +21 -0
  199. package/templates/vite/tsconfig.app.json +31 -0
  200. package/templates/vite/tsconfig.json +7 -0
  201. package/templates/vite/tsconfig.node.json +23 -0
  202. package/templates/vite/vite.config.ts +30 -0
@@ -0,0 +1,34 @@
1
+ import { cloneElement, isValidElement, type ReactElement, type ReactNode } from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ type AnyProps = Record<string, unknown>;
6
+
7
+ /**
8
+ * Renders its only child, merging the given props into it (like Radix's Slot).
9
+ * Used for `asChild`: <Button asChild><Link href="/">Home</Link></Button>.
10
+ */
11
+ export function Slot({ children, ...props }: AnyProps & { children?: ReactNode }) {
12
+ if (!isValidElement(children)) return null;
13
+ const child = children as ReactElement<AnyProps>;
14
+ const childProps = child.props;
15
+ const merged: AnyProps = { ...props, ...childProps };
16
+
17
+ // Compose event handlers so both the slot's and the child's run.
18
+ for (const key of Object.keys(props)) {
19
+ const slotHandler = props[key];
20
+ const childHandler = childProps[key];
21
+ if (
22
+ /^on[A-Z]/.test(key) &&
23
+ typeof slotHandler === "function" &&
24
+ typeof childHandler === "function"
25
+ ) {
26
+ merged[key] = (...args: unknown[]) => {
27
+ childHandler(...args);
28
+ slotHandler(...args);
29
+ };
30
+ }
31
+ }
32
+ merged.className = cn(props.className as string, childProps.className as string);
33
+ return cloneElement(child, merged);
34
+ }
@@ -0,0 +1,56 @@
1
+ import type { ComponentProps } from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ export function Table({ className, ...props }: ComponentProps<"table">) {
6
+ return (
7
+ <div data-slot="table-container" className="relative w-full overflow-x-auto">
8
+ <table
9
+ data-slot="table"
10
+ className={cn("w-full caption-bottom text-sm", className)}
11
+ {...props}
12
+ />
13
+ </div>
14
+ );
15
+ }
16
+
17
+ export function TableHeader({ className, ...props }: ComponentProps<"thead">) {
18
+ return <thead data-slot="table-header" className={cn("[&_tr]:border-b", className)} {...props} />;
19
+ }
20
+
21
+ export function TableBody({ className, ...props }: ComponentProps<"tbody">) {
22
+ return (
23
+ <tbody
24
+ data-slot="table-body"
25
+ className={cn("[&_tr:last-child]:border-0", className)}
26
+ {...props}
27
+ />
28
+ );
29
+ }
30
+
31
+ export function TableRow({ className, ...props }: ComponentProps<"tr">) {
32
+ return (
33
+ <tr
34
+ data-slot="table-row"
35
+ className={cn("border-b transition-colors hover:bg-muted/50", className)}
36
+ {...props}
37
+ />
38
+ );
39
+ }
40
+
41
+ export function TableHead({ className, ...props }: ComponentProps<"th">) {
42
+ return (
43
+ <th
44
+ data-slot="table-head"
45
+ className={cn(
46
+ "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground",
47
+ className,
48
+ )}
49
+ {...props}
50
+ />
51
+ );
52
+ }
53
+
54
+ export function TableCell({ className, ...props }: ComponentProps<"td">) {
55
+ return <td data-slot="table-cell" className={cn("p-2 align-middle", className)} {...props} />;
56
+ }
@@ -0,0 +1 @@
1
+ export { cn } from "cn";
@@ -0,0 +1,29 @@
1
+ # syntax=docker/dockerfile:1
2
+ # Multi-stage build: compile the static site with Node, serve it with nginx.
3
+
4
+ ARG NODE_VERSION=24-alpine
5
+
6
+ # ---- 1. Build ---------------------------------------------------------------
7
+ FROM node:${NODE_VERSION} AS build
8
+ WORKDIR /app
9
+ COPY package.json package-lock.json* pnpm-lock.yaml* yarn.lock* bun.lock* ./
10
+ RUN \
11
+ if [ -f package-lock.json ]; then npm ci; \
12
+ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm install --frozen-lockfile; \
13
+ elif [ -f yarn.lock ]; then corepack enable yarn && yarn install --frozen-lockfile; \
14
+ elif [ -f bun.lock ]; then npm install -g bun && bun install --frozen-lockfile; \
15
+ else npm install; \
16
+ fi
17
+ COPY . .
18
+ # VITE_* variables are baked in at build time: docker build --build-arg VITE_API_URL=...
19
+ ARG VITE_APP_NAME
20
+ ARG VITE_API_URL
21
+ ENV VITE_APP_NAME=$VITE_APP_NAME VITE_API_URL=$VITE_API_URL
22
+ RUN npm run build
23
+
24
+ # ---- 2. Serve -----------------------------------------------------------------
25
+ FROM nginx:1.29-alpine AS runner
26
+ COPY nginx.conf /etc/nginx/conf.d/default.conf
27
+ COPY --from=build /app/dist /usr/share/nginx/html
28
+ EXPOSE 80
29
+ HEALTHCHECK --interval=30s --timeout=5s CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1
@@ -0,0 +1,142 @@
1
+ # {{PROJECT_TITLE}}
2
+
3
+ A **Vite + React 19** single-page app, scaffolded with `create-mohit-next`.
4
+
5
+ ## What's inside
6
+
7
+ <!-- @feature ts -->
8
+ - **Vite** + **React 19** + **TypeScript**
9
+ <!-- @end ts -->
10
+ <!-- @feature !ts -->
11
+ - **Vite** + **React 19** (JavaScript)
12
+ <!-- @end !ts -->
13
+ <!-- @feature router -->
14
+ - **React Router** (data mode) with a shared layout, an About page and a 404 page
15
+ <!-- @end router -->
16
+ <!-- @feature shadcn -->
17
+ - **Tailwind CSS v4 + shadcn/ui** components in `src/components/ui`
18
+ <!-- @end shadcn -->
19
+ <!-- @feature tailwind -->
20
+ <!-- @feature !shadcn -->
21
+ - **Tailwind CSS v4**
22
+ <!-- @feature ui -->
23
+ with hand-written components in `src/components/ui`
24
+ <!-- @end ui -->
25
+ <!-- @end !shadcn -->
26
+ <!-- @end tailwind -->
27
+ <!-- @feature css -->
28
+ - **Plain CSS** (no Tailwind): theme tokens and component styles in `src/index.css`
29
+ <!-- @end css -->
30
+ - Light / dark / system themes, `lucide-react` icons
31
+ <!-- @feature env -->
32
+ - **zod**-validated environment variables (`src/env`)
33
+ <!-- @end env -->
34
+ <!-- @feature oxlint -->
35
+ - **Oxlint** (fast linter)
36
+ <!-- @end oxlint -->
37
+ <!-- @feature prettier -->
38
+ - **Prettier**
39
+ <!-- @end prettier -->
40
+ <!-- @feature git-hooks -->
41
+ - Git hooks: Husky + lint-staged (on commit) + commitlint (Conventional Commits)
42
+ <!-- @end git-hooks -->
43
+ <!-- @feature vitest -->
44
+ - Unit/component tests with **Vitest** + Testing Library
45
+ <!-- @end vitest -->
46
+ <!-- @feature playwright -->
47
+ - End-to-end tests with **Playwright**
48
+ <!-- @end playwright -->
49
+ <!-- @feature docker -->
50
+ - **Docker**: multi-stage build served by nginx
51
+ <!-- @end docker -->
52
+ <!-- @feature ci -->
53
+ - GitHub Actions CI + Dependabot
54
+ <!-- @end ci -->
55
+
56
+ ## Getting started
57
+
58
+ ```bash
59
+ npm install # if you skipped it during scaffolding
60
+ npm run dev # http://localhost:5173
61
+ ```
62
+
63
+ Environment variables live in `.env.local` (created from `.env.example`). Only variables prefixed
64
+ with `VITE_` reach the browser, and they are baked in at build time, so never put secrets there.
65
+
66
+ ### Scripts
67
+
68
+ | Script | What it does |
69
+ | ------ | ------------ |
70
+ | `npm run dev` | Dev server with hot reload |
71
+ | `npm run build` | Production build into `dist/` |
72
+ | `npm run preview` | Serve the production build locally |
73
+ <!-- @feature ts -->
74
+ | `npm run typecheck` | Type-check the project |
75
+ <!-- @end ts -->
76
+ <!-- @feature oxlint -->
77
+ | `npm run lint` | Lint with Oxlint |
78
+ <!-- @end oxlint -->
79
+ <!-- @feature prettier -->
80
+ | `npm run format` | Format everything with Prettier |
81
+ | `npm run format:check` | Check formatting (CI) |
82
+ <!-- @end prettier -->
83
+ <!-- @feature vitest -->
84
+ | `npm test` | Unit tests (Vitest) |
85
+ <!-- @end vitest -->
86
+ <!-- @feature playwright -->
87
+ | `npm run test:e2e` | End-to-end tests (first time: `npx playwright install chromium`) |
88
+ <!-- @end playwright -->
89
+ <!-- @feature docker -->
90
+ | `npm run docker:build` | Build the Docker image |
91
+ | `npm run docker:run` | Run it on http://localhost:8080 |
92
+ <!-- @end docker -->
93
+
94
+ ## Project structure
95
+
96
+ ```
97
+ src/
98
+ <!-- @feature router -->
99
+ ├── router.* # routes (React Router)
100
+ ├── pages/ # route pages (About, 404)
101
+ <!-- @end router -->
102
+ ├── components/
103
+ │ ├── home.* # the home page
104
+ │ ├── layout/ # header, footer and the page layout
105
+ <!-- @feature ui -->
106
+ │ └── ui/ # UI components (Button, Card, Input, ...)
107
+ <!-- @end ui -->
108
+ ├── lib/ # helpers (theme, utils)
109
+ ├── styles/app.css # layout & page styles (plain CSS on the theme tokens)
110
+ ├── env.* # environment variables
111
+ └── index.css # theme tokens (light/dark)
112
+ ```
113
+ <!-- @feature router -->
114
+
115
+ ### Add a page
116
+
117
+ 1. Create `src/pages/contact` exporting a component.
118
+ 2. Add `{ path: "contact", Component: Contact }` to the `children` in `src/router`.
119
+ 3. Link to it with `<Link to="/contact">` (or add it to `NAV` in `src/components/layout/site-header`).
120
+ <!-- @end router -->
121
+ <!-- @feature shadcn -->
122
+
123
+ ### Add UI components
124
+
125
+ shadcn/ui is configured (`components.json`):
126
+
127
+ ```bash
128
+ npx shadcn@latest add dialog tabs tooltip
129
+ ```
130
+ <!-- @end shadcn -->
131
+ <!-- @feature docker -->
132
+
133
+ ## Docker
134
+
135
+ ```bash
136
+ docker build -t {{PACKAGE_NAME}} --build-arg VITE_API_URL=https://api.example.com .
137
+ docker run --rm -p 8080:80 {{PACKAGE_NAME}}
138
+ ```
139
+
140
+ The image builds the app with Node and serves `dist/` with nginx (`nginx.conf`): client-side routes
141
+ fall back to `index.html`, and hashed assets are cached for a year.
142
+ <!-- @end docker -->
@@ -0,0 +1,14 @@
1
+ .git
2
+ node_modules
3
+ dist
4
+ npm-debug.log*
5
+ Dockerfile
6
+ .dockerignore
7
+ .env*
8
+ !.env.example
9
+ README.md
10
+ coverage
11
+ playwright-report
12
+ test-results
13
+ .vscode
14
+ .idea
@@ -0,0 +1,8 @@
1
+ # Copy to .env.local (create-mohit-next already did this for you).
2
+ # Only VITE_* variables reach the browser, and they are baked in at build time:
3
+ # never put secrets here.
4
+
5
+ VITE_APP_NAME={{PROJECT_TITLE}}
6
+
7
+ # Base URL of your backend API (optional).
8
+ VITE_API_URL=
@@ -0,0 +1,37 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
25
+
26
+ # env files (.env.example is committed; .env.local holds your values)
27
+ .env
28
+ .env.*
29
+ !.env.example
30
+ # @feature playwright
31
+
32
+ # playwright
33
+ /test-results/
34
+ /playwright-report/
35
+ /blob-report/
36
+ /playwright/.cache/
37
+ # @end playwright
@@ -0,0 +1,41 @@
1
+ import { expect, test } from "@playwright/test";
2
+
3
+ test("home page renders and the counter works", async ({ page }) => {
4
+ await page.goto("/");
5
+ await expect(page.getByRole("heading", { name: "Start building something great" })).toBeVisible();
6
+
7
+ const count = page.getByLabel("Count");
8
+ await expect(count).toHaveText("0");
9
+ await page.getByRole("button", { name: "Increment" }).click();
10
+ await expect(count).toHaveText("1");
11
+ });
12
+
13
+ test("theme can be switched", async ({ page }) => {
14
+ await page.goto("/");
15
+ const html = page.locator("html");
16
+ // @feature ui
17
+ await page.getByRole("button", { name: "Change theme" }).click();
18
+ await page.getByRole("menuitem", { name: "Dark" }).click();
19
+ // @end ui
20
+ // @feature !ui
21
+ // Cycles light -> dark -> system; start from light so one click gives dark.
22
+ await page.evaluate(() => localStorage.setItem("theme", "light"));
23
+ await page.reload();
24
+ await page.getByRole("button", { name: /^Theme: Light/ }).click();
25
+ // @end !ui
26
+ await expect(html).toHaveClass(/dark/);
27
+ });
28
+ // @feature router
29
+
30
+ test("navigation and the 404 page", async ({ page }) => {
31
+ await page.goto("/");
32
+ await page.getByRole("link", { name: "About" }).click();
33
+ await expect(page).toHaveURL(/\/about$/);
34
+ await expect(page.getByRole("heading", { name: "About" })).toBeVisible();
35
+
36
+ await page.goto("/does-not-exist");
37
+ await expect(page.getByRole("heading", { name: "Page not found" })).toBeVisible();
38
+ await page.getByRole("link", { name: "Back home" }).click();
39
+ await expect(page).toHaveURL(/\/$/);
40
+ });
41
+ // @end router
@@ -0,0 +1,32 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <meta name="description" content="{{PROJECT_TITLE}}, built with Vite and React." />
8
+ <title>{{PROJECT_TITLE}}</title>
9
+ <!-- Apply the saved theme before first paint (light / dark / system). -->
10
+ <script>
11
+ (function () {
12
+ try {
13
+ var k = "theme",
14
+ m = window.matchMedia("(prefers-color-scheme: dark)");
15
+ function a() {
16
+ var t = localStorage.getItem(k);
17
+ document.documentElement.classList.toggle(
18
+ "dark",
19
+ t === "dark" || ((!t || t === "system") && m.matches),
20
+ );
21
+ }
22
+ a();
23
+ m.addEventListener("change", a);
24
+ } catch (e) {}
25
+ })();
26
+ </script>
27
+ </head>
28
+ <body>
29
+ <div id="root"></div>
30
+ <script type="module" src="/src/main.tsx"></script>
31
+ </body>
32
+ </html>
@@ -0,0 +1,26 @@
1
+ server {
2
+ listen 80;
3
+ server_name _;
4
+ root /usr/share/nginx/html;
5
+ index index.html;
6
+
7
+ gzip on;
8
+ gzip_types text/plain text/css application/javascript application/json image/svg+xml;
9
+
10
+ add_header X-Content-Type-Options "nosniff" always;
11
+ add_header X-Frame-Options "DENY" always;
12
+ add_header Referrer-Policy "strict-origin-when-cross-origin" always;
13
+
14
+ # Hashed build assets never change: cache them for a year.
15
+ location /assets/ {
16
+ expires 1y;
17
+ add_header Cache-Control "public, immutable";
18
+ try_files $uri =404;
19
+ }
20
+
21
+ # Single-page app: unknown paths fall back to index.html (client-side routing).
22
+ location / {
23
+ add_header Cache-Control "no-cache";
24
+ try_files $uri $uri/ /index.html;
25
+ }
26
+ }
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "my-app",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "preview": "vite preview",
10
+ "typecheck": "tsc -b",
11
+ "lint": "oxlint",
12
+ "lint:fix": "oxlint --fix",
13
+ "format": "prettier --write .",
14
+ "format:check": "prettier --check .",
15
+ "test": "vitest run",
16
+ "test:watch": "vitest",
17
+ "test:e2e": "playwright test",
18
+ "prepare": "husky",
19
+ "docker:build": "docker build -t {{PACKAGE_NAME}} .",
20
+ "docker:run": "docker run --rm -p 8080:80 {{PACKAGE_NAME}}"
21
+ },
22
+ "dependencies": {
23
+ "class-variance-authority": "^0.7.1",
24
+ "cn": "^0.5.2",
25
+ "lucide-react": "^1.73.0",
26
+ "radix-ui": "^1.8.1",
27
+ "react": "^19.3.1",
28
+ "react-dom": "^19.3.1",
29
+ "react-router": "^8.5.1",
30
+ "tw-animate-css": "^1.4.0",
31
+ "zod": "^4.6.7"
32
+ },
33
+ "devDependencies": {
34
+ "@commitlint/cli": "^21.2.4",
35
+ "@commitlint/config-conventional": "^21.2.4",
36
+ "@playwright/test": "^1.65.1",
37
+ "@tailwindcss/vite": "^4.3.5",
38
+ "@testing-library/dom": "^10.4.1",
39
+ "@testing-library/jest-dom": "^7.0.1",
40
+ "@testing-library/react": "^16.3.3",
41
+ "@testing-library/user-event": "^14.6.12",
42
+ "@types/node": "^24.19.2",
43
+ "@types/react": "^19.3.0",
44
+ "@types/react-dom": "^19.3.0",
45
+ "@vitejs/plugin-react": "^6.1.2",
46
+ "husky": "^9.1.7",
47
+ "jsdom": "^31.0.1",
48
+ "lint-staged": "^17.6.1",
49
+ "oxlint": "^1.90.0",
50
+ "prettier": "^3.10.1",
51
+ "prettier-plugin-tailwindcss": "^0.8.1",
52
+ "shadcn": "^4.23.0",
53
+ "tailwindcss": "^4.3.5",
54
+ "typescript": "~7.0.2",
55
+ "vite": "^8.3.6",
56
+ "vitest": "^5.1.0"
57
+ },
58
+ "engines": {
59
+ "node": ">=22.12.0"
60
+ }
61
+ }
@@ -0,0 +1,27 @@
1
+ import { defineConfig, devices } from "@playwright/test";
2
+
3
+ const PORT = 4173;
4
+
5
+ /**
6
+ * End-to-end tests. `npm run test:e2e` builds nothing itself: in CI the
7
+ * workflow runs `npm run build` first and the tests use `vite preview`;
8
+ * locally the dev server is used. First run: `npx playwright install chromium`.
9
+ */
10
+ export default defineConfig({
11
+ testDir: "./e2e",
12
+ fullyParallel: true,
13
+ retries: process.env.CI ? 1 : 0,
14
+ reporter: process.env.CI ? "github" : "list",
15
+ use: {
16
+ baseURL: `http://localhost:${PORT}`,
17
+ trace: "on-first-retry",
18
+ },
19
+ projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
20
+ webServer: {
21
+ command: process.env.CI
22
+ ? `npx vite preview --port ${PORT} --strictPort`
23
+ : `npx vite --port ${PORT} --strictPort`,
24
+ url: `http://localhost:${PORT}`,
25
+ reuseExistingServer: !process.env.CI,
26
+ },
27
+ });
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="46" fill="none" viewBox="0 0 48 46"><path fill="#863bff" d="M25.946 44.938c-.664.845-2.021.375-2.021-.698V33.937a2.26 2.26 0 0 0-2.262-2.262H10.287c-.92 0-1.456-1.04-.92-1.788l7.48-10.471c1.07-1.497 0-3.578-1.842-3.578H1.237c-.92 0-1.456-1.04-.92-1.788L10.013.474c.214-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.471c-1.07 1.498 0 3.579 1.842 3.579h11.377c.943 0 1.473 1.088.89 1.83L25.947 44.94z" style="fill:#863bff;fill:color(display-p3 .5252 .23 1);fill-opacity:1"/><mask id="a" width="48" height="46" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M25.842 44.938c-.664.844-2.021.375-2.021-.698V33.937a2.26 2.26 0 0 0-2.262-2.262H10.183c-.92 0-1.456-1.04-.92-1.788l7.48-10.471c1.07-1.498 0-3.579-1.842-3.579H1.133c-.92 0-1.456-1.04-.92-1.787L9.91.473c.214-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.471c-1.07 1.498 0 3.578 1.842 3.578h11.377c.943 0 1.473 1.088.89 1.832L25.843 44.94z" style="fill:#000;fill-opacity:1"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#ede6ff" rx="5.508" ry="14.704" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -4.47 31.516)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#ede6ff" rx="10.399" ry="29.851" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -39.328 7.883)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#7e14ff" rx="5.508" ry="30.487" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.814 -25.913 -14.639)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#7e14ff" rx="5.508" ry="30.599" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.814 -32.644 -3.334)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#7e14ff" rx="5.508" ry="30.599" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -34.34 30.47)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#ede6ff" rx="14.072" ry="22.078" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="rotate(93.35 24.506 48.493)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#7e14ff" rx="3.47" ry="21.501" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.009 28.708 47.59)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#7e14ff" rx="3.47" ry="21.501" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.009 28.708 47.59)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx=".387" cy="8.972" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(39.51 .387 8.972)"/></g><g filter="url(#k)"><ellipse cx="47.523" cy="-6.092" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 47.523 -6.092)"/></g><g filter="url(#l)"><ellipse cx="41.412" cy="6.333" fill="#47bfff" rx="5.971" ry="9.665" style="fill:#47bfff;fill:color(display-p3 .2799 .748 1);fill-opacity:1" transform="rotate(37.892 41.412 6.333)"/></g><g filter="url(#m)"><ellipse cx="-1.879" cy="38.332" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 -1.88 38.332)"/></g><g filter="url(#n)"><ellipse cx="-1.879" cy="38.332" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 -1.88 38.332)"/></g><g filter="url(#o)"><ellipse cx="35.651" cy="29.907" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 35.651 29.907)"/></g><g filter="url(#p)"><ellipse cx="38.418" cy="32.4" fill="#47bfff" rx="5.971" ry="15.297" style="fill:#47bfff;fill:color(display-p3 .2799 .748 1);fill-opacity:1" transform="rotate(37.892 38.418 32.4)"/></g></g><defs><filter id="b" width="60.045" height="41.654" x="-19.77" y="16.149" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-54.613" y="-7.533" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filter><filter id="d" width="79.355" height="29.4" x="-49.64" y="2.03" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="e" width="79.579" height="29.4" x="-45.045" y="20.029" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="f" width="79.579" height="29.4" x="-43.513" y="21.178" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="g" width="74.749" height="58.852" x="15.756" y="-17.901" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filter><filter id="h" width="61.377" height="25.362" x="23.548" y="2.284" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="i" width="61.377" height="25.362" x="23.548" y="2.284" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="j" width="56.045" height="63.649" x="-27.636" y="-22.853" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="k" width="54.814" height="64.646" x="20.116" y="-38.415" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="l" width="33.541" height="35.313" x="24.641" y="-11.323" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="m" width="54.814" height="64.646" x="-29.286" y="6.009" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="n" width="54.814" height="64.646" x="-29.286" y="6.009" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="o" width="54.814" height="64.646" x="8.244" y="-2.416" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="p" width="39.409" height="43.623" x="18.713" y="10.588" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter></defs></svg>
@@ -0,0 +1,28 @@
1
+ import { render, screen } from "@testing-library/react";
2
+ import userEvent from "@testing-library/user-event";
3
+ import { describe, expect, it } from "vitest";
4
+
5
+ import App from "@/App";
6
+
7
+ describe("App", () => {
8
+ it("renders the home page", async () => {
9
+ render(<App />);
10
+ expect(
11
+ await screen.findByRole("heading", { name: "Start building something great" }),
12
+ ).toBeInTheDocument();
13
+ });
14
+
15
+ it("increments and resets the counter", async () => {
16
+ const user = userEvent.setup();
17
+ render(<App />);
18
+ const count = await screen.findByLabelText("Count");
19
+ expect(count).toHaveTextContent("0");
20
+
21
+ await user.click(screen.getByRole("button", { name: "Increment" }));
22
+ await user.click(screen.getByRole("button", { name: "Increment" }));
23
+ expect(count).toHaveTextContent("2");
24
+
25
+ await user.click(screen.getByRole("button", { name: "Reset" }));
26
+ expect(count).toHaveTextContent("0");
27
+ });
28
+ });
@@ -0,0 +1,26 @@
1
+ // @feature router
2
+ import { RouterProvider } from "react-router/dom";
3
+
4
+ import { router } from "@/router";
5
+
6
+ export default function App() {
7
+ return <RouterProvider router={router} />;
8
+ }
9
+ // @end router
10
+ // @feature !router
11
+ import { Home } from "@/components/home";
12
+ import { SiteFooter } from "@/components/layout/site-footer";
13
+ import { SiteHeader } from "@/components/layout/site-header";
14
+
15
+ export default function App() {
16
+ return (
17
+ <div className="app">
18
+ <SiteHeader />
19
+ <main className="main">
20
+ <Home />
21
+ </main>
22
+ <SiteFooter />
23
+ </div>
24
+ );
25
+ }
26
+ // @end !router