create-rn-folder-structure 1.0.3 → 1.0.6
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.
- package/README.md +28 -80
- package/generators/features.js +107 -1
- package/generators/navigation.js +18 -15
- package/package.json +23 -5
package/README.md
CHANGED
|
@@ -1,91 +1,39 @@
|
|
|
1
|
-
# 📦 create-rn-folder-structure
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
and production-ready folder structure** for React Native projects.
|
|
2
|
+
# React Native Project Structure Generator
|
|
5
3
|
|
|
6
|
-
This
|
|
7
|
-
you can focus on writing features---not setting up directories.
|
|
4
|
+
This project was automatically generated using **create-rn-folder-structure**.
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
## 📁 Folder Structure
|
|
10
7
|
|
|
11
|
-
## 🚀 Features
|
|
12
|
-
|
|
13
|
-
- 📁 Generates a modern, opinionated React Native folder structure\
|
|
14
|
-
- 🔌 Auto-creates feature modules (screens, store, API)\
|
|
15
|
-
- 🧩 Shared components, constants, hooks, and utilities\
|
|
16
|
-
- 📡 Centralized API configuration\
|
|
17
|
-
- 💾 Async storage service helpers\
|
|
18
|
-
- ⚡ Fast, simple, and zero-dependency CLI
|
|
19
|
-
|
|
20
|
-
------------------------------------------------------------------------
|
|
21
|
-
|
|
22
|
-
## 📦 Installation
|
|
23
|
-
|
|
24
|
-
Install the package globally:
|
|
25
|
-
|
|
26
|
-
``` sh
|
|
27
|
-
npm install -g create-rn-folder-structure
|
|
28
8
|
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
9
|
+
src/
|
|
10
|
+
├── app/
|
|
11
|
+
│ ├── navigation/
|
|
12
|
+
│ └── store/
|
|
13
|
+
├── features/
|
|
14
|
+
│ ├── auth/
|
|
15
|
+
│ ├── profile/
|
|
16
|
+
│ ├── dashboard/
|
|
17
|
+
│ └── settings/
|
|
18
|
+
├── shared/
|
|
19
|
+
│ ├── components/
|
|
20
|
+
│ ├── constants/
|
|
21
|
+
│ ├── custom-hooks/
|
|
22
|
+
│ └── utils/
|
|
23
|
+
├── services/
|
|
24
|
+
│ ├── api/
|
|
25
|
+
│ └── storage/
|
|
44
26
|
```
|
|
45
27
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## 📁 Generated Folder Structure
|
|
49
|
-
|
|
50
|
-
src/
|
|
51
|
-
├── app/
|
|
52
|
-
│ ├── navigation/
|
|
53
|
-
│ └── store/
|
|
54
|
-
├── features/
|
|
55
|
-
│ ├── auth/
|
|
56
|
-
│ ├── profile/
|
|
57
|
-
│ ├── dashboard/
|
|
58
|
-
│ └── settings/
|
|
59
|
-
├── shared/
|
|
60
|
-
│ ├── components/
|
|
61
|
-
│ ├── constants/
|
|
62
|
-
│ ├── custom-hooks/
|
|
63
|
-
│ └── utils/
|
|
64
|
-
├── services/
|
|
65
|
-
│ ├── api/
|
|
66
|
-
│ └── storage/
|
|
67
|
-
|
|
68
|
-
------------------------------------------------------------------------
|
|
69
|
-
|
|
70
|
-
## ✨ What Gets Generated?
|
|
71
|
-
|
|
72
|
-
✔ Feature screens\
|
|
73
|
-
✔ Base API service\
|
|
74
|
-
✔ Centralized store structure\
|
|
75
|
-
✔ Shared UI components folder\
|
|
76
|
-
✔ Custom hooks folder\
|
|
77
|
-
✔ App-level constants & utilities\
|
|
78
|
-
✔ Typed folder layout (if using TS)
|
|
79
|
-
|
|
80
|
-
------------------------------------------------------------------------
|
|
81
|
-
|
|
82
|
-
## 🤝 Contributing
|
|
83
|
-
|
|
84
|
-
Contributions are welcome!
|
|
28
|
+
## 🚀 Generated Modules
|
|
85
29
|
|
|
86
|
-
|
|
30
|
+
- Feature screens + API + Store
|
|
31
|
+
- Shared UI Components
|
|
32
|
+
- Custom Hooks
|
|
33
|
+
- Constants
|
|
34
|
+
- Centralized API setup
|
|
35
|
+
- Async storage helpers
|
|
87
36
|
|
|
88
|
-
|
|
37
|
+
---
|
|
89
38
|
|
|
90
39
|
Generated with ❤️ using **create-rn-folder-structure**
|
|
91
|
-
"Winner-Winner Chicken Dinner"
|
package/generators/features.js
CHANGED
|
@@ -14,6 +14,112 @@ module.exports = function generateFeatures(projectRoot) {
|
|
|
14
14
|
const features = ["auth", "profile", "dashboard", "settings"];
|
|
15
15
|
|
|
16
16
|
features.forEach((feature) => {
|
|
17
|
+
|
|
18
|
+
// --- Handle AUTH feature differently ---
|
|
19
|
+
if (feature === "auth") {
|
|
20
|
+
write(
|
|
21
|
+
projectRoot,
|
|
22
|
+
`src/features/${feature}/screens/${capitalize(feature)}Screen.tsx`,
|
|
23
|
+
`
|
|
24
|
+
import { useNavigation } from '@react-navigation/native';
|
|
25
|
+
import React, { useContext, useState } from 'react';
|
|
26
|
+
import { View, Text, TextInput, TouchableOpacity, StyleSheet } from 'react-native';
|
|
27
|
+
import { AuthContext } from '../../../app/navigation/RootNavigator';
|
|
28
|
+
import { saveToken } from '../../../services/storage/token';
|
|
29
|
+
|
|
30
|
+
export default function AuthScreen() {
|
|
31
|
+
const [email, setEmail] = useState('');
|
|
32
|
+
const [password, setPassword] = useState('');
|
|
33
|
+
const navigation = useNavigation()
|
|
34
|
+
const { login } = useContext(AuthContext);
|
|
35
|
+
|
|
36
|
+
const handleLogin = async () => {
|
|
37
|
+
// your login API logic here
|
|
38
|
+
const token = "abc123"; // from backend
|
|
39
|
+
await saveToken(token);
|
|
40
|
+
|
|
41
|
+
login(); // 🔥 triggers navigation switch
|
|
42
|
+
};
|
|
43
|
+
return (
|
|
44
|
+
<View style={styles.container}>
|
|
45
|
+
<Text style={styles.title}>Login</Text>
|
|
46
|
+
|
|
47
|
+
<TextInput
|
|
48
|
+
style={styles.input}
|
|
49
|
+
placeholder="Email"
|
|
50
|
+
value={email}
|
|
51
|
+
onChangeText={setEmail}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<TextInput
|
|
55
|
+
style={styles.input}
|
|
56
|
+
placeholder="Password"
|
|
57
|
+
secureTextEntry
|
|
58
|
+
value={password}
|
|
59
|
+
onChangeText={setPassword}
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
<TouchableOpacity style={styles.button} onPress={handleLogin}>
|
|
63
|
+
<Text style={styles.buttonText}>Login</Text>
|
|
64
|
+
</TouchableOpacity>
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const styles = StyleSheet.create({
|
|
70
|
+
container: {
|
|
71
|
+
flex: 1,
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
paddingHorizontal: 20,
|
|
74
|
+
backgroundColor: '#f5f5f5',
|
|
75
|
+
},
|
|
76
|
+
title: {
|
|
77
|
+
fontSize: 28,
|
|
78
|
+
fontWeight: 'bold',
|
|
79
|
+
textAlign: 'center',
|
|
80
|
+
marginBottom: 30,
|
|
81
|
+
},
|
|
82
|
+
input: {
|
|
83
|
+
height: 50,
|
|
84
|
+
borderWidth: 1,
|
|
85
|
+
borderColor: '#ccc',
|
|
86
|
+
borderRadius: 8,
|
|
87
|
+
paddingHorizontal: 15,
|
|
88
|
+
marginBottom: 15,
|
|
89
|
+
backgroundColor: '#fff',
|
|
90
|
+
},
|
|
91
|
+
button: {
|
|
92
|
+
backgroundColor: '#007bff',
|
|
93
|
+
paddingVertical: 15,
|
|
94
|
+
borderRadius: 8,
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
},
|
|
97
|
+
buttonText: {
|
|
98
|
+
color: '#fff',
|
|
99
|
+
fontSize: 16,
|
|
100
|
+
fontWeight: '600',
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
`,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
write(
|
|
107
|
+
projectRoot,
|
|
108
|
+
`src/features/${feature}/store/index.ts`,
|
|
109
|
+
`export default {};`,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
write(
|
|
113
|
+
projectRoot,
|
|
114
|
+
`src/features/${feature}/api/index.ts`,
|
|
115
|
+
`// API calls for ${feature}`,
|
|
116
|
+
);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// --- Default feature generation ---
|
|
121
|
+
|
|
122
|
+
|
|
17
123
|
write(
|
|
18
124
|
projectRoot,
|
|
19
125
|
`src/features/${feature}/screens/${capitalize(feature)}Screen.tsx`,
|
|
@@ -22,7 +128,7 @@ import { View, Text } from "react-native";
|
|
|
22
128
|
|
|
23
129
|
export default function ${capitalize(feature)}Screen() {
|
|
24
130
|
return (
|
|
25
|
-
<View>
|
|
131
|
+
<View style={{flex:1, alignItems:'center', justifyContent:'center'}}>
|
|
26
132
|
<Text>${capitalize(feature)} Screen</Text>
|
|
27
133
|
</View>
|
|
28
134
|
);
|
package/generators/navigation.js
CHANGED
|
@@ -19,12 +19,14 @@ module.exports = function generateNavigation(projectRoot) {
|
|
|
19
19
|
projectRoot,
|
|
20
20
|
`${navBase}/RootNavigator.tsx`,
|
|
21
21
|
`
|
|
22
|
-
import React, { useEffect, useState } from "react";
|
|
22
|
+
import React, { useEffect, useState, createContext } from "react";
|
|
23
23
|
import { NavigationContainer } from "@react-navigation/native";
|
|
24
24
|
import AuthStack from "./stacks/AuthStack";
|
|
25
25
|
import AppStack from "./stacks/AppStack";
|
|
26
26
|
import { getToken } from "../../services/storage/token";
|
|
27
27
|
|
|
28
|
+
export const AuthContext = createContext();
|
|
29
|
+
|
|
28
30
|
export default function RootNavigator() {
|
|
29
31
|
const [loading, setLoading] = useState(true);
|
|
30
32
|
const [isLoggedIn, setLoggedIn] = useState(false);
|
|
@@ -38,12 +40,22 @@ export default function RootNavigator() {
|
|
|
38
40
|
init();
|
|
39
41
|
}, []);
|
|
40
42
|
|
|
43
|
+
const login = () => {
|
|
44
|
+
setLoggedIn(true);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const logout = () => {
|
|
48
|
+
setLoggedIn(false);
|
|
49
|
+
};
|
|
50
|
+
|
|
41
51
|
if (loading) return null;
|
|
42
52
|
|
|
43
53
|
return (
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
<AuthContext.Provider value={{ login, logout }}>
|
|
55
|
+
<NavigationContainer>
|
|
56
|
+
{isLoggedIn ? <AppStack /> : <AuthStack />}
|
|
57
|
+
</NavigationContainer>
|
|
58
|
+
</AuthContext.Provider>
|
|
47
59
|
);
|
|
48
60
|
}
|
|
49
61
|
`
|
|
@@ -58,19 +70,14 @@ export default function RootNavigator() {
|
|
|
58
70
|
`
|
|
59
71
|
import React from "react";
|
|
60
72
|
import { createNativeStackNavigator } from "@react-navigation/native-stack";
|
|
61
|
-
|
|
62
|
-
import LoginScreen from "../../features/auth/screens/LoginScreen";
|
|
63
|
-
import RegisterScreen from "../../features/auth/screens/RegisterScreen";
|
|
64
|
-
import ForgotPasswordScreen from "../../features/auth/screens/ForgotPasswordScreen";
|
|
73
|
+
import AuthScreen from "../../../features/auth/screens/AuthScreen";
|
|
65
74
|
|
|
66
75
|
const Stack = createNativeStackNavigator();
|
|
67
76
|
|
|
68
77
|
export default function AuthStack() {
|
|
69
78
|
return (
|
|
70
79
|
<Stack.Navigator screenOptions={{ headerShown: false }}>
|
|
71
|
-
<Stack.Screen name="Login" component={
|
|
72
|
-
<Stack.Screen name="Register" component={RegisterScreen} />
|
|
73
|
-
<Stack.Screen name="ForgotPassword" component={ForgotPasswordScreen} />
|
|
80
|
+
<Stack.Screen name="Login" component={AuthScreen} />
|
|
74
81
|
</Stack.Navigator>
|
|
75
82
|
);
|
|
76
83
|
}
|
|
@@ -88,10 +95,8 @@ import React from "react";
|
|
|
88
95
|
import { createNativeStackNavigator } from "@react-navigation/native-stack";
|
|
89
96
|
|
|
90
97
|
import DashboardScreen from "../../features/dashboard/screens/DashboardScreen";
|
|
91
|
-
import HomeScreen from "../../features/home/screens/HomeScreen";
|
|
92
98
|
import ProfileScreen from "../../features/profile/screens/ProfileScreen";
|
|
93
99
|
import SettingsScreen from "../../features/settings/screens/SettingsScreen";
|
|
94
|
-
import NotificationsScreen from "../../features/notifications/screens/NotificationsScreen";
|
|
95
100
|
|
|
96
101
|
const Stack = createNativeStackNavigator();
|
|
97
102
|
|
|
@@ -99,10 +104,8 @@ export default function AppStack() {
|
|
|
99
104
|
return (
|
|
100
105
|
<Stack.Navigator screenOptions={{ headerShown: false }}>
|
|
101
106
|
<Stack.Screen name="Dashboard" component={DashboardScreen} />
|
|
102
|
-
<Stack.Screen name="Home" component={HomeScreen} />
|
|
103
107
|
<Stack.Screen name="Profile" component={ProfileScreen} />
|
|
104
108
|
<Stack.Screen name="Settings" component={SettingsScreen} />
|
|
105
|
-
<Stack.Screen name="Notifications" component={NotificationsScreen} />
|
|
106
109
|
</Stack.Navigator>
|
|
107
110
|
);
|
|
108
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-rn-folder-structure",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "CLI tool to generate React Native folder structure with predefined templates",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -12,9 +12,27 @@
|
|
|
12
12
|
],
|
|
13
13
|
"keywords": [
|
|
14
14
|
"react-native",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
15
|
+
"react-native-cli",
|
|
16
|
+
"react-native-generator",
|
|
17
|
+
"react-native-architecture",
|
|
18
|
+
"react-native-folder-structure",
|
|
19
|
+
"rn-cli",
|
|
20
|
+
"rn-generator",
|
|
21
|
+
"rn-project-structure",
|
|
22
|
+
"react-native-boilerplate",
|
|
23
|
+
"react-native-starter",
|
|
24
|
+
"feature-based-react-native",
|
|
25
|
+
"redux-toolkit",
|
|
26
|
+
"react-navigation",
|
|
27
|
+
"async-storage",
|
|
28
|
+
"axios",
|
|
29
|
+
"create-rn-folder-structure",
|
|
30
|
+
"react-native-template",
|
|
31
|
+
"rn-template",
|
|
32
|
+
"mobile-app-architecture",
|
|
33
|
+
"mobile-app-generator",
|
|
34
|
+
"react-native-app-setup",
|
|
35
|
+
"smart-folder-structure"
|
|
18
36
|
],
|
|
19
37
|
"author": "Sandhip Kumar Dhall & Hriday Kaushal",
|
|
20
38
|
"license": "MIT",
|
|
@@ -26,7 +44,7 @@
|
|
|
26
44
|
"axios": "^1.13.4",
|
|
27
45
|
"create-rn-folder-structure": "^1.0.2",
|
|
28
46
|
"react-native-safe-area-context": "^5.6.2",
|
|
29
|
-
"react-native-screens": "^4.
|
|
47
|
+
"react-native-screens": "^4.23.0",
|
|
30
48
|
"react-redux": "^9.2.0"
|
|
31
49
|
}
|
|
32
50
|
}
|