feat(script): check-deps will prompt user to install dependencies (#165)
This commit is contained in:
+19
-9
@@ -12,7 +12,8 @@ set -e
|
|||||||
main() {
|
main() {
|
||||||
script_path="$argc_script_path"
|
script_path="$argc_script_path"
|
||||||
if [[ ! -f "$script_path" ]]; then
|
if [[ ! -f "$script_path" ]]; then
|
||||||
_exit "✗ not found $script_path"
|
echo "✗ not found $script_path"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
ext="${script_path##*.}"
|
ext="${script_path##*.}"
|
||||||
if [[ "$script_path" == tools/* ]]; then
|
if [[ "$script_path" == tools/* ]]; then
|
||||||
@@ -39,7 +40,7 @@ check_sh_dependencies() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ -n "${missing_deps}" ]]; then
|
if [[ -n "${missing_deps}" ]]; then
|
||||||
_exit "✗ missing tools: ${missing_deps[*]}"
|
echo "✗ missing tools: ${missing_deps[*]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +48,14 @@ check_agent_js_dependencies() {
|
|||||||
agent_dir="$(dirname "$script_path")"
|
agent_dir="$(dirname "$script_path")"
|
||||||
if [[ -f "$agent_dir/package.json" ]]; then
|
if [[ -f "$agent_dir/package.json" ]]; then
|
||||||
npm ls --prefix="$agent_dir" --depth=0 --silent >/dev/null 2>&1 || \
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,14 +63,16 @@ check_agent_py_dependencies() {
|
|||||||
agent_dir="$(dirname "$script_path")"
|
agent_dir="$(dirname "$script_path")"
|
||||||
if [[ -f "$agent_dir/requirements.txt" ]]; then
|
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 || \
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit() {
|
|
||||||
echo "$*" >&2
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# See more details at https://github.com/sigoden/argc
|
# See more details at https://github.com/sigoden/argc
|
||||||
eval "$(argc --argc-eval "$0" "$@")"
|
eval "$(argc --argc-eval "$0" "$@")"
|
||||||
|
|||||||
Reference in New Issue
Block a user