@highbeek/create-rnstarterkit 1.0.2-beta.5 → 1.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 (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +268 -0
  3. package/dist/bin/create-rnstarterkit.js +205 -7
  4. package/dist/src/generators/appGenerator.js +2474 -58
  5. package/dist/src/generators/codeGenerator.js +289 -0
  6. package/dist/templates/cli-base/App.tsx +199 -21
  7. package/dist/templates/cli-base/assets/images/icon.png +0 -0
  8. package/dist/templates/cli-base/assets/images/partial-react-logo.png +0 -0
  9. package/dist/templates/cli-base/assets/images/react-logo.png +0 -0
  10. package/dist/templates/cli-base/babel.config.js +1 -0
  11. package/dist/templates/cli-base/ios/BaseApp.xcodeproj/project.pbxproj +6 -0
  12. package/dist/templates/cli-base/ios/Podfile +5 -0
  13. package/dist/templates/cli-base/jest.config.js +4 -0
  14. package/dist/templates/cli-base/package.json +7 -4
  15. package/dist/templates/cli-base/tsconfig.json +1 -0
  16. package/dist/templates/expo-base/app/_layout.tsx +7 -18
  17. package/dist/templates/expo-base/app/home.tsx +37 -0
  18. package/dist/templates/expo-base/app/index.tsx +170 -0
  19. package/dist/templates/expo-base/app.json +2 -1
  20. package/dist/templates/expo-base/package.json +7 -3
  21. package/dist/templates/optional/auth-context/components/layout/ScreenLayout.tsx +46 -0
  22. package/dist/templates/optional/auth-context/navigation/ProtectedStack.tsx +33 -5
  23. package/dist/templates/optional/auth-context/screens/HomeScreen.tsx +4 -3
  24. package/dist/templates/optional/auth-context/screens/LoginScreen.tsx +42 -7
  25. package/dist/templates/optional/auth-context/screens/ProfileScreen.tsx +4 -3
  26. package/dist/templates/optional/auth-context/screens/RegisterScreen.tsx +42 -7
  27. package/dist/templates/optional/auth-context/screens/SettingsScreen.tsx +4 -3
  28. package/dist/templates/optional/auth-context/screens/WelcomeScreen.tsx +174 -0
  29. package/dist/templates/optional/auth-redux/components/layout/ScreenLayout.tsx +46 -0
  30. package/dist/templates/optional/auth-redux/navigation/ProtectedStack.tsx +39 -2
  31. package/dist/templates/optional/auth-redux/screens/HomeScreen.tsx +4 -3
  32. package/dist/templates/optional/auth-redux/screens/LoginScreen.tsx +43 -8
  33. package/dist/templates/optional/auth-redux/screens/ProfileScreen.tsx +7 -10
  34. package/dist/templates/optional/auth-redux/screens/RegisterScreen.tsx +61 -11
  35. package/dist/templates/optional/auth-redux/screens/SettingsScreen.tsx +6 -9
  36. package/dist/templates/optional/auth-redux/screens/WelcomeScreen.tsx +174 -0
  37. package/dist/templates/optional/auth-zustand/components/layout/ScreenLayout.tsx +46 -0
  38. package/dist/templates/optional/auth-zustand/navigation/ProtectedStack.tsx +34 -6
  39. package/dist/templates/optional/auth-zustand/screens/HomeScreen.tsx +4 -3
  40. package/dist/templates/optional/auth-zustand/screens/LoginScreen.tsx +42 -7
  41. package/dist/templates/optional/auth-zustand/screens/ProfileScreen.tsx +4 -3
  42. package/dist/templates/optional/auth-zustand/screens/RegisterScreen.tsx +42 -7
  43. package/dist/templates/optional/auth-zustand/screens/SettingsScreen.tsx +4 -3
  44. package/dist/templates/optional/auth-zustand/screens/WelcomeScreen.tsx +174 -0
  45. package/dist/templates/optional/ci/.github/workflows/ci.yml +32 -0
  46. package/dist/templates/optional/error-boundary/components/ErrorBoundary.tsx +83 -0
  47. package/dist/templates/optional/formik/components/formik/FormikInput.tsx +45 -0
  48. package/dist/templates/optional/formik/components/formik/LoginForm.tsx +60 -0
  49. package/dist/templates/optional/formik/schemas/auth.schema.ts +17 -0
  50. package/dist/templates/optional/i18n/src/i18n/hooks/useAppTranslation.ts +28 -0
  51. package/dist/templates/optional/i18n/src/i18n/i18n.ts +30 -0
  52. package/dist/templates/optional/i18n/src/i18n/locales/en.json +32 -0
  53. package/dist/templates/optional/i18n/src/i18n/locales/es.json +32 -0
  54. package/dist/templates/optional/maestro/.maestro/flows/01_welcome.yaml +5 -0
  55. package/dist/templates/optional/maestro-auth/.maestro/flows/01_welcome.yaml +5 -0
  56. package/dist/templates/optional/maestro-auth/.maestro/flows/02_login.yaml +13 -0
  57. package/dist/templates/optional/maestro-auth/.maestro/flows/03_logout.yaml +16 -0
  58. package/dist/templates/optional/mmkv/utils/storage.ts +17 -0
  59. package/dist/templates/optional/react-hook-form/components/rhf/LoginForm.tsx +63 -0
  60. package/dist/templates/optional/react-hook-form/components/rhf/RHFInput.tsx +50 -0
  61. package/dist/templates/optional/react-hook-form/schemas/auth.schema.ts +29 -0
  62. package/dist/templates/optional/react-query/hooks/useAppMutation.ts +16 -0
  63. package/dist/templates/optional/react-query/hooks/useAppQuery.ts +12 -0
  64. package/dist/templates/optional/react-query/services/queryClient.ts +14 -0
  65. package/dist/templates/optional/redux/store/hooks.ts +6 -0
  66. package/dist/templates/optional/redux/store/store.ts +11 -0
  67. package/dist/templates/optional/sentry/src/utils/sentry.ts +24 -0
  68. package/dist/templates/optional/swr/hooks/useSWRFetch.ts +14 -0
  69. package/dist/templates/optional/swr/providers/SWRProvider.tsx +21 -0
  70. package/dist/templates/optional/tsconfig.json +17 -0
  71. package/dist/templates/optional/zustand/store/appStore.ts +13 -0
  72. package/package.json +40 -5
  73. package/dist/templates/expo-base/App.tsx +0 -32
  74. package/dist/templates/expo-base/app/(tabs)/_layout.tsx +0 -35
  75. package/dist/templates/expo-base/app/(tabs)/explore.tsx +0 -112
  76. package/dist/templates/expo-base/app/(tabs)/index.tsx +0 -98
  77. package/dist/templates/expo-base/app/modal.tsx +0 -29
  78. package/dist/templates/expo-base/components/external-link.tsx +0 -25
  79. package/dist/templates/expo-base/components/haptic-tab.tsx +0 -18
  80. package/dist/templates/expo-base/components/hello-wave.tsx +0 -19
  81. package/dist/templates/expo-base/components/parallax-scroll-view.tsx +0 -79
  82. package/dist/templates/expo-base/components/themed-text.tsx +0 -60
  83. package/dist/templates/expo-base/components/themed-view.tsx +0 -14
  84. package/dist/templates/expo-base/components/ui/collapsible.tsx +0 -45
  85. package/dist/templates/expo-base/components/ui/icon-symbol.ios.tsx +0 -32
  86. package/dist/templates/expo-base/components/ui/icon-symbol.tsx +0 -41
  87. package/dist/templates/expo-base/constants/theme.ts +0 -53
  88. package/dist/templates/expo-base/hooks/use-color-scheme.ts +0 -1
  89. package/dist/templates/expo-base/hooks/use-color-scheme.web.ts +0 -21
  90. package/dist/templates/expo-base/hooks/use-theme-color.ts +0 -21
  91. package/dist/templates/expo-base/scripts/reset-project.js +0 -112
  92. package/dist/templates/optional/apiClient/api/client.axios.ts +0 -124
  93. /package/dist/templates/optional/auth-context/api/{authApi.ts → endpoints/auth.ts} +0 -0
  94. /package/dist/templates/optional/auth-redux/api/{authApi.ts → endpoints/auth.ts} +0 -0
  95. /package/dist/templates/optional/auth-zustand/api/{authApi.ts → endpoints/auth.ts} +0 -0
@@ -1,21 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { useColorScheme as useRNColorScheme } from 'react-native';
3
-
4
- /**
5
- * To support static rendering, this value needs to be re-calculated on the client side for web
6
- */
7
- export function useColorScheme() {
8
- const [hasHydrated, setHasHydrated] = useState(false);
9
-
10
- useEffect(() => {
11
- setHasHydrated(true);
12
- }, []);
13
-
14
- const colorScheme = useRNColorScheme();
15
-
16
- if (hasHydrated) {
17
- return colorScheme;
18
- }
19
-
20
- return 'light';
21
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Learn more about light and dark modes:
3
- * https://docs.expo.dev/guides/color-schemes/
4
- */
5
-
6
- import { Colors } from '@/constants/theme';
7
- import { useColorScheme } from '@/hooks/use-color-scheme';
8
-
9
- export function useThemeColor(
10
- props: { light?: string; dark?: string },
11
- colorName: keyof typeof Colors.light & keyof typeof Colors.dark
12
- ) {
13
- const theme = useColorScheme() ?? 'light';
14
- const colorFromProps = props[theme];
15
-
16
- if (colorFromProps) {
17
- return colorFromProps;
18
- } else {
19
- return Colors[theme][colorName];
20
- }
21
- }
@@ -1,112 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * This script is used to reset the project to a blank state.
5
- * It deletes or moves the /app, /components, /hooks, /scripts, and /constants directories to /app-example based on user input and creates a new /app directory with an index.tsx and _layout.tsx file.
6
- * You can remove the `reset-project` script from package.json and safely delete this file after running it.
7
- */
8
-
9
- const fs = require("fs");
10
- const path = require("path");
11
- const readline = require("readline");
12
-
13
- const root = process.cwd();
14
- const oldDirs = ["app", "components", "hooks", "constants", "scripts"];
15
- const exampleDir = "app-example";
16
- const newAppDir = "app";
17
- const exampleDirPath = path.join(root, exampleDir);
18
-
19
- const indexContent = `import { Text, View } from "react-native";
20
-
21
- export default function Index() {
22
- return (
23
- <View
24
- style={{
25
- flex: 1,
26
- justifyContent: "center",
27
- alignItems: "center",
28
- }}
29
- >
30
- <Text>Edit app/index.tsx to edit this screen.</Text>
31
- </View>
32
- );
33
- }
34
- `;
35
-
36
- const layoutContent = `import { Stack } from "expo-router";
37
-
38
- export default function RootLayout() {
39
- return <Stack />;
40
- }
41
- `;
42
-
43
- const rl = readline.createInterface({
44
- input: process.stdin,
45
- output: process.stdout,
46
- });
47
-
48
- const moveDirectories = async (userInput) => {
49
- try {
50
- if (userInput === "y") {
51
- // Create the app-example directory
52
- await fs.promises.mkdir(exampleDirPath, { recursive: true });
53
- console.log(`📁 /${exampleDir} directory created.`);
54
- }
55
-
56
- // Move old directories to new app-example directory or delete them
57
- for (const dir of oldDirs) {
58
- const oldDirPath = path.join(root, dir);
59
- if (fs.existsSync(oldDirPath)) {
60
- if (userInput === "y") {
61
- const newDirPath = path.join(root, exampleDir, dir);
62
- await fs.promises.rename(oldDirPath, newDirPath);
63
- console.log(`➡️ /${dir} moved to /${exampleDir}/${dir}.`);
64
- } else {
65
- await fs.promises.rm(oldDirPath, { recursive: true, force: true });
66
- console.log(`❌ /${dir} deleted.`);
67
- }
68
- } else {
69
- console.log(`➡️ /${dir} does not exist, skipping.`);
70
- }
71
- }
72
-
73
- // Create new /app directory
74
- const newAppDirPath = path.join(root, newAppDir);
75
- await fs.promises.mkdir(newAppDirPath, { recursive: true });
76
- console.log("\n📁 New /app directory created.");
77
-
78
- // Create index.tsx
79
- const indexPath = path.join(newAppDirPath, "index.tsx");
80
- await fs.promises.writeFile(indexPath, indexContent);
81
- console.log("📄 app/index.tsx created.");
82
-
83
- // Create _layout.tsx
84
- const layoutPath = path.join(newAppDirPath, "_layout.tsx");
85
- await fs.promises.writeFile(layoutPath, layoutContent);
86
- console.log("📄 app/_layout.tsx created.");
87
-
88
- console.log("\n✅ Project reset complete. Next steps:");
89
- console.log(
90
- `1. Run \`npx expo start\` to start a development server.\n2. Edit app/index.tsx to edit the main screen.${
91
- userInput === "y"
92
- ? `\n3. Delete the /${exampleDir} directory when you're done referencing it.`
93
- : ""
94
- }`
95
- );
96
- } catch (error) {
97
- console.error(`❌ Error during script execution: ${error.message}`);
98
- }
99
- };
100
-
101
- rl.question(
102
- "Do you want to move existing files to /app-example instead of deleting them? (Y/n): ",
103
- (answer) => {
104
- const userInput = answer.trim().toLowerCase() || "y";
105
- if (userInput === "y" || userInput === "n") {
106
- moveDirectories(userInput).finally(() => rl.close());
107
- } else {
108
- console.log("❌ Invalid input. Please enter 'Y' or 'N'.");
109
- rl.close();
110
- }
111
- }
112
- );
@@ -1,124 +0,0 @@
1
- import axios, {
2
- AxiosError,
3
- AxiosRequestConfig,
4
- AxiosResponse,
5
- InternalAxiosRequestConfig,
6
- } from "axios";
7
- import { API_BASE_URL } from "../config/env";
8
-
9
- export class ApiError extends Error {
10
- status: number;
11
- data: unknown;
12
-
13
- constructor(status: number, message: string, data: unknown) {
14
- super(message);
15
- this.name = "ApiError";
16
- this.status = status;
17
- this.data = data;
18
- }
19
- }
20
-
21
- type RequestOptions = {
22
- headers?: Record<string, string>;
23
- query?: Record<string, string | number | boolean | undefined>;
24
- token?: string | null;
25
- signal?: AbortSignal;
26
- };
27
-
28
- const client = axios.create({
29
- baseURL: API_BASE_URL,
30
- timeout: 15000,
31
- });
32
-
33
- let authTokenGetter: (() => string | null | undefined) | null = null;
34
-
35
- export function setAuthTokenGetter(getter: (() => string | null | undefined) | null) {
36
- authTokenGetter = getter;
37
- }
38
-
39
- function resolveErrorMessage(data: unknown, status: number) {
40
- if (
41
- typeof data === "object" &&
42
- data !== null &&
43
- "message" in data &&
44
- typeof (data as { message: unknown }).message === "string"
45
- ) {
46
- return (data as { message: string }).message;
47
- }
48
- return `Request failed with status ${status}`;
49
- }
50
-
51
- export function addRequestInterceptor(
52
- interceptor: (
53
- config: InternalAxiosRequestConfig,
54
- ) =>
55
- | InternalAxiosRequestConfig
56
- | Promise<InternalAxiosRequestConfig>,
57
- ) {
58
- return client.interceptors.request.use(interceptor);
59
- }
60
-
61
- export function addResponseInterceptor(
62
- onFulfilled?: (
63
- response: AxiosResponse,
64
- ) => AxiosResponse | Promise<AxiosResponse>,
65
- onRejected?: (error: AxiosError) => unknown,
66
- ) {
67
- return client.interceptors.response.use(onFulfilled, onRejected);
68
- }
69
-
70
- // Default auth + error interceptors.
71
- addRequestInterceptor((config) => {
72
- const token = authTokenGetter?.();
73
- if (token) {
74
- config.headers.Authorization = `Bearer ${token}`;
75
- }
76
- return config;
77
- });
78
-
79
- addResponseInterceptor(
80
- (response) => response,
81
- (error) => {
82
- if (axios.isAxiosError(error)) {
83
- const status = error.response?.status ?? 500;
84
- const data = error.response?.data ?? null;
85
- return Promise.reject(new ApiError(status, resolveErrorMessage(data, status), data));
86
- }
87
- return Promise.reject(error);
88
- },
89
- );
90
-
91
- async function request<T>(
92
- method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE",
93
- path: string,
94
- body?: unknown,
95
- options: RequestOptions = {},
96
- ): Promise<T> {
97
- const { headers = {}, query, token, signal } = options;
98
- const requestConfig: AxiosRequestConfig = {
99
- method,
100
- url: path,
101
- data: body,
102
- params: query,
103
- signal,
104
- headers: {
105
- ...(token ? { Authorization: `Bearer ${token}` } : {}),
106
- ...headers,
107
- },
108
- };
109
- const response = await client.request<T>(requestConfig);
110
- return response.data;
111
- }
112
-
113
- export const apiClient = {
114
- get: <T>(path: string, options?: RequestOptions) =>
115
- request<T>("GET", path, undefined, options),
116
- post: <T>(path: string, body?: unknown, options?: RequestOptions) =>
117
- request<T>("POST", path, body, options),
118
- put: <T>(path: string, body?: unknown, options?: RequestOptions) =>
119
- request<T>("PUT", path, body, options),
120
- patch: <T>(path: string, body?: unknown, options?: RequestOptions) =>
121
- request<T>("PATCH", path, body, options),
122
- delete: <T>(path: string, options?: RequestOptions) =>
123
- request<T>("DELETE", path, undefined, options),
124
- };