Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions scripts/kilocode/roomerge_04_apps_cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
Copy link
Preview

Copilot AI Jul 3, 2025

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.


# 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"
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirect error messages to stderr for clarity, e.g. echo "Error: Directory $APP_DIR does not exist" >&2.

Suggested change
echo "Error: Directory $APP_DIR does not exist"
echo "Error: Directory $APP_DIR does not exist" >&2

Copilot uses AI. Check for mistakes.

exit 1
fi

echo "Searching for directories matching patterns: $SEARCH_PATTERNS in $APP_DIR..."

MATCHING_DIRS=""
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The 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. MATCHING_DIRS=(); MATCHING_DIRS+=("$dir"); for dir in "${MATCHING_DIRS[@]}"; do ....

Copilot uses AI. Check for mistakes.

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."