diff options
| author | sigoden <sigoden@gmail.com> | 2025-02-13 09:24:55 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-13 09:24:55 +0800 |
| commit | f5c3071fbc41a93799629745f501b101dc0c9861 (patch) | |
| tree | afea9ee0cd0847720ade36000951518ef65e2968 | |
| parent | 42c827e556e9200662728193c85d2ba261c5332f (diff) | |
| download | llm-functions-docker-f5c3071fbc41a93799629745f501b101dc0c9861.tar.gz | |
feat(script): check-deps will prompt user to install dependencies (#165)
| -rwxr-xr-x | scripts/check-deps.sh | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/scripts/check-deps.sh b/scripts/check-deps.sh index 8d44988..d4c102b 100755 --- a/scripts/check-deps.sh +++ b/scripts/check-deps.sh @@ -12,7 +12,8 @@ set -e main() { script_path="$argc_script_path" if [[ ! -f "$script_path" ]]; then - _exit "✗ not found $script_path" + echo "✗ not found $script_path" + exit 0 fi ext="${script_path##*.}" if [[ "$script_path" == tools/* ]]; then @@ -39,7 +40,7 @@ check_sh_dependencies() { fi done if [[ -n "${missing_deps}" ]]; then - _exit "✗ missing tools: ${missing_deps[*]}" + echo "✗ missing tools: ${missing_deps[*]}" fi } @@ -47,7 +48,14 @@ check_agent_js_dependencies() { agent_dir="$(dirname "$script_path")" if [[ -f "$agent_dir/package.json" ]]; then npm ls --prefix="$agent_dir" --depth=0 --silent >/dev/null 2>&1 || \ - _exit "✗ missing node modules, FIX: cd $agent_dir && npm install" + { + cmd="cd $agent_dir && npm install" + echo "✗ missing node modules" + read -p "? run \`$cmd\` to fix [Y/n] " choice + if [[ "$choice" == "Y" || "$choice" == "y" || -z "$choice" ]]; then + (eval "$cmd") + fi + } fi } @@ -55,14 +63,16 @@ check_agent_py_dependencies() { agent_dir="$(dirname "$script_path")" if [[ -f "$agent_dir/requirements.txt" ]]; then python <(cat "$agent_dir/requirements.txt" | sed -E -n 's/^([A-Za-z_]+).*/import \1/p') >/dev/null 2>&1 || \ - _exit "✗ missing python modules, FIX: cd $agent_dir && pip install -r requirements.txt" + { + cmd="cd $agent_dir && pip install -r requirements.txt" + echo "✗ missing python modules" + read -p "? run \`$cmd\` to fix [Y/n] " choice + if [[ "$choice" == "Y" || "$choice" == "y" || -z "$choice" ]]; then + (eval "$cmd") + fi + } fi } -_exit() { - echo "$*" >&2 - exit 0 -} - # See more details at https://github.com/sigoden/argc eval "$(argc --argc-eval "$0" "$@")" |
