@idevconn/create-icore 0.1.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 (241) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +56 -0
  3. package/dist/cli.js +300 -0
  4. package/dist/index.cjs +303 -0
  5. package/dist/index.d.cts +26 -0
  6. package/dist/index.d.ts +26 -0
  7. package/dist/index.js +265 -0
  8. package/package.json +72 -0
  9. package/templates/.husky/pre-commit +56 -0
  10. package/templates/.nvmrc +1 -0
  11. package/templates/.prettierignore +7 -0
  12. package/templates/.prettierrc +7 -0
  13. package/templates/.yarnrc.yml +7 -0
  14. package/templates/apps/api/.env.example +19 -0
  15. package/templates/apps/api/eslint.config.mjs +23 -0
  16. package/templates/apps/api/package.json +20 -0
  17. package/templates/apps/api/project.json +76 -0
  18. package/templates/apps/api/src/app/abilities/__tests__/ability.guard.unit.test.ts +49 -0
  19. package/templates/apps/api/src/app/abilities/abilities.module.ts +10 -0
  20. package/templates/apps/api/src/app/abilities/ability.factory.ts +13 -0
  21. package/templates/apps/api/src/app/abilities/ability.guard.ts +29 -0
  22. package/templates/apps/api/src/app/abilities/check-ability.decorator.ts +12 -0
  23. package/templates/apps/api/src/app/app.module.ts +19 -0
  24. package/templates/apps/api/src/app/auth/__tests__/auth.guard.unit.test.ts +66 -0
  25. package/templates/apps/api/src/app/auth/auth.controller.ts +62 -0
  26. package/templates/apps/api/src/app/auth/auth.guard.ts +42 -0
  27. package/templates/apps/api/src/app/auth/auth.module.ts +17 -0
  28. package/templates/apps/api/src/app/auth/public.decorator.ts +4 -0
  29. package/templates/apps/api/src/app/profile/profile.controller.ts +15 -0
  30. package/templates/apps/api/src/app/profile/profile.module.ts +5 -0
  31. package/templates/apps/api/src/app/storage/__tests__/assert-ownership.unit.test.ts +28 -0
  32. package/templates/apps/api/src/app/storage/assert-ownership.ts +8 -0
  33. package/templates/apps/api/src/app/storage/storage.controller.ts +108 -0
  34. package/templates/apps/api/src/app/storage/storage.module.ts +10 -0
  35. package/templates/apps/api/src/assets/.gitkeep +0 -0
  36. package/templates/apps/api/src/main.ts +43 -0
  37. package/templates/apps/api/tsconfig.app.json +13 -0
  38. package/templates/apps/api/tsconfig.json +16 -0
  39. package/templates/apps/api/tsconfig.spec.json +16 -0
  40. package/templates/apps/api/vitest.config.mts +21 -0
  41. package/templates/apps/api/webpack.config.js +25 -0
  42. package/templates/apps/microservices/auth/.env.example +38 -0
  43. package/templates/apps/microservices/auth/package.json +19 -0
  44. package/templates/apps/microservices/auth/project.json +65 -0
  45. package/templates/apps/microservices/auth/src/app/__tests__/auth.controller.firebase.integration.unit.test.ts +53 -0
  46. package/templates/apps/microservices/auth/src/app/__tests__/auth.controller.supabase.integration.unit.test.ts +47 -0
  47. package/templates/apps/microservices/auth/src/app/__tests__/auth.controller.unit.test.ts +87 -0
  48. package/templates/apps/microservices/auth/src/app/app.module.ts +66 -0
  49. package/templates/apps/microservices/auth/src/app/auth.controller.ts +60 -0
  50. package/templates/apps/microservices/auth/src/assets/.gitkeep +0 -0
  51. package/templates/apps/microservices/auth/src/main.ts +28 -0
  52. package/templates/apps/microservices/auth/tsconfig.app.json +13 -0
  53. package/templates/apps/microservices/auth/tsconfig.json +16 -0
  54. package/templates/apps/microservices/auth/tsconfig.spec.json +16 -0
  55. package/templates/apps/microservices/auth/vitest.config.mts +21 -0
  56. package/templates/apps/microservices/auth/webpack.config.js +25 -0
  57. package/templates/apps/microservices/upload/.env.example +30 -0
  58. package/templates/apps/microservices/upload/package.json +21 -0
  59. package/templates/apps/microservices/upload/project.json +65 -0
  60. package/templates/apps/microservices/upload/src/app/__tests__/storage.controller.unit.test.ts +49 -0
  61. package/templates/apps/microservices/upload/src/app/app.module.ts +117 -0
  62. package/templates/apps/microservices/upload/src/app/storage.controller.ts +51 -0
  63. package/templates/apps/microservices/upload/src/assets/.gitkeep +0 -0
  64. package/templates/apps/microservices/upload/src/main.ts +28 -0
  65. package/templates/apps/microservices/upload/tsconfig.app.json +13 -0
  66. package/templates/apps/microservices/upload/tsconfig.json +16 -0
  67. package/templates/apps/microservices/upload/tsconfig.spec.json +16 -0
  68. package/templates/apps/microservices/upload/vitest.config.mts +22 -0
  69. package/templates/apps/microservices/upload/webpack.config.js +25 -0
  70. package/templates/apps/templates/client-shadcn/.env.example +2 -0
  71. package/templates/apps/templates/client-shadcn/eslint.config.mjs +10 -0
  72. package/templates/apps/templates/client-shadcn/index.html +17 -0
  73. package/templates/apps/templates/client-shadcn/project.json +9 -0
  74. package/templates/apps/templates/client-shadcn/public/favicon.ico +0 -0
  75. package/templates/apps/templates/client-shadcn/src/app/app.module.css +1 -0
  76. package/templates/apps/templates/client-shadcn/src/app/app.spec.tsx +9 -0
  77. package/templates/apps/templates/client-shadcn/src/app/app.tsx +7 -0
  78. package/templates/apps/templates/client-shadcn/src/assets/.gitkeep +0 -0
  79. package/templates/apps/templates/client-shadcn/src/components/AccessDeniedPage.tsx +15 -0
  80. package/templates/apps/templates/client-shadcn/src/components/PageLayout.tsx +55 -0
  81. package/templates/apps/templates/client-shadcn/src/components/layout/LayoutFooter.tsx +8 -0
  82. package/templates/apps/templates/client-shadcn/src/components/layout/LayoutHeader.tsx +57 -0
  83. package/templates/apps/templates/client-shadcn/src/components/layout/LayoutSider.tsx +44 -0
  84. package/templates/apps/templates/client-shadcn/src/components/ui/button.tsx +50 -0
  85. package/templates/apps/templates/client-shadcn/src/components/ui/card.tsx +63 -0
  86. package/templates/apps/templates/client-shadcn/src/components/ui/input.tsx +23 -0
  87. package/templates/apps/templates/client-shadcn/src/components/ui/label.tsx +18 -0
  88. package/templates/apps/templates/client-shadcn/src/globals.css +27 -0
  89. package/templates/apps/templates/client-shadcn/src/layouts/MainLayout.tsx +17 -0
  90. package/templates/apps/templates/client-shadcn/src/lib/notify.ts +15 -0
  91. package/templates/apps/templates/client-shadcn/src/lib/utils.ts +6 -0
  92. package/templates/apps/templates/client-shadcn/src/main.tsx +50 -0
  93. package/templates/apps/templates/client-shadcn/src/routeTree.gen.ts +136 -0
  94. package/templates/apps/templates/client-shadcn/src/routes/__root.tsx +5 -0
  95. package/templates/apps/templates/client-shadcn/src/routes/_dashboard/dashboard.tsx +33 -0
  96. package/templates/apps/templates/client-shadcn/src/routes/_dashboard/profile.tsx +88 -0
  97. package/templates/apps/templates/client-shadcn/src/routes/_dashboard.tsx +16 -0
  98. package/templates/apps/templates/client-shadcn/src/routes/index.tsx +33 -0
  99. package/templates/apps/templates/client-shadcn/src/routes/login.tsx +93 -0
  100. package/templates/apps/templates/client-shadcn/src/styles.css +1 -0
  101. package/templates/apps/templates/client-shadcn/tsconfig.app.json +27 -0
  102. package/templates/apps/templates/client-shadcn/tsconfig.json +21 -0
  103. package/templates/apps/templates/client-shadcn/tsconfig.spec.json +30 -0
  104. package/templates/apps/templates/client-shadcn/vite.config.mts +92 -0
  105. package/templates/apps/templates/client-shadcn-e2e/eslint.config.mjs +12 -0
  106. package/templates/apps/templates/client-shadcn-e2e/playwright.config.ts +69 -0
  107. package/templates/apps/templates/client-shadcn-e2e/project.json +10 -0
  108. package/templates/apps/templates/client-shadcn-e2e/src/icore.spec.ts +27 -0
  109. package/templates/apps/templates/client-shadcn-e2e/tsconfig.json +19 -0
  110. package/templates/eslint.config.mjs +20 -0
  111. package/templates/libs/auth-client/README.md +11 -0
  112. package/templates/libs/auth-client/eslint.config.mjs +22 -0
  113. package/templates/libs/auth-client/package.json +15 -0
  114. package/templates/libs/auth-client/project.json +19 -0
  115. package/templates/libs/auth-client/src/index.ts +2 -0
  116. package/templates/libs/auth-client/src/lib/auth-client.module.ts +25 -0
  117. package/templates/libs/auth-client/src/lib/auth-client.service.ts +30 -0
  118. package/templates/libs/auth-client/tsconfig.json +24 -0
  119. package/templates/libs/auth-client/tsconfig.lib.json +26 -0
  120. package/templates/libs/auth-client/tsconfig.spec.json +22 -0
  121. package/templates/libs/auth-client/vitest.config.mts +22 -0
  122. package/templates/libs/auth-strategies/firebase/README.md +11 -0
  123. package/templates/libs/auth-strategies/firebase/eslint.config.mjs +22 -0
  124. package/templates/libs/auth-strategies/firebase/package.json +15 -0
  125. package/templates/libs/auth-strategies/firebase/project.json +19 -0
  126. package/templates/libs/auth-strategies/firebase/src/index.ts +4 -0
  127. package/templates/libs/auth-strategies/firebase/src/lib/__tests__/firebase-auth.contract.unit.test.ts +13 -0
  128. package/templates/libs/auth-strategies/firebase/src/lib/firebase-auth.strategy.ts +77 -0
  129. package/templates/libs/auth-strategies/firebase/src/lib/identity-toolkit.client.ts +72 -0
  130. package/templates/libs/auth-strategies/firebase/src/lib/testing/mock-admin-auth.ts +41 -0
  131. package/templates/libs/auth-strategies/firebase/src/lib/testing/mock-identity-toolkit.ts +76 -0
  132. package/templates/libs/auth-strategies/firebase/tsconfig.json +24 -0
  133. package/templates/libs/auth-strategies/firebase/tsconfig.lib.json +23 -0
  134. package/templates/libs/auth-strategies/firebase/tsconfig.spec.json +22 -0
  135. package/templates/libs/auth-strategies/firebase/vitest.config.mts +22 -0
  136. package/templates/libs/auth-strategies/supabase/README.md +11 -0
  137. package/templates/libs/auth-strategies/supabase/eslint.config.mjs +22 -0
  138. package/templates/libs/auth-strategies/supabase/package.json +16 -0
  139. package/templates/libs/auth-strategies/supabase/project.json +19 -0
  140. package/templates/libs/auth-strategies/supabase/src/index.ts +2 -0
  141. package/templates/libs/auth-strategies/supabase/src/lib/__tests__/supabase-auth.contract.unit.test.ts +8 -0
  142. package/templates/libs/auth-strategies/supabase/src/lib/supabase-auth.strategy.ts +79 -0
  143. package/templates/libs/auth-strategies/supabase/src/lib/testing/mock-supabase.ts +107 -0
  144. package/templates/libs/auth-strategies/supabase/tsconfig.json +24 -0
  145. package/templates/libs/auth-strategies/supabase/tsconfig.lib.json +23 -0
  146. package/templates/libs/auth-strategies/supabase/tsconfig.spec.json +22 -0
  147. package/templates/libs/auth-strategies/supabase/vitest.config.mts +22 -0
  148. package/templates/libs/shared/README.md +11 -0
  149. package/templates/libs/shared/eslint.config.mjs +24 -0
  150. package/templates/libs/shared/package.json +14 -0
  151. package/templates/libs/shared/project.json +19 -0
  152. package/templates/libs/shared/src/__tests__/transport.unit.test.ts +58 -0
  153. package/templates/libs/shared/src/abilities/__tests__/ability.unit.test.ts +28 -0
  154. package/templates/libs/shared/src/abilities/ability.ts +21 -0
  155. package/templates/libs/shared/src/abilities/index.ts +2 -0
  156. package/templates/libs/shared/src/abilities/subjects.ts +2 -0
  157. package/templates/libs/shared/src/index.ts +3 -0
  158. package/templates/libs/shared/src/strategies/__tests__/fake-auth.contract.unit.test.ts +4 -0
  159. package/templates/libs/shared/src/strategies/__tests__/fake-storage.contract.unit.test.ts +4 -0
  160. package/templates/libs/shared/src/strategies/auth.ts +21 -0
  161. package/templates/libs/shared/src/strategies/contract/auth-contract.ts +66 -0
  162. package/templates/libs/shared/src/strategies/contract/storage-contract.ts +58 -0
  163. package/templates/libs/shared/src/strategies/fakes/fake-auth.ts +73 -0
  164. package/templates/libs/shared/src/strategies/fakes/fake-storage.ts +51 -0
  165. package/templates/libs/shared/src/strategies/fakes/index.ts +2 -0
  166. package/templates/libs/shared/src/strategies/index.ts +5 -0
  167. package/templates/libs/shared/src/strategies/storage.ts +17 -0
  168. package/templates/libs/shared/src/transport.ts +55 -0
  169. package/templates/libs/shared/tsconfig.json +24 -0
  170. package/templates/libs/shared/tsconfig.lib.json +23 -0
  171. package/templates/libs/shared/tsconfig.spec.json +22 -0
  172. package/templates/libs/shared/vitest.config.mts +21 -0
  173. package/templates/libs/storage-strategies/cloudinary/README.md +11 -0
  174. package/templates/libs/storage-strategies/cloudinary/eslint.config.mjs +23 -0
  175. package/templates/libs/storage-strategies/cloudinary/package.json +15 -0
  176. package/templates/libs/storage-strategies/cloudinary/project.json +19 -0
  177. package/templates/libs/storage-strategies/cloudinary/src/index.ts +2 -0
  178. package/templates/libs/storage-strategies/cloudinary/src/lib/__tests__/cloudinary-storage.contract.unit.test.ts +8 -0
  179. package/templates/libs/storage-strategies/cloudinary/src/lib/cloudinary-storage.strategy.ts +75 -0
  180. package/templates/libs/storage-strategies/cloudinary/src/lib/testing/mock-cloudinary.ts +36 -0
  181. package/templates/libs/storage-strategies/cloudinary/tsconfig.json +24 -0
  182. package/templates/libs/storage-strategies/cloudinary/tsconfig.lib.json +23 -0
  183. package/templates/libs/storage-strategies/cloudinary/tsconfig.spec.json +22 -0
  184. package/templates/libs/storage-strategies/cloudinary/vitest.config.mts +22 -0
  185. package/templates/libs/storage-strategies/firebase/README.md +11 -0
  186. package/templates/libs/storage-strategies/firebase/eslint.config.mjs +23 -0
  187. package/templates/libs/storage-strategies/firebase/package.json +15 -0
  188. package/templates/libs/storage-strategies/firebase/project.json +19 -0
  189. package/templates/libs/storage-strategies/firebase/src/index.ts +2 -0
  190. package/templates/libs/storage-strategies/firebase/src/lib/__tests__/firebase-storage.contract.unit.test.ts +8 -0
  191. package/templates/libs/storage-strategies/firebase/src/lib/firebase-storage.strategy.ts +63 -0
  192. package/templates/libs/storage-strategies/firebase/src/lib/testing/mock-firebase-storage.ts +43 -0
  193. package/templates/libs/storage-strategies/firebase/tsconfig.json +24 -0
  194. package/templates/libs/storage-strategies/firebase/tsconfig.lib.json +23 -0
  195. package/templates/libs/storage-strategies/firebase/tsconfig.spec.json +22 -0
  196. package/templates/libs/storage-strategies/firebase/vitest.config.mts +22 -0
  197. package/templates/libs/storage-strategies/supabase/README.md +11 -0
  198. package/templates/libs/storage-strategies/supabase/eslint.config.mjs +22 -0
  199. package/templates/libs/storage-strategies/supabase/package.json +16 -0
  200. package/templates/libs/storage-strategies/supabase/project.json +19 -0
  201. package/templates/libs/storage-strategies/supabase/src/index.ts +2 -0
  202. package/templates/libs/storage-strategies/supabase/src/lib/__tests__/supabase-storage.contract.unit.test.ts +8 -0
  203. package/templates/libs/storage-strategies/supabase/src/lib/supabase-storage.strategy.ts +53 -0
  204. package/templates/libs/storage-strategies/supabase/src/lib/testing/mock-supabase-storage.ts +78 -0
  205. package/templates/libs/storage-strategies/supabase/tsconfig.json +24 -0
  206. package/templates/libs/storage-strategies/supabase/tsconfig.lib.json +23 -0
  207. package/templates/libs/storage-strategies/supabase/tsconfig.spec.json +22 -0
  208. package/templates/libs/storage-strategies/supabase/vitest.config.mts +22 -0
  209. package/templates/libs/template-shared/README.md +11 -0
  210. package/templates/libs/template-shared/eslint.config.mjs +23 -0
  211. package/templates/libs/template-shared/package.json +22 -0
  212. package/templates/libs/template-shared/project.json +19 -0
  213. package/templates/libs/template-shared/src/index.ts +9 -0
  214. package/templates/libs/template-shared/src/lib/abilities/ability-provider.tsx +19 -0
  215. package/templates/libs/template-shared/src/lib/api/create-api.ts +20 -0
  216. package/templates/libs/template-shared/src/lib/draft/index.ts +1 -0
  217. package/templates/libs/template-shared/src/lib/i18n/create-i18n.ts +42 -0
  218. package/templates/libs/template-shared/src/lib/i18n/keys.ts +30 -0
  219. package/templates/libs/template-shared/src/lib/landing/LandingPage.tsx +68 -0
  220. package/templates/libs/template-shared/src/lib/notify/use-notify.ts +26 -0
  221. package/templates/libs/template-shared/src/lib/stores/auth.store.ts +29 -0
  222. package/templates/libs/template-shared/src/lib/stores/loading.store.ts +13 -0
  223. package/templates/libs/template-shared/tsconfig.json +24 -0
  224. package/templates/libs/template-shared/tsconfig.lib.json +25 -0
  225. package/templates/libs/template-shared/tsconfig.spec.json +22 -0
  226. package/templates/libs/template-shared/vitest.config.mts +22 -0
  227. package/templates/libs/upload-client/README.md +11 -0
  228. package/templates/libs/upload-client/eslint.config.mjs +22 -0
  229. package/templates/libs/upload-client/package.json +15 -0
  230. package/templates/libs/upload-client/project.json +19 -0
  231. package/templates/libs/upload-client/src/index.ts +2 -0
  232. package/templates/libs/upload-client/src/lib/upload-client.module.ts +25 -0
  233. package/templates/libs/upload-client/src/lib/upload-client.service.ts +38 -0
  234. package/templates/libs/upload-client/tsconfig.json +24 -0
  235. package/templates/libs/upload-client/tsconfig.lib.json +26 -0
  236. package/templates/libs/upload-client/tsconfig.spec.json +22 -0
  237. package/templates/libs/upload-client/vitest.config.mts +22 -0
  238. package/templates/nx.json +113 -0
  239. package/templates/package.json +24 -0
  240. package/templates/tools/create-icore/_template-shell/package.json +24 -0
  241. package/templates/tsconfig.base.json +29 -0
@@ -0,0 +1,33 @@
1
+ import { createFileRoute, Link } from '@tanstack/react-router';
2
+ import { useAuthStore } from '@icore/template-shared';
3
+ import {
4
+ Card,
5
+ CardContent,
6
+ CardDescription,
7
+ CardHeader,
8
+ CardTitle,
9
+ } from '../../components/ui/card';
10
+ import { PageLayout } from '../../components/PageLayout';
11
+
12
+ function DashboardHome() {
13
+ const user = useAuthStore((s) => s.user);
14
+ return (
15
+ <PageLayout title="Dashboard" description={`Welcome back, ${user?.email ?? 'guest'}`}>
16
+ <Card className="max-w-2xl">
17
+ <CardHeader>
18
+ <CardTitle>Hello, world</CardTitle>
19
+ <CardDescription>Edit this page in src/routes/_dashboard/dashboard.tsx</CardDescription>
20
+ </CardHeader>
21
+ <CardContent>
22
+ <Link to="/_dashboard/profile" className="underline">
23
+ Go to profile →
24
+ </Link>
25
+ </CardContent>
26
+ </Card>
27
+ </PageLayout>
28
+ );
29
+ }
30
+
31
+ export const Route = createFileRoute('/_dashboard/dashboard')({
32
+ component: DashboardHome,
33
+ });
@@ -0,0 +1,88 @@
1
+ import { createFileRoute } from '@tanstack/react-router';
2
+ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
3
+ import { FormEvent, useEffect, useState } from 'react';
4
+ import { useDraft, useNotify, useAuthStore } from '@icore/template-shared';
5
+ import { PageLayout } from '../../components/PageLayout';
6
+ import { Button } from '../../components/ui/button';
7
+ import { Input } from '../../components/ui/input';
8
+ import { Label } from '../../components/ui/label';
9
+ import { api } from '../../main';
10
+
11
+ interface ProfilePayload {
12
+ uid: string;
13
+ email?: string;
14
+ role?: string;
15
+ }
16
+
17
+ function ProfilePage() {
18
+ const notify = useNotify();
19
+ const qc = useQueryClient();
20
+ const authUser = useAuthStore((s) => s.user);
21
+
22
+ const { data, isPending } = useQuery({
23
+ queryKey: ['profile'],
24
+ queryFn: () => api<ProfilePayload>('/profile'),
25
+ });
26
+
27
+ const [name, setName] = useState('');
28
+ const [dirty, setDirty] = useState(false);
29
+ useDraft(dirty);
30
+
31
+ useEffect(() => {
32
+ if (data?.email) setName(data.email);
33
+ }, [data?.email]);
34
+
35
+ const save = useMutation({
36
+ mutationFn: async (next: string) =>
37
+ api('/profile', {
38
+ method: 'PATCH',
39
+ headers: { 'Content-Type': 'application/json' },
40
+ body: JSON.stringify({ name: next }),
41
+ }),
42
+ onSuccess: () => {
43
+ setDirty(false);
44
+ notify.success('Saved');
45
+ void qc.invalidateQueries({ queryKey: ['profile'] });
46
+ },
47
+ onError: (err) => notify.error(err instanceof Error ? err.message : 'save_failed'),
48
+ });
49
+
50
+ function handleSubmit(e: FormEvent) {
51
+ e.preventDefault();
52
+ save.mutate(name);
53
+ }
54
+
55
+ return (
56
+ <PageLayout
57
+ title="Profile"
58
+ description="Edit your account details."
59
+ action="read"
60
+ subject="Profile"
61
+ >
62
+ <form onSubmit={handleSubmit} className="max-w-md space-y-4">
63
+ <div className="space-y-2">
64
+ <Label htmlFor="email">Email</Label>
65
+ <Input id="email" value={authUser?.email ?? ''} readOnly disabled />
66
+ </div>
67
+ <div className="space-y-2">
68
+ <Label htmlFor="name">Display name</Label>
69
+ <Input
70
+ id="name"
71
+ value={name}
72
+ onChange={(e) => {
73
+ setName(e.target.value);
74
+ setDirty(true);
75
+ }}
76
+ />
77
+ </div>
78
+ <Button type="submit" disabled={!dirty || save.isPending || isPending}>
79
+ {save.isPending ? 'Saving…' : 'Save'}
80
+ </Button>
81
+ </form>
82
+ </PageLayout>
83
+ );
84
+ }
85
+
86
+ export const Route = createFileRoute('/_dashboard/profile')({
87
+ component: ProfilePage,
88
+ });
@@ -0,0 +1,16 @@
1
+ import { createFileRoute, Outlet, redirect } from '@tanstack/react-router';
2
+ import { useAuthStore } from '@icore/template-shared';
3
+ import { MainLayout } from '../layouts/MainLayout';
4
+
5
+ export const Route = createFileRoute('/_dashboard')({
6
+ beforeLoad: () => {
7
+ if (!useAuthStore.getState().accessToken) {
8
+ throw redirect({ to: '/login' });
9
+ }
10
+ },
11
+ component: () => (
12
+ <MainLayout>
13
+ <Outlet />
14
+ </MainLayout>
15
+ ),
16
+ });
@@ -0,0 +1,33 @@
1
+ import { createFileRoute } from '@tanstack/react-router';
2
+ import { LandingPage } from '@icore/template-shared';
3
+
4
+ // All version strings are injected at build time by vite.config.mts
5
+ // (reads root package.json via fs.readFileSync so they stay accurate
6
+ // even when workspace packages are bumped independently).
7
+ const APP_VERSION = (import.meta.env.VITE_APP_VERSION as string | undefined) ?? '0.0.0-dev';
8
+
9
+ export const Route = createFileRoute('/')({
10
+ component: () => (
11
+ <LandingPage
12
+ coreVersion={APP_VERSION}
13
+ uiLibrary="shadcn"
14
+ deps={[
15
+ { name: 'react', version: (import.meta.env.VITE_DEP_REACT as string) ?? '?' },
16
+ { name: 'vite', version: (import.meta.env.VITE_DEP_VITE as string) ?? '?' },
17
+ { name: 'tailwindcss', version: (import.meta.env.VITE_DEP_TAILWINDCSS as string) ?? '?' },
18
+ {
19
+ name: '@tanstack/react-router',
20
+ version: (import.meta.env.VITE_DEP_TANSTACK_ROUTER as string) ?? '?',
21
+ },
22
+ {
23
+ name: '@tanstack/react-query',
24
+ version: (import.meta.env.VITE_DEP_TANSTACK_QUERY as string) ?? '?',
25
+ },
26
+ { name: 'zustand', version: (import.meta.env.VITE_DEP_ZUSTAND as string) ?? '?' },
27
+ { name: '@casl/ability', version: (import.meta.env.VITE_DEP_CASL as string) ?? '?' },
28
+ ]}
29
+ ctaHref="/login"
30
+ ctaLabel="Log in →"
31
+ />
32
+ ),
33
+ });
@@ -0,0 +1,93 @@
1
+ import { createFileRoute, useNavigate } from '@tanstack/react-router';
2
+ import { FormEvent, useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { useAuthStore, useNotify } from '@icore/template-shared';
5
+ import { api } from '../main';
6
+ import { Button } from '../components/ui/button';
7
+ import { Input } from '../components/ui/input';
8
+ import { Label } from '../components/ui/label';
9
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../components/ui/card';
10
+
11
+ function LoginPage() {
12
+ const { t } = useTranslation();
13
+ const navigate = useNavigate();
14
+ const notify = useNotify();
15
+ const setAuth = useAuthStore((s) => s.setAuth);
16
+
17
+ const [email, setEmail] = useState('');
18
+ const [password, setPassword] = useState('');
19
+ const [submitting, setSubmitting] = useState(false);
20
+
21
+ async function handleSubmit(e: FormEvent) {
22
+ e.preventDefault();
23
+ setSubmitting(true);
24
+ try {
25
+ const session = await api<{
26
+ access_token: string;
27
+ refresh_token: string;
28
+ user: { id: string; email: string; role?: string };
29
+ }>('/auth/login', {
30
+ method: 'POST',
31
+ headers: { 'Content-Type': 'application/json' },
32
+ body: JSON.stringify({ email, password }),
33
+ });
34
+ setAuth({
35
+ accessToken: session.access_token,
36
+ refreshToken: session.refresh_token,
37
+ user: session.user,
38
+ });
39
+ notify.success(t('auth.login'));
40
+ await navigate({ to: '/_dashboard/dashboard' });
41
+ } catch (err) {
42
+ notify.error(err instanceof Error ? err.message : t('error.unknown'));
43
+ } finally {
44
+ setSubmitting(false);
45
+ }
46
+ }
47
+
48
+ return (
49
+ <main className="min-h-screen flex items-center justify-center p-6 bg-background">
50
+ <Card className="w-full max-w-sm">
51
+ <CardHeader>
52
+ <CardTitle>{t('auth.login')}</CardTitle>
53
+ <CardDescription>
54
+ {t('auth.email')} &amp; {t('auth.password')}
55
+ </CardDescription>
56
+ </CardHeader>
57
+ <CardContent>
58
+ <form onSubmit={handleSubmit} className="space-y-4">
59
+ <div className="space-y-2">
60
+ <Label htmlFor="email">{t('auth.email')}</Label>
61
+ <Input
62
+ id="email"
63
+ type="email"
64
+ value={email}
65
+ onChange={(e) => setEmail(e.target.value)}
66
+ required
67
+ autoComplete="email"
68
+ />
69
+ </div>
70
+ <div className="space-y-2">
71
+ <Label htmlFor="password">{t('auth.password')}</Label>
72
+ <Input
73
+ id="password"
74
+ type="password"
75
+ value={password}
76
+ onChange={(e) => setPassword(e.target.value)}
77
+ required
78
+ autoComplete="current-password"
79
+ />
80
+ </div>
81
+ <Button type="submit" className="w-full" disabled={submitting}>
82
+ {submitting ? t('common.loading') : t('auth.login')}
83
+ </Button>
84
+ </form>
85
+ </CardContent>
86
+ </Card>
87
+ </main>
88
+ );
89
+ }
90
+
91
+ export const Route = createFileRoute('/login')({
92
+ component: LoginPage,
93
+ });
@@ -0,0 +1 @@
1
+ /* You can add global styles to this file, and also import other style files */
@@ -0,0 +1,27 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../dist/out-tsc",
5
+ "types": [
6
+ "node",
7
+ "@nx/react/typings/cssmodule.d.ts",
8
+ "@nx/react/typings/image.d.ts",
9
+ "vite/client"
10
+ ]
11
+ },
12
+ "exclude": [
13
+ "src/**/*.spec.ts",
14
+ "src/**/*.test.ts",
15
+ "src/**/*.spec.tsx",
16
+ "src/**/*.test.tsx",
17
+ "src/**/*.spec.js",
18
+ "src/**/*.test.js",
19
+ "src/**/*.spec.jsx",
20
+ "src/**/*.test.jsx",
21
+ "vite.config.ts",
22
+ "vite.config.mts",
23
+ "vitest.config.ts",
24
+ "vitest.config.mts"
25
+ ],
26
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
27
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx",
4
+ "allowJs": false,
5
+ "esModuleInterop": false,
6
+ "allowSyntheticDefaultImports": true,
7
+ "strict": true,
8
+ "types": ["vite/client", "vitest"]
9
+ },
10
+ "files": [],
11
+ "include": [],
12
+ "references": [
13
+ {
14
+ "path": "./tsconfig.app.json"
15
+ },
16
+ {
17
+ "path": "./tsconfig.spec.json"
18
+ }
19
+ ],
20
+ "extends": "../../../tsconfig.base.json"
21
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../dist/out-tsc",
5
+ "types": [
6
+ "vitest/globals",
7
+ "vitest/importMeta",
8
+ "vite/client",
9
+ "node",
10
+ "vitest",
11
+ "@nx/react/typings/cssmodule.d.ts",
12
+ "@nx/react/typings/image.d.ts"
13
+ ]
14
+ },
15
+ "include": [
16
+ "vite.config.ts",
17
+ "vite.config.mts",
18
+ "vitest.config.ts",
19
+ "vitest.config.mts",
20
+ "src/**/*.test.ts",
21
+ "src/**/*.spec.ts",
22
+ "src/**/*.test.tsx",
23
+ "src/**/*.spec.tsx",
24
+ "src/**/*.test.js",
25
+ "src/**/*.spec.js",
26
+ "src/**/*.test.jsx",
27
+ "src/**/*.spec.jsx",
28
+ "src/**/*.d.ts"
29
+ ]
30
+ }
@@ -0,0 +1,92 @@
1
+ /// <reference types='vitest' />
2
+ import fs from 'node:fs';
3
+ import { defineConfig } from 'vite';
4
+ import react from '@vitejs/plugin-react';
5
+ import tailwindcss from '@tailwindcss/vite';
6
+ import { TanStackRouterVite } from '@tanstack/router-plugin/vite';
7
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
8
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
9
+
10
+ const rootPackageJsonPath = new URL('../../../package.json', import.meta.url);
11
+ const rootPackageJson = JSON.parse(fs.readFileSync(rootPackageJsonPath, 'utf-8')) as {
12
+ version: string;
13
+ dependencies?: Record<string, string>;
14
+ devDependencies?: Record<string, string>;
15
+ };
16
+
17
+ function depVersion(name: string): string {
18
+ return (
19
+ rootPackageJson.dependencies?.[name] ??
20
+ rootPackageJson.devDependencies?.[name] ??
21
+ '?'
22
+ );
23
+ }
24
+
25
+ export default defineConfig(() => ({
26
+ root: import.meta.dirname,
27
+ cacheDir: '../../../node_modules/.vite/apps/templates/client-shadcn',
28
+ server: {
29
+ port: 4200,
30
+ host: 'localhost',
31
+ },
32
+ preview: {
33
+ port: 4200,
34
+ host: 'localhost',
35
+ },
36
+ define: {
37
+ 'import.meta.env.VITE_APP_VERSION': JSON.stringify(rootPackageJson.version),
38
+ // Dep versions injected at build time so routes don't need JSON imports
39
+ 'import.meta.env.VITE_DEP_REACT': JSON.stringify(depVersion('react')),
40
+ 'import.meta.env.VITE_DEP_VITE': JSON.stringify(depVersion('vite')),
41
+ 'import.meta.env.VITE_DEP_TAILWINDCSS': JSON.stringify(depVersion('tailwindcss')),
42
+ 'import.meta.env.VITE_DEP_TANSTACK_ROUTER': JSON.stringify(
43
+ depVersion('@tanstack/react-router'),
44
+ ),
45
+ 'import.meta.env.VITE_DEP_TANSTACK_QUERY': JSON.stringify(
46
+ depVersion('@tanstack/react-query'),
47
+ ),
48
+ 'import.meta.env.VITE_DEP_ZUSTAND': JSON.stringify(depVersion('zustand')),
49
+ 'import.meta.env.VITE_DEP_CASL': JSON.stringify(depVersion('@casl/ability')),
50
+ },
51
+ plugins: [
52
+ TanStackRouterVite({
53
+ target: 'react',
54
+ autoCodeSplitting: true,
55
+ routeFileIgnorePattern: '(__tests__|\\.test\\.(t|j)sx?$)',
56
+ }),
57
+ react(),
58
+ tailwindcss(),
59
+ nxViteTsPaths(),
60
+ nxCopyAssetsPlugin(['*.md']),
61
+ {
62
+ name: 'inject-app-version-meta',
63
+ transformIndexHtml(html: string) {
64
+ return html.replace('%APP_VERSION%', rootPackageJson.version);
65
+ },
66
+ },
67
+ ],
68
+ // Uncomment this if you are using workers.
69
+ // worker: {
70
+ // plugins: () => [ nxViteTsPaths() ],
71
+ // },
72
+ build: {
73
+ outDir: '../../../dist/apps/templates/client-shadcn',
74
+ emptyOutDir: true,
75
+ reportCompressedSize: true,
76
+ commonjsOptions: {
77
+ transformMixedEsModules: true,
78
+ },
79
+ },
80
+ test: {
81
+ name: 'client-shadcn',
82
+ watch: false,
83
+ globals: true,
84
+ environment: 'jsdom',
85
+ include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
86
+ reporters: ['default'],
87
+ coverage: {
88
+ reportsDirectory: '../../../coverage/apps/templates/client-shadcn',
89
+ provider: 'v8' as const,
90
+ },
91
+ },
92
+ }));
@@ -0,0 +1,12 @@
1
+ import playwright from 'eslint-plugin-playwright';
2
+ import baseConfig from '../../../eslint.config.mjs';
3
+
4
+ export default [
5
+ playwright.configs['flat/recommended'],
6
+ ...baseConfig,
7
+ {
8
+ files: ['**/*.ts', '**/*.js'],
9
+ // Override or add rules here
10
+ rules: {},
11
+ },
12
+ ];
@@ -0,0 +1,69 @@
1
+ import { defineConfig, devices } from '@playwright/test';
2
+ import { nxE2EPreset } from '@nx/playwright/preset';
3
+ import { workspaceRoot } from '@nx/devkit';
4
+
5
+ // For CI, you may want to set BASE_URL to the deployed application.
6
+ const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
7
+
8
+ /**
9
+ * Read environment variables from file.
10
+ * https://github.com/motdotla/dotenv
11
+ */
12
+ // require('dotenv').config();
13
+
14
+ /**
15
+ * See https://playwright.dev/docs/test-configuration.
16
+ */
17
+ export default defineConfig({
18
+ ...nxE2EPreset(__filename, { testDir: './src' }),
19
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
20
+ use: {
21
+ baseURL,
22
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
23
+ trace: 'on-first-retry',
24
+ },
25
+ /* Run your local dev server before starting the tests */
26
+ webServer: {
27
+ command: 'yarn nx serve client-shadcn',
28
+ url: 'http://localhost:4200',
29
+ reuseExistingServer: !process.env['CI'],
30
+ cwd: workspaceRoot,
31
+ timeout: 60_000,
32
+ },
33
+ projects: [
34
+ {
35
+ name: 'chromium',
36
+ use: { ...devices['Desktop Chrome'] },
37
+ },
38
+
39
+ {
40
+ name: 'firefox',
41
+ use: { ...devices['Desktop Firefox'] },
42
+ },
43
+
44
+ {
45
+ name: 'webkit',
46
+ use: { ...devices['Desktop Safari'] },
47
+ },
48
+
49
+ // Uncomment for mobile browsers support
50
+ /* {
51
+ name: 'Mobile Chrome',
52
+ use: { ...devices['Pixel 5'] },
53
+ },
54
+ {
55
+ name: 'Mobile Safari',
56
+ use: { ...devices['iPhone 12'] },
57
+ }, */
58
+
59
+ // Uncomment for branded browsers
60
+ /* {
61
+ name: 'Microsoft Edge',
62
+ use: { ...devices['Desktop Edge'], channel: 'msedge' },
63
+ },
64
+ {
65
+ name: 'Google Chrome',
66
+ use: { ...devices['Desktop Chrome'], channel: 'chrome' },
67
+ } */
68
+ ],
69
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "client-shadcn-e2e",
3
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
4
+ "projectType": "application",
5
+ "sourceRoot": "apps/templates/client-shadcn-e2e/src",
6
+ "tags": [],
7
+ "implicitDependencies": ["client-shadcn"],
8
+ "// targets": "to see all targets run: nx show project client-shadcn-e2e --web",
9
+ "targets": {}
10
+ }
@@ -0,0 +1,27 @@
1
+ import { test, expect } from '@playwright/test';
2
+
3
+ test.describe('icore client-shadcn smoke', () => {
4
+ test('landing renders icore version heading', async ({ page }) => {
5
+ await page.goto('/');
6
+ await expect(page.getByRole('heading', { level: 1 })).toContainText('icore v');
7
+ await expect(page.getByText('shadcn')).toBeVisible();
8
+ });
9
+
10
+ test('login route renders the form', async ({ page }) => {
11
+ await page.goto('/login');
12
+ await expect(page.getByLabel(/email/i)).toBeVisible();
13
+ await expect(page.getByLabel(/password/i)).toBeVisible();
14
+ });
15
+
16
+ test('protected route redirects to login when unauthenticated', async ({ page }) => {
17
+ await page.goto('/dashboard');
18
+ await page.waitForURL(/\/login$/);
19
+ await expect(page).toHaveURL(/\/login$/);
20
+ });
21
+
22
+ test('profile route redirects to login when unauthenticated', async ({ page }) => {
23
+ await page.goto('/profile');
24
+ await page.waitForURL(/\/login$/);
25
+ await expect(page).toHaveURL(/\/login$/);
26
+ });
27
+ });
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "outDir": "../../../dist/out-tsc",
6
+ "sourceMap": false,
7
+ "module": "commonjs"
8
+ },
9
+ "include": [
10
+ "**/*.ts",
11
+ "**/*.js",
12
+ "playwright.config.ts",
13
+ "src/**/*.spec.ts",
14
+ "src/**/*.spec.js",
15
+ "src/**/*.test.ts",
16
+ "src/**/*.test.js",
17
+ "src/**/*.d.ts"
18
+ ]
19
+ }
@@ -0,0 +1,20 @@
1
+ import js from '@eslint/js';
2
+ import tseslint from 'typescript-eslint';
3
+ import nx from '@nx/eslint-plugin';
4
+
5
+ export default tseslint.config(
6
+ js.configs.recommended,
7
+ ...tseslint.configs.recommended,
8
+ ...nx.configs['flat/base'],
9
+ ...nx.configs['flat/typescript'],
10
+ ...nx.configs['flat/javascript'],
11
+ {
12
+ ignores: ['dist', '.nx', 'node_modules', '.yarn', '.pnp.*', 'coverage'],
13
+ },
14
+ {
15
+ rules: {
16
+ '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
17
+ '@typescript-eslint/no-explicit-any': 'error',
18
+ },
19
+ },
20
+ );
@@ -0,0 +1,11 @@
1
+ # auth-client
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build auth-client` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test auth-client` to execute the unit tests via [Vitest](https://vitest.dev/).
@@ -0,0 +1,22 @@
1
+ import baseConfig from '../../eslint.config.mjs';
2
+
3
+ export default [
4
+ ...baseConfig,
5
+ {
6
+ files: ['**/*.json'],
7
+ rules: {
8
+ '@nx/dependency-checks': [
9
+ 'error',
10
+ {
11
+ ignoredFiles: [
12
+ '{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}',
13
+ '{projectRoot}/vitest.config.{js,ts,mjs,mts}',
14
+ ],
15
+ },
16
+ ],
17
+ },
18
+ languageOptions: {
19
+ parser: await import('jsonc-eslint-parser'),
20
+ },
21
+ },
22
+ ];
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@icore/auth-client",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "commonjs",
6
+ "main": "./src/index.js",
7
+ "types": "./src/index.d.ts",
8
+ "dependencies": {
9
+ "@icore/shared": "*",
10
+ "@nestjs/common": "^11.1.24",
11
+ "@nestjs/microservices": "^11.1.24",
12
+ "rxjs": "^7.8.2",
13
+ "tslib": "^2.3.0"
14
+ }
15
+ }