@highbeek/create-rnstarterkit 1.0.2-beta.4 → 1.0.2-beta.5
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.
|
@@ -30,6 +30,7 @@ async function generateApp(options) {
|
|
|
30
30
|
authFolder === "auth-zustand" ||
|
|
31
31
|
authFolder === "auth-redux") {
|
|
32
32
|
await setAuthTabsByPlatform(targetPath, platform);
|
|
33
|
+
await writeAuthAppShell(targetPath, state);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
if (apiClient) {
|
|
@@ -44,6 +45,11 @@ async function generateApp(options) {
|
|
|
44
45
|
await copyOptionalModule("react-query", targetPath);
|
|
45
46
|
if (storage === "MMKV")
|
|
46
47
|
await copyOptionalModule("mmkv", targetPath);
|
|
48
|
+
await configureStateAndAuthDependencies(targetPath, {
|
|
49
|
+
state,
|
|
50
|
+
auth,
|
|
51
|
+
storage,
|
|
52
|
+
});
|
|
47
53
|
await configureAbsoluteImports(targetPath, platform, absoluteImports);
|
|
48
54
|
await configureDataFetching(targetPath, dataFetching);
|
|
49
55
|
await configureApiClientTransport(targetPath, apiClient, apiClientType);
|
|
@@ -229,6 +235,78 @@ async function configureValidation(targetPath, validation) {
|
|
|
229
235
|
await ensureDependencies(targetPath, { dependencies });
|
|
230
236
|
}
|
|
231
237
|
}
|
|
238
|
+
async function configureStateAndAuthDependencies(targetPath, options) {
|
|
239
|
+
const dependencies = {};
|
|
240
|
+
if (options.auth) {
|
|
241
|
+
dependencies["@react-navigation/native-stack"] = "^7.3.29";
|
|
242
|
+
}
|
|
243
|
+
if (options.state === "Redux Toolkit") {
|
|
244
|
+
dependencies["@reduxjs/toolkit"] = "^2.9.0";
|
|
245
|
+
dependencies["react-redux"] = "^9.2.0";
|
|
246
|
+
}
|
|
247
|
+
if (options.state === "Zustand") {
|
|
248
|
+
dependencies.zustand = "^5.0.8";
|
|
249
|
+
}
|
|
250
|
+
if (options.storage === "AsyncStorage" &&
|
|
251
|
+
(options.state === "Context API" || options.state === "Zustand")) {
|
|
252
|
+
dependencies["@react-native-async-storage/async-storage"] = "^2.2.0";
|
|
253
|
+
}
|
|
254
|
+
if (Object.keys(dependencies).length > 0) {
|
|
255
|
+
await ensureDependencies(targetPath, { dependencies });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function writeAuthAppShell(targetPath, state) {
|
|
259
|
+
const appPath = path_1.default.join(targetPath, "App.tsx");
|
|
260
|
+
const byState = {
|
|
261
|
+
"Context API": `import React from "react";
|
|
262
|
+
import { NavigationContainer } from "@react-navigation/native";
|
|
263
|
+
import { AuthProvider } from "./context/AuthContext";
|
|
264
|
+
import ProtectedStack from "./navigation/ProtectedStack";
|
|
265
|
+
|
|
266
|
+
export default function App() {
|
|
267
|
+
return (
|
|
268
|
+
<AuthProvider>
|
|
269
|
+
<NavigationContainer>
|
|
270
|
+
<ProtectedStack />
|
|
271
|
+
</NavigationContainer>
|
|
272
|
+
</AuthProvider>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
`,
|
|
276
|
+
"Redux Toolkit": `import React from "react";
|
|
277
|
+
import { NavigationContainer } from "@react-navigation/native";
|
|
278
|
+
import { Provider } from "react-redux";
|
|
279
|
+
import ProtectedStack from "./navigation/ProtectedStack";
|
|
280
|
+
import { store } from "./store/store";
|
|
281
|
+
|
|
282
|
+
export default function App() {
|
|
283
|
+
return (
|
|
284
|
+
<Provider store={store}>
|
|
285
|
+
<NavigationContainer>
|
|
286
|
+
<ProtectedStack />
|
|
287
|
+
</NavigationContainer>
|
|
288
|
+
</Provider>
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
`,
|
|
292
|
+
Zustand: `import React from "react";
|
|
293
|
+
import { NavigationContainer } from "@react-navigation/native";
|
|
294
|
+
import ProtectedStack from "./navigation/ProtectedStack";
|
|
295
|
+
|
|
296
|
+
export default function App() {
|
|
297
|
+
return (
|
|
298
|
+
<NavigationContainer>
|
|
299
|
+
<ProtectedStack />
|
|
300
|
+
</NavigationContainer>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
`,
|
|
304
|
+
};
|
|
305
|
+
const content = byState[state];
|
|
306
|
+
if (!content)
|
|
307
|
+
return;
|
|
308
|
+
await fs_extra_1.default.writeFile(appPath, content, "utf8");
|
|
309
|
+
}
|
|
232
310
|
async function configureTsconfigAlias(targetPath, absoluteImports) {
|
|
233
311
|
const tsconfigPath = path_1.default.join(targetPath, "tsconfig.json");
|
|
234
312
|
if (!(await fs_extra_1.default.pathExists(tsconfigPath)))
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SafeAreaView, StyleSheet, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
export default function App() {
|
|
5
|
+
return (
|
|
6
|
+
<SafeAreaView style={styles.container}>
|
|
7
|
+
<Text style={styles.title}>RN Starter Kit</Text>
|
|
8
|
+
<Text style={styles.subtitle}>
|
|
9
|
+
Build your app by adding screens and navigation.
|
|
10
|
+
</Text>
|
|
11
|
+
</SafeAreaView>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const styles = StyleSheet.create({
|
|
16
|
+
container: {
|
|
17
|
+
flex: 1,
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
justifyContent: "center",
|
|
20
|
+
padding: 24,
|
|
21
|
+
},
|
|
22
|
+
title: {
|
|
23
|
+
fontSize: 24,
|
|
24
|
+
fontWeight: "700",
|
|
25
|
+
marginBottom: 8,
|
|
26
|
+
},
|
|
27
|
+
subtitle: {
|
|
28
|
+
fontSize: 15,
|
|
29
|
+
textAlign: "center",
|
|
30
|
+
color: "#666",
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{projectName}}",
|
|
3
|
-
"main": "expo
|
|
3
|
+
"main": "node_modules/expo/AppEntry.js",
|
|
4
4
|
"version": "1.0.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "expo start",
|
|
7
|
-
"reset-project": "node ./scripts/reset-project.js",
|
|
8
7
|
"android": "expo start --android",
|
|
9
8
|
"ios": "expo start --ios",
|
|
10
9
|
"web": "expo start --web",
|
|
@@ -21,7 +20,6 @@
|
|
|
21
20
|
"expo-haptics": "~15.0.8",
|
|
22
21
|
"expo-image": "~3.0.11",
|
|
23
22
|
"expo-linking": "~8.0.11",
|
|
24
|
-
"expo-router": "~6.0.23",
|
|
25
23
|
"expo-splash-screen": "~31.0.13",
|
|
26
24
|
"expo-status-bar": "~3.0.9",
|
|
27
25
|
"expo-symbols": "~1.0.8",
|
package/package.json
CHANGED