-
Notifications
You must be signed in to change notification settings - Fork 656
Add cleanup scripts to remove unwanted apps in the apps directory #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,68 @@ | ||||||
#!/bin/bash | ||||||
|
||||||
# Script to remove all directories in /apps which match configurable search patterns | ||||||
# Default patterns: "web-" (configurable via SEARCH_PATTERNS variable) | ||||||
|
||||||
set -e # Exit on any error | ||||||
|
||||||
# Configuration - Add multiple patterns separated by spaces (example: "web- vscode-nightly") | ||||||
SEARCH_PATTERNS="web- vscode-nightly" | ||||||
|
||||||
# Define the target directory (relative to project root) | ||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" | ||||||
APP_DIR="$PROJECT_ROOT/apps" | ||||||
|
||||||
if [ ! -d "$APP_DIR" ]; then | ||||||
echo "Error: Directory $APP_DIR does not exist" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redirect error messages to stderr for clarity, e.g.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
exit 1 | ||||||
fi | ||||||
|
||||||
echo "Searching for directories matching patterns: $SEARCH_PATTERNS in $APP_DIR..." | ||||||
|
||||||
MATCHING_DIRS="" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using a Bash array to collect matching directories instead of building a newline-delimited string. Arrays handle spaces robustly and simplify iteration, e.g. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
for pattern in $SEARCH_PATTERNS; do | ||||||
FOUND_DIRS=$(find "$APP_DIR" -maxdepth 1 -type d -name "*$pattern*" 2>/dev/null || true) | ||||||
if [ -n "$FOUND_DIRS" ]; then | ||||||
if [ -z "$MATCHING_DIRS" ]; then | ||||||
MATCHING_DIRS="$FOUND_DIRS" | ||||||
else | ||||||
MATCHING_DIRS="$MATCHING_DIRS | ||||||
$FOUND_DIRS" | ||||||
fi | ||||||
fi | ||||||
done | ||||||
|
||||||
if [ -z "$MATCHING_DIRS" ]; then | ||||||
echo "No directories matching patterns '$SEARCH_PATTERNS' found in $APP_DIR" | ||||||
exit 0 | ||||||
fi | ||||||
|
||||||
echo "Found the following directories to remove:" | ||||||
echo "$MATCHING_DIRS" | ||||||
echo | ||||||
|
||||||
# Confirmation prompt | ||||||
read -p "Are you sure you want to remove these directories? (y/N): " -n 1 -r | ||||||
echo | ||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then | ||||||
echo "Operation cancelled." | ||||||
exit 0 | ||||||
fi | ||||||
|
||||||
# Remove the directories | ||||||
echo "Removing directories..." | ||||||
for dir in $MATCHING_DIRS; do | ||||||
if [ -d "$dir" ]; then | ||||||
echo "Removing: $dir" | ||||||
rm -rf "$dir" | ||||||
if [ $? -eq 0 ]; then | ||||||
echo "Successfully removed: $dir" | ||||||
else | ||||||
echo "Error removing: $dir" | ||||||
fi | ||||||
fi | ||||||
done | ||||||
|
||||||
echo "Operation completed." | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per Kilocode Change Marking Guidelines, new files must include a
// kilocode_change - new file
comment at the top. Please add this annotation above the shebang.Copilot generated this review using guidance from copilot-instructions.md.