forked from jfarrin73/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-fullstack-app.sh
executable file
·160 lines (111 loc) · 5.5 KB
/
create-fullstack-app.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
# READ NAME ARGUMENT OR PROMPT FOR NAME IF NONE PROVIDED
msg='\e[35m░░░░░░░░▄▄▄▀▀▀▄▄███▄░░░░░░░░░░░░░░
░░░░░▄▀▀░░░░░░░▐░▀██▌░░░░░░░░░░░░░
░░░▄▀░░░░▄▄███░▌▀▀░▀█░░░░░░░░░░░░░
░░▄█░░▄▀▀▒▒▒▒▒▄▐░░░░█▌░░░░░░░░░░░░
░▐█▀▄▀▄▄▄▄▀▀▀▀▌░░░░░▐█▄░░░░░░░░░░░
░▌▄▄▀▀░░░░░░░░▌░░░░▄███████▄░░░░░░
░░░░░░░░░░░░░▐░░░░▐███████████▄░░░
░░░░░le░░░░░░░▐░░░░▐█████████████▄
░░░░toucan░░░░░░▀▄░░░▐█████████████▄
░░░░░░has░░░░░░░░▀▄▄███████████████
░░░░░arrived░░░░░░░░░░░░█▀██████░░\e[m\n'
printf "$msg"
printf "Name of \e[32mSpring App\e[m?: "
read springName
printf 'Would you like to install \e[32mReact-Router\e[m [y/n]: '
read router
printf 'Would you like to install \e[32mAxios\e[m [y/n]: '
read axios
printf 'Would you like to install \e[32mReact-Icons\e[m [y/n]: '
read icons
printf 'Would you like to install \e[32mCypress\e[m [y/n]: '
read cypress
printf 'What is your \e[35mMYSQL Database\e[m name?: '
read dbName
printf 'What is your Database \e[35mUsername\e[m?: '
read dbUsername
printf 'What is your Database \e[35mPassword\e[m?: '
read dbPassword
brew tap spring-io/tap
# Check to see if already on the latest version somehow
brew install spring-boot
mkdir starter-app
cd starter-app
spring init --dependencies=web,data-jpa,validation,lombok,mysql,devtools --build=gradle --java-version=17 --packaging=jar --groupId=com.example --artifactId=$springName --name=$springName starter-app.zip
unzip starter-app.zip
rm starter-app.zip
echo "spring.datasource.url=jdbc:mysql://localhost/$dbName?serverTimezone=UTC" > ./src/main/resources/application.properties
echo "spring.datasource.username=$dbUsername" >> ./src/main/resources/application.properties
echo "spring.datasource.password=$dbPassword" >> ./src/main/resources/application.properties
echo "spring.datasource.driver-class-name=com.mysql.jdbc.Driver" >> ./src/main/resources/application.properties
echo "spring.jpa.hibernate.ddl-auto=create" >> ./src/main/resources/application.properties
echo "spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect" >> ./src/main/resources/application.properties
mkdir ./src/main/java/com/example/$springName/controller
mkdir ./src/main/java/com/example/$springName/service
mkdir ./src/main/java/com/example/$springName/model
mkdir ./src/main/java/com/example/$springName/repository
# CREATE REACT APP AND CD INTO DIR
npx create-react-app frontend
cd frontend
# OPTIONALLY INSTALL HEADLESS UI AND REACT ROUTER
if [[ $headless =~ ^[Yy]$ ]]
then npm install @headlessui/react
fi
if [[ $router =~ ^[Yy]$ ]]
then npm install react-router-dom
fi
if [[ $axios =~ ^[Yy]$ ]]
then npm i axios
fi
if [[ $cypress =~ ^[Yy]$ ]]
then npm install --save-dev cypress @testing-library/cypress
fi
if [[ $icons =~ ^[Yy]$ ]]
then npm install react-icons --save
fi
# INSTALL TAILWIND AND CRACO
npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
npm install @craco/craco
# UPDATE package.json
sed -i '' 's/react-scripts start/craco start/g' package.json
sed -i '' 's/react-scripts build/craco build/g' package.json
sed -i '' 's/react-scripts test/craco test/g' package.json
# CREATE craco.config.js AND ADD TEXT
echo -e "// craco.config.js\nmodule.exports = {\n style: {\n postcss: {\n plugins: [\n require('tailwindcss'),\n require('autoprefixer'),\n ],\n },\n },\n}" > craco.config.js
# CREATE tailwind.config.js AND UPDATE TEXT
npx tailwindcss-cli@latest init
echo -e "// tailwind.config.js\nmodule.exports = {\n purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],\n darkMode: false, // or 'media' or 'class'\n theme: {\n extend: {},\n },\n variants: {\n extend: {},\n },\n plugins: [],\n}" > tailwind.config.js
# UPDATE App.css WTIH @tailwind LINES
echo '@tailwind base;' > ./src/App.css
echo '@tailwind components;' >> ./src/App.css
echo '@tailwind utilities;' >> ./src/App.css
# UPDATE index.html
sed -i '' 's/<body>/<body class="bg-gray-900 text-white">/g' ./public/index.html
# UPDATE App.js
echo 'import "./App.css";' > ./src/App.js
echo -e '\n' >> ./src/App.js
echo 'const App = () => {' >> ./src/App.js
echo ' return (' >> ./src/App.js
echo ' <div>' >> ./src/App.js
echo ' <header>' >> ./src/App.js
echo ' <h1 className="text-3xl text-blue-400 p-4">Tailwind React App</h1>' >> ./src/App.js
echo ' </header>' >> ./src/App.js
echo ' </div>' >> ./src/App.js
echo ' );' >> ./src/App.js
echo -e '}\n' >> ./src/App.js
echo 'export default App;' >> ./src/App.js
# Remove create-react-app garbage
rm ./src/logo.svg
rm ./src/reportWebVitals.js
rm ./src/index.css
sed -i '' '/import reportWebVitals/d' ./src/index.js
sed -i '' '/reportWebVitals()/d' ./src/index.js
sed -i '' '/index.css/d' ./src/index.js
# Start React App
npm start
# Move up to Spring root dir
cd ..
cd ..
idea .