update:整理

This commit is contained in:
msojocs 2022-02-05 10:22:50 +08:00
parent 70ca41b66e
commit 5321bffed0
20 changed files with 2 additions and 579 deletions

View File

@ -88,26 +88,6 @@ git clone https://github.com/msojocs/wechat-devtools.git
之后即可通过点击应用图标启动微信开发者工具,也可以运行`bin/wechat-devtools`通过命令行启动
# 构筑方法2 (不再维护,未来将被移除)
1. 请先在Linux环境中自行安装`wine``wine-binfmt`
2. 请到[Mewchan第三方仓库](https://github.com/wangjunjie1996/-.git)上下载最新的运行时,
并配置到PATH环境变量中;
3. 克隆本项目:
```
git clone https://github.com/msojocs/wechat-devtools.git
```
4. 在本地项目目录中执行如下的语句,构筑开发者工具:
```
./tools/setup-wechat-devtools
```
5. 在本地项目目录中执行如下的语句,可以安装应用图标(非必须):
```
./tools/install-desktop-icon
```
之后即可通过点击应用图标启动微信开发者工具,也可以运行`bin/wechat-devtools`通过命令行启动
# 与其他Linux下的微信开发者工具版本区别
1. 支持最新版本并个人会持续更新确保运行和测试OK才会上传Release

0
tools/fix-cli-node Normal file → Executable file
View File

4
tools/fix-cloudconsole Normal file → Executable file
View File

@ -11,7 +11,7 @@ node "$root_dir/tools/wxvpkg/unpack" "$package_dir/core.wxvpkg" "$tmp_dir/core.w
# find
open_find_result=$( grep -lr "this.props.onWindowOpenFail());" "$root_dir/tmp/core.wxvpkg" )
token_find_result=$( grep -lr "constructor(){this._sessionToken=\"\",this._tokenMap={}}" "$root_dir/tmp/core.wxvpkg" )
token_find_result=$( grep -lr "constructor(){this._sessionToken=\"\",this._tokenMap={}}" "$tmp_dir/core.wxvpkg" )
echo "云开发控制台启动点: $open_find_result"
echo "WebSocket token存储对象位置: $token_find_result"
@ -25,5 +25,5 @@ sed -i "s#constructor(){this._sessionToken=\"\",this._tokenMap={}}#$new_construc
# pack 路径 到 文件
node "$root_dir/tools/wxvpkg/pack" "$root_dir/tmp/core.wxvpkg" "$package_dir/core.wxvpkg"
node "$root_dir/tools/wxvpkg/pack" "$tmp_dir/core.wxvpkg" "$package_dir/core.wxvpkg"
rm -rf "$tmp_dir/core.wxvpkg"

0
tools/fix-package-name-node Normal file → Executable file
View File

0
tools/fix-selection-copy-node Normal file → Executable file
View File

0
tools/install-desktop-icon-node Normal file → Executable file
View File

View File

@ -1,17 +0,0 @@
#!/usr/bin/env mew_js
@info("Patching CLI command");
const rootDir = @.fs.dirname(__dirname);
let cli = @.fs.readFile.sync(@path(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.writeFile.sync(@path(rootDir, "package.nw/js/common/cli/index.js"), cli);

View File

@ -1,20 +0,0 @@
#!/usr/bin/env mew_js
const parseFile = function (path) {
if (!@.fs.exists(path)) {
return;
}
let content = JSON.parse(@.fs.readFile.sync(path, "utf8"));
content.name = "wechat_devtools";
// 开启调试,更新参数
content['chromium-args'] = content['chromium-args'].replace('--disable-devtools', '').replace('--ignore-gpu-blacklist', '--ignore-gpu-blocklist')
@.fs.writeFile.sync(path, JSON.stringify(content, null, 4));
};
parseFile(@path(__dirname, "../package.nw/package.json"));
parseFile(@path(__dirname, "../package.nw/package-lock.json"));

View File

@ -1,17 +0,0 @@
#!/usr/bin/env mew_js
@info("Patching editor selection copy configs");
let configPath = @.fs.homePath(".config/wechat_devtools/Default/Editor/User/settings.json");
let config = undefined;
if (@.fs.exists.file(configPath)) {
config = JSON.parse(@.fs.readFile.sync(configPath, "utf8"));
} else {
config = {};
}
config["editor.selectionClipboard"] = false;
@.fs.makeDirs(@.fs.dirname(configPath));
@.fs.writeFile.sync(configPath, JSON.stringify(config, null, 4));

View File

@ -1,22 +0,0 @@
#!/usr/bin/env mew_js
for (let size of ["64", "128", "256", "512"]) {
let iconPath = @.fs.homePath(`.local/share/icons/hicolor/${size}x${size}/wechat-devtools.png`);
@.fs.makeDirs(@.fs.dirname(iconPath));
@info(`Writing icon file ${iconPath}`);
@.fs.copyFile.sync(@path(__dirname, "../res/icons", `wechat-devtools${size}.png`), iconPath);
}
let svgPath = @.fs.homePath(".local/share/icons/hicolor/scalable/wechat-devtools.svg");
@.fs.makeDirs(@.fs.dirname(svgPath));
@info(`Writing icon file ${svgPath}`);
@.fs.copyFile.sync(@path(__dirname, "../res/icons/wechat-devtools.svg"), svgPath);
let desktopCode = @.format(@.fs.readFile.sync(@path(__dirname, "../res/template.desktop"), "utf8"), {
"dir": (@path(__dirname, ".."))
});
desktopPath = @.fs.homePath(".local/share/applications/wechat-devtools.desktop");
@.fs.makeDirs(@.fs.dirname(desktopPath));
@info(`Writing desktop file ${desktopPath}`);
@.fs.writeFile.sync(desktopPath, desktopCode);

View File

@ -1,32 +0,0 @@
#!/usr/bin/env mew_js
let code = @.fs.readFile.sync(@path(__dirname, "../package.nw/js/unpack/hackrequire/index.js"), "utf8");
let signatureBegin = "/* patch wechat devtools begin */\n";
let signatureEnd = "/* patch wechat devtools end */\n";
let index = code.indexOf(signatureBegin);
let patch = @.fs.listFiles(@path(__dirname, "../patch")).map((file) => {
if ((file.name[0] !== ".") && (@.fs.extname(file.name) === ".js")) {
return (`/* ${file.name} */\n` +
"(() => {\n\n" +
" try {\n\n" +
@.fs.readFile.sync(@path(__dirname, "../patch", file.name), "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.writeFile.sync(@path(__dirname, "../package.nw/js/unpack/hackrequire/index.js"),
signatureBegin + patch + signatureEnd + code);

View File

@ -1,42 +0,0 @@
#!/usr/bin/env mew_js
@.async(function () {
@info("Initializing node");
if (@.fs.exists(@path(__dirname, "../node"))) {
this.next(); return;
}
@.task.execute(@path(__dirname, "update-node"), [], false, this.test);
}).then(function () {
@info("Initializing nwjs");
if (@.fs.exists(@path(__dirname, "../nwjs"))) {
this.next(); return;
}
@.task.execute(@path(__dirname, "update-nwjs"), [], false, this.test);
}).then(function () {
@info("Initializing wechat-devtools package");
if (@.fs.exists(@path(__dirname, "../package.nw"))) {
this.next(); return;
}
@.task.execute(@path(__dirname, "update-wechat-devtools"), [], false, this.test);
}).finished((error) => {
if (error) {
@error(error);
process.exit(1);
}
@celebr(`Succeeded setting up wechat-devtools`);
});

View File

@ -1,100 +0,0 @@
#!/usr/bin/env mew_js
const node = require("../conf/node.json");
@.async(function () {
@.fs.makeDirs(@path(__dirname, "../cache"));
let client = @.net.httpClient();
let url = @.format(node.url, { "version": node.version });
let localPath = @path(__dirname, "../cache", url.split("?")[0].split("/").slice(-1)[0]);
if (@.fs.exists(localPath)) {
@info(`Cache available ${@.fs.filename(localPath)}`);
this.next(localPath);
return;
}
let lastSize = 0;
let lastProgress = 0;
let lastTime = Date.now();
@info(`Downloading ${url}`);
client.download(url, localPath, {
"resumeBroken": true,
"redirects": Object.create(null),
"onSuccess": () => {
this.next(localPath);
},
"onProgress": (size, total) => {
let progress = size / total * 100;
let now = Date.now();
if ((progress - lastProgress > 10) ||
(now - lastTime > 1000)) {
let speed = (size - lastSize) / (now - lastTime) * 1000 / 1024;
lastSize = size;
lastTime = now;
lastProgress = progress;
@info(`Downloaded ${@.fs.filename(localPath)}: ${progress.toFixed(2)}%, speed ${speed.toFixed(2)} KiB/s`);
}
},
"onError": this.reject
});
}).then(function (localPath) {
@info(`Extracting ${localPath}`);
let extractPath = @path(__dirname, `../tmp/${@.fs.basename(localPath)}`);
@.fs.deleteFile.sync(extractPath);
@.fs.makeDirs(extractPath);
@.task.execute("tar", ["xf", localPath], extractPath, (error) => {
if (error) {
this.reject(error); return;
}
this.next(extractPath);
});
}).then(function (extractPath) {
@info(`Upgrading ${@.fs.filename(extractPath)}`);
@.fs.deleteFile.sync(@path(__dirname, "../node"));
@.fs.moveFile.sync(@path(extractPath, @.fs.listFiles(extractPath)[0].name),
@path(__dirname, "../node"))
@.fs.deleteFile.sync(extractPath);
if (@.fs.exists(@path(__dirname, "../nwjs"))) {
if (!@.fs.exists(@path(__dirname, "../nwjs/node"))) {
@.fs.linkFile("../node/bin/node", @path(__dirname, "../nwjs/node"));
}
if (!@.fs.exists(@path(__dirname, "../nwjs/node.exe"))) {
@.fs.linkFile("node", @path(__dirname, "../nwjs/node.exe"));
}
}
this.next();
}).finished((error) => {
if (error) {
@error(error);
process.exit(1);
}
@celebr(`Succeeded upgrading node to version ${node.version}`);
process.exit(0);
});

View File

@ -1,100 +0,0 @@
#!/usr/bin/env mew_js
const nwjs = require("../conf/nwjs.json");
@.async(function () {
@.fs.makeDirs(@path(__dirname, "../cache"));
let client = @.net.httpClient();
let url = @.format(nwjs.url, { "version": nwjs.version });
let localPath = @path(__dirname, "../cache", url.split("?")[0].split("/").slice(-1)[0]);
if (@.fs.exists(localPath)) {
@info(`Cache available ${@.fs.filename(localPath)}`);
this.next(localPath);
return;
}
let lastSize = 0;
let lastProgress = 0;
let lastTime = Date.now();
@info(`Downloading ${url}`);
client.download(url, localPath, {
"resumeBroken": true,
"redirects": Object.create(null),
"onSuccess": () => {
this.next(localPath);
},
"onProgress": (size, total) => {
let progress = size / total * 100;
let now = Date.now();
if ((progress - lastProgress > 10) ||
(now - lastTime > 1000)) {
let speed = (size - lastSize) / (now - lastTime) * 1000 / 1024;
lastSize = size;
lastTime = now;
lastProgress = progress;
process.stdout.write(`Downloaded ${@.fs.filename(localPath)}: ${progress.toFixed(2)}%, speed ${speed.toFixed(2)} KiB/s\r`);
}
},
"onError": this.reject
});
}).then(function (localPath) {
@info(`Extracting ${localPath}`);
let extractPath = @path(__dirname, `../tmp/${@.fs.basename(localPath)}`);
@.fs.deleteFile.sync(extractPath);
@.fs.makeDirs(extractPath);
@.task.execute("tar", ["xf", localPath], extractPath, (error) => {
if (error) {
this.reject(error); return;
}
this.next(extractPath);
});
}).then(function (extractPath) {
@info(`Upgrading ${@.fs.filename(extractPath)}`);
@.fs.deleteFile.sync(@path(__dirname, "../nwjs"));
console.log(@path(extractPath, @.fs.listFiles(extractPath)[0].name))
@.fs.moveFile.sync(@path(extractPath, @.fs.listFiles(extractPath)[0].name),
@path(__dirname, "../nwjs"))
@.fs.deleteFile.sync(extractPath);
if (@.fs.exists(@path(__dirname, "../node/bin/node"))) {
@.fs.linkFile("../node/bin/node", @path(__dirname, "../nwjs/node"));
@.fs.linkFile("node", @path(__dirname, "../nwjs/node.exe"));
}
if (!@.fs.exists(@path(__dirname, "../package.nw"))) {
@.fs.linkFile("../package.nw", @path(__dirname, "../nwjs/package.nw"));
}
this.next();
}).finished((error) => {
if (error) {
@error(error);
process.exit(1);
}
@celebr(`Succeeded upgrading nwjs to version ${nwjs.version}`);
process.exit(0);
});

View File

@ -1,207 +0,0 @@
#!/usr/bin/env mew_js
const http = require("http");
const { info } = require("console");
const urls = {
"stable": "https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html",
"rc": "https://developers.weixin.qq.com/miniprogram/dev/devtools/rc.html",
"nightly": "https://developers.weixin.qq.com/miniprogram/dev/devtools/nightly.html"
};
let branch = @.process.switches().commands[0];
let ver = @.process.switches().commands[1];
if ((!branch) || (!urls[branch])) {
branch = "stable";
}
const url = urls[branch];
// "https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki";
// const url = "https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&version_type=1";
// https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=1022001191&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
let version = undefined;
const packageDir = "code/package.nw";
let client = @.net.httpClient();
@.async(function () {
@.fs.makeDirs(@path(__dirname, "../cache"));
info(`Fetching wechat-dev-tool info: ${url}`);
if(ver){
version = ver
this.next(`https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=${ver}&version_type=1`);
}else
client.request(url, {
"onSuccess": (result) => {
let links = {};
result.toString("utf8").split("<div class=\"page-inner\"")[1].split("<a href=\"").slice(1).map((a) => {
return a.split("</a>")[0];
}).filter((link) => link[0] != "#").forEach((link) => {
let content = link.split(">").slice(1).join(">").replace(/<([^>]*)>/g, "").replace(/\s+/g, "-").toLowerCase();
if ((content === "windows-64") || (content === "windows-32") || (content === "macos")) {
if (!links[content]) {
links[content] = [];
}
let url = link.split("\"")[0];
links[content].push(url);
info(`Found ${content} link: ${url}`);
}
});
if (!links["windows-64"][0]) {
error("No windows-64 dist found");
process.exit(1);
}
this.next(links["windows-64"][0]);
},
"onError": this.reject
})
}).then(function (url) {
@info(`Downloading ${url}`);
let localPath = @path(__dirname, "../cache/wechat-devtools-x64.exe");
let lastSize = 0;
let lastProgress = 0;
let lastTime = Date.now();
let filename = "wechat-devtools-x64.exe";
@.fs.deleteFile.sync(localPath);
client.download(url, localPath, {
"redirects": Object.create(null),
"onSuccess": () => {
let newPath = @path(__dirname, "../cache", filename);
@.fs.moveFile(localPath, newPath);
this.next(newPath);
},
"onRedirect": (location) => {
@info(`Redirected to ${location}`);
filename = location.split("?")[0].split("/").slice(-1)[0];
version = filename.split("_").filter((x) => /^[0-9]+\.[0-9]+.[0-9]+$/.test(x))[0];
let newPath = @path(__dirname, "../cache", filename);
if (@.fs.exists(newPath)) {
this.next(newPath);
return true;
}
},
"onProgress": (size, total) => {
let progress = size / total * 100;
let now = Date.now();
if ((progress - lastProgress > 10) ||
(now - lastTime > 1000)) {
let speed = (size - lastSize) / (now - lastTime) * 1000 / 1024;
lastSize = size;
lastTime = now;
lastProgress = progress;
process.stdout.write(`Downloaded ${filename}: ${progress.toFixed(2)}%, speed ${speed.toFixed(2)} KiB/s\r`);
}
},
"onError": this.reject
});
}).then(function (localPath) {
// 解压
@info(`Extracting ${localPath}`);
let extractPath = @path(__dirname, `../tmp/${@.fs.basename(localPath)}`);
@.fs.deleteFile.sync(extractPath);
@.fs.makeDirs(extractPath);
@.task.execute("7z", ["x", localPath, `-o${extractPath}`, packageDir], extractPath, (error) => {
if (error) {
this.reject(error); return;
}
this.next(extractPath);
});
}).then(function (extractPath) {
@info(`Upgrading ${@.fs.filename(extractPath)}`);
// 删除元文件
@.fs.deleteFile.sync(@path(__dirname, "../package.nw"));
// 替换
@.fs.moveFile.sync(@path(extractPath, packageDir),
@path(__dirname, "../package.nw"));
// 删除临时
@.fs.deleteFile.sync(extractPath);
if (@.fs.exists(@path(__dirname, "../nwjs"))) {
if (!@.fs.exists(@path(__dirname, "../nwjs/package.nw"))) {
// 链接
@.fs.linkFile("../package.nw", @path(__dirname, "../nwjs/package.nw"));
}
}
this.next();
}).then(function () {
@info("Patching wechat-devtools package name");
@.task.execute(@path(__dirname, "fix-package-name"), [], false, this.test);
}).then(function () {
@info("Patching wechat-devtools editor selection autocopy");
@.task.execute(@path(__dirname, "fix-selection-copy"), [], false, this.test);
}).then(function () {
@info("Patching wechat-devtools CLI supports");
@.task.execute(@path(__dirname, "fix-cli"), [], false, this.test);
}).then(function () {
@info("Rebuilding wechat-devtools node modules");
@.task.execute(@path(__dirname, "rebuild-node-modules"), [], false, this.test);
}).then(function () {
@info("Patching wechat-devtools");
@.task.execute(@path(__dirname, "patch-wechat-devtools"), [], false, this.test);
}).then(function () {
@info("Patching wcc and wcsc");
@.fs.copyFile.sync(@path(__dirname, "../wine/wcc"), @path(__dirname, "../package.nw/js/vendor/wcc"));
@.fs.copyFile.sync(@path(__dirname, "../wine/wcsc"), @path(__dirname, "../package.nw/js/vendor/wcsc"));
this.next();
}).finished((error) => {
if (error) {
@error(error);
process.exit(1);
}
@celebr(`Succeeded upgrading wechat-devtools to version ${version}`);
process.exit(0);
});

0
tools/patch-wechat-devtools-node Normal file → Executable file
View File

0
tools/setup-wechat-devtools-node Normal file → Executable file
View File

0
tools/update-node-node Normal file → Executable file
View File

0
tools/update-nwjs-node Normal file → Executable file
View File

0
tools/update-wechat-devtools-node Normal file → Executable file
View File