-
Notifications
You must be signed in to change notification settings - Fork 114
/
createEntryFile.ts
55 lines (50 loc) · 1.2 KB
/
createEntryFile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { getDevServer } from "../getDevServer";
/** Middleware for creating an entry file in the project. */
export function createEntryFileAsync() {
if (process.env.NODE_ENV === "production") {
// No dev server
console.warn("createEntryFile() cannot be used in production");
return;
}
// Pings middleware in the Expo CLI dev server.
return fetch(getDevServer().url + "_expo/touch", {
method: "POST",
body: JSON.stringify({
contents: TEMPLATE,
path: "./app/index.js",
}),
});
}
const TEMPLATE = `import { StyleSheet, Text, View } from "react-native";
export default function Page() {
return (
<View style={styles.container}>
<View style={styles.main}>
<Text style={styles.title}>Hello World</Text>
<Text style={styles.subtitle}>This is the first page of your app.</Text>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
padding: 24,
},
main: {
flex: 1,
justifyContent: "center",
maxWidth: 960,
marginHorizontal: "auto",
},
title: {
fontSize: 64,
fontWeight: "bold",
},
subtitle: {
fontSize: 36,
color: "#38434D",
},
});
`;