Skip to content

Commit

Permalink
update: 结构优化
Browse files Browse the repository at this point in the history
  • Loading branch information
msojocs committed Feb 2, 2022
1 parent 3e9c34b commit 0ab1166
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
mkdir ${{ env. name }}
find -maxdepth 1 -not -name ${{ env.name }} -not -name . -exec mv {} ${{ env.name }} \;
ls -l
cp -r "${{ env.name }}/package.nw/node_modules/nodegit" nodegit
env:
name: 'release-${{ github.ref_name }}'

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ arch/
nwjs/
node/
package.nw
package.nw copy
cache/
tmp/
mew/
Expand Down
7 changes: 0 additions & 7 deletions compact/build

This file was deleted.

4 changes: 2 additions & 2 deletions docker/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ node-gyp list
# end test

cd /workspace
# rm -rf package.nw
# node nwjs
# rm -rf node nwjs package.nw
#
# exec ./tools/rebuild-node-modules 0.53.1
exec ./tools/setup-wechat-devtools-bash
File renamed without changes.
0 wine/wcc → old/wine/wcc
100755 → 100644
File renamed without changes.
0 wine/wcsc → old/wine/wcsc
100755 → 100644
File renamed without changes.
6 changes: 6 additions & 0 deletions test/test-bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

root_dir=$(cd `dirname $0`/.. && pwd -P)
export PATH="$root_dir/node/bin:$PATH"
export http_proxy="http://127.0.0.1:54321"


if [[ ! -z $https_proxy || ! -z $http_proxy ]]; then
echo -e "\033[41;37m 警告: 你设置了代理,有可能导致安装出现异常 \033[0m"
fi

PY_VERSION=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
echo $PY_VERSION
Expand Down
6 changes: 6 additions & 0 deletions test/wine-wcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

root_dir=$(cd `dirname $0`/.. && pwd -P)
export PATH="$root_dir/cache/wechat_devtools_1.05.2201240_x64:$PATH"
execute="$root_dir/cache/wechat_devtools_1.05.2201240_x64/node.exe"
wine $execute -e "require('wcc')"
31 changes: 21 additions & 10 deletions tools/rebuild-node-modules
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,33 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
NW_VERSION=$1
package_dir="$DIR/../package.nw"

export PATH="$DIR/../node/bin:$PATH"
PY_VERSION=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
if [ $PY_VERSION != 2 ]; then
hash python2 2>/dev/null || { echo >&2 "I require python2 but it's not installed. Aborting."; exit 1; }
ln -s "$( which python2 )" "$DIR/../node/bin/python"
fi

hash nw-gyp 2>/dev/null || {
echo "=======请安装nw-gyp======="
exit 1
}
if [ -z $NW_VERSION ]; then
echo "NW 版本未指定!"
exit 1
fi

echo -e "\033[42;37m ######## 版本信息 $(date '+%Y-%m-%d %H:%M:%S') ########\033[0m"
echo "目录: $DIR"
echo "NW VERSION: $NW_VERSION"
echo "nw-gyp version: $( nw-gyp --version )"
echo "node version: $(node --version )"
echo "npm version: $(npm --version )"

export PATH="$DIR/../node/bin:$PATH"
PY_VERSION=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
if [ $PY_VERSION != 2 ]; then
hash python2 2>/dev/null || { echo >&2 "I require python2 but it's not installed. Aborting."; exit 1; }
ln -s "$( which python2 )" "$DIR/../node/bin/python"
if [[ ! -z $https_proxy || ! -z $http_proxy ]]; then
echo -e "\033[41;37m 警告: 你设置了代理,这有可能导致安装出现异常 \033[0m"
fi

hash nw-gyp 2>/dev/null || {
echo "=======请安装nw-gyp======="
exit 1
}

rm -fr "${package_dir}/node_modules/vscode-windows-ca-certs" # the module is only available in windows
rm -fr "${package_dir}/node_modules/vscode-windows-registry" # the module is only available in windows
rm -fr "${package_dir}/node_modules/vscode-windows-registry-node" # the module is only available in windows
Expand Down Expand Up @@ -69,6 +73,7 @@ rm -fr "${package_dir}/node_modules_tmp/node_modules/spdlog-node"
trash \
vscode-oniguruma \
vscode-ripgrep \
miniprogram-compiler \
nodegit \
--registry=https://registry.npm.taobao.org \
--nodegit_binary_host_mirror=https://npm.taobao.org/mirrors/nodegit/v0.27.0/) # reinstall modules
Expand All @@ -83,6 +88,7 @@ cp -fr "${package_dir}/node_modules_tmp/node_modules/node-pty" "${package_dir}/n
cd "$package_dir/node_modules_tmp/node_modules/native-watchdog" && nw-gyp rebuild --arch=x64 "--target=$NW_VERSION"
rm -rf "${package_dir}/node_modules/native-watchdog" && cp -fr "${package_dir}/node_modules_tmp/node_modules/native-watchdog" "${package_dir}/node_modules"

cd "${package_dir}/node_modules_tmp/node_modules/nodegit" && rm -rf .github include src lifecycleScripts vendor utils build/vendor build/Release/.deps
cp -fr "${package_dir}/node_modules_tmp/node_modules/nodegit" "${package_dir}/node_modules"

(cp -fr "${package_dir}/node_modules_tmp/node_modules/oniguruma" "${package_dir}/node_modules_tmp/node_modules/oniguruma-node")
Expand All @@ -94,6 +100,11 @@ cp -fr "${package_dir}/node_modules_tmp/node_modules/nodegit" "${package_dir}/no
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"

# wcc wcsc
cd "${package_dir}/js/vendor/" && rm -rf "wcc.exe" "wcsc.exe"
cp "${package_dir}/node_modules_tmp/node_modules/miniprogram-compiler/bin/linux/wcc" "${package_dir}/js/vendor/wcc.exe"
cp "${package_dir}/node_modules_tmp/node_modules/miniprogram-compiler/bin/linux/wcsc" "${package_dir}/js/vendor/wcsc.exe"

rm -rf "${package_dir}/node_modules_tmp"

# 移除旧配置
Expand Down
34 changes: 17 additions & 17 deletions tools/update-wechat-devtools-node
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,22 @@ const patch_wechat_devtools = function () {
});
});
};
const patch_wcc_wcsc = function () {
info("Patching wcc and wcsc");

return new Promise((resolve, reject) => {
fs.copyFileSync(
path.resolve(__dirname, "../compiler/wcc"),
path.resolve(__dirname, "../package.nw/js/vendor/wcc.exe")
);
fs.copyFileSync(
path.resolve(__dirname, "../compiler/wcsc"),
path.resolve(__dirname, "../package.nw/js/vendor/wcsc.exe")
);

resolve();
});
};
// const patch_wcc_wcsc = function () {
// info("Patching wcc and wcsc");

// return new Promise((resolve, reject) => {
// fs.copyFileSync(
// path.resolve(__dirname, "../compiler/wcc"),
// path.resolve(__dirname, "../package.nw/js/vendor/wcc.exe")
// );
// fs.copyFileSync(
// path.resolve(__dirname, "../compiler/wcsc"),
// path.resolve(__dirname, "../package.nw/js/vendor/wcsc.exe")
// );

// resolve();
// });
// };

const start = async () => {
try {
Expand All @@ -296,7 +296,7 @@ const start = async () => {
await patch_wechat_devtools_CLI();
await rebuild_wechat_devtools_node_modules();
await patch_wechat_devtools();
await patch_wcc_wcsc();
// await patch_wcc_wcsc();
console.log(
`Succeeded upgrading wechat-devtools to version ${version}`
);
Expand Down

0 comments on commit 0ab1166

Please sign in to comment.