Created
October 31, 2025 10:03
-
-
Save ugmurthy/0144f72700f4da254291382ce68a3e6d to your computer and use it in GitHub Desktop.
Check compatibility of node or python modules with runtime version of node / python
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 | |
| # Check argument | |
| if [ $# -ne 1 ]; then | |
| echo "Usage: $0 {python|node}" | |
| exit 1 | |
| fi | |
| RUNTIME_TYPE="$1" | |
| # === Set MODULESFILE === | |
| case "$RUNTIME_TYPE" in | |
| python) MODULESFILE="requirements.txt" ;; | |
| node) MODULESFILE="package.json" ;; | |
| *) echo "Error: Invalid argument. Use 'python' or 'node'."; exit 1 ;; | |
| esac | |
| # === Get RUNTIME version === | |
| case "$RUNTIME_TYPE" in | |
| python) | |
| if command -v python3 &>/dev/null; then | |
| RUNTIME=$(python3 --version 2>&1 | awk '{print $2}') | |
| elif command -v python &>/dev/null; then | |
| RUNTIME=$(python --version 2>&1 | awk '{print $2}') | |
| else | |
| echo "Error: Python not found (tried python3 and python)." | |
| exit 1 | |
| fi | |
| ;; | |
| node) | |
| if ! command -v node &>/dev/null; then | |
| echo "Error: Node.js not found." | |
| exit 1 | |
| fi | |
| RUNTIME=$(node --version 2>&1 | sed 's/^v//') | |
| ;; | |
| esac | |
| # === Get OS (robust for WSL, Ubuntu, Debian, etc.) === | |
| if [ -f /etc/os-release ]; then | |
| . /etc/os-release | |
| OS="${PRETTY_NAME}" | |
| elif [ -f /etc/lsb-release ]; then | |
| . /etc/lsb-release | |
| OS="${DISTRIB_DESCRIPTION}" | |
| elif [ -f /etc/redhat-release ]; then | |
| OS=$(cat /etc/redhat-release) | |
| elif [ -f /etc/debian_version ]; then | |
| OS="Debian $(cat /etc/debian_version)" | |
| else | |
| OS="$(uname -s) $(uname -r)" | |
| fi | |
| # === Optional: Detect WSL specifically (for logging/context) === | |
| if grep -qi microsoft /proc/version 2>/dev/null || [ -f /run/WSL ]; then | |
| OS="$OS (WSL)" | |
| fi | |
| # === Check modules file === | |
| if [ ! -f "$MODULESFILE" ]; then | |
| echo "Warning: '$MODULESFILE' not found in $(pwd)" | |
| fi | |
| # === Output === | |
| #echo "RUNTIME=$RUNTIME" | |
| #echo "OS=$OS" | |
| #echo "MODULESFILE=$MODULESFILE" | |
| #echo bash source: "${BASH_SOURCE[0]}" | |
| #echo script dir : "$(dirname "${BASH_SOURCE[0]}")" | |
| #APPLY="# Apply patch to {{$MODULESFILE}}" | |
| cat << EOF | |
| You are a Dependency Compatibility Auditor. | |
| **INPUT:** | |
| - Target Runtime: $RUNTIME_TYPE $RUNTIME | |
| - Target OS: $OS | |
| - Dependency File: $MODULESFILE | |
| - There could be more than one $MODULESFILE if this is mono repo. So always do glob search for $MODULESFILE | |
| **TASK:** | |
| 1. For **every library**, check its **official PyPI/npm/GitHub page, release notes, and compatibility docs**. | |
| 2. Determine if the **current version range** is compatible with the **target runtime and OS**. | |
| 3. **DO NOT suggest upgrading/downgrading the runtime** unless **no version of the library supports it**. | |
| 4. Prefer: | |
| - Pinning to a **compatible version** in the same major range. | |
| - Using ~ or ^ ranges only if safe. | |
| - Finding **drop-in alternative libraries** if incompatible. | |
| **OUTPUT FORMAT** | |
| | Library | Current Version | Target Runtime | Compatible? | Issue | Recommended Version | Alternative | | |
| |---------|------------------|----------------|-------------|-------|----------------------|-------------| | |
| {{TABLE_ROWS}} | |
| Notes: | |
| {{REASONING_BULLETS}} | |
| **RULES:** | |
| - Use **exact version pins** in patches (no ^ or ~ unless proven safe). | |
| - Search **official sources only** (npmjs.com, pypi.org, GitHub releases). | |
| - If a library is abandoned or incompatible, suggest **active alternative**. | |
| - Be conservative: **never break compatibility** to fix another. | |
| Now analyze the input and respond **exactly** in the format above. | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment