-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgenerate_projects.sh
executable file
·66 lines (57 loc) · 2.56 KB
/
generate_projects.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
#!/bin/sh
# clean up tags
clean=false
# Sample folder names
folders=("jhipster-sample-app" "jhipster-sample-app-cassandra" "jhipster-sample-app-couchbase" "jhipster-sample-app-dto" "jhipster-sample-app-elasticsearch" "jhipster-sample-app-gateway" "jhipster-sample-app-gradle" "jhipster-sample-app-hazelcast" "jhipster-sample-app-microservice" "jhipster-sample-app-mongodb" "jhipster-sample-app-nocache" "jhipster-sample-app-noi18n" "jhipster-sample-app-oauth2" "jhipster-sample-app-react" "jhipster-sample-app-vuejs" "jhipster-sample-app-websocket")
# Function to display script usage
usage() {
echo "Usage: $0 [-c]"
echo "Options:"
echo " -c Delete existing local and remote tags when this flag is present."
exit 1
}
# Parse command-line options
while getopts "c" opt; do
case "$opt" in
c) clean=true;;
\?) echo "Invalid option: -$OPTARG" >&2; usage;;
esac
done
echo "Starting to generate JHipster sample projects"
echo "Please make sure to install the version to be tagged"
cd ../samples
read -p "Enter the JHipster version to tag: eg: v8.0.0: " JHIPSTER_VERSION
# Iterate through each folder
for folder in "${folders[@]}"; do
# Check if the folder exists
if [ -d "$folder" ]; then
echo "---------------------------------------------"
echo "current project: $folder "
echo "---------------------------------------------"
cd "$folder" || exit 1 # Change directory to the folder, exit if it fails
ls -al
echo "Clean existing files and folder"
find . -maxdepth 1 -type f ! -name ".yo-rc.json" -delete
find . -maxdepth 1 -type d ! -name ".git" ! -name ".github" ! -name ".jhipster" ! -name "." ! -name ".." -exec rm -rf {} \;
ls -al
rm .git/index
jhipster --no-insight --skip-checks --skip-install --force || exit
cp ../../jhipster-automated-samples/LICENSE.txt .
ls -al
git add .
git commit -m "automatic project update for $JHIPSTER_VERSION" --no-verify || exit
git push --no-verify || exit
# Delete tags based on the flag
if [ "$clean" = true ]; then
echo "Deleting local and remote tags for $folder."
git tag --delete $JHIPSTER_VERSION || true
git push --delete origin $JHIPSTER_VERSION || true
fi
git tag $JHIPSTER_VERSION && git push origin $JHIPSTER_VERSION --no-verify || exit
# Return to the original directory
cd ..
echo "Exited $folder."
else
echo "Folder '$folder' does not exist." && exit
fi
done