elecV2 / elecV2P

一款基于 NodeJS,可通过 JS 修改网络请求,以及定时运行脚本或 SHELL 指令的网络工具。

Home Page:https://elecv2p.onrender.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

依赖管理功能

opened this issue · comments

大佬有没有考虑做个依赖管理功能,虽然我现在通过定时任务实现了

就是每次有新的要改有一丢麻烦 hhh

@elecV2 npm 真的深坑,前几天一直在测试,全局的打架严重,报错也是五花八门

install_js_pkgs_initial() {
    if [ -d "/ql/scripts/Oreomeow_checkinpanel_master" ]; then
        cd /ql/scripts/Oreomeow_checkinpanel_master &&
            cp /ql/repo/Oreomeow_checkinpanel_master/package.json /ql/scripts/Oreomeow_checkinpanel_master/package.json
    elif [[ -d "/ql/scripts" && ! -f "/ql/scripts/package.bak.json" ]]; then
        cd /ql/scripts || exit
        rm -rf node_modules
        rm -rf .pnpm-store
        mv package-lock.json package-lock.bak.json
        mv package.json package.bak.json
        mv pnpm-lock.yaml pnpm-lock.bak.yaml
        install 1 "npm install -g package-merge" "$(echo "$(npm install -g package-merge && npm ls -g package-merge)" | grep -cE '(empty)|ERR')" &&
            export NODE_PATH="/usr/local/lib/node_modules" &&
            node -e \
                "const merge = require('package-merge');
                 const fs = require('fs');
                 const dst = fs.readFileSync('/ql/repo/Oreomeow_checkinpanel_master/package.json');
                 const src = fs.readFileSync('/ql/scripts/package.bak.json');
                 fs.writeFile('/ql/scripts/package.json', merge(dst, src), function (err) {
                     if (err) {
                         console.log(err);
                     }
                     console.log('package.json merged successfully!');
                 });"
    fi
    npm install
}
install_js_pkgs_each() {
    npm_ls="$(npm ls "$1")"
    has_err=$(echo "$npm_ls" | grep ERR)
    if [[ $npm_ls =~ $1 && $has_err == "" ]]; then
        echo "$1 已正确安装"
    elif [[ $npm_ls =~ $1 && $has_err != "" ]]; then
        uninstall_js_pkgs "$1"
    elif [[ $npm_ls =~ (empty) ]]; then
        install 1 "npm install $1" "$(echo "$(npm install --force "$1" && npm ls --force "$1")" | grep -cE '(empty)|ERR')"
    fi
}
uninstall_js_pkgs() {
    npm uninstall "$1"
    rm -rf "$(pwd)"/node_modules/"$1"
    rm -rf /usr/local/lib/node_modules/lodash/*
    npm cache clear --force
}
install_js_pkgs_all() {
    install_js_pkgs_initial
    for i in $js_pkgs; do
        install_js_pkgs_each "$i"
    done
    npm ls --depth 0
}

npm 安装的函数属实令人痛苦

commented

addons的坑更大.(劝退

commented

真心坑大啊,我感觉还不如直接开个shell接口用户自己操作

commented

😂不出意外的话我应该会整个shell页出来

@Teeoo 造轮子的事情就交给你们了

现在不是有个 minishell 吗?但估计没什么人用。 主要还是装依赖/设置默认环境这些太麻烦了,自己操作起来有时候都头疼。 反正先把这些坑给挖好了,至于什么时候填,再说😄

在用!!!自动安装失败就手动了

但是 v2p 比青龙好的一点是文件夹独立,相对来说打架不容易hhh

commented

我都是直接进容器install的,青龙不是有个依赖管理了么

@Teeoo 青龙的依赖管理是全局的,有 bug hhh

我测试了青龙和 v2p,v2p 不报错的情况下青龙报错,而且不是找不到模块,是 JSON5.parse 不是一个函数

commented

看到过还没用过不大清楚

就顺便提一下先关了,看青龙新增了所以来问问 hhh

青龙我都是拉package.json,然后手动安装对应脚本文件夹。目前没啥问题