diff --git a/readme.md b/readme.md index 2e56cda..5a4fb31 100644 --- a/readme.md +++ b/readme.md @@ -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; diff --git a/tools/fix-cli-node b/tools/fix-cli-node old mode 100644 new mode 100755 diff --git a/tools/fix-cloudconsole b/tools/fix-cloudconsole old mode 100644 new mode 100755 index 215ef77..5ffab53 --- a/tools/fix-cloudconsole +++ b/tools/fix-cloudconsole @@ -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" \ No newline at end of file diff --git a/tools/fix-package-name-node b/tools/fix-package-name-node old mode 100644 new mode 100755 diff --git a/tools/fix-selection-copy-node b/tools/fix-selection-copy-node old mode 100644 new mode 100755 diff --git a/tools/install-desktop-icon-node b/tools/install-desktop-icon-node old mode 100644 new mode 100755 diff --git a/tools/old/fix-cli b/tools/old/fix-cli deleted file mode 100644 index c6daa29..0000000 --- a/tools/old/fix-cli +++ /dev/null @@ -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); \ No newline at end of file diff --git a/tools/old/fix-package-name b/tools/old/fix-package-name deleted file mode 100644 index f719168..0000000 --- a/tools/old/fix-package-name +++ /dev/null @@ -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")); diff --git a/tools/old/fix-selection-copy b/tools/old/fix-selection-copy deleted file mode 100644 index 885eb34..0000000 --- a/tools/old/fix-selection-copy +++ /dev/null @@ -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)); diff --git a/tools/old/install-desktop-icon b/tools/old/install-desktop-icon deleted file mode 100644 index 240a01a..0000000 --- a/tools/old/install-desktop-icon +++ /dev/null @@ -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); diff --git a/tools/old/patch-wechat-devtools b/tools/old/patch-wechat-devtools deleted file mode 100644 index f37e7ca..0000000 --- a/tools/old/patch-wechat-devtools +++ /dev/null @@ -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); diff --git a/tools/old/setup-wechat-devtools b/tools/old/setup-wechat-devtools deleted file mode 100644 index 6abb3b8..0000000 --- a/tools/old/setup-wechat-devtools +++ /dev/null @@ -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`); - -}); diff --git a/tools/old/update-node b/tools/old/update-node deleted file mode 100644 index ff0e6da..0000000 --- a/tools/old/update-node +++ /dev/null @@ -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); - -}); diff --git a/tools/old/update-nwjs b/tools/old/update-nwjs deleted file mode 100644 index d463e66..0000000 --- a/tools/old/update-nwjs +++ /dev/null @@ -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); - -}); diff --git a/tools/old/update-wechat-devtools b/tools/old/update-wechat-devtools deleted file mode 100644 index 484d174..0000000 --- a/tools/old/update-wechat-devtools +++ /dev/null @@ -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("
{ - return a.split("")[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); - -}); diff --git a/tools/patch-wechat-devtools-node b/tools/patch-wechat-devtools-node old mode 100644 new mode 100755 diff --git a/tools/setup-wechat-devtools-node b/tools/setup-wechat-devtools-node old mode 100644 new mode 100755 diff --git a/tools/update-node-node b/tools/update-node-node old mode 100644 new mode 100755 diff --git a/tools/update-nwjs-node b/tools/update-nwjs-node old mode 100644 new mode 100755 diff --git a/tools/update-wechat-devtools-node b/tools/update-wechat-devtools-node old mode 100644 new mode 100755