refactor: replace compiler to linux

This commit is contained in:
msojocs 2023-08-28 13:30:36 +08:00
parent f4c6d6cc5f
commit 199b994991
4 changed files with 27 additions and 13 deletions

1
conf/compiler_version Normal file
View File

@ -0,0 +1 @@
WX_COMPILER_VERSION=v0.0.1

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{
"name": "wechat-web-devtools-linux",
"name": "workspace",
"lockfileVersion": 2,
"requires": true,
"packages": {

View File

@ -12,6 +12,27 @@ package_dir="$root_dir/package.nw"
echo "fix: webview manager"
sed -i 's#module.exports = createWebviewManager;#module.exports = createWebviewManager,( /** @type {any} */ (window)).createWebviewManager = createWebviewManager;#g' "$package_dir/js/libs/vseditor/webview-resource/main.js"
echo "replace: wcc,wcsc linux version"
source "${srcdir}/conf/compiler_version"
mkdir -p "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}"
if [ ! -f "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcc" ];then
wget -c "https://github.com/msojocs/wx-compiler/releases/download/${WX_COMPILER_VERSION}/wcc" -O "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcc.tmp"
mv "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcc.tmp" "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcc"
chmod 0755 "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcc"
fi
if [ ! -f "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcsc" ];then
wget -c "https://github.com/msojocs/wx-compiler/releases/download/${WX_COMPILER_VERSION}/wcsc" -O "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcsc.tmp"
mv "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcsc.tmp" "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcsc"
chmod 0755 "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}/wcsc"
fi
# \cp -rf "${srcdir}/compiler/generatemd5.js" "${package_dir}/js/vendor/generatemd5.js"
\cp "${srcdir}/cache/compiler/${WX_COMPILER_VERSION}"/* "${package_dir}/node_modules/wcc-exec"
cd "${package_dir}/node_modules/wcc-exec" && chmod 0755 wcc wcsc && rm -rf wcc.exe wcsc.exe
# node "${package_dir}/js/vendor/generatemd5.js"
# 修复可视化用的wcc,wcsc
echo "fix: wcc,wcsc"
# wcc wcsc
@ -24,17 +45,9 @@ cd "${srcdir}/compiler" && npm install
&& chmod +x wcc/bin/linux/*
)
# 预览编译,设置 WINE!=true 环境变量生效
# 如果是mac执行wcc,否则wcc.exe
if [[ "$WINE" != 'true' ]];then
# \cp -rf "${srcdir}/compiler/generatemd5.js" "${package_dir}/js/vendor/generatemd5.js"
\cp "${srcdir}/compiler/nodejs"/* "${package_dir}/node_modules/wcc-exec"
cd "${package_dir}/node_modules/wcc-exec" && chmod 0755 wcc wcsc wcc.bin wcsc.bin
# node "${package_dir}/js/vendor/generatemd5.js"
current=`date "+%Y-%m-%d %H:%M:%S"`
timeStamp=`date -d "$current" +%s`
echo $timeStamp > "${package_dir}/.build_time"
current=`date "+%Y-%m-%d %H:%M:%S"`
timeStamp=`date -d "$current" +%s`
echo $timeStamp > "${package_dir}/.build_time"
fi
rm -rf "$tmp_dir/node_modules"

View File

@ -91,7 +91,7 @@ const download = function (url) {
util.format("../cache/wechat_devtools_%s_x64.exe", version)
);
let headers = execSync(`curl -IL "${url}"`).toString()
console.log(headers)
console.log('response header data:', headers)
md5 = headers.match(/X-COS-META-MD5: (.*?)\r/i)[1]
if (fs.existsSync(localPath)) {