diff --git a/conf/nwjs.json b/conf/nwjs.json index 3ae4494..1ae6c9d 100644 --- a/conf/nwjs.json +++ b/conf/nwjs.json @@ -1,4 +1,4 @@ { - "version": "0.40.0", - "url": "https://npm.taobao.org/mirrors/nwjs/v${version}/nwjs-sdk-v${version}-linux-x64.tar.gz" + "version": "0.47.0", + "url": "https://oss.npmmirror.com/dist/nwjs/v${version}/nwjs-sdk-v${version}-linux-x64.tar.gz" } \ No newline at end of file diff --git a/readme.md b/readme.md index 1797ae4..54c6667 100644 --- a/readme.md +++ b/readme.md @@ -135,6 +135,9 @@ git clone https://github.com/dragonation/wechat-devtools.git # 界面截图 +版本 1.05.2201210 (待修复bug) +![screenshot 1.03.2006090](res/screenshots/1.05.2201210.png) + 版本 1.03.2006090 ![screenshot 1.03.2006090](res/screenshots/1.03.2006090.jpg) diff --git a/res/screenshots/1.05.2201210.png b/res/screenshots/1.05.2201210.png new file mode 100644 index 0000000..64c7529 Binary files /dev/null and b/res/screenshots/1.05.2201210.png differ diff --git a/tools/update-nwjs b/tools/update-nwjs index 21eb62b..7e3e147 100755 --- a/tools/update-nwjs +++ b/tools/update-nwjs @@ -38,7 +38,7 @@ const nwjs = require("../conf/nwjs.json"); lastSize = size; lastTime = now; lastProgress = progress; - process.stdout.write(`Downloaded ${@.fs.filename(localPath)}: ${progress.toFixed(2)}%, speed ${speed.toFixed(2)} KiB/s\r`); + @info(`Downloaded ${@.fs.filename(localPath)}: ${progress.toFixed(2)}%, speed ${speed.toFixed(2)} KiB/s`); } }, "onError": this.reject @@ -70,6 +70,7 @@ const nwjs = require("../conf/nwjs.json"); @.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")) diff --git a/tools/update-nwjs-node b/tools/update-nwjs-node new file mode 100644 index 0000000..7150ef3 --- /dev/null +++ b/tools/update-nwjs-node @@ -0,0 +1,118 @@ +#!/usr/bin/env node +const fs = require('fs') +const path = require('path') +const net = require('net') +const { spawn, execSync } = require('child_process'); +const util = require('util'); + +const download = (nwjs) => { + return new Promise((resolve, reject) => { + + try { + fs.mkdirSync(path.resolve(__dirname, "../cache")); + } catch (error) { + + } + + let url = nwjs.url.replace('${version}', nwjs.version).replace('${version}', nwjs.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}`); + + const wgetCMD = `wget -c ${url} -O ${localPath}.tmp` + console.log(`执行 --- ${wgetCMD}`) + const ls = spawn('wget', ['-c', url, '-O', `${localPath}.tmp`], { stdio: 'inherit' }); + + // ls.stdout.on('data', (data) => { + // console.log(`stdout: ${data}`); + // }); + + // ls.stderr.on('data', (data) => { + // console.log(data.length) + // process.stderr.write(data); + // }); + + ls.on('close', (code) => { + console.log(`child process exited with code ${code}`); + fs.rename(`${localPath}.tmp`, localPath, err => { + if (err) reject(err) + else resolve(localPath) + }) + }); + + }) +} +const extract = function (localPath) { + return new Promise((resolve, reject) => { + + console.info(`Extracting ${localPath}`); + + let extractPath = path.resolve(__dirname, `../tmp/${path.basename(localPath)}`); + + execSync(`rm -rf ${extractPath}`) + + fs.mkdirSync(extractPath); + + console.log(`执行 tar -xf ${localPath} -C ${extractPath}`) + // v参数可输出过程 + const tarP = spawn("tar", ["-xf", localPath, "-C", extractPath], { stdio: 'inherit' }); + tarP.on('error', (err) => { + reject(err) + }) + tarP.on('close', (code) => { + + console.log(`child process close all stdio with code ${code}`); + + resolve(extractPath); + }) + }) +} + +const upgrade = function (extractPath) { + + return new Promise((resolve, reject) => { + + console.info(`Upgrading ${path.basename(extractPath)}`); + + execSync(`rm -rf ${path.resolve(__dirname, "../nwjs")}`); + + fs.renameSync(path.resolve(extractPath, fs.readdirSync(extractPath)[0]), + path.resolve(__dirname, "../nwjs")) + + execSync(`rm -rf ${extractPath}`); + + if (fs.existsSync(path.resolve(__dirname, "../node/bin/node"))) { + fs.linkSync(path.resolve(__dirname, "../node/bin/node"), path.resolve(__dirname, "../nwjs/node")); + fs.linkSync(path.resolve(__dirname, "../node/bin/node"), path.resolve(__dirname, "../nwjs/node.exe")); + } + if (!fs.existsSync(path.resolve(__dirname, "../package.nw"))) { + fs.linkSync(path.resolve(__dirname, "../package.nw"), path.resolve(__dirname, "../nwjs/package.nw")); + } + + resolve(); + + }) +} +const init = async () => { + try { + const nwjs = require("../conf/nwjs.json"); + const localPath = await download(nwjs) + const extractPath = await extract(localPath) + const result = await upgrade(extractPath) + + console.info(`Succeeded upgrading nwjs to version ${nwjs.version}`); + } catch (error) { + + if (error) { + console.error('error--->', error); + } + } +} +init() \ No newline at end of file