Skip to content

Commit cee9e0e

Browse files
authored
AYS-693 | Project Setup SH Script Has Been Created and Implemented (#473)
1 parent fc74052 commit cee9e0e

File tree

2 files changed

+109
-39
lines changed

2 files changed

+109
-39
lines changed

README.md

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -85,81 +85,55 @@ First of all, generate personal access token with this url : https://github.com/
8585
- Then click on "Generate Token"
8686
- In case of errors, please check [here](#Common Maven errors)
8787

88-
# Before Running Locally On IDE
89-
90-
> 0. If you don't want to replace your `~/m2/settings.xml` file, use following command to build the project (go to the root folder of the application): `mvn -gs template-settings.xml clean install -U`
91-
> 1. If you have `~/m2/settings.xml` file in your computer, skip the step without reading the after section.
92-
If you aren't using the `~/.m2/settings.xml` file to actively, you can be back up it before creating
93-
the new `settings.xml` file, if you want. If you are using actively, after the perform step 3 you can
94-
manually merge the `settings.xml` file in the project with the `~/.m2/settings.xml` file and skip step 2 and 4.
95-
> 2. While inside the project directory in the terminal; that is, when you are in the `~/afet-yonetim-sistemi/ays-be`
96-
directory, run the command `cp template-settings.xml settings.xml`.
97-
> 3. In the settings.xml file within the project, replace the `{YOUR_GITHUB_USERNAME}` placeholder with your GitHub
98-
username and replace `{YOUR_PERSONAL_GITHUB_ACCESS_TOKEN}` with the access token value you created on GitHub as
99-
described in the instructions under the `'Instructions Before Building The Project'` section.
100-
> 4. If the `.m2` directory has not been created before, you can use the command `mkdir ~/.m2` and then run the
101-
command `cp settings.xml ~/.m2/settings.xml` for copy the `settings.xml` file located in the project
102-
to the `~/.m2` directory.
88+
# Setup Project
10389

104-
#### Don't forget to enable Lombok pre-processing in your IDE!
105-
106-
## Building The Project With Tests
90+
Run the following command to set up the project:
10791

92+
```shell
93+
sh setup/setup.sh
10894
```
109-
./mvnw clean install
110-
```
111-
112-
## Building The Project Without Tests
11395

114-
```
115-
./mvnw clean install -DskipTests
116-
```
96+
#### Don't forget to enable Lombok pre-processing in your IDE!
11797

11898
## Running as Docker MySQL container
11999

120100
Before running the project, you need to run the following command to start the MySQL container:
121101

122-
```
102+
```shell
123103
docker compose up -d --build database
124104
```
125105

126106
If you want to recreate the MySQL container, you can run the following command:
127107

128-
```
108+
```shell
129109
docker compose up --force-recreate -d --build database
130110
```
131111

132112
If you want to stop the MySQL container, you can run the following command:
133113

134-
```
114+
```shell
135115
docker compose down -v database
136116
```
137117

138118
---
139119

140120
# Running As Docker Container
141121

142-
> 1. While inside the project directory in the terminal; that is, when you are in the `~/afet-yonetim-sistemi/ays-be`
143-
directory, run the command `cp template-settings.xml settings.xml`.
144-
> 2. In the `settings.xml` file within the project, replace the `{YOUR_GITHUB_USERNAME}` placeholder with your GitHub
145-
username and replace `{YOUR_PERSONAL_GITHUB_ACCESS_TOKEN}` with the access token value you created on GitHub as
146-
described in the instructions under the `'Instructions Before Building The Project'` section.
147-
148122
Before running the project, you need to run the following command to start the project container:
149123

150-
```
124+
```shell
151125
docker compose up -d --build
152126
```
153127

154128
If you want to recreate the project container, you can run the following command:
155129

156-
```
130+
```shell
157131
docker compose up --force-recreate -d --build
158132
```
159133

160134
If you want to stop the project container, you can run the following command:
161135

162-
```
136+
```shell
163137
docker compose down -v
164138
```
165139

@@ -212,7 +186,7 @@ ZipException opening "bcprov-jdk18on-1.78.jar": zip END header not found
212186

213187
#### Solution:
214188

215-
> Make sure to remove bouncy castle from your .m2 folder then run `mvn clean install` again to download the packages.
189+
> Make sure to remove bouncy castle from your .m2 folder then run `./mvnw clean install` again to download the packages.
216190
217191
### 3. Can't download the package from the private repo:
218192

@@ -228,7 +202,7 @@ or updates are forced -> [Help 1]
228202

229203
#### Solution:
230204

231-
> Use the following command to build the project: `mvn clean install -U -DskipTests`
205+
> Use the following command to build the project: `./mvnw clean install -U -DskipTests`
232206
233207
### 4. Email Configuration Errors:
234208

setup/setup.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
echo "\033[96m
3+
___ ____ ____ _______,
4+
/ \ \ \ / / / |
5+
/ ^ \ \ \/ / | (----'
6+
/ /_\ \ \_ _/ \ \\
7+
/ _____ \ | | .----) |
8+
/__/ \__\ |__| |_______/
9+
:: AYS | Afet Yönetim Sistemi ::\033[0m
10+
"
11+
12+
FILE_NAME="settings.xml"
13+
IS_OVERWRITE=true
14+
if [[ -f "$FILE_NAME" ]]; then
15+
echo "⚠️ \033[93m$FILE_NAME file already exists. If you want to update your credentials, you can overwrite it now.\033[0m"
16+
while true; do
17+
echo "\033[97m"
18+
read -p "➡️ Do you want to overwrite the existing $FILE_NAME file? (y/n): " choice
19+
case "$choice" in
20+
[Yy]* )
21+
IS_OVERWRITE=true
22+
echo ""
23+
echo ""
24+
break
25+
;;
26+
[Nn]* )
27+
IS_OVERWRITE=false
28+
break
29+
;;
30+
* )
31+
echo "Invalid choice, please enter 'y' or 'n'."
32+
;;
33+
esac
34+
done
35+
fi
36+
37+
if [[ "$IS_OVERWRITE" == true ]]; then
38+
echo "\033[96mPlease provide the following values for setup 🚀\033[0m"
39+
while true; do
40+
echo "\033[97m"
41+
read -p "➡️ Enter your GitHub username: " YOUR_GITHUB_USERNAME
42+
if [[ -n "$YOUR_GITHUB_USERNAME" ]]; then
43+
break
44+
fi
45+
echo "\033[41mPlease enter your GitHub username.\033[0m"
46+
done
47+
48+
while true; do
49+
echo "\033[97m"
50+
read -p "➡️ Enter your GitHub Access Token (press enter for creating) : " YOUR_PERSONAL_GITHUB_ACCESS_TOKEN
51+
if [[ -n "$YOUR_PERSONAL_GITHUB_ACCESS_TOKEN" ]]; then
52+
break
53+
fi
54+
55+
echo ""
56+
echo "\033[96mPress Enter to open browser for creating a new Personal Access Token...\033[0m"
57+
read -p "" _
58+
59+
if command -v xdg-open >/dev/null; then
60+
xdg-open "https://github.com/settings/tokens/new"
61+
elif command -v open >/dev/null; then
62+
open "https://github.com/settings/tokens/new"
63+
else
64+
echo "Please open the following URL in your browser to create a new Personal Access Token: "
65+
echo " https://github.com/settings/tokens/new"
66+
fi
67+
68+
while true; do
69+
echo "\033[97m"
70+
read -p "➡️ Paste your Personal Access Token here: " YOUR_PERSONAL_GITHUB_ACCESS_TOKEN
71+
if [[ -n "$YOUR_PERSONAL_GITHUB_ACCESS_TOKEN" ]]; then
72+
break
73+
fi
74+
echo "\033[41mPlease paste your Personal Access Token.\033[0m"
75+
done
76+
break
77+
done
78+
echo "\033[0m"
79+
80+
echo "📝 \033[44mCredentials setting up...\033[0m"
81+
82+
sleep 1
83+
84+
cp template-settings.xml settings.xml
85+
sed 's|'{YOUR_GITHUB_USERNAME}'|'${YOUR_GITHUB_USERNAME}'|g' settings.xml >> temp-settings.xml ; rm settings.xml ; mv temp-settings.xml settings.xml
86+
sed 's|'{YOUR_PERSONAL_GITHUB_ACCESS_TOKEN}'|'${YOUR_PERSONAL_GITHUB_ACCESS_TOKEN}'|g' settings.xml >> temp-settings.xml ; rm settings.xml ; mv temp-settings.xml settings.xml
87+
88+
echo "🎉 \033[102mCredentials have been configured!\033[0m"
89+
echo ""
90+
else
91+
echo ""
92+
echo "ℹ️ \033[44mSkipping credentials setup...\033[0m"
93+
echo ""
94+
fi
95+
96+
./mvnw -s settings.xml clean install -DskipTests

0 commit comments

Comments
 (0)