create-fate 0.0.0 → 1.0.0-rc.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 (266) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -0
  3. package/bin/create-fate.mjs +333 -0
  4. package/package.json +26 -3
  5. package/templates/fate/README.md +8 -0
  6. package/templates/fate/drizzle/.github/workflows/push.yml +27 -0
  7. package/templates/fate/drizzle/.oxfmtrc.jsonc +23 -0
  8. package/templates/fate/drizzle/.vite-hooks/pre-commit +1 -0
  9. package/templates/fate/drizzle/.vscode/extensions.json +12 -0
  10. package/templates/fate/drizzle/.vscode/settings.json +25 -0
  11. package/templates/fate/drizzle/AGENTS.md +55 -0
  12. package/templates/fate/drizzle/README.md +77 -0
  13. package/templates/fate/drizzle/_gitignore +18 -0
  14. package/templates/fate/drizzle/client/package.json +58 -0
  15. package/templates/fate/drizzle/client/pages/index.tsx +96 -0
  16. package/templates/fate/drizzle/client/pages/layout.tsx +94 -0
  17. package/templates/fate/drizzle/client/pages/login.tsx +107 -0
  18. package/templates/fate/drizzle/client/pages/post/[id].tsx +22 -0
  19. package/templates/fate/drizzle/client/pages/search.tsx +95 -0
  20. package/templates/fate/drizzle/client/public/icon.svg +1 -0
  21. package/templates/fate/drizzle/client/src/App.css +153 -0
  22. package/templates/fate/drizzle/client/src/lib/AvailableLanguages.tsx +5 -0
  23. package/templates/fate/drizzle/client/src/lib/cx.tsx +6 -0
  24. package/templates/fate/drizzle/client/src/lib/env.tsx +5 -0
  25. package/templates/fate/drizzle/client/src/ui/Badge.tsx +31 -0
  26. package/templates/fate/drizzle/client/src/ui/Button.tsx +108 -0
  27. package/templates/fate/drizzle/client/src/ui/Card.tsx +32 -0
  28. package/templates/fate/drizzle/client/src/ui/CommentCard.tsx +75 -0
  29. package/templates/fate/drizzle/client/src/ui/Error.tsx +19 -0
  30. package/templates/fate/drizzle/client/src/ui/H2.tsx +15 -0
  31. package/templates/fate/drizzle/client/src/ui/H3.tsx +20 -0
  32. package/templates/fate/drizzle/client/src/ui/Header.tsx +96 -0
  33. package/templates/fate/drizzle/client/src/ui/Input.tsx +17 -0
  34. package/templates/fate/drizzle/client/src/ui/Link.tsx +11 -0
  35. package/templates/fate/drizzle/client/src/ui/LocaleSwitcher.tsx +52 -0
  36. package/templates/fate/drizzle/client/src/ui/PostCard.tsx +281 -0
  37. package/templates/fate/drizzle/client/src/ui/Section.tsx +23 -0
  38. package/templates/fate/drizzle/client/src/ui/UserCard.tsx +131 -0
  39. package/templates/fate/drizzle/client/src/user/AuthClient.tsx +6 -0
  40. package/templates/fate/drizzle/client/translations/de_DE.json +689 -0
  41. package/templates/fate/drizzle/client/translations/ja_JP.json +689 -0
  42. package/templates/fate/drizzle/client/vite.config.ts +37 -0
  43. package/templates/fate/drizzle/client/void.json +29 -0
  44. package/templates/fate/drizzle/docker-compose.yml +11 -0
  45. package/templates/fate/drizzle/package.json +46 -0
  46. package/templates/fate/drizzle/pnpm-workspace.yaml +36 -0
  47. package/templates/fate/drizzle/public/fate-logo-dark.svg +4 -0
  48. package/templates/fate/drizzle/public/fate-logo.svg +4 -0
  49. package/templates/fate/drizzle/server/.env.example +5 -0
  50. package/templates/fate/drizzle/server/drizzle.config.ts +11 -0
  51. package/templates/fate/drizzle/server/package.json +48 -0
  52. package/templates/fate/drizzle/server/src/__tests__/index.test.tsx +5 -0
  53. package/templates/fate/drizzle/server/src/app.tsx +40 -0
  54. package/templates/fate/drizzle/server/src/drizzle/db.ts +25 -0
  55. package/templates/fate/drizzle/server/src/drizzle/queries.ts +89 -0
  56. package/templates/fate/drizzle/server/src/drizzle/schema.ts +174 -0
  57. package/templates/fate/drizzle/server/src/drizzle/seed.tsx +77 -0
  58. package/templates/fate/drizzle/server/src/drizzle/seedData.ts +205 -0
  59. package/templates/fate/drizzle/server/src/index.tsx +24 -0
  60. package/templates/fate/drizzle/server/src/lib/auth.ts +33 -0
  61. package/templates/fate/drizzle/server/src/lib/env.ts +3 -0
  62. package/templates/fate/drizzle/server/src/lib/origins.ts +18 -0
  63. package/templates/fate/drizzle/server/src/router.ts +14 -0
  64. package/templates/fate/drizzle/server/src/trpc/connection.ts +4 -0
  65. package/templates/fate/drizzle/server/src/trpc/context.ts +22 -0
  66. package/templates/fate/drizzle/server/src/trpc/init.ts +19 -0
  67. package/templates/fate/drizzle/server/src/trpc/routers/comment.ts +140 -0
  68. package/templates/fate/drizzle/server/src/trpc/routers/post.ts +95 -0
  69. package/templates/fate/drizzle/server/src/trpc/routers/user.ts +68 -0
  70. package/templates/fate/drizzle/server/src/trpc/views.ts +75 -0
  71. package/templates/fate/drizzle/server/src/user/SessionUser.tsx +17 -0
  72. package/templates/fate/drizzle/server/vite.config.ts +8 -0
  73. package/templates/fate/drizzle/tsconfig.json +33 -0
  74. package/templates/fate/drizzle/vite.config.ts +71 -0
  75. package/templates/fate/http/.github/workflows/push.yml +27 -0
  76. package/templates/fate/http/.oxfmtrc.jsonc +23 -0
  77. package/templates/fate/http/.vite-hooks/pre-commit +1 -0
  78. package/templates/fate/http/.vscode/extensions.json +12 -0
  79. package/templates/fate/http/.vscode/settings.json +25 -0
  80. package/templates/fate/http/AGENTS.md +55 -0
  81. package/templates/fate/http/README.md +77 -0
  82. package/templates/fate/http/_gitignore +18 -0
  83. package/templates/fate/http/client/package.json +56 -0
  84. package/templates/fate/http/client/pages/index.tsx +96 -0
  85. package/templates/fate/http/client/pages/layout.tsx +89 -0
  86. package/templates/fate/http/client/pages/login.tsx +107 -0
  87. package/templates/fate/http/client/pages/post/[id].tsx +22 -0
  88. package/templates/fate/http/client/pages/search.tsx +95 -0
  89. package/templates/fate/http/client/public/icon.svg +1 -0
  90. package/templates/fate/http/client/src/App.css +153 -0
  91. package/templates/fate/http/client/src/lib/AvailableLanguages.tsx +5 -0
  92. package/templates/fate/http/client/src/lib/cx.tsx +6 -0
  93. package/templates/fate/http/client/src/lib/env.tsx +5 -0
  94. package/templates/fate/http/client/src/ui/Badge.tsx +31 -0
  95. package/templates/fate/http/client/src/ui/Button.tsx +108 -0
  96. package/templates/fate/http/client/src/ui/Card.tsx +32 -0
  97. package/templates/fate/http/client/src/ui/CommentCard.tsx +75 -0
  98. package/templates/fate/http/client/src/ui/Error.tsx +19 -0
  99. package/templates/fate/http/client/src/ui/H2.tsx +15 -0
  100. package/templates/fate/http/client/src/ui/H3.tsx +20 -0
  101. package/templates/fate/http/client/src/ui/Header.tsx +96 -0
  102. package/templates/fate/http/client/src/ui/Input.tsx +17 -0
  103. package/templates/fate/http/client/src/ui/Link.tsx +11 -0
  104. package/templates/fate/http/client/src/ui/LocaleSwitcher.tsx +52 -0
  105. package/templates/fate/http/client/src/ui/PostCard.tsx +281 -0
  106. package/templates/fate/http/client/src/ui/Section.tsx +23 -0
  107. package/templates/fate/http/client/src/ui/UserCard.tsx +131 -0
  108. package/templates/fate/http/client/src/user/AuthClient.tsx +6 -0
  109. package/templates/fate/http/client/translations/de_DE.json +689 -0
  110. package/templates/fate/http/client/translations/ja_JP.json +689 -0
  111. package/templates/fate/http/client/vite.config.ts +38 -0
  112. package/templates/fate/http/client/void.json +29 -0
  113. package/templates/fate/http/docker-compose.yml +11 -0
  114. package/templates/fate/http/package.json +46 -0
  115. package/templates/fate/http/pnpm-workspace.yaml +36 -0
  116. package/templates/fate/http/public/fate-logo-dark.svg +4 -0
  117. package/templates/fate/http/public/fate-logo.svg +4 -0
  118. package/templates/fate/http/server/.env.example +5 -0
  119. package/templates/fate/http/server/drizzle.config.ts +11 -0
  120. package/templates/fate/http/server/package.json +46 -0
  121. package/templates/fate/http/server/src/__tests__/index.test.tsx +5 -0
  122. package/templates/fate/http/server/src/app.tsx +36 -0
  123. package/templates/fate/http/server/src/drizzle/db.ts +25 -0
  124. package/templates/fate/http/server/src/drizzle/queries.ts +89 -0
  125. package/templates/fate/http/server/src/drizzle/schema.ts +174 -0
  126. package/templates/fate/http/server/src/drizzle/seed.tsx +77 -0
  127. package/templates/fate/http/server/src/drizzle/seedData.ts +205 -0
  128. package/templates/fate/http/server/src/fate/context.ts +20 -0
  129. package/templates/fate/http/server/src/fate/server.ts +285 -0
  130. package/templates/fate/http/server/src/fate/views.ts +75 -0
  131. package/templates/fate/http/server/src/index.tsx +24 -0
  132. package/templates/fate/http/server/src/lib/auth.ts +33 -0
  133. package/templates/fate/http/server/src/lib/env.ts +3 -0
  134. package/templates/fate/http/server/src/lib/origins.ts +18 -0
  135. package/templates/fate/http/server/src/router.ts +2 -0
  136. package/templates/fate/http/server/src/user/SessionUser.tsx +17 -0
  137. package/templates/fate/http/server/vite.config.ts +8 -0
  138. package/templates/fate/http/tsconfig.json +33 -0
  139. package/templates/fate/http/vite.config.ts +71 -0
  140. package/templates/fate/prisma/.github/workflows/push.yml +27 -0
  141. package/templates/fate/prisma/.oxfmtrc.jsonc +23 -0
  142. package/templates/fate/prisma/.vite-hooks/pre-commit +1 -0
  143. package/templates/fate/prisma/.vscode/extensions.json +12 -0
  144. package/templates/fate/prisma/.vscode/settings.json +25 -0
  145. package/templates/fate/prisma/AGENTS.md +55 -0
  146. package/templates/fate/prisma/README.md +79 -0
  147. package/templates/fate/prisma/_gitignore +18 -0
  148. package/templates/fate/prisma/client/package.json +58 -0
  149. package/templates/fate/prisma/client/pages/index.tsx +96 -0
  150. package/templates/fate/prisma/client/pages/layout.tsx +94 -0
  151. package/templates/fate/prisma/client/pages/login.tsx +107 -0
  152. package/templates/fate/prisma/client/pages/post/[id].tsx +22 -0
  153. package/templates/fate/prisma/client/pages/search.tsx +95 -0
  154. package/templates/fate/prisma/client/public/icon.svg +1 -0
  155. package/templates/fate/prisma/client/src/App.css +153 -0
  156. package/templates/fate/prisma/client/src/lib/AvailableLanguages.tsx +5 -0
  157. package/templates/fate/prisma/client/src/lib/cx.tsx +6 -0
  158. package/templates/fate/prisma/client/src/lib/env.tsx +5 -0
  159. package/templates/fate/prisma/client/src/ui/Badge.tsx +31 -0
  160. package/templates/fate/prisma/client/src/ui/Button.tsx +108 -0
  161. package/templates/fate/prisma/client/src/ui/Card.tsx +32 -0
  162. package/templates/fate/prisma/client/src/ui/CommentCard.tsx +75 -0
  163. package/templates/fate/prisma/client/src/ui/Error.tsx +19 -0
  164. package/templates/fate/prisma/client/src/ui/H2.tsx +15 -0
  165. package/templates/fate/prisma/client/src/ui/H3.tsx +20 -0
  166. package/templates/fate/prisma/client/src/ui/Header.tsx +96 -0
  167. package/templates/fate/prisma/client/src/ui/Input.tsx +17 -0
  168. package/templates/fate/prisma/client/src/ui/Link.tsx +11 -0
  169. package/templates/fate/prisma/client/src/ui/LocaleSwitcher.tsx +52 -0
  170. package/templates/fate/prisma/client/src/ui/PostCard.tsx +281 -0
  171. package/templates/fate/prisma/client/src/ui/Section.tsx +23 -0
  172. package/templates/fate/prisma/client/src/ui/UserCard.tsx +131 -0
  173. package/templates/fate/prisma/client/src/user/AuthClient.tsx +6 -0
  174. package/templates/fate/prisma/client/translations/de_DE.json +689 -0
  175. package/templates/fate/prisma/client/translations/ja_JP.json +689 -0
  176. package/templates/fate/prisma/client/vite.config.ts +37 -0
  177. package/templates/fate/prisma/client/void.json +29 -0
  178. package/templates/fate/prisma/docker-compose.yml +11 -0
  179. package/templates/fate/prisma/package.json +47 -0
  180. package/templates/fate/prisma/pnpm-workspace.yaml +39 -0
  181. package/templates/fate/prisma/public/fate-logo-dark.svg +4 -0
  182. package/templates/fate/prisma/public/fate-logo.svg +4 -0
  183. package/templates/fate/prisma/server/.env.example +5 -0
  184. package/templates/fate/prisma/server/package.json +42 -0
  185. package/templates/fate/prisma/server/prisma.config.ts +21 -0
  186. package/templates/fate/prisma/server/src/__tests__/index.test.tsx +5 -0
  187. package/templates/fate/prisma/server/src/app.tsx +40 -0
  188. package/templates/fate/prisma/server/src/index.tsx +24 -0
  189. package/templates/fate/prisma/server/src/lib/auth.ts +31 -0
  190. package/templates/fate/prisma/server/src/lib/env.ts +3 -0
  191. package/templates/fate/prisma/server/src/lib/origins.ts +18 -0
  192. package/templates/fate/prisma/server/src/prisma/prisma.ts +9 -0
  193. package/templates/fate/prisma/server/src/prisma/schema.prisma +98 -0
  194. package/templates/fate/prisma/server/src/prisma/seed.tsx +71 -0
  195. package/templates/fate/prisma/server/src/prisma/seedData.ts +205 -0
  196. package/templates/fate/prisma/server/src/router.ts +14 -0
  197. package/templates/fate/prisma/server/src/trpc/connection.ts +4 -0
  198. package/templates/fate/prisma/server/src/trpc/context.ts +22 -0
  199. package/templates/fate/prisma/server/src/trpc/init.ts +8 -0
  200. package/templates/fate/prisma/server/src/trpc/routers/comment.ts +176 -0
  201. package/templates/fate/prisma/server/src/trpc/routers/post.ts +154 -0
  202. package/templates/fate/prisma/server/src/trpc/routers/user.ts +71 -0
  203. package/templates/fate/prisma/server/src/trpc/views.ts +77 -0
  204. package/templates/fate/prisma/server/src/user/SessionUser.tsx +17 -0
  205. package/templates/fate/prisma/server/vite.config.ts +8 -0
  206. package/templates/fate/prisma/tsconfig.json +33 -0
  207. package/templates/fate/prisma/vite.config.ts +72 -0
  208. package/templates/fate/void/.oxfmtrc.jsonc +14 -0
  209. package/templates/fate/void/README.md +18 -0
  210. package/templates/fate/void/auth.ts +22 -0
  211. package/templates/fate/void/db/migrations/20260508073357_initial_schema.sql +133 -0
  212. package/templates/fate/void/db/migrations/20260508120500_seed_void_demo.sql +170 -0
  213. package/templates/fate/void/db/migrations/meta/20260508073357_snapshot.json +868 -0
  214. package/templates/fate/void/db/migrations/meta/_journal.json +20 -0
  215. package/templates/fate/void/db/queries.ts +211 -0
  216. package/templates/fate/void/db/schema.ts +325 -0
  217. package/templates/fate/void/db/seed-auth.ts +31 -0
  218. package/templates/fate/void/db/seed.ts +163 -0
  219. package/templates/fate/void/middleware/01.shared.ts +29 -0
  220. package/templates/fate/void/package.json +62 -0
  221. package/templates/fate/void/pages/category/[id].tsx +23 -0
  222. package/templates/fate/void/pages/index.tsx +153 -0
  223. package/templates/fate/void/pages/layout.tsx +46 -0
  224. package/templates/fate/void/pages/login.tsx +103 -0
  225. package/templates/fate/void/pages/post/[id].tsx +20 -0
  226. package/templates/fate/void/pages/search.tsx +81 -0
  227. package/templates/fate/void/pnpm-workspace.yaml +31 -0
  228. package/templates/fate/void/public/.assetsignore +1 -0
  229. package/templates/fate/void/public/icon.svg +1 -0
  230. package/templates/fate/void/routes/fate-live.ts +8 -0
  231. package/templates/fate/void/routes/fate.ts +8 -0
  232. package/templates/fate/void/seedData.ts +535 -0
  233. package/templates/fate/void/src/App.css +130 -0
  234. package/templates/fate/void/src/fate/__tests__/commentPermissions.test.ts +31 -0
  235. package/templates/fate/void/src/fate/commentPermissions.ts +17 -0
  236. package/templates/fate/void/src/fate/context.ts +15 -0
  237. package/templates/fate/void/src/fate/live.ts +6 -0
  238. package/templates/fate/void/src/fate/server.ts +401 -0
  239. package/templates/fate/void/src/fate/views.ts +164 -0
  240. package/templates/fate/void/src/lib/cx.tsx +6 -0
  241. package/templates/fate/void/src/lib/formatLabel.tsx +6 -0
  242. package/templates/fate/void/src/lib/shared.ts +10 -0
  243. package/templates/fate/void/src/ui/Badge.tsx +31 -0
  244. package/templates/fate/void/src/ui/Button.tsx +92 -0
  245. package/templates/fate/void/src/ui/Card.tsx +29 -0
  246. package/templates/fate/void/src/ui/CategoryCard.tsx +105 -0
  247. package/templates/fate/void/src/ui/CommentCard.tsx +80 -0
  248. package/templates/fate/void/src/ui/CreatePost.tsx +111 -0
  249. package/templates/fate/void/src/ui/Error.tsx +19 -0
  250. package/templates/fate/void/src/ui/EventCard.tsx +152 -0
  251. package/templates/fate/void/src/ui/H2.tsx +15 -0
  252. package/templates/fate/void/src/ui/H3.tsx +20 -0
  253. package/templates/fate/void/src/ui/Header.tsx +96 -0
  254. package/templates/fate/void/src/ui/Input.tsx +33 -0
  255. package/templates/fate/void/src/ui/Link.tsx +11 -0
  256. package/templates/fate/void/src/ui/Number.tsx +5 -0
  257. package/templates/fate/void/src/ui/PostCard.tsx +294 -0
  258. package/templates/fate/void/src/ui/Section.tsx +23 -0
  259. package/templates/fate/void/src/ui/TagBadge.tsx +23 -0
  260. package/templates/fate/void/src/ui/UserCard.tsx +129 -0
  261. package/templates/fate/void/src/user/AuthClient.tsx +1 -0
  262. package/templates/fate/void/src/user/SessionUser.tsx +17 -0
  263. package/templates/fate/void/tsconfig.json +34 -0
  264. package/templates/fate/void/vite.config.ts +76 -0
  265. package/templates/fate/void/void.json +32 -0
  266. package/templates/fate/void/wrangler.jsonc +16 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Nakazawa Tech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # create-fate
2
+
3
+ Create a new fate app:
4
+
5
+ ```sh
6
+ vp create fate my-app
7
+ ```
8
+
9
+ Choose between these templates:
10
+
11
+ - `void`: Void pages router with Drizzle.
12
+ - `drizzle`: tRPC with Drizzle.
13
+ - `http`: Native HTTP with Drizzle.
14
+ - `prisma`: tRPC with Prisma.
15
+
16
+ For a non-interactive install:
17
+
18
+ ```sh
19
+ vp create fate my-app --template void
20
+ ```
21
+
22
+ The template sources live in `packages/create-fate/templates/fate`.
@@ -0,0 +1,333 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import process from 'node:process';
5
+ import { fileURLToPath, URL } from 'node:url';
6
+ import { cancel, intro, isCancel, outro, select, text } from '@clack/prompts';
7
+
8
+ const variants = {
9
+ drizzle: {
10
+ description: 'tRPC with Drizzle',
11
+ label: 'Drizzle',
12
+ template: 'drizzle',
13
+ },
14
+ http: {
15
+ description: 'Native HTTP with Drizzle',
16
+ label: 'Native HTTP',
17
+ template: 'http',
18
+ },
19
+ prisma: {
20
+ description: 'tRPC with Prisma',
21
+ label: 'Prisma',
22
+ template: 'prisma',
23
+ },
24
+ void: {
25
+ description: 'Void with void-fate and Drizzle',
26
+ label: 'Void',
27
+ template: 'void',
28
+ },
29
+ };
30
+
31
+ const fateDependencyNames = ['@nkzw/fate', 'react-fate', 'void-fate'];
32
+
33
+ const usage = () => {
34
+ process.stdout.write(`Usage: create-fate [directory] [--template void|drizzle|http|prisma]
35
+
36
+ Create a new fate app.
37
+
38
+ Options:
39
+ --template, -t Template variant to create
40
+ --help, -h Show this help message
41
+ `);
42
+ };
43
+
44
+ const normalizePackageName = (name) =>
45
+ name
46
+ .trim()
47
+ .toLowerCase()
48
+ .replaceAll(/[^a-z0-9._-]+/g, '-')
49
+ .replaceAll(/^-+|-+$/g, '') || 'my-app';
50
+
51
+ const parseArgs = (args) => {
52
+ let targetDir;
53
+ let variant;
54
+
55
+ for (let index = 0; index < args.length; index += 1) {
56
+ const arg = args[index];
57
+ if (arg === '--help' || arg === '-h') {
58
+ return { help: true };
59
+ }
60
+
61
+ if (arg === '--template' || arg === '-t' || arg === '--variant') {
62
+ variant = args[++index];
63
+ continue;
64
+ }
65
+
66
+ if (arg?.startsWith('--template=')) {
67
+ variant = arg.slice('--template='.length);
68
+ continue;
69
+ }
70
+
71
+ if (arg?.startsWith('--variant=')) {
72
+ variant = arg.slice('--variant='.length);
73
+ continue;
74
+ }
75
+
76
+ if (!targetDir) {
77
+ targetDir = arg;
78
+ continue;
79
+ }
80
+
81
+ throw new Error(`Unexpected argument: ${arg}`);
82
+ }
83
+
84
+ return { targetDir, variant };
85
+ };
86
+
87
+ const validateTargetDir = (value) => {
88
+ const targetDir = value?.trim();
89
+ if (!targetDir) {
90
+ throw new Error('Target directory is required.');
91
+ }
92
+
93
+ const normalized = path.normalize(targetDir);
94
+ if (
95
+ !path.isAbsolute(normalized) &&
96
+ (normalized === '.' || normalized.startsWith('..') || normalized.includes(`${path.sep}..`))
97
+ ) {
98
+ throw new Error('Target directory cannot escape the current directory.');
99
+ }
100
+
101
+ return normalized;
102
+ };
103
+
104
+ const validateTargetDirInput = (value) => {
105
+ try {
106
+ validateTargetDir(value || 'my-app');
107
+ return;
108
+ } catch (error) {
109
+ return error instanceof Error ? error.message : String(error);
110
+ }
111
+ };
112
+
113
+ const abortPrompt = () => {
114
+ cancel('Create fate app cancelled.');
115
+ process.exit(0);
116
+ };
117
+
118
+ const promptForTargetDir = async () => {
119
+ const result = await text({
120
+ defaultValue: 'my-app',
121
+ message: 'Project directory',
122
+ placeholder: 'my-app',
123
+ validate: validateTargetDirInput,
124
+ });
125
+
126
+ if (isCancel(result)) {
127
+ abortPrompt();
128
+ }
129
+
130
+ return result;
131
+ };
132
+
133
+ const promptForVariant = async () => {
134
+ const result = await select({
135
+ message: 'Select a fate template',
136
+ options: Object.entries(variants).map(([value, variant]) => ({
137
+ hint: variant.description,
138
+ label: variant.label,
139
+ value,
140
+ })),
141
+ });
142
+
143
+ if (isCancel(result)) {
144
+ abortPrompt();
145
+ }
146
+
147
+ return result;
148
+ };
149
+
150
+ const getRegistryURL = () => {
151
+ const registry = process.env.npm_config_registry || 'https://registry.npmjs.org/';
152
+ return registry.endsWith('/') ? registry : `${registry}/`;
153
+ };
154
+
155
+ const fetchLatestPackageVersion = async (packageName) => {
156
+ const response = await globalThis.fetch(
157
+ new URL(encodeURIComponent(packageName), getRegistryURL()),
158
+ );
159
+ if (!response.ok) {
160
+ throw new Error(`Could not fetch ${packageName} from npm registry.`);
161
+ }
162
+
163
+ const metadata = await response.json();
164
+ const version = metadata?.['dist-tags']?.latest;
165
+ if (typeof version !== 'string' || !version) {
166
+ throw new Error(`Could not resolve latest version for ${packageName}.`);
167
+ }
168
+
169
+ return version;
170
+ };
171
+
172
+ const collectFateDependencies = (dir, dependencies = new Set()) => {
173
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
174
+ if (entry.name === 'node_modules' || entry.name === '.git') {
175
+ continue;
176
+ }
177
+
178
+ const entryPath = path.join(dir, entry.name);
179
+ if (entry.isDirectory()) {
180
+ collectFateDependencies(entryPath, dependencies);
181
+ continue;
182
+ }
183
+
184
+ if (entry.name !== 'package.json') {
185
+ continue;
186
+ }
187
+
188
+ const json = JSON.parse(fs.readFileSync(entryPath, 'utf8'));
189
+ for (const dependencyType of ['dependencies', 'devDependencies', 'peerDependencies']) {
190
+ const packageDependencies = json[dependencyType];
191
+ if (!packageDependencies) {
192
+ continue;
193
+ }
194
+
195
+ for (const dependencyName of fateDependencyNames) {
196
+ if (packageDependencies[dependencyName]) {
197
+ dependencies.add(dependencyName);
198
+ }
199
+ }
200
+ }
201
+ }
202
+
203
+ return dependencies;
204
+ };
205
+
206
+ const resolveFateDependencyVersions = async (rootDir) => {
207
+ const dependencies = [...collectFateDependencies(rootDir)];
208
+ return Object.fromEntries(
209
+ await Promise.all(
210
+ dependencies.map(async (dependencyName) => [
211
+ dependencyName,
212
+ `^${await fetchLatestPackageVersion(dependencyName)}`,
213
+ ]),
214
+ ),
215
+ );
216
+ };
217
+
218
+ const updatePackageJsonFiles = (rootDir, dir, packageName, fateDependencyVersions) => {
219
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
220
+ if (entry.name === 'node_modules' || entry.name === '.git') {
221
+ continue;
222
+ }
223
+
224
+ const entryPath = path.join(dir, entry.name);
225
+ if (entry.isDirectory()) {
226
+ updatePackageJsonFiles(rootDir, entryPath, packageName, fateDependencyVersions);
227
+ continue;
228
+ }
229
+
230
+ if (entry.name !== 'package.json') {
231
+ continue;
232
+ }
233
+
234
+ const json = JSON.parse(fs.readFileSync(entryPath, 'utf8'));
235
+ if (entryPath === path.join(rootDir, 'package.json')) {
236
+ json.name = packageName;
237
+ }
238
+
239
+ for (const dependencyType of ['dependencies', 'devDependencies', 'peerDependencies']) {
240
+ const dependencies = json[dependencyType];
241
+ if (!dependencies) {
242
+ continue;
243
+ }
244
+
245
+ for (const [dependencyName, version] of Object.entries(fateDependencyVersions)) {
246
+ if (dependencies[dependencyName]) {
247
+ dependencies[dependencyName] = version;
248
+ }
249
+ }
250
+ }
251
+
252
+ fs.writeFileSync(entryPath, `${JSON.stringify(json, null, 2)}\n`);
253
+ }
254
+ };
255
+
256
+ const restoreTemplateFileNames = (dir) => {
257
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
258
+ const entryPath = path.join(dir, entry.name);
259
+ if (entry.isDirectory()) {
260
+ restoreTemplateFileNames(entryPath);
261
+ continue;
262
+ }
263
+
264
+ if (entry.name === '_gitignore') {
265
+ fs.renameSync(entryPath, path.join(dir, '.gitignore'));
266
+ }
267
+ }
268
+ };
269
+
270
+ const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
271
+
272
+ const resolveTemplateRoot = (template) => {
273
+ const templateRoot = path.resolve(packageRoot, 'templates', 'fate', template);
274
+ if (!fs.existsSync(templateRoot)) {
275
+ throw new Error(`Template '${template}' could not be found.`);
276
+ }
277
+
278
+ return templateRoot;
279
+ };
280
+
281
+ const main = async () => {
282
+ const options = parseArgs(process.argv.slice(2));
283
+ if (options.help) {
284
+ usage();
285
+ return;
286
+ }
287
+
288
+ const interactive = process.stdin.isTTY && process.stdout.isTTY;
289
+ if (interactive) {
290
+ intro('create-fate');
291
+ }
292
+
293
+ const selectedVariant = options.variant ?? (interactive ? await promptForVariant() : 'void');
294
+ if (!selectedVariant || !variants[selectedVariant]) {
295
+ throw new Error(
296
+ `Unknown template '${selectedVariant}'. Expected one of: ${Object.keys(variants).join(', ')}.`,
297
+ );
298
+ }
299
+
300
+ const targetDir = validateTargetDir(
301
+ options.targetDir ?? (interactive ? await promptForTargetDir() : 'my-app'),
302
+ );
303
+ const targetPath = path.resolve(process.cwd(), targetDir);
304
+ if (fs.existsSync(targetPath) && fs.readdirSync(targetPath).length > 0) {
305
+ throw new Error(`Target directory '${targetDir}' is not empty.`);
306
+ }
307
+
308
+ const templateRoot = resolveTemplateRoot(variants[selectedVariant].template);
309
+ const fateDependencyVersions = await resolveFateDependencyVersions(templateRoot);
310
+ fs.mkdirSync(targetPath, { recursive: true });
311
+ fs.cpSync(templateRoot, targetPath, { recursive: true });
312
+ restoreTemplateFileNames(targetPath);
313
+ updatePackageJsonFiles(
314
+ targetPath,
315
+ targetPath,
316
+ normalizePackageName(path.basename(targetDir)),
317
+ fateDependencyVersions,
318
+ );
319
+
320
+ const message = `Created ${variants[selectedVariant].label} fate app in ${targetDir}`;
321
+ if (interactive) {
322
+ outro(message);
323
+ } else {
324
+ process.stdout.write(`${message}\n`);
325
+ }
326
+ };
327
+
328
+ try {
329
+ await main();
330
+ } catch (error) {
331
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
332
+ process.exit(1);
333
+ }
package/package.json CHANGED
@@ -1,7 +1,30 @@
1
1
  {
2
2
  "name": "create-fate",
3
- "version": "0.0.0",
4
- "description": "",
3
+ "version": "1.0.0-rc.0",
4
+ "description": "Create a new fate app.",
5
+ "homepage": "https://github.com/nkzw-tech/fate",
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "Christoph Nakazawa",
9
+ "email": "christoph.pojer@gmail.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/nkzw-tech/fate",
14
+ "directory": "packages/create-fate"
15
+ },
16
+ "bin": {
17
+ "create-fate": "./bin/create-fate.mjs"
18
+ },
19
+ "files": [
20
+ "bin",
21
+ "templates"
22
+ ],
5
23
  "type": "module",
6
- "main": "index.js"
24
+ "dependencies": {
25
+ "@clack/prompts": "^0.11.0"
26
+ },
27
+ "engines": {
28
+ "node": ">=24.0.0"
29
+ }
7
30
  }
@@ -0,0 +1,8 @@
1
+ # fate Templates
2
+
3
+ This directory is the canonical source for fate project scaffolds.
4
+
5
+ - `void/` contains the Void pages router + Drizzle template.
6
+ - `drizzle/` contains the tRPC + Drizzle template.
7
+ - `http/` contains the native HTTP + Drizzle template.
8
+ - `prisma/` contains the tRPC + Prisma template.
@@ -0,0 +1,27 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ node-version: [24]
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: voidzero-dev/setup-vp@v1
20
+ with:
21
+ node-version: ${{ matrix.node-version }}
22
+ cache: true
23
+ run-install: true
24
+ - run: |
25
+ vp run dev:setup
26
+ vp run test:all
27
+ vp run build
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
+ "singleQuote": true,
4
+ "experimentalSortImports": {
5
+ "newlinesBetween": false,
6
+ },
7
+ "experimentalSortPackageJson": {
8
+ "sortScripts": true,
9
+ },
10
+ "experimentalTailwindcss": {
11
+ "stylesheet": "client/src/App.css",
12
+ },
13
+ "ignorePatterns": [
14
+ "client/dist/",
15
+ "client/index.html",
16
+ "client/src/fate.ts",
17
+ "client/src/translations/",
18
+ "coverage/",
19
+ "dist/",
20
+ "pnpm-lock.yaml",
21
+ "server/dist",
22
+ ],
23
+ }
@@ -0,0 +1 @@
1
+ vp staged
@@ -0,0 +1,12 @@
1
+ {
2
+ "recommendations": [
3
+ "dbaeumer.vscode-eslint",
4
+ "oxc.oxc-vscode",
5
+ "styled-components.vscode-styled-components",
6
+ "sysoev.vscode-open-in-github",
7
+ "tailwindcss.intellisense",
8
+ "TypeScriptTeam.native-preview",
9
+ "usernamehw.errorlens",
10
+ "wix.vscode-import-cost"
11
+ ]
12
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "files.insertFinalNewline": true,
4
+ "files.trimFinalNewlines": true,
5
+ "editor.codeActionsOnSave": {
6
+ "source.fixAll.eslint": "explicit"
7
+ },
8
+ "[javascript]": {
9
+ "editor.defaultFormatter": "oxc.oxc-vscode"
10
+ },
11
+ "[typescriptreact]": {
12
+ "editor.defaultFormatter": "oxc.oxc-vscode"
13
+ },
14
+ "[typescript]": {
15
+ "editor.defaultFormatter": "oxc.oxc-vscode"
16
+ },
17
+ "[json]": {
18
+ "editor.defaultFormatter": "oxc.oxc-vscode"
19
+ },
20
+ "typescript.preferences.importModuleSpecifierEnding": "js",
21
+ "typescript.reportStyleChecksAsWarnings": false,
22
+ "typescript.updateImportsOnFileMove.enabled": "always",
23
+ "typescript.preferences.autoImportFileExcludePatterns": ["**/node_modules/vitest"],
24
+ "typescript.experimental.useTsgo": true
25
+ }
@@ -0,0 +1,55 @@
1
+ # Using _fate_ for React applications
2
+
3
+ This guidance is for agents working in projects bootstrapped from the fate template. It focuses on the client-side patterns for fate's view composition and action execution.
4
+
5
+ ## Core Workflow
6
+
7
+ - **Define views with explicit selections:** Define reusable view objects with `view<T>()({...})`, compose them via spreads, and resolve them with `useView`.
8
+ - **Resolve data via references:** Avoid passing raw fetched objects; instead pass `ViewRef`s to downstream components to keep selections scoped and cache-aware. Then call `const result = useView(viewDefinition, ref)` to read only the selected fields while subscribing to cache updates. Name the prop after the result data, and rename it using destructuring in the function arguments: `const PostComponent = ({ post: postRef }: { post: ViewRef<'Post'>}) => { const post = useView(PostView, postRef); ... }`.
9
+ - **Request data at screen roots:** Use `useRequest` to compose all views required for a route or screen into a single typed request; wrap roots in `Suspense` and an error boundary since requests may suspend or throw.
10
+ - **Compose reusable views:** Extract nested selections into their own views (e.g., `UserView`) and compose them inside parent views (`author: UserView`) to avoid duplication and overfetching. This keeps selections DRY and ensures view updates propagate consistently when the cache changes.
11
+
12
+ ## Actions & Mutations
13
+
14
+ - **Prefer `fate.actions` with `useActionState`:** Trigger mutations through React Actions to integrate with Suspense/`useTransition`, receiving `[result, action, isPending]`. Call actions via the relevant data inputs, for example `action({input: { id: post.id }})`.
15
+ - **Optimistic updates by default:** Pass `optimistic` payloads to immediately update the normalized cache; only views selecting the changed fields re-render and failures roll back automatically. Optimistic payloads should match the expected server data changes of the associated object.
16
+ - **Select extra fields when side effects matter:** When a mutation affects related entities (e.g., comment count on a post), pass a `view` to the action to fetch the needed fields in the same round-trip and keep the cache coherent for all dependent views.
17
+ - **Imperative escape hatch:** Use `fate.mutations` when you must fire mutations outside React components or without waiting on prior actions; handle loading/error states yourself.
18
+ - **Handle deletions and resets explicitly:** Use the `delete: true` flag to evict records from the cache, and send the `'reset'` token to clear stale action errors without re-running the mutation.
19
+ - **Error handling model:** Treat expected errors (e.g., 404) at the call site via the action result; unexpected errors bubble to the nearest React error boundary.
20
+
21
+ ## Common Pitfalls
22
+
23
+ - **Use ViewRefs:** Pass references instead of raw data. Keep components focused on views and `ViewRef`s to let fate manage data masking and updates.
24
+ - **Co-locate data needs:** Keep view definitions near their components and compose them upward to the request root for predictable fetching.
25
+ - **Use Suspense:** Wrap pages in `Suspense`/`ErrorBoundary` instead of ad-hoc loading/error flags; fate aligns with Async React by design.
26
+ - **Do not duplicate types:** Keep generated tRPC types and views imported from the server package. Avoid redefining entity shapes on the client. This ensures view selections stay type-safe end-to-end.
27
+ - **`useRequest` only at the root:** When adding routes or layouts, create a dedicated `useRequest` call per screen root that pulls together all child views; do not scatter `useRequest` across leaf components unless it's necessary to issue requests due to user input.
28
+ - **React Actions:** Prefer React Action-friendly UI primitives (buttons/forms that accept an `action` prop). If unavailable, wrap action calls with `startTransition` in `onClick` handlers.
29
+ - **Generated Client** The fate client is generated via `pnpm fate:generate`. It should not be manually edited. Instead make the proper schema changes on the server and run `pnpm fate:generate`.
30
+ - **Library Versions:** This repository uses the most recent releases of React, fate, Vite, tRPC, and more. You might not know about the new releases yet, please don't get confused. The versions you see are real, and there are no feature or version mismatches. You can search the internet for more information about them.
31
+
32
+ Full documentation can be found on the filesystem at `./client/node_modules/react-fate/README.md` or online at [fate.technology](https://fate.technology/).
33
+
34
+ ## Review Checklist for Agents
35
+
36
+ - [ ] Every component that reads server data does so through `useView` and receives a `ViewRef` prop.
37
+ - [ ] Root components gather data with a single `useRequest` call.
38
+ - [ ] Mutations are wired through `useActionState` with optimistic updates and necessary `view` selections; imperative `fate.mutations` are justified when used.
39
+ - [ ] Shared selections live in reusable views using regular JavaScript object spreads rather than duplicated field lists.
40
+
41
+ <!--VITE PLUS START-->
42
+
43
+ # Using Vite+, the Unified Toolchain for the Web
44
+
45
+ This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called `vp`. Vite+ is distinct from Vite, and it invokes Vite through `vp dev` and `vp build`. Run `vp help` to print a list of commands and `vp <command> --help` for information about a specific command.
46
+
47
+ Docs are local at `node_modules/vite-plus/docs` or online at https://viteplus.dev/guide/.
48
+
49
+ ## Review Checklist
50
+
51
+ - [ ] Run `vp install` after pulling remote changes and before getting started.
52
+ - [ ] Run `vp check` and `vp test` to format, lint, type check and test changes.
53
+ - [ ] Check if there are `vite.config.ts` tasks or `package.json` scripts necessary for validation, run via `vp run <script>`.
54
+
55
+ <!--VITE PLUS END-->
@@ -0,0 +1,77 @@
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="/public/fate-logo-dark.svg">
4
+ <source media="(prefers-color-scheme: light)" srcset="/public/fate-logo.svg">
5
+ <img alt="Logo" src="/public/fate-logo.svg" width="50%">
6
+ </picture>
7
+ </p>
8
+
9
+ **_fate_** is a modern data client for React inspired by [Relay](https://relay.dev/) and [GraphQL](https://graphql.org/). It combines view composition, normalized caching, data masking, Async React features, and type-safe data fetching.
10
+
11
+ Check out [fate.technology](https://fate.technology) for documentation, examples, and guides.
12
+
13
+ # _fate_ Quick Start Template
14
+
15
+ Create a new fate app with Vite+:
16
+
17
+ ```bash
18
+ vp create fate my-app --template drizzle
19
+ ```
20
+
21
+ ## Getting Started with _fate_
22
+
23
+ Read the [Getting Started Guide](https://fate.technology/guide/core-concepts) to learn how to use _fate_ in your React applications.
24
+
25
+ ## Technologies
26
+
27
+ This template combines the Nakazawa Tech's [Web App Template](https://github.com/nkzw-tech/web-app-template) and [Server Template](https://github.com/nkzw-tech/server-template) into a monorepo, with unified tooling and _fate_ as the data client. It uses tRPC with Drizzle.
28
+
29
+ _This template lives on the edge._ It's a turbocharged starting point on top of an already optimized stack. It uses TypeScript Go, Vite+, and ships with sensible defaults to unlock an incredibly fast development experience. It follows the principles laid out in [Building Scalable Applications](https://www.youtube.com/watch?v=rxPTEko8J7c&t=36s).
30
+
31
+ Next to [_fate_](https://fate.technology), it comes with the following technologies:
32
+
33
+ ### Client Technologies
34
+
35
+ - [Vite 8](https://vitejs.dev/)
36
+ - [React](https://reactjs.org/) with [React Compiler](https://react.dev/learn/react-compiler) enabled
37
+ - [Tailwind](https://tailwindcss.com/)
38
+ - [fbtee](https://github.com/nkzw-tech/fbtee) for i18n
39
+ - [Better Auth](https://www.better-auth.com/) for authentication
40
+ - [Void Pages Router](https://void.cloud/docs)
41
+ - [TypeScript](https://www.typescriptlang.org)
42
+ - [pnpm](https://pnpm.io/)
43
+
44
+ ### Server Technologies
45
+
46
+ - [Drizzle](https://orm.drizzle.team/) as the ORM.
47
+ - [tRPC](https://trpc.io/) for type-safe APIs.
48
+ - [Hono](https://hono.dev/)
49
+ - [Better Auth](https://better-auth.com/) for Authentication.
50
+
51
+ ### Folder Structure
52
+
53
+ - `client/` - The React client application using _fate_.
54
+ - `server/` - The fate server using tRPC with Drizzle.
55
+
56
+ ## Initial Setup
57
+
58
+ You'll need Node.js 24+ and [Vite+](https://viteplus.dev/guide/).
59
+
60
+ - Run `vp install`.
61
+ - Copy `server/.env.example` to `server/.env`.
62
+ - Set up a Postgres database locally or run `docker-compose up -d` to start Postgres in a Docker container.
63
+ - Postgres setup:
64
+
65
+ ```SQL
66
+ CREATE ROLE fate WITH LOGIN PASSWORD 'echo';
67
+ CREATE DATABASE fate;
68
+ ALTER DATABASE fate OWNER TO fate;
69
+ ```
70
+
71
+ Then, at the root of the project, run:
72
+
73
+ - `vp run dev:setup` to create the database tables and seed initial data.
74
+ - Run `vp run fate:generate` to regenerate the fate client code.
75
+ - Run `vp test` to run all tests.
76
+ - Run `vp run dev` to run the client and server.
77
+ - Visit `http://localhost:5173` to see the app in action.
@@ -0,0 +1,18 @@
1
+ .fate/
2
+ **/.fate/
3
+ .void/
4
+ **/.void/
5
+ .eslintcache
6
+ .pnpm-debug.log
7
+ **/node_modules/
8
+ /node_modules/
9
+ client/.enum_manifest.json
10
+ client/dist/
11
+ client/source_strings.json
12
+ client/src/translations/
13
+ coverage/
14
+ dist/
15
+ server/dist/
16
+ server/src/prisma/prisma-client/
17
+ tsconfig.tsbuildinfo
18
+ vite.config.ts.timestamp-*