diff --git a/.github/workflows/health-check.yml b/.github/workflows/health-check.yml index e1f5321..395026d 100644 --- a/.github/workflows/health-check.yml +++ b/.github/workflows/health-check.yml @@ -29,7 +29,7 @@ jobs: run: make check-scripts Test: - name: Test install on macOS + name: Test install and uninstall on macOS runs-on: macos-14 timeout-minutes: 30 steps: @@ -45,3 +45,13 @@ jobs: run: | cd ~ ls -la + + - name: Run uninstall script + run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/YasminTeles/dotfiles/main/uninstall.sh)" + env: + CI: true + + - name: Show the Home directory + run: | + cd ~ + ls -la diff --git a/Makefile b/Makefile index 2c1e409..1c0d394 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help del ssh backup check-scripts +.PHONY: help check_clean del ssh backup check-scripts help: ## Show help. @printf "A set of environment management commands.\n" @@ -7,7 +7,10 @@ help: ## Show help. @printf "\nThe Commands are:\n\n" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\t\033[36m%-30s\033[0m %s\n", $$1, $$2}' -del: ## Delete your development environment. +check_clean: + @echo -n "Are you sure you want to remove all configurations? [y/N] " && read ans && [ $${ans:-N} = y ] + +del: check_clean ## Delete your development environment. @echo "Deleting all dotfiles, applications, and folders..." @stow --dotfiles -D git ssh brew @rm -rf ~/Projects diff --git a/README.md b/README.md index 8b94559..fe75ee7 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,23 @@ A set of environment management commands is available at `Makefile`. To access t make help ``` +## Uninstall + +This script is designed to remove all configurations of your environment. **Please proceed with caution** as this action is irreversible. + +### Instructions + +Enter this command into a macOS Terminal or Linux shell prompt. The script will outline its actions. + +```bash + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/YasminTeles/dotfiles/main/uninstall.sh)" +``` + +> [!CAUTION] +> Ensure you have **backups** of any important configurations before running this script. + +By following these steps, you can safely remove all configurations of the environment as needed. + ## License This project is licensed under the [MIT License](LICENSE). diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..2e497ad --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Tells the shell script to exit if it encounters an error +set -e + +# Print a step description +TOTAL_STEPS=5 +STEP=1 +function step_msg { + printf "\n\033[36;1m[%s/%s] %s...\033[0m\n" "$STEP" "$TOTAL_STEPS" "$1"; + ((STEP++)) +} + +echo "This script will remove all configurations of the environment." + +if [ ! "$CI" ] +then + read -r -p "Are you sure you want to proceed? (y/n) " CONFIRM +fi + +if [[ "$CI" || "$CONFIRM" == [yY] || "$CONFIRM" == [yY][eE][sS] ]] +then + printf "\nPlease wait! Proceeding with the removal of all configurations...\n" + + # -- Symlinks ---------------------------------------------------------------- + step_msg "Removing all symlinks" + cd ~/.dotfiles && stow --dotfiles -D git ssh brew + + # -- Project folder ---------------------------------------------------------- + step_msg "Removing the Project directory" + rm -rf ~/Projects + + # -- SSH Key ----------------------------------------------------------------- + step_msg "Removing SSH Keys" + rm -rf ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub + + # -- Productivity Apps ------------------------------------------------------- + step_msg "Removing all productivity apps" + brew uninstall --force "$(brew list)" + rm -rf ~/Brewfile.lock.json + + # -- Dotfiles ---------------------------------------------------------------- + step_msg "Removing Dotfiles directory" + rm -rf ~/.dotfiles + +# -- Happy end ----------------------------------------------------------------- + printf "\nAll configurations have been removed." + +else + printf "\nOperation cancelled." +fi + +printf "\nHave a nice day!\n" +