mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
弱化对宿主环境的要求;
更新赞赏支持名单
This commit is contained in:
parent
848d6c9122
commit
a603376125
@ -1,6 +0,0 @@
|
||||
{
|
||||
"description": "此处版本应与nwjs使用的node版本一致",
|
||||
"version": "16.1.0",
|
||||
"url": "https://npm.taobao.org/mirrors/node/v${version}/node-v${version}-linux-x64.tar.gz",
|
||||
"url-global": "https://nodejs.org/download/release/v${version}/node-v${version}-linux-x64.tar.gz"
|
||||
}
|
6
conf/node_info
Normal file
6
conf/node_info
Normal file
@ -0,0 +1,6 @@
|
||||
# 此处版本应与nwjs使用的node版本一致
|
||||
if [ -z $NODE_VERSION ];then
|
||||
NODE_VERSION=16.1.0
|
||||
fi
|
||||
NODE_URL_CN=https://npm.taobao.org/mirrors/node/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz
|
||||
NODE_URL_GLOBAL=https://nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz
|
@ -15,7 +15,7 @@
|
||||
|
||||
3. 为什么自己构筑或更新后的运行时编辑器和调试器是一片空白?
|
||||
|
||||
检查一下`conf/node.json`和`conf/nwjs.json`里面定义的版本是否与最新微信官方开发者工具的一致。如果有修改版本号的情况,则在更新完这两个JSON文件后,执行`tools/update-node`和`tools/update-nwjs`命令。然后删除`package.nw`目录重新执行`tools/setup-wechat-devtools`命令(感谢ReggieCai31的issue和解决方案)
|
||||
检查一下`conf/node_info`和`conf/nwjs.json`里面定义的版本是否与最新微信官方开发者工具的一致。如果有修改版本号的情况,则在更新完这两个JSON文件后,执行`tools/update-node`和`tools/update-nwjs`命令。然后删除`package.nw`目录重新执行`tools/setup-wechat-devtools`命令(感谢ReggieCai31的issue和解决方案)
|
||||
|
||||
4. 为什么自己构筑的运行时加载项目时会卡住?
|
||||
|
||||
|
@ -95,8 +95,7 @@ docker-compose up
|
||||
|
||||
1. 如果构建`wine`版本,请先在Linux环境中自行安装`wine` `wine-binfmt`;
|
||||
2. 安装编译`nodegit`所需的依赖:`python2.7 python3.6及以上 libkrb5-dev gcc openssl libssh2-1-dev g++ make pkg-config`
|
||||
3. 请安装nodejs,并配置到PATH环境变量中,版本不限;
|
||||
4. 克隆本项目:
|
||||
3. 克隆本项目:
|
||||
```
|
||||
git clone https://github.com/msojocs/wechat-devtools-linux.git
|
||||
```
|
||||
@ -147,5 +146,6 @@ git clone https://github.com/msojocs/wechat-devtools-linux.git
|
||||
|
||||

|
||||
|
||||
# 感谢支持
|
||||
# 感谢赞赏支持
|
||||
1. *喆
|
||||
2. @shaoxp
|
0
test/core-test
Normal file → Executable file
0
test/core-test
Normal file → Executable file
2
test/env
Normal file → Executable file
2
test/env
Normal file → Executable file
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
console.log(process.env['action']==='true')
|
||||
console.log(process.version)
|
@ -27,7 +27,7 @@ echo "==========Initializing node=========="
|
||||
if [ -f "$root_dir/node/bin/node" ]; then
|
||||
success "node安装完毕"
|
||||
else
|
||||
node "$root_dir/tools/update-node-node"
|
||||
"$root_dir/tools/update-node.sh"
|
||||
success "node ok"
|
||||
fi
|
||||
|
||||
|
@ -1,120 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { execSync, spawn } = require("child_process");
|
||||
|
||||
const nodeConfig = require("../conf/node.json");
|
||||
const { exit } = require("process");
|
||||
|
||||
const download = function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
fs.mkdirSync(path.resolve(__dirname, "../cache"));
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
let url = process.env['ACTION_MODE'] === 'true'?nodeConfig["url-global"]:nodeConfig.url
|
||||
url = url.replace("${version}", nodeConfig.version)
|
||||
.replace("${version}", nodeConfig.version);
|
||||
|
||||
let localPath = path.resolve(
|
||||
__dirname,
|
||||
"../cache",
|
||||
url.split("?")[0].split("/").slice(-1)[0]
|
||||
);
|
||||
|
||||
if (fs.existsSync(localPath)) {
|
||||
console.info(`Cache available ${path.basename(localPath)}`);
|
||||
resolve(localPath);
|
||||
return;
|
||||
}
|
||||
|
||||
console.info(`Downloading ${url} ---> ${localPath}`);
|
||||
spawn("wget", ["-c", url, "-O", `${localPath}.tmp`], {
|
||||
stdio: "inherit",
|
||||
}).on("close", (code) => {
|
||||
fs.renameSync(`${localPath}.tmp`, localPath);
|
||||
resolve(localPath);
|
||||
});
|
||||
});
|
||||
};
|
||||
const extract = function (localPath) {
|
||||
console.info(`Extracting ${localPath}`);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
fs.mkdirSync(path.resolve(__dirname, "../tmp"));
|
||||
} catch (error) {}
|
||||
let extractPath = path.resolve(
|
||||
__dirname,
|
||||
`../tmp/${path.basename(localPath)}`
|
||||
);
|
||||
|
||||
execSync(`rm -rf ${extractPath}`);
|
||||
|
||||
fs.mkdirSync(extractPath);
|
||||
|
||||
spawn("tar", ["xf", localPath, '-C', extractPath], { stdio: "inherit" }).on(
|
||||
"close",
|
||||
(code) => {
|
||||
console.log(`Extracting result code: ${code}`)
|
||||
resolve(extractPath);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
const upgrade = function (extractPath) {
|
||||
console.info(`Upgrading ${path.basename(extractPath)}`);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execSync(`rm -rf ${path.resolve(__dirname, "../node")}`);
|
||||
|
||||
fs.renameSync(
|
||||
path.resolve(extractPath, fs.readdirSync(extractPath)[0]),
|
||||
path.resolve(__dirname, "../node")
|
||||
);
|
||||
|
||||
execSync(`rm -rf ${extractPath}`);
|
||||
|
||||
if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) {
|
||||
if (!fs.existsSync(path.resolve(__dirname, "../nwjs/node"))) {
|
||||
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -sr ../node/bin/node node`)
|
||||
}
|
||||
if (!fs.existsSync(path.resolve(__dirname, "../nwjs/node.exe"))) {
|
||||
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -s node node.exe`)
|
||||
}
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
const start = async () => {
|
||||
try {
|
||||
const args = process.argv.slice(2);
|
||||
if(args[0])nodeConfig.version=args[0]
|
||||
const nodePath = path.resolve(__dirname, "../node/bin/node")
|
||||
if(fs.existsSync(nodePath)){
|
||||
const version = execSync(`${path.resolve(__dirname, "../node/bin/node")} --version`).toString().replace('\n', '')
|
||||
if(version === `v${nodeConfig.version}`){
|
||||
console.log(`Node版本:${version} 已经安装,忽略`)
|
||||
exit(0)
|
||||
}else{
|
||||
console.log(`已安装Node版本:${version},将要安装v${nodeConfig.version}`)
|
||||
}
|
||||
}
|
||||
const localPath = await download();
|
||||
const extractPath = await extract(localPath);
|
||||
await upgrade(extractPath);
|
||||
|
||||
console.log(
|
||||
`Succeeded upgrading nodeConfig to version ${nodeConfig.version}`
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("异常", error);
|
||||
exit(-1)
|
||||
}
|
||||
};
|
||||
|
||||
start();
|
63
tools/update-node.sh
Executable file
63
tools/update-node.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||
|
||||
# 获取配置
|
||||
NODE_VERSION=$1
|
||||
source "$root_dir/conf/node_info"
|
||||
echo "NODE_VERSION:$NODE_VERSION"
|
||||
echo "NODE_URL_CN:$NODE_URL_CN"
|
||||
echo "NODE_URL_GLOBAL:$NODE_URL_GLOBAL"
|
||||
|
||||
# 检测安装
|
||||
if [ -f $root_dir/node/bin/node ];then
|
||||
# 存在,检测已有版本是否与要安装的版本一致
|
||||
version=$($root_dir/node/bin/node --version)
|
||||
if [ $version == "v$NODE_VERSION" ];then
|
||||
echo "已安装NODE版本: v$NODE_VERSION"
|
||||
exit 0
|
||||
fi
|
||||
# 不一致,装
|
||||
fi
|
||||
|
||||
# ########未安装或已有版本与目标版本不一致########
|
||||
|
||||
# 下载
|
||||
cache_dir="$root_dir/cache"
|
||||
mkdir -p $cache_dir
|
||||
if [ "$ACTION_MODE" == "true" ];then
|
||||
echo "ACTION_MODE true"
|
||||
url=$NODE_URL_GLOBAL
|
||||
else
|
||||
echo "ACTION_MODE false"
|
||||
url=$NODE_URL_CN
|
||||
fi
|
||||
parse=(${url//\// })
|
||||
localPath="$cache_dir/${parse[-1]}"
|
||||
if [ ! -f $localPath ];then
|
||||
# 不存在,下载
|
||||
wget -c $url -O${localPath}.tmp
|
||||
mv ${localPath}.tmp ${localPath}
|
||||
fi
|
||||
|
||||
# 解压(下载完成或已存在)
|
||||
tmp_dir="$root_dir/tmp"
|
||||
mkdir -p $tmp_dir
|
||||
extractPath="$tmp_dir/${parse[-1]}"
|
||||
rm -rf $extractPath
|
||||
mkdir -p $extractPath
|
||||
tar xf $localPath -C $extractPath
|
||||
|
||||
# 升级
|
||||
rm -rf "$root_dir/node"
|
||||
ls $extractPath | xargs -I {} mv $extractPath/{} "$root_dir/node"
|
||||
rm -rf $extractPath
|
||||
if [ -d "$root_dir/nwjs" ];then
|
||||
cd "$root_dir/nwjs"
|
||||
rm -rf node node.exe
|
||||
ln -s ../node/bin/node node
|
||||
ln -s node node.exe
|
||||
fi
|
||||
|
||||
echo "Succeeded upgrading node to version ${NODE_VERSION}"
|
Loading…
x
Reference in New Issue
Block a user