mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
update: 优化自定义开发工具版本号
This commit is contained in:
parent
418714ca65
commit
18e80ba04f
@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
"version": "0.53.1",
|
"version": "0.53.1",
|
||||||
"url": "https://oss.npmmirror.com/dist/nwjs/v${version}/nwjs-sdk-v${version}-linux-x64.tar.gz",
|
"url": "https://oss.npmmirror.com/dist/nwjs/v${version}/nwjs-sdk-v${version}-linux-x64.tar.gz",
|
||||||
|
"url-global": "https://dl.nwjs.io/v${version}/nwjs-sdk-v${version}-linux-x64.tar.gz",
|
||||||
"nw2node": {
|
"nw2node": {
|
||||||
|
"0.61.0": "17.3.0",
|
||||||
"0.60.0": "17.3.0",
|
"0.60.0": "17.3.0",
|
||||||
"0.59.1": "17.1.0",
|
"0.59.1": "17.1.0",
|
||||||
"0.59.0": "17.1.0",
|
"0.59.0": "17.1.0",
|
||||||
|
@ -35,14 +35,13 @@ if [ ! -f "$root_dir/node/bin/node" ]; then
|
|||||||
fail "Node安装失败"
|
fail "Node安装失败"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
# 将node加入环境
|
# 将node加入环境
|
||||||
export PATH="$root_dir/node/bin":$PATH
|
export PATH="$root_dir/node/bin":$PATH
|
||||||
echo "=====安装node-gyp nw-gyp===="
|
echo "=====安装node-gyp nw-gyp===="
|
||||||
npm uninstall node-gyp -g
|
npm uninstall node-gyp -g
|
||||||
npm install node-gyp nw-gyp npm -g --registry=https://registry.npm.taobao.org
|
npm install node-gyp nw-gyp npm -g --registry=https://registry.npm.taobao.org
|
||||||
node-gyp install
|
node-gyp install
|
||||||
node-gyp list
|
node-gyp list
|
||||||
|
|
||||||
|
|
||||||
echo "==========Initializing nwjs=========="
|
echo "==========Initializing nwjs=========="
|
||||||
if [ -f "$root_dir/nwjs/nw" ]; then
|
if [ -f "$root_dir/nwjs/nw" ]; then
|
||||||
@ -51,6 +50,7 @@ else
|
|||||||
node "$root_dir/tools/update-nwjs-node"
|
node "$root_dir/tools/update-nwjs-node"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 7z旧版本解压不正常
|
||||||
# rm -rf "$root_dir/tmp/7z"
|
# rm -rf "$root_dir/tmp/7z"
|
||||||
# mkdir -p "$root_dir/tmp/7z"
|
# mkdir -p "$root_dir/tmp/7z"
|
||||||
# cd "$root_dir/tmp/7z"
|
# cd "$root_dir/tmp/7z"
|
||||||
@ -58,10 +58,10 @@ fi
|
|||||||
# tar -xJf 7z2107-linux-x64.tar.xz
|
# tar -xJf 7z2107-linux-x64.tar.xz
|
||||||
# ln -s 7zz 7z
|
# ln -s 7zz 7z
|
||||||
# export PATH="$root_dir/tmp/7z:$PATH"
|
# export PATH="$root_dir/tmp/7z:$PATH"
|
||||||
# 7z
|
|
||||||
echo "==========Initializing wechat-devtools package=========="
|
echo "==========Initializing wechat-devtools package=========="
|
||||||
if [ -f "$root_dir/package.nw/package.json" ]; then
|
if [ -f "$root_dir/package.nw/package.json" ]; then
|
||||||
success "微信开发者工具安装完毕"
|
success "微信开发者工具安装完毕"
|
||||||
else
|
else
|
||||||
node "$root_dir/tools/update-wechat-devtools-node"
|
node "$root_dir/tools/update-wechat-devtools-node" $@
|
||||||
fi
|
fi
|
@ -1,93 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
const path = require("path");
|
|
||||||
const fs = require("fs");
|
|
||||||
const { spawn } = require("child_process");
|
|
||||||
|
|
||||||
const init_node = function () {
|
|
||||||
console.info("===============Initializing node=======================");
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (fs.existsSync(path.resolve(__dirname, "../node"))) {
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateNode = spawn(
|
|
||||||
path.resolve(__dirname, "update-node-node"),
|
|
||||||
[],
|
|
||||||
{
|
|
||||||
stdio: "inherit",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
updateNode.on("close", (code) => {
|
|
||||||
console.log(`Update Node code: ${code}`);
|
|
||||||
if (code === 0) resolve();
|
|
||||||
else reject();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const init_nwjs = function () {
|
|
||||||
console.info("==================Initializing nwjs==================");
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) {
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateNwjs = spawn(
|
|
||||||
path.resolve(__dirname, "update-nwjs-node"),
|
|
||||||
[],
|
|
||||||
{
|
|
||||||
stdio: "inherit",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
updateNwjs.on("close", (code) => {
|
|
||||||
console.log(`Update Nwjs result code: ${code}`);
|
|
||||||
if (code === 0) resolve();
|
|
||||||
else reject();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const init_wechat = function () {
|
|
||||||
console.info(
|
|
||||||
"==========Initializing wechat-devtools package=============="
|
|
||||||
);
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (fs.existsSync(path.resolve(__dirname, "../package.nw"))) {
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateWechat = spawn(
|
|
||||||
path.resolve(__dirname, "update-wechat-devtools-node"),
|
|
||||||
[],
|
|
||||||
{
|
|
||||||
stdio: "inherit",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
updateWechat.on("close", (code) => {
|
|
||||||
console.log(
|
|
||||||
`Initializing wechat-devtools package result code:${code}`
|
|
||||||
);
|
|
||||||
if (code === 0) resolve();
|
|
||||||
else reject();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const start = async () => {
|
|
||||||
try {
|
|
||||||
await init_node();
|
|
||||||
await init_nwjs();
|
|
||||||
await init_wechat();
|
|
||||||
|
|
||||||
console.log(`Succeeded setting up wechat-devtools`);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("异常", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
start();
|
|
@ -6,7 +6,7 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { info } = require("console");
|
const { info } = require("console");
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
const {exit} = require("process")
|
const { exit } = require("process");
|
||||||
|
|
||||||
const urls = {
|
const urls = {
|
||||||
stable: "https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html",
|
stable: "https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html",
|
||||||
@ -15,9 +15,13 @@ const urls = {
|
|||||||
"https://developers.weixin.qq.com/miniprogram/dev/devtools/nightly.html",
|
"https://developers.weixin.qq.com/miniprogram/dev/devtools/nightly.html",
|
||||||
};
|
};
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const arguments = process.argv.slice(2);
|
||||||
let branch = args[0];
|
const args = {};
|
||||||
let ver = args[1];
|
for (let arg of arguments) {
|
||||||
|
let t = arg.split("=");
|
||||||
|
args[t[0]] = t[1];
|
||||||
|
}
|
||||||
|
let branch = args.branch;
|
||||||
if (!branch || !urls[branch]) {
|
if (!branch || !urls[branch]) {
|
||||||
branch = "stable";
|
branch = "stable";
|
||||||
}
|
}
|
||||||
@ -29,7 +33,7 @@ const url = urls[branch];
|
|||||||
// https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=1021911180&version_type=1
|
// https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=1021911180&version_type=1
|
||||||
// https://dldir1.qq.com/WechatWebDev/nightly/p-7aa88fbb60d64e4a96fac38999591e31/wechat_devtools_1.02.2001202_x64.exe
|
// https://dldir1.qq.com/WechatWebDev/nightly/p-7aa88fbb60d64e4a96fac38999591e31/wechat_devtools_1.02.2001202_x64.exe
|
||||||
|
|
||||||
let version = undefined;
|
let version = args.version;
|
||||||
|
|
||||||
const packageDir = "code/package.nw";
|
const packageDir = "code/package.nw";
|
||||||
|
|
||||||
@ -39,14 +43,15 @@ const fetching = function () {
|
|||||||
fs.mkdirSync(path(__dirname, "../cache"));
|
fs.mkdirSync(path(__dirname, "../cache"));
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
|
|
||||||
info(`Fetching wechat-dev-tool info: ${url}`);
|
if (version && version !== "latest") {
|
||||||
|
if (!/\d+\.\d+\.\d+/.test(version)) reject("版本格式有误!");
|
||||||
if (ver) {
|
else {
|
||||||
version = ver;
|
resolve(
|
||||||
resolve(
|
`https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=${version.replace(/\./g, '')}&version_type=1`
|
||||||
`https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=${ver}&version_type=1`
|
);
|
||||||
);
|
}
|
||||||
} else {
|
} else {
|
||||||
|
info(`Fetching wechat-dev-tool info: ${url}`);
|
||||||
https
|
https
|
||||||
.get(url, (res) => {
|
.get(url, (res) => {
|
||||||
let result = "";
|
let result = "";
|
||||||
@ -124,11 +129,11 @@ const download = function (url) {
|
|||||||
|
|
||||||
ls.on("close", (code) => {
|
ls.on("close", (code) => {
|
||||||
console.info(`Download Wechat DevTools Result Code: ${code}`);
|
console.info(`Download Wechat DevTools Result Code: ${code}`);
|
||||||
if (code === 0){
|
if (code === 0) {
|
||||||
fs.renameSync(`${localPath}.tmp`, localPath);
|
fs.renameSync(`${localPath}.tmp`, localPath);
|
||||||
resolve(localPath);
|
resolve(localPath);
|
||||||
}else{
|
} else {
|
||||||
reject()
|
reject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -156,9 +161,9 @@ const extract = function (localPath) {
|
|||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ext.on("error", code=>{
|
ext.on("error", (code) => {
|
||||||
reject(code)
|
reject(code);
|
||||||
})
|
});
|
||||||
ext.on("close", (code) => {
|
ext.on("close", (code) => {
|
||||||
info(`解压完毕:${code}`);
|
info(`解压完毕:${code}`);
|
||||||
resolve(extractPath);
|
resolve(extractPath);
|
||||||
@ -181,22 +186,37 @@ const upgrade = function (extractPath) {
|
|||||||
|
|
||||||
// 尝试修改权限
|
// 尝试修改权限
|
||||||
try {
|
try {
|
||||||
execSync(`chmod -R 755 ${path.resolve(__dirname, '../package.nw')}`)
|
execSync(
|
||||||
|
`chmod -R 755 ${path.resolve(__dirname, "../package.nw")}`
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// ignore
|
// ignore
|
||||||
console.error(err)
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除临时
|
// 删除临时
|
||||||
execSync(`rm -rf ${extractPath}`);
|
execSync(`rm -rf ${extractPath}`);
|
||||||
|
|
||||||
if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) {
|
if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) {
|
||||||
if (!fs.statSync(__dirname, "../nwjs/package.nw").isSymbolicLink()) {
|
if (
|
||||||
execSync(`rm -rf ${path.resolve(__dirname, "../nwjs/package.nw")}`)
|
!fs.statSync(__dirname, "../nwjs/package.nw").isSymbolicLink()
|
||||||
console.log(`创建链接 ${path.resolve(__dirname, "../package.nw")}--->${path.resolve(__dirname, "../nwjs/package.nw")}`)
|
) {
|
||||||
|
execSync(
|
||||||
|
`rm -rf ${path.resolve(__dirname, "../nwjs/package.nw")}`
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`创建链接 ${path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../package.nw"
|
||||||
|
)}--->${path.resolve(__dirname, "../nwjs/package.nw")}`
|
||||||
|
);
|
||||||
// 链接
|
// 链接
|
||||||
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -s ../package.nw package.nw`)
|
execSync(
|
||||||
|
`cd ${path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../nwjs"
|
||||||
|
)} && ln -s ../package.nw package.nw`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,19 +272,24 @@ 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(path.resolve(__dirname, "rebuild-node-modules.sh"), [nwConfig.version], {
|
const e = spawn(
|
||||||
stdio: "inherit",
|
path.resolve(__dirname, "rebuild-node-modules.sh"),
|
||||||
})
|
[nwConfig.version],
|
||||||
e.on("error", code=>{
|
{
|
||||||
reject(code)
|
stdio: "inherit",
|
||||||
})
|
}
|
||||||
|
);
|
||||||
|
e.on("error", (code) => {
|
||||||
|
reject(code);
|
||||||
|
});
|
||||||
e.on("close", (code) => {
|
e.on("close", (code) => {
|
||||||
console.info(`Rebuilding wechat-devtools node modules Result Code: ${code}`)
|
console.info(
|
||||||
if(0 === code)
|
`Rebuilding wechat-devtools node modules Result Code: ${code}`
|
||||||
resolve();
|
);
|
||||||
else{
|
if (0 === code) resolve();
|
||||||
reject(code)
|
else {
|
||||||
|
reject(code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -273,13 +298,9 @@ 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(
|
const exec = spawn(path.resolve(__dirname, "fix-menu.sh"), [], {
|
||||||
path.resolve(__dirname, "fix-menu.sh"),
|
stdio: "inherit",
|
||||||
[],
|
});
|
||||||
{
|
|
||||||
stdio: "inherit",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
exec.on("close", (code) => {
|
exec.on("close", (code) => {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
@ -289,7 +310,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.sh"))
|
execSync(path.resolve(__dirname, "fix-other.sh"));
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
@ -309,13 +330,16 @@ const start = async () => {
|
|||||||
await patch_wechat_devtools();
|
await patch_wechat_devtools();
|
||||||
await patch_other();
|
await patch_other();
|
||||||
// 写入构建时间戳
|
// 写入构建时间戳
|
||||||
fs.writeFileSync(path.resolve(__dirname, '../package.nw/.build_time'), '' + parseInt(new Date().getTime()/1000))
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, "../package.nw/.build_time"),
|
||||||
|
"" + parseInt(new Date().getTime() / 1000)
|
||||||
|
);
|
||||||
console.log(
|
console.log(
|
||||||
`Succeeded upgrading wechat-devtools to version ${version}`
|
`Succeeded upgrading wechat-devtools to version ${version}`
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("异常", error);
|
console.error("异常", error);
|
||||||
exit(-1)
|
exit(-1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
start();
|
start();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user