Last active
September 17, 2025 07:19
-
-
Save bjarneo/ecf8b3ebe529e01eb1731eefe4cba708 to your computer and use it in GitHub Desktop.
Search for packages affected by the Shai-Halud attack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Extract packages from npm.sh and search for them across the system | |
| # This script searches through package.json, yarn.lock, bun files, and node_modules | |
| # Default search paths (can be overridden with SEARCH_PATHS environment variable) | |
| DEFAULT_SEARCH_PATHS="/Users/ob907/Code" | |
| SEARCH_PATHS="${SEARCH_PATHS:-$DEFAULT_SEARCH_PATHS}" | |
| # Array of packages with versions extracted from npm.sh | |
| packages=( | |
| "@ahmedhfarag/[email protected]" | |
| "@ahmedhfarag/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@art-ws/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@crowdstrike/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@ctrl/[email protected]" | |
| "@hestjs/[email protected]" | |
| "@hestjs/[email protected]" | |
| "@hestjs/[email protected]" | |
| "@hestjs/[email protected]" | |
| "@hestjs/[email protected]" | |
| "@hestjs/[email protected]" | |
| "@hestjs/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nativescript-community/[email protected]" | |
| "@nexe/[email protected]" | |
| "@nexe/[email protected]" | |
| "@nexe/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@nstudio/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@operato/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@teselagen/[email protected]" | |
| "@thangved/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@things-factory/[email protected]" | |
| "@tnf-dev/[email protected]" | |
| "@tnf-dev/[email protected]" | |
| "@tnf-dev/[email protected]" | |
| "@tnf-dev/[email protected]" | |
| "@tnf-dev/[email protected]" | |
| "@ui-ux-gang/[email protected]" | |
| "@yoobic/[email protected]" | |
| "@yoobic/[email protected]" | |
| "@yoobic/[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| "[email protected]" | |
| ) | |
| # Colors for output | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| BLUE='\033[0;34m' | |
| NC='\033[0m' # No Color | |
| # Function to search for a package | |
| search_package() { | |
| local package_with_version="$1" | |
| local package_name="${package_with_version%@*}" | |
| local version="${package_with_version##*@}" | |
| local found=false | |
| echo -e "${BLUE}Searching for package: ${YELLOW}$package_name@$version${NC}" | |
| # Search in package.json files for the exact package@version | |
| local exact_package_json_files=$(rg -l "\"$package_with_version\"" --glob="**/package.json" --type=json $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$exact_package_json_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found exact version in package.json files:${NC}" | |
| echo "$exact_package_json_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in package.json files for version ranges that could include our specific version | |
| # Look for patterns like: "package": "^1.0.0", "~1.0.0", ">=1.0.0", "1.0.0" | |
| local version_range_files=$(rg -l "\"$package_name\":\\s*\"[~^>=]*$version" --glob="**/package.json" --type=json $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$version_range_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found version in range specifications in package.json files:${NC}" | |
| echo "$version_range_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in package.json files for the package name (any version) | |
| local package_json_files=$(rg -l "\"$package_name\"" --glob="**/package.json" --type=json $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$package_json_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found package name in package.json files:${NC}" | |
| echo "$package_json_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in yarn.lock files for exact package@version | |
| local exact_yarn_files=$(rg -l "^$package_with_version:" --glob="**/yarn.lock" $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$exact_yarn_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found exact version in yarn.lock files:${NC}" | |
| echo "$exact_yarn_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in yarn.lock files for package name | |
| local yarn_files=$(rg -l "^$package_name@" --glob="**/yarn.lock" $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$yarn_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found package name in yarn.lock files:${NC}" | |
| echo "$yarn_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in bun.lockb files (binary, so we'll search for bun.lock text files) | |
| local exact_bun_files=$(rg -l "$package_with_version" --glob="**/bun.lock*" $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$exact_bun_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found exact version in bun.lock files:${NC}" | |
| echo "$exact_bun_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in bun.lock files for package name | |
| local bun_files=$(rg -l "$package_name" --glob="**/bun.lock*" $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$bun_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found package name in bun.lock files:${NC}" | |
| echo "$bun_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in package-lock.json files for exact version | |
| local exact_package_lock_files=$(rg -l "\"$package_with_version\"" --glob="**/package-lock.json" --type=json $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$exact_package_lock_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found exact version in package-lock.json files:${NC}" | |
| echo "$exact_package_lock_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in package-lock.json files for version ranges | |
| local version_range_package_lock_files=$(rg -l "\"$package_name\":\\s*\"[~^>=]*$version" --glob="**/package-lock.json" --type=json $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$version_range_package_lock_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found version in range specifications in package-lock.json files:${NC}" | |
| echo "$version_range_package_lock_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in package-lock.json files for package name | |
| local package_lock_files=$(rg -l "\"$package_name\"" --glob="**/package-lock.json" --type=json $SEARCH_PATHS 2>/dev/null | head -10) | |
| if [ -n "$package_lock_files" ]; then | |
| found=true | |
| echo -e "${GREEN} Found package name in package-lock.json files:${NC}" | |
| echo "$package_lock_files" | while read -r file; do | |
| echo -e " ${YELLOW}$file${NC}" | |
| done | |
| fi | |
| # Search in node_modules directories for package name | |
| local node_modules_dirs=$(find $SEARCH_PATHS -type d -name "node_modules" -exec find {} -name "*$package_name*" -type d \; 2>/dev/null | head -5) | |
| if [ -n "$node_modules_dirs" ]; then | |
| found=true | |
| echo -e "${GREEN} Found package in node_modules directories:${NC}" | |
| echo "$node_modules_dirs" | while read -r dir; do | |
| echo -e " ${YELLOW}$dir${NC}" | |
| done | |
| fi | |
| if [ "$found" = false ]; then | |
| echo -e "${RED} Package not found${NC}" | |
| fi | |
| echo "" | |
| } | |
| # Function to search all packages | |
| search_all_packages() { | |
| echo -e "${BLUE}Starting search for ${#packages[@]} packages across the system...${NC}" | |
| echo "" | |
| for package in "${packages[@]}"; do | |
| search_package "$package" | |
| done | |
| } | |
| # Function to search for specific package | |
| search_specific() { | |
| local query="$1" | |
| echo -e "${BLUE}Searching for packages matching: ${YELLOW}$query${NC}" | |
| echo "" | |
| for package in "${packages[@]}"; do | |
| if [[ "$package" == *"$query"* ]]; then | |
| search_package "$package" | |
| fi | |
| done | |
| } | |
| # Function to list all packages | |
| list_packages() { | |
| echo -e "${BLUE}All packages from npm.sh:${NC}" | |
| printf '%s\n' "${packages[@]}" | |
| } | |
| # Main script logic | |
| case "${1:-all}" in | |
| "all") | |
| search_all_packages | |
| ;; | |
| "list") | |
| list_packages | |
| ;; | |
| "search") | |
| if [ -z "$2" ]; then | |
| echo -e "${RED}Please provide a search term: $0 search <term>${NC}" | |
| exit 1 | |
| fi | |
| search_specific "$2" | |
| ;; | |
| "help" | "-h" | "--help") | |
| echo -e "${BLUE}Usage:${NC}" | |
| echo " $0 [all] - Search for all packages (default)" | |
| echo " $0 list - List all packages" | |
| echo " $0 search <term> - Search for packages containing <term>" | |
| echo " $0 help - Show this help" | |
| echo "" | |
| echo -e "${BLUE}Environment Variables:${NC}" | |
| echo " SEARCH_PATHS - Override default search paths" | |
| echo " Default: '$DEFAULT_SEARCH_PATHS'" | |
| echo "" | |
| echo -e "${BLUE}Examples:${NC}" | |
| echo " $0 search react" | |
| echo " SEARCH_PATHS='/home /opt' $0 search react" | |
| echo " SEARCH_PATHS='/' $0 search react # Search entire system" | |
| ;; | |
| *) | |
| echo -e "${RED}Unknown option: $1${NC}" | |
| echo "Use '$0 help' for usage information" | |
| exit 1 | |
| ;; | |
| esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment