-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildReactApp.sh
executable file
·55 lines (43 loc) · 1.4 KB
/
BuildReactApp.sh
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
read -p "What would you like your app to be called:" appname
mkdir $appname
cd $appname
#read -p "What components would you like to create?(separate by spaces)" componentnames
echo "building pages $@"
mainpages=(app\.jsx index\.html index\.js package\.json manifest\.json README\.md)
pages=(Home About Contact Projects)
components=(App Starter)
addMainHtml="<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<link></link>\n\t</head>\n\t<body>\n\t\t<div id='app'></div>\n\t\t<script></script>\n\t</body>\n</html>"
#add lowercase ids to page components
addpageName(){
lowerCase=${1}
lc=$(echo "$lowerCase" | tr '[:upper:]' '[:lower:]')
echo -e "import React, { useState } from 'react'; \nexport default function(){\n\n\treturn(\n\t\t<div id='"$lc"'></div>\n\t)\n\n};"
}
#add html to index.html
echo -e $addMainHtml > index.html
#build gitignore
echo -e ".DS_Store\n.env\n" > .gitignore
#build .env
echo -e "PW=\nSECRET=" > .env
#add page and component directories
mkdir pages components
#build pages
for page in "${pages[@]}"
do
mkdir pages/${page}
addpageName "${page}" > pages/${page}/$page.jsx
done
#build starter components
for component in "${components[@]}"
do
addpageName "${component}" > components/$component.jsx
done
#Build the basics
for main in "${mainpages[@]}"
do
touch ${main}
done
#add server files
mkdir server
touch server/app.js
echo "Build Complete. Enjoy your web application building process!";