perf: npm缓存处理

This commit is contained in:
msojocs 2023-01-21 10:45:19 +08:00
parent 78170a663e
commit 1d169d995a
3 changed files with 18 additions and 6 deletions

View File

@ -7,12 +7,10 @@ const { execSync } = require("child_process");
console.info("Patching editor selection copy configs"); console.info("Patching editor selection copy configs");
let configPath = os.homedir() + "/.config/wechat_devtools/Default/Editor/User/settings.json"; let configPath = os.homedir() + "/.config/wechat_devtools/Default/Editor/User/settings.json";
let config = undefined; let config = {};
if (fs.existsSync(configPath)) { if (fs.existsSync(configPath)) {
// console.info(configPath) // console.info(configPath)
config = JSON.parse(fs.readFileSync(configPath, "utf8")); config = JSON.parse(fs.readFileSync(configPath, "utf8"));
} else {
config = {};
} }
config["editor.selectionClipboard"] = false; config["editor.selectionClipboard"] = false;

View File

@ -52,8 +52,18 @@ mkdir -p tmp && cd tmp
# notice "非ACTION模式, 设置镜像源" # notice "非ACTION模式, 设置镜像源"
# export https_proxy="http://127.0.0.1:7890" # export https_proxy="http://127.0.0.1:7890"
# fi # fi
wget https://github.com/microsoft/ripgrep-prebuilt/releases/download/v12.1.1-1/ripgrep-v12.1.1-1-x86_64-unknown-linux-musl.tar.gz -O ripgrep-v12.1.1-1-x86_64-unknown-linux-musl.tar.gz
tar xvf ripgrep-v12.1.1-1-x86_64-unknown-linux-musl.tar.gz -C ../bin && \ # ripgrep版本
ripgrep_version="12.1.1-1"
# ripgrep路径
ripgrep_path="$root_dir/cache/ripgrep-v${ripgrep_version}-x86_64-unknown-linux-musl.tar.gz"
# 文件不存在,下载
if [ ! -f "$ripgrep_path" ];then
wget https://github.com/microsoft/ripgrep-prebuilt/releases/download/v12.1.1-1/ripgrep-v12.1.1-1-x86_64-unknown-linux-musl.tar.gz \
-O "${ripgrep_path}.tmp"
mv "${ripgrep_path}.tmp" "${ripgrep_path}"
fi
tar xvf "$ripgrep_path" -C ../bin && \
cd .. && rm -rf tmp cd .. && rm -rf tmp
(cd "${package_dir}/node_modules" && \ (cd "${package_dir}/node_modules" && \
@ -112,6 +122,7 @@ find -name "*.a" -delete && \
find -name "*.lib" -delete && \ find -name "*.lib" -delete && \
find -name "*.mk" -delete) find -name "*.mk" -delete)
# TODO: 检查路径包含空格时,是否正常
notice "copy node files" notice "copy node files"
(cd "${package_dir}/node_modules_tmp/node_modules" && \ (cd "${package_dir}/node_modules_tmp/node_modules" && \
find -name "*.node" | xargs -I{} \cp -rf {} ${package_dir}/node_modules/{}) find -name "*.node" | xargs -I{} \cp -rf {} ${package_dir}/node_modules/{})

View File

@ -52,11 +52,13 @@ if [ $CURRENT_STEP == $INSTALL_START ];then
fi fi
# 将node加入环境 # 将node加入环境
export PATH="$root_dir/node/bin":$PATH export PATH="$root_dir/cache/npm/node_global/bin:$root_dir/node/bin:$PATH"
node --version node --version
npm --version npm --version
if [ $CURRENT_STEP == $INSTALL_NODE_SUCCESS ];then if [ $CURRENT_STEP == $INSTALL_NODE_SUCCESS ];then
npm config set prefix "$root_dir/cache/npm/node_global"
npm config set cache "$root_dir/cache/npm/node_cache"
if [ "$ACTION_MODE" != "true" ]; then if [ "$ACTION_MODE" != "true" ]; then
notice "非ACTION模式, 设置镜像源" notice "非ACTION模式, 设置镜像源"
npm config set registry http://registry.npmmirror.com/ # 注册模块镜像 npm config set registry http://registry.npmmirror.com/ # 注册模块镜像
@ -79,6 +81,7 @@ if [ $CURRENT_STEP == $INSTALL_NPM_CONFIG_SUCCESS ];then
notice "=====安装node-gyp nw-gyp====" notice "=====安装node-gyp nw-gyp===="
npm uninstall node-gyp -g npm uninstall node-gyp -g
npm install node-gyp nw-gyp -g npm install node-gyp nw-gyp -g
echo $PATH
node-gyp install node-gyp install
node-gyp list node-gyp list
step_switch $INSTALL_GYP_SUCCESS step_switch $INSTALL_GYP_SUCCESS