generator-kodly-react-app 1.0.10 → 1.0.11

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.
@@ -76,6 +76,7 @@ export default class ReactAppGenerator extends BaseGenerator {
76
76
  'src/modules/auth/contexts/auth-context.tsx',
77
77
  'src/modules/auth/hooks/use-auth-hook.ts',
78
78
  'src/modules/auth/layouts/auth-layout.tsx',
79
+ 'src/modules/auth/schemas/form-schemas.ts',
79
80
  'src/modules/auth/locales/auth-en.json',
80
81
  'src/modules/auth/locales/auth-ja.json',
81
82
  ];
@@ -102,14 +103,7 @@ export default class ReactAppGenerator extends BaseGenerator {
102
103
  }
103
104
 
104
105
  _writeLibFiles() {
105
- const libFiles = [
106
- 'src/lib/utils.ts',
107
- 'src/lib/i18n.ts',
108
- 'src/lib/routes.ts',
109
- 'src/lib/api/client.ts',
110
- 'src/lib/utils/error-handler.ts',
111
- 'src/lib/utils/init-form-schema.ts',
112
- ];
106
+ const libFiles = ['src/lib/utils.ts', 'src/lib/i18n.ts', 'src/lib/routes.ts', 'src/lib/utils/error-handler.ts'];
113
107
  libFiles.forEach((file) => this._writeFile(file));
114
108
  }
115
109
 
@@ -1,10 +1,86 @@
1
+ # Dependencies
1
2
  node_modules
2
- .DS_Store
3
+ .pnp
4
+ .pnp.js
5
+ .yarn/cache
6
+ .yarn/unplugged
7
+ .yarn/build-state.yml
8
+ .yarn/install-state.gz
9
+
10
+ # Build outputs
3
11
  dist
4
12
  dist-ssr
5
13
  dist-electron
6
- *.local
14
+ build
15
+ out
16
+ .next
17
+ .nuxt
18
+ .output
19
+
20
+ # Environment variables
7
21
  .env
8
22
  .env.local
23
+ .env.development.local
24
+ .env.test.local
25
+ .env.production.local
9
26
  .env.*.local
27
+ *.local
28
+
29
+ # Logs
30
+ logs
31
+ *.log
32
+ npm-debug.log*
33
+ yarn-debug.log*
34
+ yarn-error.log*
35
+ pnpm-debug.log*
36
+ lerna-debug.log*
37
+
38
+ # OS files
39
+ .DS_Store
40
+ .DS_Store?
41
+ ._*
42
+ .Spotlight-V100
43
+ .Trashes
44
+ ehthumbs.db
45
+ Thumbs.db
46
+ Desktop.ini
47
+
48
+ # IDE and editors
49
+ .vscode/*
50
+ !.vscode/extensions.json
51
+ !.vscode/settings.json
52
+ .idea
53
+ *.swp
54
+ *.swo
55
+ *~
56
+ .project
57
+ .classpath
58
+ .settings/
59
+ *.sublime-project
60
+ *.sublime-workspace
61
+
62
+ # Testing
63
+ coverage
64
+ *.lcov
65
+ .nyc_output
66
+ .jest
67
+ .cache
68
+
69
+ # TypeScript
70
+ *.tsbuildinfo
71
+ .tsbuildinfo
72
+
73
+ # Temporary files
74
+ *.tmp
75
+ *.temp
76
+ .cache
77
+ .parcel-cache
78
+ .turbo
79
+
80
+ # Package manager
81
+ .pnpm-store
10
82
 
83
+ # Misc
84
+ *.pem
85
+ .vite
86
+ .swc
@@ -42,8 +42,7 @@
42
42
  "tailwind-merge": "^3.4.0",
43
43
  "tailwindcss-animate": "^1.0.7",
44
44
  "tw-animate-css": "^1.4.0",
45
- "zod": "^4.3.5",
46
- "zod-empty": "^2.0.2"
45
+ "zod": "^4.3.5"
47
46
  },
48
47
  "devDependencies": {
49
48
  "@tailwindcss/postcss": "^4.1.18",
@@ -11,7 +11,7 @@ const localStorageKey = 'app-language';
11
11
 
12
12
  const setLanguageHooks = (language: SupportedLanguages) => {
13
13
  setLocaleInClient(language);
14
- z.config(z.locales[language]());
14
+ z.config((z.locales[language] ?? z.locales[defaultLanguage] ?? z.locales['en'])());
15
15
  };
16
16
 
17
17
  const getStoredLanguage = (): SupportedLanguages => {
@@ -6,9 +6,9 @@ import { z } from 'zod';
6
6
  import { zodResolver } from '@hookform/resolvers/zod';
7
7
  import { useForm } from 'react-hook-form';
8
8
  import { useTranslation } from 'react-i18next';
9
- import { init } from 'zod-empty';
10
9
  import { Link } from '@tanstack/react-router';
11
10
  import { Route as LoginRoute } from '@/routes/auth/login';
11
+ import { forgotPasswordFormDefaults } from '@/modules/auth/schemas/form-schemas';
12
12
 
13
13
  const zForgotPasswordDto = z.object({
14
14
  email: z.email().min(1).max(256),
@@ -21,7 +21,7 @@ export function ForgotPasswordForm() {
21
21
  const { mutate, isPending } = useSendOtp();
22
22
  const form = useForm<ForgotPasswordFormData>({
23
23
  resolver: zodResolver(zForgotPasswordDto),
24
- defaultValues: init(zForgotPasswordDto),
24
+ defaultValues: forgotPasswordFormDefaults,
25
25
  });
26
26
 
27
27
  const onSubmit = (data: ForgotPasswordFormData) => {
@@ -6,11 +6,11 @@ import { zUserLoginDto } from '@/sdk/zod.gen';
6
6
  import { zodResolver } from '@hookform/resolvers/zod';
7
7
  import { useForm } from 'react-hook-form';
8
8
  import { useTranslation } from 'react-i18next';
9
- import { init } from 'zod-empty';
10
9
  import type { z } from 'zod';
11
10
  import { Link } from '@tanstack/react-router';
12
11
  import { Route as SignupRoute } from '@/routes/auth/signup';
13
12
  import { Route as ForgotPasswordRoute } from '@/routes/auth/forgot-password';
13
+ import { loginFormDefaults } from '@/modules/auth/schemas/form-schemas';
14
14
 
15
15
  type LoginFormData = z.infer<typeof zUserLoginDto>;
16
16
 
@@ -19,7 +19,7 @@ export function LoginForm() {
19
19
  const { mutate, isPending } = useLogin();
20
20
  const form = useForm<LoginFormData>({
21
21
  resolver: zodResolver(zUserLoginDto),
22
- defaultValues: init(zUserLoginDto),
22
+ defaultValues: loginFormDefaults,
23
23
  });
24
24
 
25
25
  const onSubmit = (data: LoginFormData) => {
@@ -6,10 +6,10 @@ import { zUserResetPasswordDto } from '@/sdk/zod.gen';
6
6
  import { zodResolver } from '@hookform/resolvers/zod';
7
7
  import { useForm } from 'react-hook-form';
8
8
  import { useTranslation } from 'react-i18next';
9
- import { init } from 'zod-empty';
10
9
  import type { z } from 'zod';
11
10
  import { Link, useSearch } from '@tanstack/react-router';
12
11
  import { Route as LoginRoute } from '@/routes/auth/login';
12
+ import { resetPasswordFormDefaults } from '@/modules/auth/schemas/form-schemas';
13
13
 
14
14
  type ResetPasswordFormData = z.infer<typeof zUserResetPasswordDto>;
15
15
 
@@ -20,7 +20,7 @@ export function ResetPasswordForm() {
20
20
  const form = useForm<ResetPasswordFormData>({
21
21
  resolver: zodResolver(zUserResetPasswordDto),
22
22
  defaultValues: {
23
- ...init(zUserResetPasswordDto),
23
+ ...resetPasswordFormDefaults,
24
24
  email: search.email || '',
25
25
  },
26
26
  });
@@ -6,10 +6,10 @@ import { zUserSignupDto } from '@/sdk/zod.gen';
6
6
  import { zodResolver } from '@hookform/resolvers/zod';
7
7
  import { useForm } from 'react-hook-form';
8
8
  import { useTranslation } from 'react-i18next';
9
- import { init } from 'zod-empty';
10
9
  import { Link } from '@tanstack/react-router';
11
10
  import { Route as LoginRoute } from '@/routes/auth/login';
12
11
  import { z } from 'zod';
12
+ import { signupFormDefaults } from '@/modules/auth/schemas/form-schemas';
13
13
 
14
14
  type SignupFormData = z.infer<typeof zUserSignupDto>;
15
15
 
@@ -21,7 +21,7 @@ export function SignupForm() {
21
21
  });
22
22
  const form = useForm<SignupFormData>({
23
23
  resolver: zodResolver(extendedSchema),
24
- defaultValues: init(zUserSignupDto),
24
+ defaultValues: signupFormDefaults,
25
25
  });
26
26
 
27
27
  const onSubmit = (data: SignupFormData) => {
@@ -77,6 +77,7 @@ export const useLogin = () => {
77
77
  setTokenInClient(authData?.token);
78
78
  },
79
79
  onError: (err) => {
80
+ console.error('Login error:', err);
80
81
  toast.error(err.response?.data.message || t('auth.messages.loginFailed'));
81
82
  },
82
83
  });
@@ -95,6 +96,7 @@ export const useSignup = () => {
95
96
  setTokenInClient(authData?.token);
96
97
  },
97
98
  onError: (err) => {
99
+ console.error('Signup error:', err);
98
100
  toast.error(err.response?.data.message || t('auth.messages.signupFailed'));
99
101
  },
100
102
  });
@@ -114,7 +116,8 @@ export const useValidateToken = () => {
114
116
  setAuthToken(authData?.token || '');
115
117
  setTokenInClient(authData?.token);
116
118
  },
117
- onError: () => {
119
+ onError: (err) => {
120
+ console.error('Validate token error:', err);
118
121
  setCurrentUser(undefined);
119
122
  setAuthToken('');
120
123
  setTokenInClient();
@@ -154,6 +157,7 @@ export const useSendOtp = () => {
154
157
  }
155
158
  },
156
159
  onError: (err) => {
160
+ console.error('Send OTP error:', err);
157
161
  toast.error(err.response?.data.message || t('auth.messages.otpSendFailed'));
158
162
  },
159
163
  });
@@ -169,6 +173,7 @@ export const useResetPassword = () => {
169
173
  navigate({ to: LoginRoute.to });
170
174
  },
171
175
  onError: (err) => {
176
+ console.error('Reset password error:', err);
172
177
  toast.error(err.response?.data.message || t('auth.messages.passwordResetFailed'));
173
178
  },
174
179
  });
@@ -0,0 +1,26 @@
1
+ import type { z } from 'zod';
2
+ import { zUserLoginDto, zUserSignupDto, zUserResetPasswordDto } from '@/sdk/zod.gen';
3
+
4
+ type LoginFormData = z.infer<typeof zUserLoginDto>;
5
+ type SignupFormData = z.infer<typeof zUserSignupDto>;
6
+ type ResetPasswordFormData = z.infer<typeof zUserResetPasswordDto>;
7
+
8
+ export const loginFormDefaults: LoginFormData = {
9
+ email: '',
10
+ password: '',
11
+ };
12
+
13
+ export const signupFormDefaults: SignupFormData = {
14
+ email: '',
15
+ password: '',
16
+ };
17
+
18
+ export const forgotPasswordFormDefaults = {
19
+ email: '',
20
+ };
21
+
22
+ export const resetPasswordFormDefaults: ResetPasswordFormData = {
23
+ email: '',
24
+ password: '',
25
+ otp: '',
26
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-kodly-react-app",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
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",
@@ -1,34 +0,0 @@
1
- import axios, { AxiosResponse } from 'axios';
2
- import { handleBackendError } from '@/lib/utils/error-handler';
3
-
4
- const apiBaseUrl = import.meta.env.VITE_API_BASE_URL;
5
- export const client = axios.create({
6
- baseURL: apiBaseUrl,
7
- headers: {
8
- 'Content-Type': 'application/json',
9
- },
10
- });
11
-
12
- // Add response interceptor to handle non-2xx responses and network errors
13
- client.interceptors.response.use(
14
- (response: AxiosResponse) => response,
15
- (error: unknown) => {
16
- // Handle all errors: non-2xx responses and network errors
17
- if (error && typeof error === 'object' && 'response' in error) {
18
- const axiosError = error as { response?: { status?: number }; code?: string };
19
- if (axiosError.response && axiosError.response.status && axiosError.response.status >= 300) {
20
- // Backend returned an error response
21
- handleBackendError(error);
22
- } else if (axiosError.code === 'ERR_NETWORK' || !axiosError.response) {
23
- // Network error or no response (connection refused, timeout, etc.)
24
- handleBackendError(error);
25
- }
26
- } else {
27
- // Handle non-axios errors
28
- handleBackendError(error);
29
- }
30
- return Promise.reject(error);
31
- }
32
- );
33
-
34
- export default client;
@@ -1,12 +0,0 @@
1
- import { zodResolver } from '@hookform/resolvers/zod';
2
- import { init } from 'zod-empty';
3
- import * as z from 'zod';
4
-
5
- z.config(z.locales.ja());
6
-
7
- export function initFormSchema<T extends {}>(zodObject: any, defaultValues?: T) {
8
- return {
9
- defaultValues: defaultValues || (init(zodObject) as T),
10
- resolver: zodResolver(zodObject) as any,
11
- };
12
- }