🌱Improve dependencies
thx to Andywoo
This commit is contained in:
parent
125faca2c2
commit
379606c24d
@ -110,15 +110,71 @@ ql repo https://github.com/Wenmoux/scripts.git "chinnkarahoi_jd_bookshop" "" ""
|
||||
|
||||
|
||||
# 依赖
|
||||
install_dependencies(){
|
||||
## Python 3 安装 requests
|
||||
pip3 install requests
|
||||
## 安装 canvas,适用于柠檬胖虎代维护 lxk0301 仓库,宠汪汪二代目和宠汪汪兑换,只支持国内机
|
||||
apk add --no-cache build-base g++ cairo-dev pango-dev giflib-dev && cd scripts && npm install canvas --build-from-source
|
||||
## 安装 png-js,适用于 JDHelloWorld 和 he1pu 的宠汪汪二代目和宠汪汪兑奖品二代目
|
||||
npm install png-js -S
|
||||
## 安装 date-fns axios crypto-js ts-md5 tslib @types/node ,用于解决新版惊喜财富岛依赖问题
|
||||
npm i -S date-fns axios crypto-js ts-md5 tslib @types/node dotenv
|
||||
package_name="canvas png-js date-fns axios crypto-js ts-md5 tslib @types/node dotenv"
|
||||
|
||||
install_dependencies_normal(){
|
||||
for i in $@; do
|
||||
case $i in
|
||||
canvas)
|
||||
if [[ "$(npm ls $i)" =~ (empty) ]]; then
|
||||
apk add --no-cache build-base g++ cairo-dev pango-dev giflib-dev && npm install $i --build-from-source
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ "$(npm ls $i -g)" =~ (empty) ]]; then
|
||||
if [[ "$(npm ls $i)" =~ $i ]]; then
|
||||
npm uninstall $i
|
||||
fi
|
||||
npm i $i -g
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
install_dependencies &
|
||||
install_dependencies_force(){
|
||||
for i in $@; do
|
||||
if [[ "$(npm ls $i)" =~ $i ]]; then
|
||||
npm uninstall $i
|
||||
rm -rf /ql/scripts/node_modules/$i
|
||||
rm -rf /ql/scripts/node_modules/lodash
|
||||
elif [[ "$(npm ls $i -g)" =~ $i ]]; then
|
||||
npm uninstall -g $i
|
||||
rm -rf /usr/local/lib/node_modules/$i
|
||||
rm -rf /usr/local/lib/node_modules/lodash
|
||||
fi
|
||||
case $i in
|
||||
canvas)
|
||||
if [[ "$(npm ls $i)" =~ (empty) ]]; then
|
||||
apk add --no-cache build-base g++ cairo-dev pango-dev giflib-dev && npm install $i --build-from-source
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ "$(npm ls $i -g)" =~ (empty) ]]; then
|
||||
if [[ "$(npm ls $i)" =~ $i ]]; then
|
||||
npm uninstall $i
|
||||
fi
|
||||
npm i $i -g
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
install_dependencies_all(){
|
||||
install_dependencies_normal $package_name
|
||||
for i in $package_name; do
|
||||
if [[ "$(npm ls $i -g)" =~ (empty) ]] && [[ "$(npm ls $i)" =~ (empty) ]]; then
|
||||
install_dependencies_force $i
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
install_dependencies_all &
|
||||
|
||||
:<<!EOF!
|
||||
1、解决 JDHelloWorld 的 ts 脚本依赖问题;
|
||||
2、解决宠汪汪的依赖问题;
|
||||
3、解决京东图形验证签到的依赖问题;
|
||||
4、检测依赖包的安装状态判断是否安装依赖。安全可靠,也避免重复安装依赖导致报错。
|
||||
!EOF!
|
||||
|
||||
Loading…
Reference in New Issue
Block a user