mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
feat: step
This commit is contained in:
parent
0447f18b42
commit
78170a663e
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e # 命令出错就退出
|
set -e # 命令出错就退出
|
||||||
trap 'catchError $LINENO $BASH_COMMAND' SIGHUP SIGINT SIGQUIT EXIT # 捕获错误情况
|
trap 'catchError $LINENO $BASH_COMMAND' ERR # 捕获错误情况
|
||||||
|
|
||||||
catchError() {
|
catchError() {
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
@ -24,7 +24,6 @@ python --version
|
|||||||
echo "docker node version: $( node --version )"
|
echo "docker node version: $( node --version )"
|
||||||
|
|
||||||
cd /workspace
|
cd /workspace
|
||||||
rm -rf node nwjs package.nw
|
|
||||||
#
|
#
|
||||||
# exec ./tools/rebuild-node-modules 0.53.1
|
# exec ./tools/rebuild-node-modules 0.53.1
|
||||||
./tools/setup-wechat-devtools-bash
|
./tools/setup-wechat-devtools-bash
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
set -e
|
# set -e
|
||||||
trap 'catchError $LINENO "$BASH_COMMAND"' ERR # 捕获错误情况
|
# trap 'catchError $LINENO "$BASH_COMMAND"' ERR # 捕获错误情况
|
||||||
catchError() {
|
# catchError() {
|
||||||
exit_code=$?
|
# exit_code=$?
|
||||||
if [ $exit_code -ne 0 ]; then
|
# if [ $exit_code -ne 0 ]; then
|
||||||
fail "\033[31mcommand: $2\n at $0:$1\n at $STEP\033[0m"
|
# fail "\033[31mcommand: $2\n at $0:$1\n at $STEP\033[0m"
|
||||||
fi
|
# fi
|
||||||
exit $exit_code
|
# exit $exit_code
|
||||||
}
|
# }
|
||||||
|
|
||||||
notice() {
|
notice() {
|
||||||
echo -e "\033[36m $1 \033[0m "
|
echo -e "\033[36m $1 \033[0m "
|
||||||
}
|
}
|
||||||
|
warn() {
|
||||||
|
echo -e "\033[43;37m 警告 \033[0m $1"
|
||||||
|
}
|
||||||
fail() {
|
fail() {
|
||||||
echo -e "\033[41;37m 失败 \033[0m $1"
|
echo -e "\033[41;37m 失败 \033[0m $1"
|
||||||
}
|
}
|
||||||
@ -41,6 +44,8 @@ if [[ ! -z $open_find_result ]];then
|
|||||||
# replace
|
# replace
|
||||||
new_cb_handle="this.props.onWindowOpenFail());Object.keys(window).forEach(key=>{if(!e.window[key]){try{e.window[key]=window[key];}catch(e){console.error(e);}}});"
|
new_cb_handle="this.props.onWindowOpenFail());Object.keys(window).forEach(key=>{if(!e.window[key]){try{e.window[key]=window[key];}catch(e){console.error(e);}}});"
|
||||||
sed -i "s/this.props.onWindowOpenFail());/$new_cb_handle/g" $open_find_result
|
sed -i "s/this.props.onWindowOpenFail());/$new_cb_handle/g" $open_find_result
|
||||||
|
else
|
||||||
|
warn "云开发控制台启动点未找到"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
token_find_result=$( grep -lr "constructor(){this._sessionToken=\"\",this._tokenMap={}}" "$tmp_dir/core.wxvpkg" )
|
token_find_result=$( grep -lr "constructor(){this._sessionToken=\"\",this._tokenMap={}}" "$tmp_dir/core.wxvpkg" )
|
||||||
@ -48,6 +53,8 @@ echo "WebSocket token存储对象位置: $token_find_result"
|
|||||||
if [[ ! -z $token_find_result ]];then
|
if [[ ! -z $token_find_result ]];then
|
||||||
new_constructor="constructor(){if(window.tokenData){/*有就直接用*/this._sessionToken=window.tokenData._sessionToken;this._tokenMap=window.tokenData._tokenMap;}else{/*没有就新建*/this._sessionToken=\"\",this._tokenMap={};window.tokenData=this;/*新建完要给中间人*/}}"
|
new_constructor="constructor(){if(window.tokenData){/*有就直接用*/this._sessionToken=window.tokenData._sessionToken;this._tokenMap=window.tokenData._tokenMap;}else{/*没有就新建*/this._sessionToken=\"\",this._tokenMap={};window.tokenData=this;/*新建完要给中间人*/}}"
|
||||||
sed -i "s#constructor(){this._sessionToken=\"\",this._tokenMap={}}#$new_constructor#g" "$token_find_result"
|
sed -i "s#constructor(){this._sessionToken=\"\",this._tokenMap={}}#$new_constructor#g" "$token_find_result"
|
||||||
|
else
|
||||||
|
warn "WebSocket token存储对象位置未找到"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# open -a Terminal "`pwd`" --> gnome-terminal
|
# open -a Terminal "`pwd`" --> gnome-terminal
|
||||||
@ -57,6 +64,8 @@ echo "Terminal启动位置: $find_result"
|
|||||||
if [[ ! -z $find_result ]];then
|
if [[ ! -z $find_result ]];then
|
||||||
new_str="gnome-terminal"
|
new_str="gnome-terminal"
|
||||||
sed -i "s#open -a Terminal \"\`pwd\`\"#$new_str#g" "$find_result"
|
sed -i "s#open -a Terminal \"\`pwd\`\"#$new_str#g" "$find_result"
|
||||||
|
else
|
||||||
|
warn "Terminal启动位置未找到"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# wcc、wcsc处理,设置WINE=fasle环境变量生效
|
# wcc、wcsc处理,设置WINE=fasle环境变量生效
|
||||||
@ -80,6 +89,8 @@ if [[ "$WINE" != 'true' ]];then
|
|||||||
sed -i "s#wcc\\.exe#wcc#g" "$find_result"
|
sed -i "s#wcc\\.exe#wcc#g" "$find_result"
|
||||||
sed -i "s#wcsc\\.exe#wcsc#g" "$find_result"
|
sed -i "s#wcsc\\.exe#wcsc#g" "$find_result"
|
||||||
sed -i "s#code/package.nw#package.nw#g" "$find_result"
|
sed -i "s#code/package.nw#package.nw#g" "$find_result"
|
||||||
|
else
|
||||||
|
warn "wcc位置未找到"
|
||||||
fi
|
fi
|
||||||
# 处理报错时控制台显示的环境
|
# 处理报错时控制台显示的环境
|
||||||
find_result=$( grep -lr '(env:' "$tmp_dir/core.wxvpkg" )
|
find_result=$( grep -lr '(env:' "$tmp_dir/core.wxvpkg" )
|
||||||
@ -88,6 +99,8 @@ if [[ "$WINE" != 'true' ]];then
|
|||||||
for file in $find_result; do
|
for file in $find_result; do
|
||||||
sed -i 's#"Windows"#"Linux"#g' "$file"
|
sed -i 's#"Windows"#"Linux"#g' "$file"
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
warn "Windows字符串位置未找到"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
current=`date "+%Y-%m-%d %H:%M:%S"`
|
current=`date "+%Y-%m-%d %H:%M:%S"`
|
||||||
@ -108,6 +121,8 @@ if [[ -n $find_result ]];then
|
|||||||
sed -i 's/mediaQuery.matches/isDark/' $find_result
|
sed -i 's/mediaQuery.matches/isDark/' $find_result
|
||||||
# add functions
|
# add functions
|
||||||
sed -i 's#}getDefaultTheme#}get isDark(){try{const{DESKTOP_SESSION}=process.env;console.log(DESKTOP_SESSION);let theme="";switch(DESKTOP_SESSION){case"deepin":theme=execSync(`gsettings get com.deepin.dde.appearance gtk-theme`);break;case"gnome":case"gnome-classic":theme=execSync(`gsettings get org.gnome.desktop.interface ${this.gnomeScheme}`);break;default:break}return theme.includes("dark");}catch(err){console.error("尝试获取主题信息失败,使用默认暗色",err);return true;}}get gnomeScheme(){try{const gnomeVersion=execSync(`gnome-shell --version`).toString().replace(/[\\r\\n]/g,"").split(" ");const gnomeVersionNum=gnomeVersion.length==3?Number(gnomeVersion[2]):0;return gnomeVersionNum>=42?"color-scheme":"gtk-theme";}catch(err){console.error("检查gnome版本失败, 使用gtk-theme", err);return "gtk-theme";}}monitorTheme(){try{let monitor=null;const{DESKTOP_SESSION}=process.env;switch(DESKTOP_SESSION){case"deepin":monitor=spawn("gsettings",["monitor","com.deepin.dde.appearance","gtk-theme",]);break;case"gnome":case"gnome-classic":monitor=spawn("gsettings",["monitor","org.gnome.desktop.interface",this.gnomeScheme,]);break;default:console.warn(`NOT SUPPORTED!!!DESKTOP_SESSION:${DESKTOP_SESSION}`);break}monitor\&\&monitor.on("error",(err)=>{console.error("monitorTheme",err)});monitor\&\&monitor.stdout.on("data",e.debounce((chunk)=>{const data=chunk.toString();const t=data.toLowerCase().includes("dark");(this._theme=t?i.Dark:i.Light),this._onDidThemeChange.fire(this._theme)},400));process.on("SIGTERM",(signal)=>{monitor.kill(signal);});}catch(err){console.error("尝试监听主题失败!", err);}}getDefaultTheme#' $find_result
|
sed -i 's#}getDefaultTheme#}get isDark(){try{const{DESKTOP_SESSION}=process.env;console.log(DESKTOP_SESSION);let theme="";switch(DESKTOP_SESSION){case"deepin":theme=execSync(`gsettings get com.deepin.dde.appearance gtk-theme`);break;case"gnome":case"gnome-classic":theme=execSync(`gsettings get org.gnome.desktop.interface ${this.gnomeScheme}`);break;default:break}return theme.includes("dark");}catch(err){console.error("尝试获取主题信息失败,使用默认暗色",err);return true;}}get gnomeScheme(){try{const gnomeVersion=execSync(`gnome-shell --version`).toString().replace(/[\\r\\n]/g,"").split(" ");const gnomeVersionNum=gnomeVersion.length==3?Number(gnomeVersion[2]):0;return gnomeVersionNum>=42?"color-scheme":"gtk-theme";}catch(err){console.error("检查gnome版本失败, 使用gtk-theme", err);return "gtk-theme";}}monitorTheme(){try{let monitor=null;const{DESKTOP_SESSION}=process.env;switch(DESKTOP_SESSION){case"deepin":monitor=spawn("gsettings",["monitor","com.deepin.dde.appearance","gtk-theme",]);break;case"gnome":case"gnome-classic":monitor=spawn("gsettings",["monitor","org.gnome.desktop.interface",this.gnomeScheme,]);break;default:console.warn(`NOT SUPPORTED!!!DESKTOP_SESSION:${DESKTOP_SESSION}`);break}monitor\&\&monitor.on("error",(err)=>{console.error("monitorTheme",err)});monitor\&\&monitor.stdout.on("data",e.debounce((chunk)=>{const data=chunk.toString();const t=data.toLowerCase().includes("dark");(this._theme=t?i.Dark:i.Light),this._onDidThemeChange.fire(this._theme)},400));process.on("SIGTERM",(signal)=>{monitor.kill(signal);});}catch(err){console.error("尝试监听主题失败!", err);}}getDefaultTheme#' $find_result
|
||||||
|
else
|
||||||
|
warn "theme位置未找到"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# fix update check
|
# fix update check
|
||||||
@ -118,6 +133,6 @@ grep -lr "t=>{R(\"new_version_hint" "$find_result"
|
|||||||
sed -i 's#t=>{R("new_version_hint#t=>{const keys = ["shareData", "windowMap", "isSimple","masterProxyPort", "proxyPort", "masterH2ProxyPort", "h2ProxyPort"];for(let k of keys)t.window.global[k] = global[k];R("new_version_hint#' $find_result
|
sed -i 's#t=>{R("new_version_hint#t=>{const keys = ["shareData", "windowMap", "isSimple","masterProxyPort", "proxyPort", "masterH2ProxyPort", "h2ProxyPort"];for(let k of keys)t.window.global[k] = global[k];R("new_version_hint#' $find_result
|
||||||
|
|
||||||
# pack 路径 到 文件
|
# pack 路径 到 文件
|
||||||
echo "pack"
|
notice "pack"
|
||||||
node "$pack_script" "$tmp_dir/core.wxvpkg" "$package_dir/core.wxvpkg"
|
node "$pack_script" "$tmp_dir/core.wxvpkg" "$package_dir/core.wxvpkg"
|
||||||
rm -rf "$tmp_dir/core.wxvpkg"
|
rm -rf "$tmp_dir/core.wxvpkg"
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
warn() {
|
||||||
|
echo -e "\033[43;37m 警告 \033[0m $1"
|
||||||
|
}
|
||||||
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
NW_PACKAGE_DIR="$root_dir/package.nw"
|
NW_PACKAGE_DIR="$root_dir/package.nw"
|
||||||
|
|
||||||
@ -15,8 +18,8 @@ if [ ! -f "$target_file" ]; then
|
|||||||
fi
|
fi
|
||||||
# 判断匹配函数,匹配函数不为0,则包含给定字符
|
# 判断匹配函数,匹配函数不为0,则包含给定字符
|
||||||
if [ `grep -c "patch wechat devtools begin" $target_file` -ne '0' ];then
|
if [ `grep -c "patch wechat devtools begin" $target_file` -ne '0' ];then
|
||||||
echo -e "\e[1;31m$target_file seems to have been modified\e[0m" >&2
|
warn "$target_file seems to have been modified"
|
||||||
exit 1
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmp_file=$(mktemp)
|
tmp_file=$(mktemp)
|
||||||
|
@ -6,6 +6,12 @@
|
|||||||
# x.xx.xxxxx - 指定版本号
|
# x.xx.xxxxx - 指定版本号
|
||||||
#
|
#
|
||||||
|
|
||||||
|
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
|
|
||||||
|
export PATH="$root_dir/tools:$PATH"
|
||||||
|
# 步骤
|
||||||
|
source "step.sh"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
trap 'catchError $LINENO "$BASH_COMMAND"' ERR # 捕获错误情况
|
trap 'catchError $LINENO "$BASH_COMMAND"' ERR # 捕获错误情况
|
||||||
catchError() {
|
catchError() {
|
||||||
@ -25,49 +31,67 @@ notice() {
|
|||||||
echo -e "\033[36m $1 \033[0m "
|
echo -e "\033[36m $1 \033[0m "
|
||||||
}
|
}
|
||||||
|
|
||||||
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
|
||||||
|
|
||||||
echo "==========Initializing node=========="
|
if [ $CURRENT_STEP == $INSTALL_START ];then
|
||||||
|
rm -rf "$root_dir"/{node,nwjs,package.nw}
|
||||||
|
echo "==========Initializing node=========="
|
||||||
|
if [ -f "$root_dir/node/bin/node" ]; then
|
||||||
|
step_switch $INSTALL_NODE_SUCCESS
|
||||||
|
success "node安装完毕"
|
||||||
|
else
|
||||||
|
"$root_dir/tools/update-node.sh"
|
||||||
|
step_switch $INSTALL_NODE_SUCCESS
|
||||||
|
success "node ok"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f "$root_dir/node/bin/node" ]; then
|
if [ ! -f "$root_dir/node/bin/node" ]; then
|
||||||
success "node安装完毕"
|
step_switch $INSTALL_START
|
||||||
else
|
fail "Node安装失败"
|
||||||
"$root_dir/tools/update-node.sh"
|
exit
|
||||||
success "node ok"
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$root_dir/node/bin/node" ]; then
|
|
||||||
fail "Node安装失败"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
# 将node加入环境
|
# 将node加入环境
|
||||||
export PATH="$root_dir/node/bin":$PATH
|
export PATH="$root_dir/node/bin":$PATH
|
||||||
if [ "$ACTION_MODE" != "true" ]; then
|
node --version
|
||||||
notice "非ACTION模式, 设置镜像源"
|
npm --version
|
||||||
npm config set registry http://registry.npmmirror.com/ # 注册模块镜像
|
|
||||||
npm config set disturl http://npmmirror.com/dist # node-gyp 编译依赖的 node 源码镜像
|
|
||||||
## 以下选择添加
|
|
||||||
npm config set sass_binary_site http://npmmirror.com/mirrors/node-sass # node-sass 二进制包镜像
|
|
||||||
npm config set electron_mirror http://npmmirror.com/mirrors/electron/ # electron 二进制包镜像
|
|
||||||
npm config set puppeteer_download_host http://npmmirror.com/mirrors # puppeteer 二进制包镜像
|
|
||||||
npm config set chromedriver_cdnurl http://npmmirror.com/mirrors/chromedriver # chromedriver 二进制包镜像
|
|
||||||
npm config set operadriver_cdnurl http://npmmirror.com/mirrors/operadriver # operadriver 二进制包镜像
|
|
||||||
npm config set phantomjs_cdnurl http://npmmirror.com/mirrors/phantomjs # phantomjs 二进制包镜像
|
|
||||||
npm config set selenium_cdnurl http://npmmirror.com/mirrors/selenium # selenium 二进制包镜像
|
|
||||||
npm config set node_inspector_cdnurl http://npmmirror.com/mirrors/node-inspector # node-inspector 二进制包镜像
|
|
||||||
# npm cache clean --force # 清空缓存
|
|
||||||
fi
|
|
||||||
echo "=====安装node-gyp nw-gyp===="
|
|
||||||
npm uninstall node-gyp -g
|
|
||||||
npm install node-gyp nw-gyp npm -g
|
|
||||||
node-gyp install
|
|
||||||
node-gyp list
|
|
||||||
|
|
||||||
echo "==========Initializing nwjs=========="
|
if [ $CURRENT_STEP == $INSTALL_NODE_SUCCESS ];then
|
||||||
if [ -f "$root_dir/nwjs/nw" ]; then
|
if [ "$ACTION_MODE" != "true" ]; then
|
||||||
success "nwjs安装完毕"
|
notice "非ACTION模式, 设置镜像源"
|
||||||
else
|
npm config set registry http://registry.npmmirror.com/ # 注册模块镜像
|
||||||
node "$root_dir/tools/update-nwjs-node"
|
npm config set disturl http://npmmirror.com/dist # node-gyp 编译依赖的 node 源码镜像
|
||||||
|
## 以下选择添加
|
||||||
|
npm config set sass_binary_site http://npmmirror.com/mirrors/node-sass # node-sass 二进制包镜像
|
||||||
|
npm config set electron_mirror http://npmmirror.com/mirrors/electron/ # electron 二进制包镜像
|
||||||
|
npm config set puppeteer_download_host http://npmmirror.com/mirrors # puppeteer 二进制包镜像
|
||||||
|
npm config set chromedriver_cdnurl http://npmmirror.com/mirrors/chromedriver # chromedriver 二进制包镜像
|
||||||
|
npm config set operadriver_cdnurl http://npmmirror.com/mirrors/operadriver # operadriver 二进制包镜像
|
||||||
|
npm config set phantomjs_cdnurl http://npmmirror.com/mirrors/phantomjs # phantomjs 二进制包镜像
|
||||||
|
npm config set selenium_cdnurl http://npmmirror.com/mirrors/selenium # selenium 二进制包镜像
|
||||||
|
npm config set node_inspector_cdnurl http://npmmirror.com/mirrors/node-inspector # node-inspector 二进制包镜像
|
||||||
|
# npm cache clean --force # 清空缓存
|
||||||
|
fi
|
||||||
|
step_switch $INSTALL_NPM_CONFIG_SUCCESS
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $CURRENT_STEP == $INSTALL_NPM_CONFIG_SUCCESS ];then
|
||||||
|
notice "=====安装node-gyp nw-gyp===="
|
||||||
|
npm uninstall node-gyp -g
|
||||||
|
npm install node-gyp nw-gyp -g
|
||||||
|
node-gyp install
|
||||||
|
node-gyp list
|
||||||
|
step_switch $INSTALL_GYP_SUCCESS
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $CURRENT_STEP == $INSTALL_GYP_SUCCESS ];then
|
||||||
|
echo "==========Initializing nwjs=========="
|
||||||
|
if [ -f "$root_dir/nwjs/nw" ]; then
|
||||||
|
success "nwjs安装完毕"
|
||||||
|
else
|
||||||
|
node "$root_dir/tools/update-nwjs-node"
|
||||||
|
fi
|
||||||
|
step_switch $INSTALL_NW_SUCCESS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 7z旧版本解压不正常
|
# 7z旧版本解压不正常
|
||||||
@ -79,31 +103,65 @@ fi
|
|||||||
# ln -s 7zz 7z
|
# ln -s 7zz 7z
|
||||||
# export PATH="$root_dir/tmp/7z:$PATH"
|
# export PATH="$root_dir/tmp/7z:$PATH"
|
||||||
|
|
||||||
echo "==========Initializing wechat-devtools package=========="
|
if [ $CURRENT_STEP == $INSTALL_NW_SUCCESS ];then
|
||||||
|
notice "==========Initializing wechat-devtools package=========="
|
||||||
|
if [[ $@ == *version* ]];then
|
||||||
|
# 参数有版本号,优先级高,清空TARGET_VERSION
|
||||||
|
echo "参数有版本号"
|
||||||
|
TARGET_VERSION=""
|
||||||
|
else
|
||||||
|
# 参数没有版本号,获取
|
||||||
|
echo "参数没有版本号"
|
||||||
|
VERSION_DATA=$( cat "$root_dir/conf/devtools_v" )
|
||||||
|
VERSION_DATA=(${VERSION_DATA//,/ })
|
||||||
|
TARGET_VERSION="version=${VERSION_DATA[0]}"
|
||||||
|
fi
|
||||||
|
echo "TARGET_VERSION: $TARGET_VERSION"
|
||||||
|
if [ ! -f "$root_dir/package.nw/package.json" ];then
|
||||||
|
# 没装,直接装
|
||||||
|
node "$root_dir/tools/update-wechat-devtools-node" $TARGET_VERSION $@
|
||||||
|
|
||||||
|
step_switch $INSTALL_WECHAT_SUCCESS
|
||||||
|
else
|
||||||
|
# 装了,获取已安装版本
|
||||||
|
DEVTOOLS_VERSION=$( cat "$root_dir/package.nw/package.json" | grep -m 1 -Eo "\"[0-9]{1}\.[0-9]{2}\.[0-9]+" )
|
||||||
|
DEVTOOLS_VERSION="${DEVTOOLS_VERSION//\"/}"
|
||||||
|
# 已安装, 比较目标版本
|
||||||
|
if [ "$TARGET_VERSION" != "$DEVTOOLS_VERSION" ];then
|
||||||
|
node "$root_dir/tools/update-wechat-devtools-node" $TARGET_VERSION $@
|
||||||
|
fi
|
||||||
|
step_switch $INSTALL_WECHAT_SUCCESS
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $@ == *version* ]];then
|
if [ $CURRENT_STEP == $INSTALL_WECHAT_SUCCESS ];then
|
||||||
# 参数有版本号,优先级高,清空TARGET_VERSION
|
notice "Patching wechat-devtools package name"
|
||||||
echo "参数有版本号"
|
"$root_dir/tools/fix-package-name.js"
|
||||||
TARGET_VERSION=""
|
|
||||||
else
|
notice "Patching wechat-devtools editor selection autocopy"
|
||||||
# 参数没有版本号,获取
|
"$root_dir/tools/fix-selection-copy-node"
|
||||||
echo "参数没有版本号"
|
|
||||||
VERSION_DATA=$( cat "$root_dir/conf/devtools_v" )
|
notice "Patching wechat-devtools CLI supports"
|
||||||
VERSION_DATA=(${VERSION_DATA//,/ })
|
"$root_dir/tools/fix-cli.sh"
|
||||||
TARGET_VERSION="version=${VERSION_DATA[0]}"
|
|
||||||
|
notice "Patching wechat-devtools core.wxvpkg"
|
||||||
|
"$root_dir/tools/fix-core.sh"
|
||||||
|
|
||||||
|
notice "Rebuilding wechat-devtools node modules"
|
||||||
|
nwjsConfig=`cat "$root_dir/conf/nwjs.json" | grep -m 1 -Eo "version\": \"[0-9]{1}\.[0-9]{2}\.[0-9]+"`
|
||||||
|
nwjs_version="${nwjsConfig/version\": \"/}"
|
||||||
|
"$root_dir/tools/rebuild-node-modules.sh" "$nwjs_version"
|
||||||
|
step_switch $INSTALL_REBUILD_SUCCESS
|
||||||
fi
|
fi
|
||||||
echo "TARGET_VERSION: $TARGET_VERSION"
|
|
||||||
if [ ! -f "$root_dir/package.nw/package.json" ];then
|
if [ $CURRENT_STEP == $INSTALL_REBUILD_SUCCESS ];then
|
||||||
# 没装,直接装
|
notice "Patching wechat-devtools"
|
||||||
node "$root_dir/tools/update-wechat-devtools-node" $TARGET_VERSION $@
|
"$root_dir/tools/fix-menu.sh"
|
||||||
exit 0
|
|
||||||
|
notice "Patching Other"
|
||||||
|
"$root_dir/tools/fix-other.sh"
|
||||||
fi
|
fi
|
||||||
# 装了,获取已安装版本
|
|
||||||
DEVTOOLS_VERSION=$( cat "$root_dir/package.nw/package.json" | grep -m 1 -Eo "\"[0-9]{1}\.[0-9]{2}\.[0-9]+" )
|
success "微信开发者工具安装完毕"
|
||||||
DEVTOOLS_VERSION="${DEVTOOLS_VERSION//\"/}"
|
|
||||||
# 已安装, 比较目标版本
|
step_over
|
||||||
if [ "$TARGET_VERSION" == "$DEVTOOLS_VERSION" ];then
|
|
||||||
success "微信开发者工具安装完毕"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
node "$root_dir/tools/update-wechat-devtools-node" $TARGET_VERSION $@
|
|
||||||
|
43
tools/step.sh
Executable file
43
tools/step.sh
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
|
if [ -f "$_dir/tmp/.step" ];then
|
||||||
|
CURRENT_STEP=`cat "$_dir/tmp/.step"`
|
||||||
|
unset _dir
|
||||||
|
if [ "$CURRENT_STEP" == "" ];then
|
||||||
|
echo "default"
|
||||||
|
CURRENT_STEP="INSTALL_START"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
CURRENT_STEP="INSTALL_START"
|
||||||
|
fi
|
||||||
|
|
||||||
|
INSTALL_START="INSTALL_START"
|
||||||
|
INSTALL_NODE_SUCCESS="INSTALL_NODE_SUCCESS"
|
||||||
|
INSTALL_NPM_CONFIG_SUCCESS="INSTALL_NPM_CONFIG_SUCCESS"
|
||||||
|
INSTALL_GYP_SUCCESS="INSTALL_GYP_SUCCESS"
|
||||||
|
INSTALL_NW_SUCCESS="INSTALL_NW_SUCCESS"
|
||||||
|
INSTALL_WECHAT_SUCCESS="INSTALL_WECHAT_SUCCESS"
|
||||||
|
INSTALL_REBUILD_SUCCESS="INSTALL_REBUILD_SUCCESS"
|
||||||
|
|
||||||
|
|
||||||
|
step_switch() {
|
||||||
|
echo -e "\033[42;36m 切换步骤-> \033[0m $1"
|
||||||
|
CURRENT_STEP=$1
|
||||||
|
_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
|
echo -n "$1" > "$_dir/tmp/.step"
|
||||||
|
unset _dir
|
||||||
|
}
|
||||||
|
|
||||||
|
step_error() {
|
||||||
|
echo -e "\033[41;37m 步骤异常-> \033[0m $1 $2"
|
||||||
|
step_switch $2
|
||||||
|
CURRENT_STEP=$1
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
step_over() {
|
||||||
|
_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
|
echo -n "" > "$_dir/tmp/.step"
|
||||||
|
unset _dir
|
||||||
|
}
|
1
tools/update-wechat-devtools-bash
Executable file
1
tools/update-wechat-devtools-bash
Executable file
@ -0,0 +1 @@
|
|||||||
|
#!/bin/bash
|
@ -201,97 +201,97 @@ const upgrade = function (extractPath) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const patch_wechat_devtools_package_name = function () {
|
// const patch_wechat_devtools_package_name = function () {
|
||||||
info("Patching wechat-devtools package name");
|
// info("Patching wechat-devtools package name");
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
// return new Promise((resolve, reject) => {
|
||||||
spawn(path.resolve(__dirname, "fix-package-name.js"), [], {
|
// spawn(path.resolve(__dirname, "fix-package-name.js"), [], {
|
||||||
stdio: "inherit",
|
// stdio: "inherit",
|
||||||
}).on("close", (code) => {
|
// }).on("close", (code) => {
|
||||||
resolve();
|
// resolve();
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
const patch_wechat_devtools_editor_selection_autocopy = function () {
|
// const patch_wechat_devtools_editor_selection_autocopy = function () {
|
||||||
info("Patching wechat-devtools editor selection autocopy");
|
// info("Patching wechat-devtools editor selection autocopy");
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
// return new Promise((resolve, reject) => {
|
||||||
spawn(path.resolve(__dirname, "fix-selection-copy-node"), [], {
|
// spawn(path.resolve(__dirname, "fix-selection-copy-node"), [], {
|
||||||
stdio: "inherit",
|
// stdio: "inherit",
|
||||||
}).on("close", (code) => {
|
// }).on("close", (code) => {
|
||||||
resolve();
|
// resolve();
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
const patch_wechat_devtools_CLI = function () {
|
// const patch_wechat_devtools_CLI = function () {
|
||||||
info("Patching wechat-devtools CLI supports");
|
// info("Patching wechat-devtools CLI supports");
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
// return new Promise((resolve, reject) => {
|
||||||
spawn(path.resolve(__dirname, "fix-cli.sh"), [], {
|
// spawn(path.resolve(__dirname, "fix-cli.sh"), [], {
|
||||||
stdio: "inherit",
|
// stdio: "inherit",
|
||||||
}).on("close", (code) => {
|
// }).on("close", (code) => {
|
||||||
resolve();
|
// resolve();
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
const patch_wechat_devtools_core = function () {
|
// const patch_wechat_devtools_core = function () {
|
||||||
info("Patching wechat-devtools core.wxvpkg");
|
// info("Patching wechat-devtools core.wxvpkg");
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
// return new Promise((resolve, reject) => {
|
||||||
spawn(path.resolve(__dirname, "fix-core.sh"), [], {
|
// spawn(path.resolve(__dirname, "fix-core.sh"), [], {
|
||||||
stdio: "inherit",
|
// stdio: "inherit",
|
||||||
}).on("close", (code) => {
|
// }).on("close", (code) => {
|
||||||
resolve();
|
// resolve();
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
const rebuild_wechat_devtools_node_modules = function () {
|
// const rebuild_wechat_devtools_node_modules = function () {
|
||||||
info("Rebuilding wechat-devtools node modules");
|
// info("Rebuilding wechat-devtools node modules");
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
// return new Promise((resolve, reject) => {
|
||||||
const nwConfig = require(path.resolve(__dirname, "../conf/nwjs.json"));
|
// const nwConfig = require(path.resolve(__dirname, "../conf/nwjs.json"));
|
||||||
const e = spawn(
|
// const e = spawn(
|
||||||
path.resolve(__dirname, "rebuild-node-modules.sh"),
|
// path.resolve(__dirname, "rebuild-node-modules.sh"),
|
||||||
[nwConfig.version],
|
// [nwConfig.version],
|
||||||
{
|
// {
|
||||||
stdio: "inherit",
|
// stdio: "inherit",
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
e.on("error", (code) => {
|
// e.on("error", (code) => {
|
||||||
reject(code);
|
// reject(code);
|
||||||
});
|
// });
|
||||||
e.on("close", (code) => {
|
// e.on("close", (code) => {
|
||||||
console.info(
|
// console.info(
|
||||||
`Rebuilding wechat-devtools node modules Result Code: ${code}`
|
// `Rebuilding wechat-devtools node modules Result Code: ${code}`
|
||||||
);
|
// );
|
||||||
if (0 === code) resolve();
|
// if (0 === code) resolve();
|
||||||
else {
|
// else {
|
||||||
reject(code);
|
// reject(code);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
const patch_wechat_devtools = function () {
|
// const patch_wechat_devtools = function () {
|
||||||
info("Patching wechat-devtools");
|
// info("Patching wechat-devtools");
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
// return new Promise((resolve, reject) => {
|
||||||
const exec = spawn(path.resolve(__dirname, "fix-menu.sh"), [], {
|
// const exec = spawn(path.resolve(__dirname, "fix-menu.sh"), [], {
|
||||||
stdio: "inherit",
|
// stdio: "inherit",
|
||||||
});
|
// });
|
||||||
exec.on("close", (code) => {
|
// exec.on("close", (code) => {
|
||||||
resolve();
|
// resolve();
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
const patch_other = function () {
|
// const patch_other = function () {
|
||||||
info("Patching Other");
|
// info("Patching Other");
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
// return new Promise((resolve, reject) => {
|
||||||
execSync(path.resolve(__dirname, "fix-other.sh"));
|
// execSync(path.resolve(__dirname, "fix-other.sh"));
|
||||||
|
|
||||||
resolve();
|
// resolve();
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
|
|
||||||
const start = async () => {
|
const start = async () => {
|
||||||
try {
|
try {
|
||||||
@ -299,13 +299,13 @@ const start = async () => {
|
|||||||
const localPath = await download(url);
|
const localPath = await download(url);
|
||||||
const extractPath = await extract(localPath);
|
const extractPath = await extract(localPath);
|
||||||
await upgrade(extractPath);
|
await upgrade(extractPath);
|
||||||
await patch_wechat_devtools_package_name();
|
// await patch_wechat_devtools_package_name();
|
||||||
await patch_wechat_devtools_editor_selection_autocopy();
|
// await patch_wechat_devtools_editor_selection_autocopy();
|
||||||
await patch_wechat_devtools_CLI();
|
// await patch_wechat_devtools_CLI();
|
||||||
await patch_wechat_devtools_core();
|
// await patch_wechat_devtools_core();
|
||||||
await rebuild_wechat_devtools_node_modules();
|
// await rebuild_wechat_devtools_node_modules();
|
||||||
await patch_wechat_devtools();
|
// await patch_wechat_devtools();
|
||||||
await patch_other();
|
// await patch_other();
|
||||||
// 写入构建时间戳
|
// 写入构建时间戳
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.resolve(__dirname, "../package.nw/.build_time"),
|
path.resolve(__dirname, "../package.nw/.build_time"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user