mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
refactor: 整理文件,便于维护
This commit is contained in:
parent
41938a29a0
commit
e9c717dd5d
@ -11,7 +11,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- ACTION=${ACTION_MODE:-false}
|
- ACTION=${ACTION_MODE:-false}
|
||||||
# - https_proxy=${https_proxy:-}
|
# - https_proxy=${https_proxy:-}
|
||||||
- NO_WINE=${NO_WINE:-false}
|
- NO_WINE=${NO_WINE:-true}
|
||||||
- LOCAL_USER_ID=${UID:-1000}
|
- LOCAL_USER_ID=${UID:-1000}
|
||||||
entrypoint: /workspace/docker/docker-entrypoint
|
entrypoint: /workspace/docker/docker-entrypoint
|
||||||
userns_mode: "host"
|
userns_mode: "host"
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
4. 为什么自己构筑的运行时加载项目时会卡住?
|
4. 为什么自己构筑的运行时加载项目时会卡住?
|
||||||
|
|
||||||
检查一下在`package.nw/node_modules`目录下的node文件,是否依旧是Windows版本的dll,而非linux需要的so。如果依旧是Windows下的dll的话,可以考虑执行`tools/rebuild-node-modules`命令重新编译。如果已经是linux的so文件的话,则同问题3解决方法
|
检查一下在`package.nw/node_modules`目录下的node文件,是否依旧是Windows版本的dll,而非linux需要的so。如果依旧是Windows下的dll的话,可以考虑执行`tools/rebuild-node-modules.sh`命令重新编译。如果已经是linux的so文件的话,则同问题3解决方法
|
||||||
|
|
||||||
5. 为什么自己构筑或更新后的在加载项目后,IDE界面会显示错误崩溃?
|
5. 为什么自己构筑或更新后的在加载项目后,IDE界面会显示错误崩溃?
|
||||||
|
|
||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
8. 直接下载下来的发布包,在加载项目后,为什么右侧的编辑界面是空白?
|
8. 直接下载下来的发布包,在加载项目后,为什么右侧的编辑界面是空白?
|
||||||
|
|
||||||
根据相关的情况分析,可以打开在微信开发者工具菜单里的调试支持。查看里面的日志报错,目前大部分情况是您的系统里libstdc++版本与预编译的版本不一致。可以考虑采用docker版本,或者执行`tools/rebuild-node-modules`命令重新编译系统支持的原生模块。
|
根据相关的情况分析,可以打开在微信开发者工具菜单里的调试支持。查看里面的日志报错,目前大部分情况是您的系统里libstdc++版本与预编译的版本不一致。可以考虑采用docker版本,或者执行`tools/rebuild-node-modules.sh`命令重新编译系统支持的原生模块。
|
||||||
|
|
||||||
9. 自己构筑时,为什么会报告python执行错误?
|
9. 自己构筑时,为什么会报告python执行错误?
|
||||||
|
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
FROM debian:stretch
|
|
||||||
LABEL maintainer="minun (minun@mewmew.cn)"
|
|
||||||
|
|
||||||
ENV LANG=C.UTF-8
|
|
||||||
|
|
||||||
# update repo sources
|
|
||||||
RUN set -ex; \
|
|
||||||
cp /etc/apt/sources.list /etc/apt/sources.list.bak; \
|
|
||||||
echo "deb http://mirrors.aliyun.com/debian/ stretch main" > /etc/apt/sources.list; \
|
|
||||||
echo "deb http://mirrors.aliyun.com/debian/ stretch-updates main" >> /etc/apt/sources.list; \
|
|
||||||
rm -rf /var/cache/apt/archives/lock \
|
|
||||||
apt-get clean; \
|
|
||||||
apt-get update --fix-missing;
|
|
||||||
|
|
||||||
RUN DEBIAN_FRONTEND=noninteractive \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
apt-utils \
|
|
||||||
build-essential \
|
|
||||||
ca-certificates \
|
|
||||||
git \
|
|
||||||
libx11-dev \
|
|
||||||
libxkbfile-dev \
|
|
||||||
pkg-config \
|
|
||||||
python \
|
|
||||||
p7zip-full
|
|
||||||
|
|
||||||
ADD runtime-mewjs.tar.gz /opt/mewjs
|
|
||||||
COPY node-v12.6.0-linux-x64.tar.gz /opt/wechat/cache/node-v12.6.0-linux-x64.tar.gz
|
|
||||||
COPY nwjs-sdk-v0.39.3-linux-x64.tar.gz /opt/wechat/cache/nwjs-sdk-v0.39.3-linux-x64.tar.gz
|
|
||||||
COPY wechat_devtools_1.03.2009140_x64.exe /opt/wechat/cache/wechat_devtools_1.03.2009140_x64.exe
|
|
||||||
COPY build /opt/wechat/cache/build
|
|
||||||
|
|
||||||
RUN chmod +x /opt/mewjs/bin/hako \
|
|
||||||
/opt/mewjs/bin/mew \
|
|
||||||
/opt/mewjs/bin/chan \
|
|
||||||
/opt/mewjs/bin/mew_* \
|
|
||||||
/opt/mewjs/bin/npm \
|
|
||||||
/opt/mewjs/bin/npx
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
useradd -m builder -s /bin/bash; \
|
|
||||||
mkdir -p /opt/local/proj; \
|
|
||||||
cd /opt/local/proj; \
|
|
||||||
git clone https://github.com/dragonation/wechat-devtools.git; \
|
|
||||||
mkdir -p /opt/local/proj/wechat-devtools/cache; \
|
|
||||||
cd wechat-devtools; \
|
|
||||||
cp -fr /opt/wechat/cache/* cache/; \
|
|
||||||
cp -f /opt/wechat/cache/build build; \
|
|
||||||
chmod -R 777 .
|
|
||||||
|
|
||||||
ENV PATH=/opt/mewjs/bin:/usr/local/bin:/usr/bin:/bin
|
|
||||||
|
|
||||||
WORKDIR /opt/local/proj/wechat-devtools
|
|
||||||
|
|
||||||
# docker build -t wechat-devtools-compact-builder .
|
|
||||||
# docker run -ti --rm -v `pwd`:/opt/wechat/output wechat-devtools-compact-builder /bin/bash --login -i
|
|
||||||
|
|
||||||
# su builder
|
|
||||||
# export PATH=/opt/mewjs/bin:$PATH
|
|
||||||
# ./build
|
|
||||||
# cp wechat-devtools-compact.tar.gz /opt/wechat/output/wechat-devtools-1.03.2009140-compact.tar.gz
|
|
@ -1,92 +0,0 @@
|
|||||||
if (typeof nw === "undefined") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let log = function (content) {
|
|
||||||
process.stderr.write(content + "\n");
|
|
||||||
};
|
|
||||||
|
|
||||||
let originMenuItem = nw.MenuItem;
|
|
||||||
nw.MenuItem = function MenuItem(options) {
|
|
||||||
|
|
||||||
options = Object.assign({}, options);
|
|
||||||
|
|
||||||
delete options.shortcutName;
|
|
||||||
delete options.shouldEnabled;
|
|
||||||
|
|
||||||
if (options.label && (typeof options.label === "string")) {
|
|
||||||
|
|
||||||
if (options.label.indexOf("[") !== -1) {
|
|
||||||
let rest = options.label.split("[").slice(1).join("[").trim();
|
|
||||||
if (rest[rest.length - 1] === "]") {
|
|
||||||
rest = rest.slice(0, -1).split("+").map((x) => {
|
|
||||||
if (!x) { return "+" }
|
|
||||||
switch (x) {
|
|
||||||
case "↓": { return "Down"; }
|
|
||||||
case "↑": { return "Up"; }
|
|
||||||
case "PAGE↓": { return "PageDown"; }
|
|
||||||
case "PAGE↑": { return "PageUp"; }
|
|
||||||
case "←": { return "Left"; }
|
|
||||||
case "→": { return "Right"; }
|
|
||||||
default: { return x; }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (rest.length > 1) {
|
|
||||||
options.key = rest[rest.length - 1];
|
|
||||||
options.modifiers = rest.slice(0, -1).join("+");
|
|
||||||
} else {
|
|
||||||
options.key = rest[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options.label = options.label.split("[")[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.label.indexOf("(&") !== -1) {
|
|
||||||
options.label = options.label.split("(&")[0];
|
|
||||||
}
|
|
||||||
options.label = options.label.replace("&", "").trim();
|
|
||||||
|
|
||||||
switch (options.label) {
|
|
||||||
case "Go to Declaration": { options.label = "转到声明"; break; }
|
|
||||||
case "Go to References": { options.label = "转到引用"; break; }
|
|
||||||
case "Find All References": { options.label = "查找所有引用"; break; }
|
|
||||||
case "Find All Implementations": { options.label = "查找所有实现"; break; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return new originMenuItem(options);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
let originAppend = nw.Menu.prototype.append;
|
|
||||||
nw.Menu.prototype.append = function (item) {
|
|
||||||
|
|
||||||
if (item.parentMenu) {
|
|
||||||
item.parentMenu.remove(item);
|
|
||||||
}
|
|
||||||
item.parentMenu = this;
|
|
||||||
|
|
||||||
if ((this.items.length > 0) &&
|
|
||||||
(this.items[this.items.length - 1].type === "separator") &&
|
|
||||||
(item.type === "separator")) {
|
|
||||||
originInsert.call(this, item, this.items.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((this.items.length === 0) && (item.type === "separator")) {
|
|
||||||
originInsert.call(this, item, this.items.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return originAppend.call(this, item);
|
|
||||||
};
|
|
||||||
|
|
||||||
let originInsert = nw.Menu.prototype.insert;
|
|
||||||
nw.Menu.prototype.insert = function (item, index) {
|
|
||||||
if (item.parentMenu) {
|
|
||||||
item.parentMenu.remove(item);
|
|
||||||
}
|
|
||||||
item.parentMenu = this;
|
|
||||||
return originInsert.call(this, item, index);
|
|
||||||
};
|
|
@ -2,5 +2,5 @@
|
|||||||
export NO_WINE=true
|
export NO_WINE=true
|
||||||
|
|
||||||
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
$root_dir/tools/fix-core
|
$root_dir/tools/fix-core.sh
|
||||||
$root_dir/tools/fix-other
|
$root_dir/tools/fix-other.sh
|
0
tools/appimage.sh
Normal file → Executable file
0
tools/appimage.sh
Normal file → Executable file
4
tools/build-release.sh
Normal file → Executable file
4
tools/build-release.sh
Normal file → Executable file
@ -47,8 +47,8 @@ for type in wine no_wine; do
|
|||||||
if [[ $type == 'no_wine' ]];then
|
if [[ $type == 'no_wine' ]];then
|
||||||
notice "no wine handle"
|
notice "no wine handle"
|
||||||
export NO_WINE=true
|
export NO_WINE=true
|
||||||
bash "$root_dir/tools/fix-core"
|
bash "$root_dir/tools/fix-core.sh"
|
||||||
bash "$root_dir/tools/fix-other"
|
bash "$root_dir/tools/fix-other.sh"
|
||||||
fi
|
fi
|
||||||
mkdir -p "$build_dir/$FULL_NAME"
|
mkdir -p "$build_dir/$FULL_NAME"
|
||||||
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
const path = require("path");
|
|
||||||
const fs = require("fs");
|
|
||||||
|
|
||||||
console.info("Patching CLI command");
|
|
||||||
|
|
||||||
const rootDir = path.dirname(__dirname);
|
|
||||||
|
|
||||||
let cli = fs.readFileSync(path.resolve(rootDir, "package.nw/js/common/cli/index.js"), "utf8");
|
|
||||||
|
|
||||||
cli = cli.replace(/USERPROFILE/g, "HOME");
|
|
||||||
cli = cli.replace(/AppData\/Local\/\$\{global\.userDirName\}\/User Data/g,
|
|
||||||
".config/${global.userDirName}");
|
|
||||||
cli = cli.replace(/`\.\/\$\{global.appname\}\.exe`/g,
|
|
||||||
"require(\"path\").join(__dirname, \"../../../../bin/wechat-devtools\")");
|
|
||||||
cli = cli.replace(/"\.\.\/\.\.\/\.\.\/\.\.\/resources_win\/nw\/x64\/nw.exe"/g,
|
|
||||||
"\"../../../../nwjs/nw\"");
|
|
||||||
|
|
||||||
fs.writeFileSync(path.resolve(rootDir, "package.nw/js/common/cli/index.js"), cli);
|
|
15
tools/fix-cli.sh
Executable file
15
tools/fix-cli.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
|
NW_PACKAGE_DIR="$root_dir/package.nw"
|
||||||
|
|
||||||
|
if [ -z "$NW_PACKAGE_DIR" ]; then
|
||||||
|
echo -e "\e[1;31m\$NW_PACKAGE_DIR is empty\e[0m" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$NW_PACKAGE_DIR"
|
||||||
|
|
||||||
|
sed -i 's#AppData/Local/\${global.userDirName}/User Data/Default#.config/\${global.userDirName}/Default#g' js/common/cli/index.js
|
||||||
|
sed -i 's#USERPROFILE#HOME#g' js/common/cli/index.js
|
@ -1,13 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo "Fix Core"
|
|
||||||
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
|
|
||||||
package_dir="$root_dir/package.nw"
|
package_dir="$root_dir/package.nw"
|
||||||
tmp_dir="$root_dir/tmp/core"
|
tmp_dir="$root_dir/tmp/core"
|
||||||
unpack_script="$root_dir/tools/wxvpkg/unpack"
|
|
||||||
pack_script="$root_dir/tools/wxvpkg/pack"
|
|
||||||
mkdir -p $tmp_dir
|
mkdir -p $tmp_dir
|
||||||
|
unpack_script="$root_dir/tools/wxvpkg_unpack.js"
|
||||||
|
pack_script="$root_dir/tools/wxvpkg_pack.js"
|
||||||
|
|
||||||
|
echo "Fix Core"
|
||||||
# unpack 文件 到 路径
|
# unpack 文件 到 路径
|
||||||
node "$unpack_script" "$package_dir/core.wxvpkg" "$tmp_dir/core.wxvpkg"
|
node "$unpack_script" "$package_dir/core.wxvpkg" "$tmp_dir/core.wxvpkg"
|
||||||
|
|
130
tools/fix-menu.sh
Executable file
130
tools/fix-menu.sh
Executable file
@ -0,0 +1,130 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
# Author: https://github.com/cytle/wechat_web_devtools/issues/293#issuecomment-604623774
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
|
NW_PACKAGE_DIR="$root_dir/package.nw"
|
||||||
|
|
||||||
|
cd "$NW_PACKAGE_DIR"
|
||||||
|
target_file=js/unpack/hackrequire/index.js
|
||||||
|
|
||||||
|
if [ ! -f "$target_file" ]; then
|
||||||
|
echo -e "\e[1;31m$target_file is not exist\e[0m" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# 判断匹配函数,匹配函数不为0,则包含给定字符
|
||||||
|
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
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmp_file=$(mktemp)
|
||||||
|
cat > "$tmp_file" <<EOF
|
||||||
|
/* patch wechat devtools begin */
|
||||||
|
/* nw-menu.js */
|
||||||
|
(() => {
|
||||||
|
try {
|
||||||
|
if (typeof nw === "undefined") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let log = function (content) {
|
||||||
|
process.stderr.write(content + "\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
let originMenuItem = nw.MenuItem;
|
||||||
|
nw.MenuItem = function MenuItem(options) {
|
||||||
|
|
||||||
|
options = Object.assign({}, options);
|
||||||
|
|
||||||
|
delete options.shortcutName;
|
||||||
|
delete options.shouldEnabled;
|
||||||
|
|
||||||
|
if (options.label && (typeof options.label === "string")) {
|
||||||
|
|
||||||
|
if (options.label.indexOf("[") !== -1) {
|
||||||
|
let rest = options.label.split("[").slice(1).join("[").trim();
|
||||||
|
if (rest[rest.length - 1] === "]") {
|
||||||
|
rest = rest.slice(0, -1).split("+").map((x) => {
|
||||||
|
if (!x) { return "+" }
|
||||||
|
switch (x) {
|
||||||
|
case "↓": { return "Down"; }
|
||||||
|
case "↑": { return "Up"; }
|
||||||
|
case "PAGE↓": { return "PageDown"; }
|
||||||
|
case "PAGE↑": { return "PageUp"; }
|
||||||
|
case "←": { return "Left"; }
|
||||||
|
case "→": { return "Right"; }
|
||||||
|
default: { return x; }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (rest.length > 1) {
|
||||||
|
options.key = rest[rest.length - 1];
|
||||||
|
options.modifiers = rest.slice(0, -1).join("+");
|
||||||
|
} else {
|
||||||
|
options.key = rest[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options.label = options.label.split("[")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.label.indexOf("(&") !== -1) {
|
||||||
|
options.label = options.label.split("(&")[0];
|
||||||
|
}
|
||||||
|
options.label = options.label.replace("&", "").trim();
|
||||||
|
|
||||||
|
switch (options.label) {
|
||||||
|
case "Go to Declaration": { options.label = "转到声明"; break; }
|
||||||
|
case "Go to References": { options.label = "转到引用"; break; }
|
||||||
|
case "Find All References": { options.label = "查找所有引用"; break; }
|
||||||
|
case "Find All Implementations": { options.label = "查找所有实现"; break; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new originMenuItem(options);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
let originAppend = nw.Menu.prototype.append;
|
||||||
|
nw.Menu.prototype.append = function (item) {
|
||||||
|
|
||||||
|
if (item.parentMenu) {
|
||||||
|
item.parentMenu.remove(item);
|
||||||
|
}
|
||||||
|
item.parentMenu = this;
|
||||||
|
|
||||||
|
if ((this.items.length > 0) &&
|
||||||
|
(this.items[this.items.length - 1].type === "separator") &&
|
||||||
|
(item.type === "separator")) {
|
||||||
|
originInsert.call(this, item, this.items.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((this.items.length === 0) && (item.type === "separator")) {
|
||||||
|
originInsert.call(this, item, this.items.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return originAppend.call(this, item);
|
||||||
|
};
|
||||||
|
|
||||||
|
let originInsert = nw.Menu.prototype.insert;
|
||||||
|
nw.Menu.prototype.insert = function (item, index) {
|
||||||
|
if (item.parentMenu) {
|
||||||
|
item.parentMenu.remove(item);
|
||||||
|
}
|
||||||
|
item.parentMenu = this;
|
||||||
|
return originInsert.call(this, item, index);
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
process.stderr.write(error.message);
|
||||||
|
process.stderr.write(error.stack);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
/* patch wechat devtools end */
|
||||||
|
EOF
|
||||||
|
cat "$target_file" >> "$tmp_file"
|
||||||
|
|
||||||
|
cat "$tmp_file" > "$target_file"
|
||||||
|
rm "$tmp_file"
|
@ -15,7 +15,7 @@ sed -i 's#module.exports = createWebviewManager;#module.exports = createWebviewM
|
|||||||
# 修复:可视化用的wcc,wcsc
|
# 修复:可视化用的wcc,wcsc
|
||||||
echo "fix: wcc,wcsc"
|
echo "fix: wcc,wcsc"
|
||||||
if [[ ! -d "$tmp_dir/node_modules" ]];then
|
if [[ ! -d "$tmp_dir/node_modules" ]];then
|
||||||
mkdir "$tmp_dir/node_modules"
|
mkdir -p "$tmp_dir/node_modules"
|
||||||
fi
|
fi
|
||||||
cd $tmp_dir && npm install miniprogram-compiler
|
cd $tmp_dir && npm install miniprogram-compiler
|
||||||
# wcc wcsc
|
# wcc wcsc
|
1
tools/fix-package-name-node → tools/fix-package-name.js
Executable file → Normal file
1
tools/fix-package-name-node → tools/fix-package-name.js
Executable file → Normal file
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const { spawn } = require("child_process");
|
|
||||||
|
|
||||||
const parseFile = function (path) {
|
const parseFile = function (path) {
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const { spawn, execSync } = require("child_process");
|
const { execSync } = require("child_process");
|
||||||
|
|
||||||
console.info("Patching editor selection copy configs");
|
console.info("Patching editor selection copy configs");
|
||||||
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
const path = require("path");
|
|
||||||
const fs = require("fs");
|
|
||||||
const { spawn } = require("child_process");
|
|
||||||
|
|
||||||
let code = fs.readFileSync(path.resolve(__dirname, "../package.nw/js/unpack/hackrequire/index.js"), {encoding:"utf8"});
|
|
||||||
|
|
||||||
let signatureBegin = "/* patch wechat devtools begin */\n";
|
|
||||||
let signatureEnd = "/* patch wechat devtools end */\n";
|
|
||||||
|
|
||||||
let index = code.indexOf(signatureBegin);
|
|
||||||
|
|
||||||
let patch = fs.readdirSync(path.resolve(__dirname, "../patch")).map((file) => {
|
|
||||||
console.log(file)
|
|
||||||
if ((file !== ".") && (file.endsWith(".js"))) {
|
|
||||||
return (`/* ${file} */\n` +
|
|
||||||
"(() => {\n\n" +
|
|
||||||
" try {\n\n" +
|
|
||||||
fs.readFileSync(path.resolve(__dirname, "../patch", file), {encoding:"utf8"}).trim().split("\n").map((line) => {
|
|
||||||
return " " + line;
|
|
||||||
}).join("\n") + "\n\n" +
|
|
||||||
" } catch (error) {\n" +
|
|
||||||
" process.stderr.write(error.message);\n" +
|
|
||||||
" process.stderr.write(error.stack);\n" +
|
|
||||||
" }\n\n" +
|
|
||||||
"})();");
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}).join("\n").trim() + "\n";
|
|
||||||
|
|
||||||
if (code.indexOf(signatureBegin) !== -1) {
|
|
||||||
code = code.split(signatureEnd).slice(1).join(signatureEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(path.resolve(__dirname, "../package.nw/js/unpack/hackrequire/index.js"),
|
|
||||||
signatureBegin + patch + signatureEnd + code);
|
|
@ -3,17 +3,13 @@
|
|||||||
# 1 ---- NW版本
|
# 1 ---- NW版本
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
SOURCE="${BASH_SOURCE[0]}"
|
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
package_dir="$root_dir/package.nw"
|
||||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
export PATH="$root_dir/node/bin:$PATH"
|
||||||
SOURCE="$(readlink "$SOURCE")"
|
|
||||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
|
||||||
done
|
|
||||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
package_dir="$DIR/../package.nw"
|
|
||||||
export PATH="$DIR/../node/bin:$PATH"
|
|
||||||
|
|
||||||
|
if [ ! -z $1 ];then
|
||||||
NW_VERSION=$1
|
NW_VERSION=$1
|
||||||
|
fi
|
||||||
if [ -z $NW_VERSION ]; then
|
if [ -z $NW_VERSION ]; then
|
||||||
echo "NW 版本未指定!"
|
echo "NW 版本未指定!"
|
||||||
exit 1
|
exit 1
|
||||||
@ -22,7 +18,7 @@ fi
|
|||||||
PY_VERSION=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
|
PY_VERSION=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
|
||||||
if [ $PY_VERSION != 2 ]; then
|
if [ $PY_VERSION != 2 ]; then
|
||||||
hash python2 2>/dev/null || { echo >&2 "I require python2 but it's not installed. Aborting."; exit 1; }
|
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"
|
ln -s "$( which python2 )" "$root_dir/node/bin/python"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
hash nw-gyp 2>/dev/null || {
|
hash nw-gyp 2>/dev/null || {
|
@ -208,7 +208,7 @@ 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-node"), [], {
|
spawn(path.resolve(__dirname, "fix-package-name.js"), [], {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
}).on("close", (code) => {
|
}).on("close", (code) => {
|
||||||
resolve();
|
resolve();
|
||||||
@ -230,7 +230,7 @@ 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-node"), [], {
|
spawn(path.resolve(__dirname, "fix-cli.sh"), [], {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
}).on("close", (code) => {
|
}).on("close", (code) => {
|
||||||
resolve();
|
resolve();
|
||||||
@ -241,7 +241,7 @@ 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"), [], {
|
spawn(path.resolve(__dirname, "fix-core.sh"), [], {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
}).on("close", (code) => {
|
}).on("close", (code) => {
|
||||||
resolve();
|
resolve();
|
||||||
@ -253,7 +253,7 @@ const rebuild_wechat_devtools_node_modules = function () {
|
|||||||
|
|
||||||
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(path.resolve(__dirname, "rebuild-node-modules"), [nwConfig.version], {
|
const e = spawn(path.resolve(__dirname, "rebuild-node-modules.sh"), [nwConfig.version], {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
})
|
})
|
||||||
e.on("error", code=>{
|
e.on("error", code=>{
|
||||||
@ -274,7 +274,7 @@ const patch_wechat_devtools = function () {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const exec = spawn(
|
const exec = spawn(
|
||||||
path.resolve(__dirname, "patch-wechat-devtools-node"),
|
path.resolve(__dirname, "fix-menu.sh"),
|
||||||
[],
|
[],
|
||||||
{
|
{
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
@ -289,7 +289,7 @@ 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"))
|
execSync(path.resolve(__dirname, "fix-other.sh"))
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SOURCE="${BASH_SOURCE[0]}"
|
|
||||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
|
||||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
SOURCE="$(readlink "$SOURCE")"
|
|
||||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
|
||||||
done
|
|
||||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
|
|
||||||
export PATH=$DIR/../node/bin:$PATH
|
|
||||||
export PATH=$DIR/../nwjs:$PATH
|
|
Loading…
x
Reference in New Issue
Block a user