mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 10:30:06 +00:00
✨ update mole
This commit is contained in:
@@ -1,30 +0,0 @@
|
|||||||
class CleanMac < Formula
|
|
||||||
desc "Clean Mac - Deep Clean Your Mac with One Click"
|
|
||||||
homepage "https://github.com/tw93/clean-mac"
|
|
||||||
url "https://github.com/tw93/clean-mac/archive/refs/tags/v1.0.0.tar.gz"
|
|
||||||
sha256 "8274af48615205ab3ce4b75c9b2e898a53b4d49972cd7757fe8b6fe27603a5ab"
|
|
||||||
license "MIT"
|
|
||||||
head "https://github.com/tw93/clean-mac.git", branch: "main"
|
|
||||||
|
|
||||||
def install
|
|
||||||
bin.install "clean.sh" => "clean"
|
|
||||||
end
|
|
||||||
|
|
||||||
test do
|
|
||||||
# Test that the script is executable and shows help
|
|
||||||
assert_match "Clean Mac", shell_output("#{bin}/clean --help", 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
def caveats
|
|
||||||
<<~EOS
|
|
||||||
Clean Mac has been installed!
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
clean - User-level cleanup (no password required)
|
|
||||||
clean --system - Deep system cleanup (password required)
|
|
||||||
clean --help - Show help message
|
|
||||||
|
|
||||||
For Apple Silicon Macs, the tool includes M-series specific optimizations.
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
14
Formula/mole.rb
Normal file
14
Formula/mole.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
class Mole < Formula
|
||||||
|
desc "Mole - Clean your Mac"
|
||||||
|
homepage "https://github.com/tw93/mole"
|
||||||
|
license "MIT"
|
||||||
|
head "https://github.com/tw93/mole.git", branch: "main"
|
||||||
|
|
||||||
|
def install
|
||||||
|
bin.install "mole"
|
||||||
|
end
|
||||||
|
|
||||||
|
test do
|
||||||
|
assert_match "Mole", shell_output("#{bin}/mole --help", 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fsSL https://raw.githubusercontent.com/tw93/clean-mac/main/install.sh | bash
|
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -86,7 +86,7 @@ If Mole has been helpful to you:
|
|||||||
|
|
||||||
- **Star this repository** and share with fellow Mac users
|
- **Star this repository** and share with fellow Mac users
|
||||||
- **Report issues** or suggest new cleanup targets
|
- **Report issues** or suggest new cleanup targets
|
||||||
- I have two cats, if you think Clean helps you, you can <a href="https://miaoyan.app/cats.html?name=CleanMac" target="_blank">feed them canned food 🥩🍤</a>
|
- I have two cats. If Mole helps you, you can <a href="https://miaoyan.app/cats.html?name=Mole" target="_blank">feed them canned food 🥩🍤</a>
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ should_preserve_bundle() {
|
|||||||
|
|
||||||
# Help information
|
# Help information
|
||||||
show_help() {
|
show_help() {
|
||||||
echo "Clean Mac - Interactive App Uninstaller"
|
echo "Mole - Interactive App Uninstaller"
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Description: Interactive tool to uninstall applications and clean their data"
|
echo "Description: Interactive tool to uninstall applications and clean their data"
|
||||||
@@ -394,7 +394,7 @@ trap cleanup EXIT INT TERM
|
|||||||
|
|
||||||
# Main function
|
# Main function
|
||||||
main() {
|
main() {
|
||||||
echo "🗑️ Clean Mac - Interactive App Uninstaller"
|
echo "🗑️ Mole - Interactive App Uninstaller"
|
||||||
echo "============================================"
|
echo "============================================"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
@@ -444,4 +444,4 @@ main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Run main function
|
# Run main function
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
78
install.sh
78
install.sh
@@ -19,7 +19,8 @@ log_error() { echo -e "${RED}❌ $1${NC}"; }
|
|||||||
|
|
||||||
# Default installation directory
|
# Default installation directory
|
||||||
INSTALL_DIR="/usr/local/bin"
|
INSTALL_DIR="/usr/local/bin"
|
||||||
CONFIG_DIR="$HOME/.config/clean"
|
CONFIG_DIR="$HOME/.config/mole"
|
||||||
|
SOURCE_DIR=""
|
||||||
|
|
||||||
show_help() {
|
show_help() {
|
||||||
cat << 'EOF'
|
cat << 'EOF'
|
||||||
@@ -31,7 +32,7 @@ USAGE:
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
--prefix PATH Install to custom directory (default: /usr/local/bin)
|
--prefix PATH Install to custom directory (default: /usr/local/bin)
|
||||||
--config PATH Config directory (default: ~/.config/clean)
|
--config PATH Config directory (default: ~/.config/mole)
|
||||||
--uninstall Uninstall mole
|
--uninstall Uninstall mole
|
||||||
--help, -h Show this help
|
--help, -h Show this help
|
||||||
|
|
||||||
@@ -47,6 +48,54 @@ The installer will:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Resolve the directory containing source files (supports curl | bash)
|
||||||
|
resolve_source_dir() {
|
||||||
|
# 1) If script is on disk, use its directory
|
||||||
|
if [[ -n "${BASH_SOURCE[0]:-}" && -f "${BASH_SOURCE[0]}" ]]; then
|
||||||
|
local script_dir
|
||||||
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
if [[ -f "$script_dir/mole" || -d "$script_dir/bin" || -d "$script_dir/lib" ]]; then
|
||||||
|
SOURCE_DIR="$script_dir"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2) If CLEAN_SOURCE_DIR env is provided, honor it
|
||||||
|
if [[ -n "${CLEAN_SOURCE_DIR:-}" && -d "$CLEAN_SOURCE_DIR" ]]; then
|
||||||
|
SOURCE_DIR="$CLEAN_SOURCE_DIR"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3) Fallback: fetch repository to a temp directory (works for curl | bash)
|
||||||
|
local tmp
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
|
|
||||||
|
echo "Fetching Mole source..."
|
||||||
|
if command -v curl >/dev/null 2>&1; then
|
||||||
|
# Download main branch tarball
|
||||||
|
if curl -fsSL -o "$tmp/mole.tar.gz" "https://github.com/tw93/mole/archive/refs/heads/main.tar.gz"; then
|
||||||
|
tar -xzf "$tmp/mole.tar.gz" -C "$tmp"
|
||||||
|
# Extracted folder name: mole-main
|
||||||
|
if [[ -d "$tmp/mole-main" ]]; then
|
||||||
|
SOURCE_DIR="$tmp/mole-main"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4) Fallback to git if available
|
||||||
|
if command -v git >/dev/null 2>&1; then
|
||||||
|
if git clone --depth=1 https://github.com/tw93/mole.git "$tmp/mole" >/dev/null 2>&1; then
|
||||||
|
SOURCE_DIR="$tmp/mole"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_error "Failed to fetch source files. Ensure curl or git is available."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# Parse command line arguments
|
# Parse command line arguments
|
||||||
parse_args() {
|
parse_args() {
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
@@ -125,40 +174,39 @@ create_directories() {
|
|||||||
install_files() {
|
install_files() {
|
||||||
log_info "Installing mole files..."
|
log_info "Installing mole files..."
|
||||||
|
|
||||||
# Get the directory where this script is located
|
resolve_source_dir
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
|
|
||||||
# Copy main executable
|
# Copy main executable
|
||||||
if [[ -f "$SCRIPT_DIR/mole" ]]; then
|
if [[ -f "$SOURCE_DIR/mole" ]]; then
|
||||||
if [[ "$INSTALL_DIR" == "/usr/local/bin" ]] && [[ ! -w "$INSTALL_DIR" ]]; then
|
if [[ "$INSTALL_DIR" == "/usr/local/bin" ]] && [[ ! -w "$INSTALL_DIR" ]]; then
|
||||||
sudo cp "$SCRIPT_DIR/mole" "$INSTALL_DIR/mole"
|
sudo cp "$SOURCE_DIR/mole" "$INSTALL_DIR/mole"
|
||||||
sudo chmod +x "$INSTALL_DIR/mole"
|
sudo chmod +x "$INSTALL_DIR/mole"
|
||||||
else
|
else
|
||||||
cp "$SCRIPT_DIR/mole" "$INSTALL_DIR/mole"
|
cp "$SOURCE_DIR/mole" "$INSTALL_DIR/mole"
|
||||||
chmod +x "$INSTALL_DIR/mole"
|
chmod +x "$INSTALL_DIR/mole"
|
||||||
fi
|
fi
|
||||||
log_success "Main executable installed to $INSTALL_DIR/mole"
|
log_success "Main executable installed to $INSTALL_DIR/mole"
|
||||||
else
|
else
|
||||||
log_error "mole executable not found in $SCRIPT_DIR"
|
log_error "mole executable not found in ${SOURCE_DIR:-unknown}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy configuration and modules
|
# Copy configuration and modules
|
||||||
if [[ -d "$SCRIPT_DIR/bin" ]]; then
|
if [[ -d "$SOURCE_DIR/bin" ]]; then
|
||||||
cp -r "$SCRIPT_DIR/bin"/* "$CONFIG_DIR/bin/"
|
cp -r "$SOURCE_DIR/bin"/* "$CONFIG_DIR/bin/"
|
||||||
chmod +x "$CONFIG_DIR/bin"/*
|
chmod +x "$CONFIG_DIR/bin"/*
|
||||||
log_success "Modules copied to $CONFIG_DIR/bin"
|
log_success "Modules copied to $CONFIG_DIR/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "$SCRIPT_DIR/lib" ]]; then
|
if [[ -d "$SOURCE_DIR/lib" ]]; then
|
||||||
cp -r "$SCRIPT_DIR/lib"/* "$CONFIG_DIR/lib/"
|
cp -r "$SOURCE_DIR/lib"/* "$CONFIG_DIR/lib/"
|
||||||
log_success "Libraries copied to $CONFIG_DIR/lib"
|
log_success "Libraries copied to $CONFIG_DIR/lib"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy other files if they exist
|
# Copy other files if they exist
|
||||||
for file in README.md LICENSE; do
|
for file in README.md LICENSE; do
|
||||||
if [[ -f "$SCRIPT_DIR/$file" ]]; then
|
if [[ -f "$SOURCE_DIR/$file" ]]; then
|
||||||
cp "$SCRIPT_DIR/$file" "$CONFIG_DIR/"
|
cp "$SOURCE_DIR/$file" "$CONFIG_DIR/"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -271,4 +319,4 @@ main() {
|
|||||||
|
|
||||||
# Run installation
|
# Run installation
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
main
|
main
|
||||||
|
|||||||
6
mole
6
mole
@@ -38,7 +38,7 @@ COMMANDS:
|
|||||||
mole uninstall # Remove applications completely
|
mole uninstall # Remove applications completely
|
||||||
mole --help # Show this help message
|
mole --help # Show this help message
|
||||||
|
|
||||||
For more information, visit: https://github.com/tw93/clean-mac
|
For more information, visit: https://github.com/tw93/mole
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ show_main_menu() {
|
|||||||
show_menu_option 1 "Clean System - Remove junk files and optimize" "$([[ $selected -eq 1 ]] && echo true || echo false)"
|
show_menu_option 1 "Clean System - Remove junk files and optimize" "$([[ $selected -eq 1 ]] && echo true || echo false)"
|
||||||
show_menu_option 2 "Uninstall Apps - Completely remove applications" "$([[ $selected -eq 2 ]] && echo true || echo false)"
|
show_menu_option 2 "Uninstall Apps - Completely remove applications" "$([[ $selected -eq 2 ]] && echo true || echo false)"
|
||||||
show_menu_option 3 "Help & Information - Usage guide and tips" "$([[ $selected -eq 3 ]] && echo true || echo false)"
|
show_menu_option 3 "Help & Information - Usage guide and tips" "$([[ $selected -eq 3 ]] && echo true || echo false)"
|
||||||
show_menu_option 4 "Exit - Close Clean" "$([[ $selected -eq 4 ]] && echo true || echo false)"
|
show_menu_option 4 "Exit - Close Mole" "$([[ $selected -eq 4 ]] && echo true || echo false)"
|
||||||
|
|
||||||
if [[ "$redraw_full" == "true" ]]; then
|
if [[ "$redraw_full" == "true" ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
@@ -166,4 +166,4 @@ main() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user