Initial commit
This commit is contained in:
96
ProjectConfigurator.sh
Executable file
96
ProjectConfigurator.sh
Executable file
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# -----------------------------
|
||||
# Intro
|
||||
# -----------------------------
|
||||
echo "Project Configurator"
|
||||
echo "--------------------"
|
||||
|
||||
# -----------------------------
|
||||
# Projektname abfragen
|
||||
# -----------------------------
|
||||
read -rp "What should the project be called? " PROJECT_NAME
|
||||
|
||||
if [[ -z "$PROJECT_NAME" ]]; then
|
||||
echo "Project name cannot be empty."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! "$PROJECT_NAME" =~ ^[a-zA-Z0-9_-]+$ ]]; then
|
||||
echo "Invalid project name. Use only letters, numbers, _ or -"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -----------------------------
|
||||
# Ordner umbenennen
|
||||
# -----------------------------
|
||||
if [ ! -d "__Project_Name__" ]; then
|
||||
echo "Placeholder directory '__Project_Name__' not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Renaming project directory..."
|
||||
mv "__Project_Name__" "$PROJECT_NAME"
|
||||
|
||||
# -----------------------------
|
||||
# CMakeLists.txt anpassen
|
||||
# -----------------------------
|
||||
if [ ! -f "CMakeLists.txt" ]; then
|
||||
echo "CMakeLists.txt not found in root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Updating CMakeLists.txt..."
|
||||
sed -i "s/__Project_Name__/$PROJECT_NAME/g" CMakeLists.txt
|
||||
|
||||
# -----------------------------
|
||||
# globalVars.hpp anpassen
|
||||
# -----------------------------
|
||||
GLOBAL_VARS_PATH="$PROJECT_NAME/include/globalVars.hpp"
|
||||
|
||||
if [ ! -f "$GLOBAL_VARS_PATH" ]; then
|
||||
echo "globalVars.hpp not found in root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Updating globalVars.hpp..."
|
||||
sed -i "s/__Project_Name__/$PROJECT_NAME/g" "$GLOBAL_VARS_PATH"
|
||||
|
||||
# -----------------------------
|
||||
# Git Submodule aktualisieren
|
||||
# -----------------------------
|
||||
if [ -f ".gitmodules" ]; then
|
||||
echo "Initializing and updating submodules..."
|
||||
git submodule update --init --recursive
|
||||
|
||||
echo "Updating submodules to latest main branch..."
|
||||
git submodule foreach '
|
||||
git fetch origin &&
|
||||
git checkout main &&
|
||||
git pull origin main
|
||||
'
|
||||
else
|
||||
echo "No submodules found. Skipping."
|
||||
fi
|
||||
|
||||
# -----------------------------
|
||||
# Git vorbereiten
|
||||
# -----------------------------
|
||||
echo "Preparing git repository..."
|
||||
|
||||
# falls das Repo aus Template kommt, existiert Git schon
|
||||
git add .
|
||||
git commit -m "Configure project $PROJECT_NAME"
|
||||
|
||||
# -----------------------------
|
||||
# Ziel-Repository pushen
|
||||
# -----------------------------
|
||||
|
||||
git push -u origin main
|
||||
|
||||
# -----------------------------
|
||||
# Fertig
|
||||
# -----------------------------
|
||||
echo "Done."
|
||||
echo "Project '$PROJECT_NAME' is ready."
|
||||
Reference in New Issue
Block a user