generator-kodly-react-app 1.0.6 → 1.0.10

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 (101) hide show
  1. package/generators/app/index.js +63 -11
  2. package/generators/app/templates/.env.dev +4 -0
  3. package/generators/app/templates/.env.sandbox +4 -0
  4. package/generators/app/templates/STRUCTURE.md +661 -0
  5. package/generators/app/templates/components.json +22 -0
  6. package/generators/app/templates/index.html +14 -6
  7. package/generators/app/templates/openapi-ts.config.ts +29 -0
  8. package/generators/app/templates/package.json +46 -26
  9. package/generators/app/templates/public/favicon.svg +4 -0
  10. package/generators/app/templates/src/app.tsx +8 -8
  11. package/generators/app/templates/src/components/layout/language-switcher.tsx +40 -0
  12. package/generators/app/templates/src/components/layout/theme-switcher.tsx +37 -0
  13. package/generators/app/templates/src/components/theme/theme-provider.tsx +22 -28
  14. package/generators/app/templates/src/components/ui/button.tsx +34 -32
  15. package/generators/app/templates/src/components/ui/card.tsx +76 -0
  16. package/generators/app/templates/src/components/ui/field.tsx +242 -0
  17. package/generators/app/templates/src/components/ui/form.tsx +129 -0
  18. package/generators/app/templates/src/components/ui/input-group.tsx +170 -0
  19. package/generators/app/templates/src/components/ui/input.tsx +19 -21
  20. package/generators/app/templates/src/components/ui/label.tsx +24 -0
  21. package/generators/app/templates/src/components/ui/select.tsx +184 -0
  22. package/generators/app/templates/src/components/ui/separator.tsx +31 -0
  23. package/generators/app/templates/src/components/ui/textarea.tsx +22 -0
  24. package/generators/app/templates/src/index.css +83 -26
  25. package/generators/app/templates/src/lib/api/client.ts +4 -5
  26. package/generators/app/templates/src/lib/i18n.ts +31 -16
  27. package/generators/app/templates/src/lib/routes.ts +14 -0
  28. package/generators/app/templates/src/lib/utils/error-handler.ts +7 -2
  29. package/generators/app/templates/src/lib/utils/init-form-schema.ts +12 -0
  30. package/generators/app/templates/src/lib/utils.ts +3 -4
  31. package/generators/app/templates/src/locales/en/common.json +5 -0
  32. package/generators/app/templates/src/locales/en/theme.json +5 -0
  33. package/generators/app/templates/src/locales/index.ts +31 -0
  34. package/generators/app/templates/src/locales/ja/common.json +5 -0
  35. package/generators/app/templates/src/locales/ja/theme.json +6 -0
  36. package/generators/app/templates/src/main.tsx +19 -15
  37. package/generators/app/templates/src/modules/app/layouts/app-layout.tsx +37 -0
  38. package/generators/app/templates/src/modules/app/locales/app-en.json +9 -0
  39. package/generators/app/templates/src/modules/app/locales/app-ja.json +9 -0
  40. package/generators/app/templates/src/modules/auth/components/forgot-password-form.tsx +74 -0
  41. package/generators/app/templates/src/modules/auth/components/login-form.tsx +95 -0
  42. package/generators/app/templates/src/modules/auth/components/reset-password-form.tsx +112 -0
  43. package/generators/app/templates/src/modules/auth/components/signup-form.tsx +92 -0
  44. package/generators/app/templates/src/modules/auth/contexts/auth-context.tsx +11 -0
  45. package/generators/app/templates/src/modules/auth/hooks/use-auth-hook.ts +175 -0
  46. package/generators/app/templates/src/modules/auth/layouts/auth-layout.tsx +28 -0
  47. package/generators/app/templates/src/modules/auth/locales/auth-en.json +105 -0
  48. package/generators/app/templates/src/modules/auth/locales/auth-ja.json +105 -0
  49. package/generators/app/templates/src/modules/landing/components/auth-hero.tsx +34 -0
  50. package/generators/app/templates/src/modules/landing/components/welcome-hero.tsx +24 -0
  51. package/generators/app/templates/src/modules/landing/landing-page-layout.tsx +24 -0
  52. package/generators/app/templates/src/modules/landing/landing-page.tsx +17 -0
  53. package/generators/app/templates/src/modules/landing/layouts/landing-page-layout.tsx +24 -0
  54. package/generators/app/templates/src/modules/landing/locales/landing-en.json +12 -0
  55. package/generators/app/templates/src/modules/landing/locales/landing-ja.json +11 -0
  56. package/generators/app/templates/src/openapi-client-config.ts +6 -0
  57. package/generators/app/templates/src/routeTree.gen.ts +268 -3
  58. package/generators/app/templates/src/router.tsx +2 -2
  59. package/generators/app/templates/src/routes/__root.tsx +3 -3
  60. package/generators/app/templates/src/routes/_landing/index.tsx +10 -0
  61. package/generators/app/templates/src/routes/_landing/route.tsx +14 -0
  62. package/generators/app/templates/src/routes/app/index.tsx +4 -21
  63. package/generators/app/templates/src/routes/app/route.tsx +12 -8
  64. package/generators/app/templates/src/routes/auth/forgot-password.tsx +10 -0
  65. package/generators/app/templates/src/routes/auth/login.tsx +6 -7
  66. package/generators/app/templates/src/routes/auth/reset-password.tsx +15 -0
  67. package/generators/app/templates/src/routes/auth/route.tsx +23 -6
  68. package/generators/app/templates/src/routes/auth/signup.tsx +11 -0
  69. package/generators/app/templates/src/sdk/@tanstack/react-query.gen.ts +91 -0
  70. package/generators/app/templates/src/sdk/client/client.gen.ts +167 -0
  71. package/generators/app/templates/src/sdk/client/index.ts +23 -0
  72. package/generators/app/templates/src/sdk/client/types.gen.ts +197 -0
  73. package/generators/app/templates/src/sdk/client/utils.gen.ts +213 -0
  74. package/generators/app/templates/src/sdk/client.gen.ts +18 -0
  75. package/generators/app/templates/src/sdk/core/auth.gen.ts +42 -0
  76. package/generators/app/templates/src/sdk/core/bodySerializer.gen.ts +100 -0
  77. package/generators/app/templates/src/sdk/core/params.gen.ts +176 -0
  78. package/generators/app/templates/src/sdk/core/pathSerializer.gen.ts +181 -0
  79. package/generators/app/templates/src/sdk/core/queryKeySerializer.gen.ts +136 -0
  80. package/generators/app/templates/src/sdk/core/serverSentEvents.gen.ts +266 -0
  81. package/generators/app/templates/src/sdk/core/types.gen.ts +118 -0
  82. package/generators/app/templates/src/sdk/core/utils.gen.ts +143 -0
  83. package/generators/app/templates/src/sdk/index.ts +4 -0
  84. package/generators/app/templates/src/sdk/schemas.gen.ts +195 -0
  85. package/generators/app/templates/src/sdk/sdk.gen.ts +80 -0
  86. package/generators/app/templates/src/sdk/types.gen.ts +158 -0
  87. package/generators/app/templates/src/sdk/zod.gen.ts +148 -0
  88. package/generators/app/templates/src/vite-env.d.ts +2 -1
  89. package/generators/app/templates/tsconfig.json +1 -1
  90. package/generators/app/templates/vite.config.js +35 -21
  91. package/generators/constants.js +9 -9
  92. package/package.json +3 -2
  93. package/generators/app/templates/.env.example +0 -5
  94. package/generators/app/templates/README.md +0 -57
  95. package/generators/app/templates/src/locales/en.json +0 -18
  96. package/generators/app/templates/src/modules/auth/auth-context.tsx +0 -13
  97. package/generators/app/templates/src/modules/auth/login/login-form.tsx +0 -49
  98. package/generators/app/templates/src/modules/auth/login/login-page.tsx +0 -12
  99. package/generators/app/templates/src/modules/auth/use-auth-hook.ts +0 -87
  100. package/generators/app/templates/src/routes/index.tsx +0 -12
  101. package/generators/app/templates/types.d.ts +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-kodly-react-app",
3
- "version": "1.0.6",
3
+ "version": "1.0.10",
4
4
  "description": "A Yeoman generator for creating React.js applications with Vite, TanStack Router, authentication, and i18n",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -18,7 +18,8 @@
18
18
  "generator"
19
19
  ],
20
20
  "scripts": {
21
- "test": "echo \"Error: no test specified\" && exit 1"
21
+ "test": "echo \"Error: no test specified\" && exit 1",
22
+ "prepublishOnly": "rm -rf generators/app/templates/node_modules generators/app/templates/dist generators/app/templates/.tanstack generators/app/templates/package-lock.json generators/app/templates/*.tsbuildinfo"
22
23
  },
23
24
  "author": "The Panther <info@thepanther.io>",
24
25
  "license": "MIT",
@@ -1,5 +0,0 @@
1
- # API Configuration
2
- VITE_API_BASE_URL=http://localhost:8181
3
-
4
- # Server Configuration
5
- PORT=3000
@@ -1,57 +0,0 @@
1
- # <%= appNameTitleCase %>
2
-
3
- A React application built with Vite, TanStack Router, and TypeScript.
4
-
5
- ## Getting Started
6
-
7
- 1. Install dependencies:
8
- ```bash
9
- npm install
10
- ```
11
-
12
- 2. Create a `.env` file from `.env.example`:
13
- ```bash
14
- cp .env.example .env
15
- ```
16
-
17
- 3. Update the `.env` file with your API base URL.
18
-
19
- 4. Start the development server:
20
- ```bash
21
- npm run dev
22
- ```
23
-
24
- ## Environment Variables
25
-
26
- - `VITE_API_BASE_URL` - Base URL for your API backend (default: `http://localhost:8181`)
27
- - `PORT` - Port for the development server (default: `3000`)
28
-
29
- ### Setting Environment Variables
30
-
31
- You can set environment variables in several ways:
32
-
33
- **Option 1: Using a `.env` file (recommended)**
34
- ```bash
35
- # Create .env file
36
- echo "VITE_API_BASE_URL=http://localhost:8080/api" > .env
37
- echo "PORT=3001" >> .env
38
- ```
39
-
40
- **Option 2: Using environment variables when running commands**
41
- ```bash
42
- VITE_API_BASE_URL=http://localhost:8080/api PORT=3001 npm run dev
43
- ```
44
-
45
- **Option 3: Using cross-env (works on all platforms)**
46
- ```bash
47
- cross-env VITE_API_BASE_URL=http://localhost:8080/api PORT=3001 npm run dev
48
- ```
49
-
50
- ## Project Structure
51
-
52
- - `src/routes/` - File-based routing with TanStack Router
53
- - `src/modules/auth/` - Authentication module
54
- - `src/components/` - Reusable UI components
55
- - `src/lib/` - Utility functions and configurations
56
- - `src/locales/` - i18n translation files
57
-
@@ -1,18 +0,0 @@
1
- {
2
- "login": {
3
- "title": "Login",
4
- "email": "Email",
5
- "emailPlaceholder": "Enter your email",
6
- "password": "Password",
7
- "passwordPlaceholder": "Enter your password",
8
- "submit": "Sign In"
9
- },
10
- "welcome": {
11
- "title": "Welcome",
12
- "message": "You have successfully logged in!",
13
- "logout": "Logout"
14
- },
15
- "notFound": {
16
- "message": "Page not found"
17
- }
18
- }
@@ -1,13 +0,0 @@
1
- import { createContext } from "react";
2
- import { currentUserDetailsAtom } from "./use-auth-hook";
3
- import { useAtomValue } from "jotai";
4
-
5
- export const AuthContext = createContext<any | undefined>(undefined);
6
-
7
- export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
8
- const authData = useAtomValue(currentUserDetailsAtom);
9
- return (
10
- <AuthContext.Provider value={authData}>{children}</AuthContext.Provider>
11
- );
12
- };
13
-
@@ -1,49 +0,0 @@
1
- import { Button } from "@/components/ui/button";
2
- import { Input } from "@/components/ui/input";
3
- import { useLogin } from "../use-auth-hook";
4
- import { useState } from "react";
5
- import { useTranslation } from "react-i18next";
6
-
7
- export function LoginForm() {
8
- const { t } = useTranslation();
9
- const { mutate, isPending } = useLogin();
10
- const [email, setEmail] = useState("");
11
- const [password, setPassword] = useState("");
12
-
13
- const handleSubmit = (e: React.FormEvent) => {
14
- e.preventDefault();
15
- mutate({ email, password });
16
- };
17
-
18
- return (
19
- <div className="flex flex-col gap-6">
20
- <h1 className="text-2xl font-semibold">{t("login.title")}</h1>
21
- <form className="flex flex-col gap-4" onSubmit={handleSubmit}>
22
- <div className="flex flex-col gap-2">
23
- <label className="text-sm font-medium">{t("login.email")}</label>
24
- <Input
25
- type="email"
26
- value={email}
27
- onChange={(e) => setEmail(e.target.value)}
28
- placeholder={t("login.emailPlaceholder")}
29
- required
30
- />
31
- </div>
32
- <div className="flex flex-col gap-2">
33
- <label className="text-sm font-medium">{t("login.password")}</label>
34
- <Input
35
- type="password"
36
- value={password}
37
- onChange={(e) => setPassword(e.target.value)}
38
- placeholder={t("login.passwordPlaceholder")}
39
- required
40
- />
41
- </div>
42
- <Button type="submit" disabled={isPending}>
43
- {t("login.submit")}
44
- </Button>
45
- </form>
46
- </div>
47
- );
48
- }
49
-
@@ -1,12 +0,0 @@
1
- import { LoginForm } from "./login-form";
2
-
3
- export function LoginPage() {
4
- return (
5
- <div className="flex h-screen items-center justify-center bg-background">
6
- <div className="w-full max-w-md p-8">
7
- <LoginForm />
8
- </div>
9
- </div>
10
- );
11
- }
12
-
@@ -1,87 +0,0 @@
1
- import { Route as LoginRoute } from '@/routes/auth/login';
2
- import { Route as AppRoute } from '@/routes/index';
3
- import { useMutation } from '@tanstack/react-query';
4
- import { useNavigate } from '@tanstack/react-router';
5
- import { atom, useAtomValue, useSetAtom } from 'jotai';
6
- import { atomWithStorage } from 'jotai/utils';
7
- import { client } from '@/lib/api/client';
8
-
9
- export const authTokenAtom = atomWithStorage<string>('authTokenAtom', '', undefined, {
10
- getOnInit: true,
11
- });
12
-
13
- export const currentUserDetailsAtom = atom<any>();
14
-
15
- export const setTokenInAxios = (token?: string | null) => {
16
- if (token) {
17
- client.defaults.headers.common['x-auth-token'] = token;
18
- } else {
19
- delete client.defaults.headers.common['x-auth-token'];
20
- }
21
- };
22
-
23
- export const setLocaleInAxios = (locale: 'en') => {
24
- client.defaults.headers.common['Accept-Language'] = locale;
25
- };
26
-
27
- export const useLogin = () => {
28
- const setAuthToken = useSetAtom(authTokenAtom);
29
- const setCurrentUser = useSetAtom(currentUserDetailsAtom);
30
- const navigate = useNavigate();
31
- return useMutation({
32
- mutationFn: async (data: { email: string; password: string }) => {
33
- const response = await client.post('/auth/user/login', data);
34
- return response.data;
35
- },
36
- onSuccess: (authData) => {
37
- const token = authData?.data?.token || '';
38
- setAuthToken(token);
39
- setCurrentUser(authData.data);
40
- setTokenInAxios(token);
41
- navigate({ to: AppRoute.to });
42
- },
43
- onError: (err: any) => {
44
- // Error is already handled by axios interceptor
45
- console.error('Login failed:', err);
46
- },
47
- });
48
- };
49
-
50
- export const useValidateToken = () => {
51
- const setCurrentUser = useSetAtom(currentUserDetailsAtom);
52
- const setAuthToken = useSetAtom(authTokenAtom);
53
- const authToken = useAtomValue(authTokenAtom);
54
- setTokenInAxios(authToken);
55
- return useMutation({
56
- mutationFn: async () => {
57
- const response = await client.post('/auth/user/validate-token');
58
- return response.data;
59
- },
60
- retry: false,
61
- onSuccess: (data) => {
62
- setCurrentUser(data.data);
63
- },
64
- onError: () => {
65
- setCurrentUser(undefined);
66
- setAuthToken('');
67
- setTokenInAxios();
68
- },
69
- });
70
- };
71
-
72
- export const useLogout = () => {
73
- const setAuthToken = useSetAtom(authTokenAtom);
74
- const setCurrentUser = useSetAtom(currentUserDetailsAtom);
75
- const navigate = useNavigate();
76
- return useMutation({
77
- mutationFn: async () => {
78
- await client.post('/auth/user/logout');
79
- },
80
- onSuccess: () => {
81
- setAuthToken('');
82
- setCurrentUser(undefined);
83
- setTokenInAxios();
84
- navigate({ to: LoginRoute.to });
85
- },
86
- });
87
- };
@@ -1,12 +0,0 @@
1
- import { createFileRoute, redirect } from "@tanstack/react-router";
2
- import { Route as AppRoute } from "./app";
3
-
4
- export const Route = createFileRoute("/")({
5
- beforeLoad: () => {
6
- throw redirect({
7
- to: AppRoute.to,
8
- replace: true,
9
- });
10
- },
11
- });
12
-
@@ -1,3 +0,0 @@
1
- // Global type definitions
2
- // Add your custom type definitions here
3
-