diff --git a/bin/build.conf b/bin/build.conf index 378b4cc9e..f2da8b060 100644 --- a/bin/build.conf +++ b/bin/build.conf @@ -1,4 +1,2 @@ -wechat_v="0.15.152900" -#nwjs_v="0.21.3" - +wechat_v="0.17.170900" nwjs_v="0.19.4" diff --git a/bin/pack.sh b/bin/pack.sh index 704e74281..0bd0f36a3 100755 --- a/bin/pack.sh +++ b/bin/pack.sh @@ -1,67 +1,68 @@ -#! /bin/sh -# tar wechat-dev-tools +#! /bin/bash +# 下载nwjs,构建项目,支持以下选项 +# pack - 打包 +# install - 构建,并且执行scripts/replace_weapp_vendor.sh +# build - 可以使用,但不执行scripts/replace_weapp_vendor.sh -param1=${1:-"pack"} -echo $param1 +want=${1:-"build"} +if [ $want = "install" -o $want = "build" -o $want = "pack" ]; then + echo $want +else + echo "不支持$want操作" + exit 127 +fi cd `dirname $0`/.. -cur_dir=$(pwd) +root_dir=$(pwd) -. "$cur_dir/bin/build.conf" +. "$root_dir/bin/build.conf" -tmp_dir="$cur_dir/.tmp" -dist_dir="$cur_dir/dist" +tmp_dir="$root_dir/.tmp" +dist_dir="$root_dir/dist" nwjs_file="$tmp_dir/nwjs-v$nwjs_v.tar.gz" nwjs_dir="$tmp_dir/nwjs-sdk-v${nwjs_v}-linux-x64" nwjs_download="https://dl.nwjs.io/v$nwjs_v/nwjs-sdk-v${nwjs_v}-linux-x64.tar.gz" -dist_wechat_dir="wechat-dev-tools-xsp" dist_wechat_package="wechat-v${wechat_v}-nwjs-v${nwjs_v}.tar.gz" -if [ $param1 = "install" ]; then - echo "install" - # rm -rf $tmp_dir -fi - mkdir -p $tmp_dir if [ ! -d "$nwjs_dir" ]; then if [ ! -f "$nwjs_file" ]; then echo "=================================" echo "[注意]需要下载nwjs.请耐心等待下载完成" - echo $nwjs_download + echo "$nwjs_download" echo "=================================" - wget "$nwjs_download" -O $nwjs_file + wget "$nwjs_download" -O "$nwjs_file" $? -ne 0 && exit "$?" fi - tar -xf $nwjs_file -C $tmp_dir + tar -xf "$nwjs_file" -C $tmp_dir $? -ne 0 && exit "$?" cd "$nwjs_dir/locales" || exit "$?" - rm $(ls -I "zh*" -I "en*" ) - cd "$cur_dir" + # 移除其他语言 + ls -I "zh*" -I "en*" | xargs rm + cd "$root_dir" fi -rm -rf $cur_dir/dist -mkdir -p $cur_dir/dist +rm -rf "$dist_dir" +mkdir -p "$dist_dir" + +cp -r "$nwjs_dir"/* "$root_dir/scripts" "$dist_dir" -if [ $param1 = "install" ]; then - cp -r "$nwjs_dir"/* "$cur_dir/scripts" "$cur_dir/dist" - cd "$cur_dir/dist" - ln -s "$cur_dir/package.nw" - sh scripts/install.sh -elif [ $param1 = "build" ]; then - cp -r "$nwjs_dir"/* "$cur_dir/scripts" "$cur_dir/dist" - cd "$cur_dir/dist" - ln -s "$cur_dir/package.nw" -elif [ $param1 = "pack" ]; then - cp -r "$nwjs_dir"/* "$cur_dir/package.nw" "$cur_dir/scripts" "$cur_dir/dist" - mkdir -p $tmp_dir/build - tar -zcvf "$tmp_dir/build/$dist_wechat_package" -C "$cur_dir" dist +if [ $want = "pack" ]; then + cp -r "$root_dir/package.nw" "$dist_dir" + mkdir -p "$tmp_dir/build" + tar -zcvf "$tmp_dir/build/$dist_wechat_package" -C "$root_dir" dist else - echo "不支持$param1操作" - exit 127 + ln -s "$root_dir/package.nw" + if [ $want = "install" ]; then + sh "$dist_dir/scripts/replace_weapp_vendor.sh" + fi fi -echo "$param1 success" +echo "=================================" +echo "$want success" +echo "可以手动删除目录下.tmp文件夹" +echo "=================================" diff --git a/bin/update_package_nw.sh b/bin/update_package_nw.sh new file mode 100755 index 000000000..281977a18 --- /dev/null +++ b/bin/update_package_nw.sh @@ -0,0 +1,33 @@ +#! /bin/bash + +cd `dirname $0`/.. + +root_dir=$(pwd) + +. "$root_dir/bin/build.conf" + +tmp_dir="$root_dir/.tmp" +dist_dir="$root_dir/dist" + +wcwd_file="$tmp_dir/wechat_web_devtools_${wechat_v}_x64.exe" +wcwd_download="https://dldir1.qq.com/WechatWebDev/${wechat_v//./}/wechat_web_devtools_${wechat_v}_x64.exe" + +wcwd_package_dir="$HOME/.wine/drive_c/Program Files (x86)/Tencent/微信web开发者工具/package.nw" + +mkdir -p $tmp_dir + +# 下载 +if [ ! -f "$wcwd_file" ]; then + echo "=================================" + echo "[注意]需要下载微信开发者工具.请耐心等待下载完成" + echo $wcwd_download + echo "=================================" + wget "$wcwd_download" -O $wcwd_file + $? -ne 0 && exit "$?" +fi + +# 安装 +wine $wcwd_file + +rm -rf "$root_dir/package.nw" +cp -r "$wcwd_package_dir" "$root_dir" diff --git a/note.md b/note.md deleted file mode 100644 index b81f6aa00..000000000 --- a/note.md +++ /dev/null @@ -1,7 +0,0 @@ - -package.nw 需要替换的 -Create/create => create/create - -./main.js => ./Main.js - -config/appServiceConfig.js => config/appserviceConfig.js diff --git a/replace.sh b/replace.sh deleted file mode 100755 index bd3159fdd..000000000 --- a/replace.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh - -files=$(find ./package.nw/app/dist -type f -name '*.js') - -echo $files | xargs sed -i 's/\.\/main\.js/.\/Main\.js/g' -echo $files | xargs sed -i 's/Create\/create/create\/create/g' -echo $files | xargs sed -i 's/config\/appServiceConfig\.js/config\/appserviceConfig\.js/g' - diff --git a/scripts/install.sh b/scripts/replace_weapp_vendor.sh similarity index 100% rename from scripts/install.sh rename to scripts/replace_weapp_vendor.sh