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,358 @@
1
+ /**
2
+ * Everything the CLI can ask, and which files / packages / scripts depend on
3
+ * each answer.
4
+ *
5
+ * Every answer becomes a "key". Keys are used in three places:
6
+ * 1. FILE_RULES - delete a path unless its condition holds
7
+ * 2. package rules - drop a dependency / script unless its condition holds
8
+ * 3. code markers - `// @feature key` ... `// @end key` blocks in template
9
+ * files are kept only when the key is on (`!key` = off)
10
+ *
11
+ * A condition is a key, "!key", "a|b" (either), or an array of those (all must hold).
12
+ *
13
+ * Built-in keys besides the questions below:
14
+ * ts | next | vite | shadcn | tailwind (shadcn or tailwind-only) | css | ui
15
+ */
16
+
17
+ export const LANGUAGES = [
18
+ { value: "ts", label: "TypeScript", hint: "recommended" },
19
+ { value: "js", label: "JavaScript" },
20
+ ];
21
+
22
+ export const FRAMEWORKS = [
23
+ {
24
+ value: "next",
25
+ label: "Next.js",
26
+ hint: "full-stack: MongoDB + auth + RBAC + API routes",
27
+ },
28
+ { value: "vite", label: "Vite + React", hint: "frontend single-page app" },
29
+ ];
30
+
31
+ export const STYLES = [
32
+ { value: "shadcn", label: "Tailwind CSS + shadcn/ui", hint: "recommended" },
33
+ { value: "tailwind", label: "Tailwind CSS only", hint: "hand-written Tailwind components" },
34
+ { value: "css", label: "None", hint: "plain CSS, no Tailwind" },
35
+ ];
36
+
37
+ /** Yes/no questions, asked in this order (grouped by `group`). */
38
+ export const QUESTIONS = [
39
+ // --- Core -----------------------------------------------------------------
40
+ {
41
+ key: "router",
42
+ group: "Core",
43
+ frameworks: ["vite"],
44
+ message: "Add React Router (pages + client-side routing)?",
45
+ },
46
+ {
47
+ key: "ui",
48
+ group: "Core",
49
+ frameworks: ["vite"],
50
+ message: "Add basic UI components (Button, Input, Card, Badge, Table, Dialog...)?",
51
+ },
52
+ {
53
+ key: "env",
54
+ group: "Core",
55
+ frameworks: ["next", "vite"],
56
+ message: "Add environment variables with validation (zod)?",
57
+ },
58
+
59
+ // --- Code quality -----------------------------------------------------------
60
+ {
61
+ key: "eslint",
62
+ group: "Code quality",
63
+ frameworks: ["next"],
64
+ message: "Add ESLint (eslint-config-next)?",
65
+ },
66
+ {
67
+ key: "oxlint",
68
+ group: "Code quality",
69
+ frameworks: ["vite"],
70
+ message: "Add Oxlint (fast linter, the create-vite default)?",
71
+ },
72
+ {
73
+ key: "prettier",
74
+ group: "Code quality",
75
+ frameworks: ["next", "vite"],
76
+ message: "Add Prettier (code formatter)?",
77
+ },
78
+ {
79
+ key: "git-hooks",
80
+ group: "Code quality",
81
+ frameworks: ["next", "vite"],
82
+ message: "Add Git hooks (Husky + lint-staged + commitlint)?",
83
+ // Only useful when there is something to run on commit.
84
+ when: (on) => on("eslint") || on("oxlint") || on("prettier"),
85
+ },
86
+
87
+ // --- Frontend (Next.js) -----------------------------------------------------
88
+ {
89
+ key: "sidebar",
90
+ group: "Frontend",
91
+ frameworks: ["next"],
92
+ message: "Use a sidebar layout for the dashboard? (No = top navbar)",
93
+ },
94
+ {
95
+ key: "data-table",
96
+ group: "Frontend",
97
+ frameworks: ["next"],
98
+ message: "Add an admin users table with search, sorting & pagination?",
99
+ },
100
+ {
101
+ key: "charts",
102
+ group: "Frontend",
103
+ frameworks: ["next"],
104
+ message: "Add charts to the reports page (Recharts)?",
105
+ },
106
+ {
107
+ key: "seo",
108
+ group: "Frontend",
109
+ frameworks: ["next"],
110
+ message: "Add SEO files (sitemap.xml, robots.txt, Open Graph image)?",
111
+ },
112
+
113
+ // --- Backend (Next.js) ------------------------------------------------------
114
+ {
115
+ key: "profile",
116
+ group: "Backend",
117
+ frameworks: ["next"],
118
+ message: "Add a profile & settings page (change name/password, sign out other devices)?",
119
+ },
120
+ {
121
+ key: "email",
122
+ group: "Backend",
123
+ frameworks: ["next"],
124
+ message: "Add forgot-password + email verification (Resend; prints emails in dev)?",
125
+ },
126
+ {
127
+ key: "rate-limit",
128
+ group: "Backend",
129
+ frameworks: ["next"],
130
+ message: "Add rate limiting to the auth endpoints?",
131
+ },
132
+ {
133
+ key: "audit-log",
134
+ group: "Backend",
135
+ frameworks: ["next"],
136
+ message: "Add an audit log of admin actions?",
137
+ },
138
+ {
139
+ key: "seed",
140
+ group: "Backend",
141
+ frameworks: ["next"],
142
+ message: "Add a seed script with demo users (npm run seed)?",
143
+ },
144
+
145
+ // --- Testing ----------------------------------------------------------------
146
+ {
147
+ key: "vitest",
148
+ group: "Testing",
149
+ frameworks: ["next", "vite"],
150
+ message: "Add unit tests with Vitest?",
151
+ },
152
+ {
153
+ key: "playwright",
154
+ group: "Testing",
155
+ frameworks: ["next", "vite"],
156
+ message: "Add end-to-end tests with Playwright?",
157
+ },
158
+
159
+ // --- DevOps -----------------------------------------------------------------
160
+ {
161
+ key: "docker",
162
+ group: "DevOps",
163
+ frameworks: ["next", "vite"],
164
+ message: (fw) =>
165
+ fw === "next"
166
+ ? "Add Docker (Dockerfile + docker-compose with MongoDB)?"
167
+ : "Add Docker (multi-stage build served by nginx)?",
168
+ },
169
+ {
170
+ key: "ci",
171
+ group: "DevOps",
172
+ frameworks: ["next", "vite"],
173
+ message: "Add GitHub Actions CI + Dependabot?",
174
+ },
175
+ {
176
+ key: "editor",
177
+ group: "DevOps",
178
+ frameworks: ["next", "vite"],
179
+ message: "Add VS Code settings + EditorConfig?",
180
+ },
181
+ ];
182
+
183
+ export const QUESTION_KEYS = QUESTIONS.map((q) => q.key);
184
+
185
+ /** Every key a template marker or rule may reference. */
186
+ export const KNOWN_KEYS = new Set([
187
+ ...QUESTION_KEYS,
188
+ "ts",
189
+ "next",
190
+ "vite",
191
+ "shadcn",
192
+ "tailwind",
193
+ "css",
194
+ ]);
195
+
196
+ /**
197
+ * Paths (relative to the generated project) that are deleted unless their
198
+ * condition holds. Paths that don't exist for a framework are ignored.
199
+ */
200
+ export const FILE_RULES = [
201
+ // --- language ---
202
+ { path: "tsconfig.json", when: "ts" },
203
+ { path: "tsconfig.app.json", when: "ts" },
204
+ { path: "tsconfig.node.json", when: "ts" },
205
+
206
+ // --- styling ---
207
+ { path: "components.json", when: "shadcn" },
208
+
209
+ // --- core ---
210
+ { path: "src/lib/env.ts", when: "next" }, // Next.js always needs env access (validated or not)
211
+ { path: "src/env.ts", when: "vite" },
212
+ { path: "src/components/ui", when: "ui" },
213
+ { path: "src/router.ts", when: "router" },
214
+ { path: "src/pages", when: "router" },
215
+ { path: "src/components/layout/root-layout.tsx", when: "router" },
216
+
217
+ // --- code quality ---
218
+ { path: "eslint.config.mjs", when: "eslint" },
219
+ { path: ".oxlintrc.json", when: "oxlint" },
220
+ { path: ".prettierrc", when: "prettier" },
221
+ { path: ".prettierignore", when: "prettier" },
222
+ { path: ".husky", when: "git-hooks" },
223
+ { path: "commitlint.config.mjs", when: "git-hooks" },
224
+
225
+ // --- frontend (next) ---
226
+ { path: "src/components/layout/sidebar.tsx", when: "sidebar" },
227
+ { path: "src/components/layout/navbar.tsx", when: "!sidebar" },
228
+ { path: "src/components/admin/users-data-table.tsx", when: "data-table" },
229
+ { path: "src/components/admin/users-table.tsx", when: "!data-table" },
230
+ { path: "src/components/reports/role-chart.tsx", when: "charts" },
231
+ { path: "src/components/reports/signups-chart.tsx", when: "charts" },
232
+ { path: "src/components/reports/animated-bar.tsx", when: "!charts" },
233
+ { path: "src/app/sitemap.ts", when: "seo" },
234
+ { path: "src/app/robots.ts", when: "seo" },
235
+ { path: "src/app/opengraph-image.tsx", when: "seo" },
236
+ { path: "public/robots.txt", when: "!seo" },
237
+
238
+ // --- backend (next) ---
239
+ { path: "src/app/(app)/settings", when: "profile" },
240
+ { path: "src/components/settings", when: "profile" },
241
+ { path: "src/app/api/account", when: "profile" },
242
+ { path: "src/lib/validations/account.ts", when: "profile" },
243
+
244
+ { path: "src/app/(auth)/forgot-password", when: "email" },
245
+ { path: "src/app/(auth)/reset-password", when: "email" },
246
+ { path: "src/app/verify-email", when: "email" },
247
+ { path: "src/app/api/auth/forgot-password", when: "email" },
248
+ { path: "src/app/api/auth/reset-password", when: "email" },
249
+ { path: "src/app/api/auth/verify-email", when: "email" },
250
+ { path: "src/app/api/auth/resend-verification", when: "email" },
251
+ { path: "src/components/auth/forgot-password-form.tsx", when: "email" },
252
+ { path: "src/components/auth/reset-password-form.tsx", when: "email" },
253
+ { path: "src/components/auth/verify-email-status.tsx", when: "email" },
254
+ { path: "src/components/auth/verify-email-banner.tsx", when: "email" },
255
+ { path: "src/lib/email.ts", when: "email" },
256
+ { path: "src/lib/email-templates.ts", when: "email" },
257
+ { path: "src/lib/tokens.ts", when: "email" },
258
+ { path: "src/models/auth-token.ts", when: "email" },
259
+
260
+ { path: "src/lib/rate-limit.ts", when: "rate-limit" },
261
+
262
+ { path: "src/app/(app)/admin/audit", when: "audit-log" },
263
+ { path: "src/app/api/admin/audit", when: "audit-log" },
264
+ { path: "src/lib/audit.ts", when: "audit-log" },
265
+ { path: "src/models/audit-log.ts", when: "audit-log" },
266
+
267
+ { path: "scripts/seed.ts", when: "seed" },
268
+
269
+ // --- testing ---
270
+ { path: "vitest.config.mts", when: "vitest" },
271
+ { path: "src/test", when: "vitest" },
272
+ { path: "src/config/rbac.test.ts", when: "vitest" },
273
+ { path: "src/lib/redirect.test.ts", when: "vitest" },
274
+ { path: "src/lib/password-strength.test.ts", when: "vitest" },
275
+ { path: "src/lib/validations/auth.test.ts", when: "vitest" },
276
+ { path: "src/lib/rate-limit.test.ts", when: ["vitest", "rate-limit"] },
277
+ { path: "src/App.test.tsx", when: "vitest" },
278
+ { path: "playwright.config.ts", when: "playwright" },
279
+ { path: "e2e", when: "playwright" },
280
+
281
+ // --- devops ---
282
+ { path: "Dockerfile", when: "docker" },
283
+ { path: "docker-compose.yml", when: "docker" },
284
+ { path: ".dockerignore", when: "docker" },
285
+ { path: "nginx.conf", when: "docker" },
286
+ { path: ".github", when: "ci" },
287
+ { path: ".vscode", when: "editor" },
288
+ { path: ".editorconfig", when: "editor" },
289
+ ];
290
+
291
+ /** package.json dependencies kept only when their condition holds (others are always kept). */
292
+ export const PACKAGE_RULES = {
293
+ // language
294
+ typescript: "ts",
295
+ "@types/node": "ts",
296
+ "@types/react": "ts",
297
+ "@types/react-dom": "ts",
298
+ "@types/bcryptjs": "ts",
299
+ // styling
300
+ tailwindcss: "tailwind",
301
+ "@tailwindcss/turbopack": "tailwind",
302
+ "@tailwindcss/vite": "tailwind",
303
+ cn: "tailwind",
304
+ shadcn: "shadcn",
305
+ "radix-ui": "shadcn",
306
+ "class-variance-authority": "shadcn",
307
+ "tw-animate-css": "shadcn",
308
+ // core
309
+ zod: "next|env", // Next.js always uses zod (API + form schemas)
310
+ "react-router": "router",
311
+ // code quality
312
+ eslint: "eslint",
313
+ "eslint-config-next": "eslint",
314
+ "eslint-config-prettier": ["eslint", "prettier"],
315
+ oxlint: "oxlint",
316
+ prettier: "prettier",
317
+ "prettier-plugin-tailwindcss": ["prettier", "tailwind"],
318
+ husky: "git-hooks",
319
+ "lint-staged": "git-hooks",
320
+ "@commitlint/cli": "git-hooks",
321
+ "@commitlint/config-conventional": "git-hooks",
322
+ // features
323
+ recharts: "charts",
324
+ tsx: ["seed", "ts"],
325
+ // testing
326
+ vitest: "vitest",
327
+ jsdom: ["vitest", "vite"],
328
+ "@testing-library/react": ["vitest", "vite"],
329
+ "@testing-library/dom": ["vitest", "vite"],
330
+ "@testing-library/jest-dom": ["vitest", "vite"],
331
+ "@testing-library/user-event": ["vitest", "vite"],
332
+ "@playwright/test": "playwright",
333
+ "mongodb-memory-server": ["playwright", "next"],
334
+ };
335
+
336
+ /** package.json scripts kept only when their condition holds. */
337
+ export const SCRIPT_RULES = {
338
+ typecheck: "ts",
339
+ lint: "eslint|oxlint",
340
+ "lint:fix": "eslint|oxlint",
341
+ format: "prettier",
342
+ "format:check": "prettier",
343
+ prepare: "git-hooks",
344
+ seed: "seed",
345
+ test: "vitest",
346
+ "test:watch": "vitest",
347
+ "test:e2e": "playwright",
348
+ "docker:db": "docker",
349
+ "docker:up": "docker",
350
+ "docker:down": "docker",
351
+ "docker:build": "docker",
352
+ "docker:run": "docker",
353
+ };
354
+
355
+ /** Top-level package.json keys kept only when their condition holds. */
356
+ export const PACKAGE_KEY_RULES = {
357
+ "lint-staged": "git-hooks",
358
+ };