diff --git a/.gitignore b/.gitignore index ef90f6d..a1be225 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ temp.sh # flatpak .flatpak-builder build-dir -__pycache__ \ No newline at end of file +__pycache__ +*.txt diff --git a/bin/wechat-devtools-docker b/bin/wechat-devtools-docker deleted file mode 100755 index c149e10..0000000 --- a/bin/wechat-devtools-docker +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -xhost + - -docker run \ - -t -i --rm \ - -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ - -v $HOME/.Xauthority:/root/.Xauthority \ - -e DISPLAY=unix:0.0 \ - -e GDK_SCALE \ - -e GDK_DPI_SCALE \ - --privileged \ - wechat-devtools /opt/wechat/devtools/bin/docker-entrypoint - diff --git a/bin/wechat-devtools-snap b/bin/wechat-devtools-snap new file mode 100644 index 0000000..96a7362 --- /dev/null +++ b/bin/wechat-devtools-snap @@ -0,0 +1,27 @@ +#!/bin/bash +echo "SNAP 启动" +root_dir=$(cd `dirname $0`/.. && pwd -P) +echo "root_dir: $root_dir" +ls -l "$root_dir" + +export WECHAT_DEVTOOLS_DIR="$root_dir/nwjs" +export APPDATA="$SNAP_USER_DATA/.config/wechat_devtools" +export PATH="$root_dir/wine:$root_dir/node/bin:$root_dir/nwjs:$PATH" +export USERPROFILE=$SNAP_USER_DATA + +ls -l /usr/lib/x86_64-linux-gnu +ls -l /usr/lib + +echo -e "\033[46;37m环境变量: \033[0m" +env +# LANG=zh_CN.UTF-8 exec "$DIR"/../nwjs/nw --load-extension="$DIR"/../nwjs/package.nw/js/ideplugin "$@" + +EXTENSION1="--load-extension=$SNAP/package.nw/js/ideplugin" +EXTENSION2="--load-extension=$SNAP_USER_DATA/.config/wechat_devtools/WeappPlugin" +INSPECTOR1="--custom-devtools-frontend=file://$SNAP/package.nw/js/ideplugin/inspector" # 要加file://指明为本地文件路径 +INSPECTOR2="--custom-devtools-frontend=file://$SNAP_USER_DATA/.config/wechat_devtools/WeappPlugin/inspector/" +USERDATADIR="$SNAP_USER_DATA/.config/wechat_devtools" + +# "$@"参数 +LANG=zh_CN.UTF-8 +"$SNAP/nw" $EXTENSION2 $INSPECTOR1 "$@" \ No newline at end of file diff --git a/other/multipass-change-storage.sh b/other/multipass-change-storage.sh new file mode 100644 index 0000000..bbf0a1f --- /dev/null +++ b/other/multipass-change-storage.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# 由于var目录空间大小不够,故修改multipass镜像的存储位置 +# https://github.com/canonical/multipass/pull/1789#issuecomment-704991752 +# as root +snap stop multipass +snap connect multipass:removable-media # for /mnt /media https://snapcraft.io/docs/removable-media-interface +snap connect multipass:all-home # for /home/* https://snapcraft.io/docs/home-interface +mkdir -p /mnt/disk2/multipass +mkdir /etc/systemd/system/snap.multipass.multipassd.service.d/ +tee /etc/systemd/system/snap.multipass.multipassd.service.d/override.conf <' +base: core18 # the base snap is the execution environment for this snap +version: '0.1' # just for humans, typically '1.2+git' or '1.3.2' +summary: WeChat Devtools for Linux # 79 char long summary +description: | + WeChat Devtools for Linux. + +grade: stable # must be 'stable' to release into candidate/stable channels +confinement: strict # use 'strict' once you have the right plugs and slots + +architectures: + - build-on: [amd64] + run-on: [amd64] + +# pull +# build +# stage +# prime +# snap +# /root/parts/my-part/src/nw +parts: + # compiler: + # plugin: nil + # source: https://download.fastgit.org/msojocs/wechat-devtools-linux/releases/download/v0.6/compiler.tar.xz + + node-js: + plugin: dump + source: https://npmmirror.com/mirrors/node/v16.4.2/node-v16.4.2-linux-x64.tar.gz + # source: './cache/node-v16.4.2-linux-x64.tar.gz' + organize: + "*": nodejs/ + stage: + - nodejs/* + + devtools: + plugin: dump + source: https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=1052203070&version_type=1 + # source: ./cache/wechat_devtools_1.05.2201240_x64.exe + source-type: 7z + source-subdir: ./code + build-environment: + - PATH: "$SNAPCRAFT_STAGE/nodejs/bin:$PATH" + - NW_VERSION: 0.55.0 + # - NW_PACKAGE_DIR: "$SNAPCRAFT_PART_BUILD/code/package.nw" + # - srcdir: "$SNAPCRAFT_PROJECT_DIR" + build-packages: + - python2.7 + - libxkbfile-dev + - pkg-config + - libkrb5-dev + - gcc + - g++ + - make + - openssl + - libssh2-1-dev + override-build: | + env + echo "3" + ls -l $SNAPCRAFT_STAGE + ls -l $SNAPCRAFT_PROJECT_DIR + + # 执行构建脚本 + chmod -R 755 $SNAPCRAFT_PART_BUILD/code/package.nw + npm install node-gyp nw-gyp -g --registry=https://registry.npm.taobao.org + node-gyp install --registry=https://registry.npm.taobao.org + + cp -r "${SNAPCRAFT_PROJECT_DIR}/tools" "$SNAPCRAFT_PART_BUILD/code/tools" + cp -r "${SNAPCRAFT_PROJECT_DIR}/compiler" "$SNAPCRAFT_PART_BUILD/code/compiler" + for script in fix-package-name.js fix-cli.sh fix-core.sh fix-other.sh; do + echo -e "\e[1;34mrun ${script}\e[0m" + "${SNAPCRAFT_PART_BUILD}/code/tools/${script}" + done + # 构建模块 + "${SNAPCRAFT_PART_BUILD}/code/tools/rebuild-node-modules.sh" $NW_VERSION + rm -rf "${SNAPCRAFT_PART_BUILD}/code/tools" + + snapcraftctl build + + stage-packages: + - libxkbfile1 + - git-core + override-prime: | + snapcraftctl prime + rm -rf node node.exe + cp "$SNAPCRAFT_PRIME/nodejs/bin/node" "$SNAPCRAFT_PRIME/node" + ln -s "node" "node.exe" + + after: + - node-js + # - compiler + # - desktop-gnome-platform + + nw-js: + plugin: dump + source: https://npmmirror.com/mirrors/nwjs/v0.55.0/nwjs-sdk-v0.55.0-linux-x64.tar.gz + # source: ./cache/nwjs-sdk-v0.55.0-linux-x64.tar.gz + stage-packages: + - libnss3 + - libnspr4 + + run-script: + plugin: nil + override-build: | + snapcraftctl build + cp "${SNAPCRAFT_PROJECT_DIR}/bin/wechat-devtools-snap" "$SNAPCRAFT_PART_INSTALL/wechat-devtools-snap" + stage: + - wechat-devtools-snap + + zzz: + plugin: nil + # source: https://npmmirror.com/mirrors/nwjs/v0.53.1/nwjs-sdk-v0.53.1-linux-x64.tar.gz + override-stage: | + echo "6" + env + ls -l $SNAPCRAFT_STAGE + +apps: + wechat-devtools: + # autostart: wechat-devtools.desktop + command: desktop-launch $SNAP/wechat-devtools-snap + environment: + WECHAT_DEVTOOLS_DIR: $SNAP/nwjs + APPDATA: "$SNAP_USER_DATA/wechat_devtools" + PATH: "$SNAP/node/bin:$SNAP/nwjs:$PATH" + USERPROFILE: $SNAP_USER_DATA + GIT_EXEC_PATH: $SNAP/usr/lib/git-core + + extensions: + - gnome-3-34 + plugs: + - desktop + - desktop-legacy + - opengl + - mount-observe + - x11 + - wayland + - network + - network-bind + - gsettings + - browser-support + - password-manager-service + +plugs: + gtk-3-themes: + interface: content + target: $SNAP/data-dir/themes + default-provider: gtk-common-themes + icon-themes: + interface: content + target: $SNAP/data-dir/icons + default-provider: gtk-common-themes + sound-themes: + interface: content + target: $SNAP/data-dir/sounds + default-provider: gtk-common-themes + # platform_snap: + # interface: content + # target: $SNAP/gnome-platform + # default-provider: gnome-3-34-1804 diff --git a/test/nw-gyp.sh b/test/nw-gyp.sh new file mode 100644 index 0000000..17d4003 --- /dev/null +++ b/test/nw-gyp.sh @@ -0,0 +1,9 @@ +#!/bin/bash +root_dir=$(cd `dirname $0`/.. && pwd -P) +NW_VERSION=0.53.0 +ln -s $( which python2 ) "$root_dir/tmp/python" +export PATH="$root_dir/tmp:$PATH" +export all_proxy="sock5://127.0.0.1:7890" + +cd /mnt/disk1/GitHub/wechat-devtools-linux/node_modules/node-pty +nw-gyp rebuild --arch=x64 "--target=$NW_VERSION" --dist-url=https://registry.npmmirror.com/-/binary/nwjs \ No newline at end of file diff --git a/test/snap.sh b/test/snap.sh new file mode 100644 index 0000000..827c5a5 --- /dev/null +++ b/test/snap.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +cd "/mnt/disk1/GitHub/wechat-devtools-linux" +snapcraft #--http-proxy="http://192.168.249.236:7890" --https-proxy="http://192.168.249.236:7890" +snap install wechat-devtools_0.1_amd64.snap --devmode +wechat-devtools \ No newline at end of file diff --git a/test/test-bash b/test/test-bash index 27d8450..4cf188b 100644 --- a/test/test-bash +++ b/test/test-bash @@ -21,10 +21,10 @@ exit echo "$@ $0 $1 $2" root_dir=$(cd `dirname $0`/.. && pwd -P) -export PATH="$root_dir/node/bin:$PATH" - -PY_VERSION=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'` -echo $PY_VERSION -if [ "$PY_VERSION" == "Python 3.10.1" ]; then - echo ok -fi \ No newline at end of file +cd $root_dir/tmp +export HTTPS_PROXY="http://127.0.0.1:7890" +# npm uninstall vscode-ripgrep +# npm install vscode-ripgrep +cd $root_dir/tmp/node_modules/vscode-ripgrep +rm -rf bin /tmp/vscode-ripgrep-cache-1.13.2/ripgrep-v13.0.0-4-x86_64-unknown-linux-musl.tar.gz +npm run postinstall diff --git a/tools/rebuild-node-modules.sh b/tools/rebuild-node-modules.sh index 2e3373b..f6253b0 100755 --- a/tools/rebuild-node-modules.sh +++ b/tools/rebuild-node-modules.sh @@ -27,15 +27,15 @@ hash nw-gyp 2>/dev/null || { } # 代理处理 -echo "尝试取消所有代理" -unset http_proxy -unset HTTP_PROXY -unset https_proxy -unset HTTPS_PROXY -unset socket_proxy -unset SOCKET_PROXY -unset all_proxy -unset ALL_PROXY +# echo "尝试取消所有代理" +# unset http_proxy +# unset HTTP_PROXY +# unset https_proxy +# unset HTTPS_PROXY +# unset socket_proxy +# unset SOCKET_PROXY +# unset all_proxy +# unset ALL_PROXY echo -e "\033[42;37m ######## 版本信息 $(date '+%Y-%m-%d %H:%M:%S') ########\033[0m" echo "NW VERSION: $NW_VERSION" @@ -80,10 +80,10 @@ export JOBS=$max_thread spdlog@0.11.1 \ trash \ vscode-oniguruma \ - vscode-ripgrep \ + @vscode/ripgrep \ nodegit \ - --registry=http://registry.npmmirror.com \ - --nodegit_binary_host_mirror=http://npmmirror.com/mirrors/nodegit/v0.27.0/) # reinstall modules + --registry=https://registry.npmmirror.com \ + --nodegit_binary_host_mirror=https://npmmirror.com/mirrors/nodegit/v0.27.0/ ) # reinstall modules # rebuild cd "$package_dir/node_modules_tmp/node_modules/node-pty" && nw-gyp rebuild --arch=x64 "--target=$NW_VERSION" --dist-url=https://registry.npmmirror.com/-/binary/nwjs @@ -105,14 +105,14 @@ cd "$package_dir/node_modules_tmp/node_modules/spdlog" && nw-gyp rebuild --arch= (cd "${package_dir}/node_modules_tmp/node_modules" && find -name ".deps" | xargs -I{} rm -rf {} && find -name "obj.target" | xargs -I{} rm -rf {} && find -name "*.a" -delete && find -name "*.lib" -delete && find -name "*.mk" -delete) (cd "${package_dir}/node_modules_tmp/node_modules" && find -name "*.node" | xargs -I{} \cp -rf {} ${package_dir}/node_modules/{}) -cd "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep" && \ +cd "${package_dir}/node_modules_tmp/node_modules/@vscode/ripgrep" && \ sed -i 's/api.github.com/wechat-devtools.jiyecafe.workers.dev/' lib/download.js && \ sed -i "s/ const release/ downloadOpts.headers.upstream = 'api.github.com';const release/" lib/download.js && \ sed -i "s/ return download/ opts.headers.upstream = 'objects.githubusercontent.com';return download/" lib/download.js && \ sed -i 's/response.headers.location,/response.headers.location.replace("objects.githubusercontent.com", "wechat-devtools.jiyecafe.workers.dev"),/' lib/download.js && \ npm run postinstall mkdir -p "${package_dir}/node_modules/vscode-ripgrep/bin" -\cp -fr "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep/bin/rg" "${package_dir}/node_modules/vscode-ripgrep/bin/rg" +\cp -fr "${package_dir}/node_modules_tmp/node_modules/@vscode/ripgrep/bin/rg" "${package_dir}/node_modules/vscode-ripgrep/bin/rg" (cd "${package_dir}/node_modules" && find -name ".deps" | xargs -I{} rm -rf {} && find -name "obj.target" | xargs -I{} rm -rf {} && find -name "*.a" -delete && find -name "*.lib" -delete && find -name "*.mk" -delete && find -name "*Makefile" -delete && find -name "*gyp*" -delete) rm -rf "${package_dir}/node_modules_tmp"