create-croissant 0.1.46 ā 0.1.48
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/package.json +1 -1
- package/template/apps/platform/src/routes/api/auth/$.ts +1 -1
- package/template/apps/platform/src/routes/api/rpc.$.ts +2 -2
- package/template/package.json +2 -7
- package/template/tsconfig.json +1 -2
- package/template/.github/dependabot.yml +0 -15
- package/template/.github/workflows/ci.yml +0 -143
- package/template/.github/workflows/dependabot-automerge.yml +0 -23
- package/template/.husky/pre-push +0 -11
- package/template/apps/mobile/.vscode/extensions.json +0 -1
- package/template/apps/mobile/.vscode/settings.json +0 -7
- package/template/apps/mobile/README.md +0 -50
- package/template/apps/mobile/app/(tabs)/_layout.tsx +0 -43
- package/template/apps/mobile/app/(tabs)/account.tsx +0 -147
- package/template/apps/mobile/app/(tabs)/explore.tsx +0 -345
- package/template/apps/mobile/app/(tabs)/index.tsx +0 -112
- package/template/apps/mobile/app/_layout.tsx +0 -43
- package/template/apps/mobile/app/index.tsx +0 -129
- package/template/apps/mobile/app/login.tsx +0 -135
- package/template/apps/mobile/app/signup.tsx +0 -144
- package/template/apps/mobile/app.json +0 -56
- package/template/apps/mobile/assets/images/android-icon-background.png +0 -0
- package/template/apps/mobile/assets/images/android-icon-foreground.png +0 -0
- package/template/apps/mobile/assets/images/android-icon-monochrome.png +0 -0
- package/template/apps/mobile/assets/images/favicon.png +0 -0
- package/template/apps/mobile/assets/images/icon.png +0 -0
- package/template/apps/mobile/assets/images/partial-react-logo.png +0 -0
- package/template/apps/mobile/assets/images/react-logo.png +0 -0
- package/template/apps/mobile/assets/images/react-logo@2x.png +0 -0
- package/template/apps/mobile/assets/images/react-logo@3x.png +0 -0
- package/template/apps/mobile/assets/images/splash-icon.png +0 -0
- package/template/apps/mobile/components/external-link.tsx +0 -25
- package/template/apps/mobile/components/haptic-tab.tsx +0 -18
- package/template/apps/mobile/components/hello-wave.tsx +0 -20
- package/template/apps/mobile/components/parallax-scroll-view.tsx +0 -81
- package/template/apps/mobile/components/themed-text.tsx +0 -60
- package/template/apps/mobile/components/themed-view.tsx +0 -14
- package/template/apps/mobile/components/ui/button.tsx +0 -86
- package/template/apps/mobile/components/ui/collapsible.tsx +0 -46
- package/template/apps/mobile/components/ui/icon-symbol.ios.tsx +0 -32
- package/template/apps/mobile/components/ui/icon-symbol.tsx +0 -41
- package/template/apps/mobile/components/ui/input.tsx +0 -56
- package/template/apps/mobile/constants/theme.ts +0 -53
- package/template/apps/mobile/hooks/use-color-scheme.ts +0 -1
- package/template/apps/mobile/hooks/use-color-scheme.web.ts +0 -21
- package/template/apps/mobile/hooks/use-theme-color.ts +0 -21
- package/template/apps/mobile/lib/auth-client.ts +0 -14
- package/template/apps/mobile/lib/orpc.ts +0 -28
- package/template/apps/mobile/package.json +0 -57
- package/template/apps/mobile/scripts/reset-project.js +0 -112
- package/template/apps/mobile/tsconfig.json +0 -13
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren, useState } from "react";
|
|
2
|
-
import { StyleSheet, TouchableOpacity } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { ThemedText } from "@/components/themed-text";
|
|
5
|
-
import { ThemedView } from "@/components/themed-view";
|
|
6
|
-
import { IconSymbol } from "@/components/ui/icon-symbol";
|
|
7
|
-
import { Colors } from "@/constants/theme";
|
|
8
|
-
import { useColorScheme } from "@/hooks/use-color-scheme";
|
|
9
|
-
|
|
10
|
-
export function Collapsible({ children, title }: PropsWithChildren & { title: string }) {
|
|
11
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
-
const theme = useColorScheme() ?? "light";
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<ThemedView>
|
|
16
|
-
<TouchableOpacity
|
|
17
|
-
style={styles.heading}
|
|
18
|
-
onPress={() => setIsOpen((value) => !value)}
|
|
19
|
-
activeOpacity={0.8}
|
|
20
|
-
>
|
|
21
|
-
<IconSymbol
|
|
22
|
-
name="chevron.right"
|
|
23
|
-
size={18}
|
|
24
|
-
weight="medium"
|
|
25
|
-
color={theme === "light" ? Colors.light.icon : Colors.dark.icon}
|
|
26
|
-
style={{ transform: [{ rotate: isOpen ? "90deg" : "0deg" }] }}
|
|
27
|
-
/>
|
|
28
|
-
|
|
29
|
-
<ThemedText type="defaultSemiBold">{title}</ThemedText>
|
|
30
|
-
</TouchableOpacity>
|
|
31
|
-
{isOpen && <ThemedView style={styles.content}>{children}</ThemedView>}
|
|
32
|
-
</ThemedView>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const styles = StyleSheet.create({
|
|
37
|
-
heading: {
|
|
38
|
-
flexDirection: "row",
|
|
39
|
-
alignItems: "center",
|
|
40
|
-
gap: 6,
|
|
41
|
-
},
|
|
42
|
-
content: {
|
|
43
|
-
marginTop: 6,
|
|
44
|
-
marginLeft: 24,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { SymbolView, SymbolViewProps, SymbolWeight } from "expo-symbols";
|
|
2
|
-
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
|
|
4
|
-
export function IconSymbol({
|
|
5
|
-
name,
|
|
6
|
-
size = 24,
|
|
7
|
-
color,
|
|
8
|
-
style,
|
|
9
|
-
weight = "regular",
|
|
10
|
-
}: {
|
|
11
|
-
name: SymbolViewProps["name"];
|
|
12
|
-
size?: number;
|
|
13
|
-
color: string;
|
|
14
|
-
style?: StyleProp<ViewStyle>;
|
|
15
|
-
weight?: SymbolWeight;
|
|
16
|
-
}) {
|
|
17
|
-
return (
|
|
18
|
-
<SymbolView
|
|
19
|
-
weight={weight}
|
|
20
|
-
tintColor={color}
|
|
21
|
-
resizeMode="scaleAspectFit"
|
|
22
|
-
name={name}
|
|
23
|
-
style={[
|
|
24
|
-
{
|
|
25
|
-
width: size,
|
|
26
|
-
height: size,
|
|
27
|
-
},
|
|
28
|
-
style,
|
|
29
|
-
]}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Fallback for using MaterialIcons on Android and web.
|
|
2
|
-
|
|
3
|
-
import MaterialIcons from "@expo/vector-icons/MaterialIcons";
|
|
4
|
-
import { SymbolWeight, SymbolViewProps } from "expo-symbols";
|
|
5
|
-
import { ComponentProps } from "react";
|
|
6
|
-
import { OpaqueColorValue, type StyleProp, type TextStyle } from "react-native";
|
|
7
|
-
|
|
8
|
-
type IconMapping = Record<SymbolViewProps["name"], ComponentProps<typeof MaterialIcons>["name"]>;
|
|
9
|
-
type IconSymbolName = keyof typeof MAPPING;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Add your SF Symbols to Material Icons mappings here.
|
|
13
|
-
* - see Material Icons in the [Icons Directory](https://icons.expo.fyi).
|
|
14
|
-
* - see SF Symbols in the [SF Symbols](https://developer.apple.com/sf-symbols/) app.
|
|
15
|
-
*/
|
|
16
|
-
const MAPPING = {
|
|
17
|
-
"house.fill": "home",
|
|
18
|
-
"paperplane.fill": "send",
|
|
19
|
-
"chevron.left.forwardslash.chevron.right": "code",
|
|
20
|
-
"chevron.right": "chevron-right",
|
|
21
|
-
} as IconMapping;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* An icon component that uses native SF Symbols on iOS, and Material Icons on Android and web.
|
|
25
|
-
* This ensures a consistent look across platforms, and optimal resource usage.
|
|
26
|
-
* Icon `name`s are based on SF Symbols and require manual mapping to Material Icons.
|
|
27
|
-
*/
|
|
28
|
-
export function IconSymbol({
|
|
29
|
-
name,
|
|
30
|
-
size = 24,
|
|
31
|
-
color,
|
|
32
|
-
style,
|
|
33
|
-
}: {
|
|
34
|
-
name: IconSymbolName;
|
|
35
|
-
size?: number;
|
|
36
|
-
color: string | OpaqueColorValue;
|
|
37
|
-
style?: StyleProp<TextStyle>;
|
|
38
|
-
weight?: SymbolWeight;
|
|
39
|
-
}) {
|
|
40
|
-
return <MaterialIcons color={color} size={size} name={MAPPING[name]} style={style} />;
|
|
41
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { TextInput, StyleSheet, TextInputProps, View, Text } from "react-native";
|
|
3
|
-
|
|
4
|
-
interface InputProps extends TextInputProps {
|
|
5
|
-
label?: string;
|
|
6
|
-
error?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function Input({ label, error, style, ...props }: InputProps) {
|
|
10
|
-
return (
|
|
11
|
-
<View style={styles.container}>
|
|
12
|
-
{label && <Text style={styles.label}>{label}</Text>}
|
|
13
|
-
<TextInput
|
|
14
|
-
style={[
|
|
15
|
-
styles.input,
|
|
16
|
-
error && styles.inputError,
|
|
17
|
-
style,
|
|
18
|
-
]}
|
|
19
|
-
placeholderTextColor="#999"
|
|
20
|
-
{...props}
|
|
21
|
-
/>
|
|
22
|
-
{error && <Text style={styles.errorText}>{error}</Text>}
|
|
23
|
-
</View>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const styles = StyleSheet.create({
|
|
28
|
-
container: {
|
|
29
|
-
width: "100%",
|
|
30
|
-
marginBottom: 16,
|
|
31
|
-
},
|
|
32
|
-
label: {
|
|
33
|
-
fontSize: 14,
|
|
34
|
-
fontWeight: "500",
|
|
35
|
-
marginBottom: 8,
|
|
36
|
-
color: "#333",
|
|
37
|
-
},
|
|
38
|
-
input: {
|
|
39
|
-
height: 48,
|
|
40
|
-
borderWidth: 1,
|
|
41
|
-
borderColor: "#e0e0e0",
|
|
42
|
-
borderRadius: 8,
|
|
43
|
-
paddingHorizontal: 12,
|
|
44
|
-
fontSize: 16,
|
|
45
|
-
color: "#000",
|
|
46
|
-
backgroundColor: "#fff",
|
|
47
|
-
},
|
|
48
|
-
inputError: {
|
|
49
|
-
borderColor: "#ff4444",
|
|
50
|
-
},
|
|
51
|
-
errorText: {
|
|
52
|
-
color: "#ff4444",
|
|
53
|
-
fontSize: 12,
|
|
54
|
-
marginTop: 4,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Below are the colors that are used in the app. The colors are defined in the light and dark mode.
|
|
3
|
-
* There are many other ways to style your app. For example, [Nativewind](https://www.nativewind.dev/), [Tamagui](https://tamagui.dev/), [unistyles](https://reactnativeunistyles.vercel.app), etc.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { Platform } from "react-native";
|
|
7
|
-
|
|
8
|
-
const tintColorLight = "#0a7ea4";
|
|
9
|
-
const tintColorDark = "#fff";
|
|
10
|
-
|
|
11
|
-
export const Colors = {
|
|
12
|
-
light: {
|
|
13
|
-
text: "#11181C",
|
|
14
|
-
background: "#fff",
|
|
15
|
-
tint: tintColorLight,
|
|
16
|
-
icon: "#687076",
|
|
17
|
-
tabIconDefault: "#687076",
|
|
18
|
-
tabIconSelected: tintColorLight,
|
|
19
|
-
},
|
|
20
|
-
dark: {
|
|
21
|
-
text: "#ECEDEE",
|
|
22
|
-
background: "#151718",
|
|
23
|
-
tint: tintColorDark,
|
|
24
|
-
icon: "#9BA1A6",
|
|
25
|
-
tabIconDefault: "#9BA1A6",
|
|
26
|
-
tabIconSelected: tintColorDark,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const Fonts = Platform.select({
|
|
31
|
-
ios: {
|
|
32
|
-
/** iOS `UIFontDescriptorSystemDesignDefault` */
|
|
33
|
-
sans: "system-ui",
|
|
34
|
-
/** iOS `UIFontDescriptorSystemDesignSerif` */
|
|
35
|
-
serif: "ui-serif",
|
|
36
|
-
/** iOS `UIFontDescriptorSystemDesignRounded` */
|
|
37
|
-
rounded: "ui-rounded",
|
|
38
|
-
/** iOS `UIFontDescriptorSystemDesignMonospaced` */
|
|
39
|
-
mono: "ui-monospace",
|
|
40
|
-
},
|
|
41
|
-
default: {
|
|
42
|
-
sans: "normal",
|
|
43
|
-
serif: "serif",
|
|
44
|
-
rounded: "normal",
|
|
45
|
-
mono: "monospace",
|
|
46
|
-
},
|
|
47
|
-
web: {
|
|
48
|
-
sans: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
49
|
-
serif: "Georgia, 'Times New Roman', serif",
|
|
50
|
-
rounded: "'SF Pro Rounded', 'Hiragino Maru Gothic ProN', Meiryo, 'MS PGothic', sans-serif",
|
|
51
|
-
mono: "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
|
|
52
|
-
},
|
|
53
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useColorScheme } from "react-native";
|
|
@@ -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,14 +0,0 @@
|
|
|
1
|
-
import { createAuthClient } from "better-auth/react";
|
|
2
|
-
import { expoClient } from "@better-auth/expo/client";
|
|
3
|
-
import * as SecureStore from "expo-secure-store";
|
|
4
|
-
|
|
5
|
-
export const authClient = createAuthClient({
|
|
6
|
-
baseURL: process.env.EXPO_PUBLIC_BETTER_AUTH_URL || "https://platform.local",
|
|
7
|
-
plugins: [
|
|
8
|
-
expoClient({
|
|
9
|
-
scheme: "mobile",
|
|
10
|
-
storagePrefix: "mobile",
|
|
11
|
-
storage: SecureStore,
|
|
12
|
-
}),
|
|
13
|
-
],
|
|
14
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createORPCClient } from '@orpc/client'
|
|
2
|
-
import { RPCLink } from '@orpc/client/fetch'
|
|
3
|
-
import { RouterClient } from '@orpc/server'
|
|
4
|
-
import { router } from '@workspace/orpc/router'
|
|
5
|
-
import { authClient } from './auth-client'
|
|
6
|
-
|
|
7
|
-
export const link = new RPCLink({
|
|
8
|
-
url: `https://platform.local/api/rpc`,
|
|
9
|
-
async fetch(request, init) {
|
|
10
|
-
const { fetch } = await import('expo/fetch')
|
|
11
|
-
const headers = new Map<string, string>();
|
|
12
|
-
const cookies = authClient.getCookie();
|
|
13
|
-
if (cookies) {
|
|
14
|
-
headers.set("Cookie", cookies);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const resp = await fetch(request.url, {
|
|
18
|
-
body: request.body,
|
|
19
|
-
headers: Object.fromEntries(headers),
|
|
20
|
-
method: request.method,
|
|
21
|
-
...init,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
return resp
|
|
25
|
-
},
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
export const orpc: RouterClient<typeof router> = createORPCClient(link)
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mobile",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"main": "expo-router/entry",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "expo start",
|
|
8
|
-
"start": "expo start",
|
|
9
|
-
"reset-project": "node ./scripts/reset-project.js",
|
|
10
|
-
"android": "expo start --android",
|
|
11
|
-
"ios": "expo start --ios",
|
|
12
|
-
"web": "expo start --web",
|
|
13
|
-
"build": "expo export --output-dir .output"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@better-auth/expo": "^1.6.9",
|
|
17
|
-
"@expo/vector-icons": "^15.0.3",
|
|
18
|
-
"@orpc/client": "^1.14.0",
|
|
19
|
-
"@orpc/server": "^1.14.0",
|
|
20
|
-
"@orpc/tanstack-query": "^1.14.0",
|
|
21
|
-
"@react-navigation/bottom-tabs": "^7.4.0",
|
|
22
|
-
"@react-navigation/elements": "^2.6.3",
|
|
23
|
-
"@react-navigation/native": "^7.1.8",
|
|
24
|
-
"@tanstack/react-form": "^1.29.1",
|
|
25
|
-
"@tanstack/react-query": "^5.100.5",
|
|
26
|
-
"@workspace/orpc": "workspace:*",
|
|
27
|
-
"@workspace/ui": "workspace:*",
|
|
28
|
-
"better-auth": "^1.6.9",
|
|
29
|
-
"expo": "^55.0.17",
|
|
30
|
-
"expo-constants": "~55.0.15",
|
|
31
|
-
"expo-font": "~55.0.6",
|
|
32
|
-
"expo-haptics": "~55.0.14",
|
|
33
|
-
"expo-image": "~55.0.9",
|
|
34
|
-
"expo-linking": "~55.0.14",
|
|
35
|
-
"expo-network": "^55.0.13",
|
|
36
|
-
"expo-router": "~55.0.13",
|
|
37
|
-
"expo-secure-store": "^55.0.13",
|
|
38
|
-
"expo-splash-screen": "~55.0.19",
|
|
39
|
-
"expo-status-bar": "~55.0.5",
|
|
40
|
-
"expo-symbols": "~55.0.7",
|
|
41
|
-
"expo-system-ui": "~55.0.16",
|
|
42
|
-
"expo-web-browser": "~55.0.14",
|
|
43
|
-
"react": "19.2.5",
|
|
44
|
-
"react-dom": "19.2.5",
|
|
45
|
-
"react-native": "0.83.6",
|
|
46
|
-
"react-native-gesture-handler": "~2.30.0",
|
|
47
|
-
"react-native-reanimated": "4.2.1",
|
|
48
|
-
"react-native-safe-area-context": "~5.6.0",
|
|
49
|
-
"react-native-screens": "~4.23.0",
|
|
50
|
-
"react-native-web": "~0.21.0",
|
|
51
|
-
"react-native-worklets": "0.7.4"
|
|
52
|
-
},
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"babel-plugin-transform-import-meta": "^2.3.3",
|
|
55
|
-
"metro-react-native-babel-transformer": "^0.77.0"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -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
|
-
);
|