makedeb
WeChat Devtools For Linux.
Click here to go back to the commit logs for wechat-devtools.
Hash: 4771ab73036a3a642851e9042877face3505893f
Message: fix
diff --git a/.SRCINFO b/.SRCINFO
index 3562a0a..5ed4ccd 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,39 +1,40 @@
+generated-by = makedeb-makepkg
+
pkgbase = wechat-devtools
pkgdesc = WeChat Devtools For Linux.
pkgver = 1.05.2201240
- pkgrel = 13
+ pkgrel = 15
epoch = 2
url = https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
arch = x86_64
license = unknown
makedepends = p7zip
- makedepends = python2
makedepends = openssl
makedepends = gcc
makedepends = make
- makedepends = libssh2
- makedepends = krb5
- depends = gconf
- depends = libxkbfile
+ makedepends = libssh2-1-dev
+ makedepends = libkrb5-dev
+ depends = gconf2
+ depends = libxkbfile-dev
options = !strip
source = nwjs-v0.53.1.tar.gz::https://npm.taobao.org/mirrors/nwjs/v0.53.1/nwjs-sdk-v0.53.1-linux-x64.tar.gz
source = wechat_devtools_1.05.2201240_x64.exe::https://dldir1.qq.com/WechatWebDev/release/p-ae42ee2cde4d42ee80ac60b35f183a99/wechat_devtools_1.05.2201240_x64.exe
source = node-v16.1.0.tar.gz::https://npm.taobao.org/mirrors/node/v16.1.0/node-v16.1.0-linux-x64.tar.gz
- source = compiler.tar.gz::https://download.fastgit.org/msojocs/wechat-devtools-linux/releases/download/v0.17/compiler.tar.gz
+ source = compiler.tar.gz::https://github.com/msojocs/wechat-devtools-linux/releases/download/v0.19/compiler.tar.gz
source = wechat-devtools.desktop
source = logo.svg
source = fix-cli.sh
source = fix-menu.sh
source = fix-core.sh
- source = rebuild-modules.sh
- source = fix-package-name-node
- source = wxvpkg_pack
- source = wxvpkg_unpack
+ source = rebuild-node-modules.sh
+ source = fix-package-name.js
+ source = wxvpkg_pack.js
+ source = wxvpkg_unpack.js
source = fix-other.sh
md5sums = b6f49803c51d0abacca2d1e566c7fe19
md5sums = 85552bae33e98eb186c5068419efce03
md5sums = 2280bfbbf29981fd5adce334f40146ff
- md5sums = 87a3849f7105f411bee25da9532b0382
+ md5sums = a9e061c97afbbc295b5664a2d8065492
md5sums = 1abd6b4ebbbb918f601a6c5dbad55a05
md5sums = 0f4353664123320280ea4d6bb295dce2
md5sums = SKIP
diff --git a/fix-package-name-node b/fix-package-name-node
deleted file mode 100644
index a37f59e..0000000
--- a/fix-package-name-node
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env node
-const path = require("path");
-const fs = require("fs");
-
-const parseFile = function (path) {
-
- if (!fs.existsSync(path)) {
- return;
- }
- let content = JSON.parse(fs.readFileSync(path, "utf8"));
-
- content.name = "wechat_devtools";
- // 开启调试,更新参数
- content['chromium-args'] = content['chromium-args'].replace('--ignore-gpu-blacklist', '--ignore-gpu-blocklist') + ' --mixed-context'
- content.window.height = content.window.width = 1000
- fs.writeFileSync(path, JSON.stringify(content, null, 4));
-
-};
-
-const pkgDir = process.env['NW_PACKAGE_DIR']
-parseFile(`${pkgDir}/package.json`);
-parseFile(`${pkgDir}/package-lock.json`);
diff --git a/fix-package-name.js b/fix-package-name.js
new file mode 100644
index 0000000..a37f59e
--- /dev/null
+++ b/fix-package-name.js
@@ -0,0 +1,22 @@
+#!/usr/bin/env node
+const path = require("path");
+const fs = require("fs");
+
+const parseFile = function (path) {
+
+ if (!fs.existsSync(path)) {
+ return;
+ }
+ let content = JSON.parse(fs.readFileSync(path, "utf8"));
+
+ content.name = "wechat_devtools";
+ // 开启调试,更新参数
+ content['chromium-args'] = content['chromium-args'].replace('--ignore-gpu-blacklist', '--ignore-gpu-blocklist') + ' --mixed-context'
+ content.window.height = content.window.width = 1000
+ fs.writeFileSync(path, JSON.stringify(content, null, 4));
+
+};
+
+const pkgDir = process.env['NW_PACKAGE_DIR']
+parseFile(`${pkgDir}/package.json`);
+parseFile(`${pkgDir}/package-lock.json`);
diff --git a/rebuild-modules.sh b/rebuild-modules.sh
deleted file mode 100644
index e58bca7..0000000
--- a/rebuild-modules.sh
+++ /dev/null
@@ -1,115 +0,0 @@
-#! /bin/bash
-
-set -e
-
-if [ -z "$NW_PACKAGE_DIR" ]; then
- echo -e "\e[1;31m\$NW_PACKAGE_DIR is empty\e[0m" >&2
- exit 1
-fi
-
-if [ -z "$NW_VERSION" ]; then
- echo -e "\e[1;31m\$NW_VERSION is empty\e[0m" >&2
- exit 1
-fi
-
-TEMP_DIR=$(mktemp -d)
-trap "{ rm -rf $TEMP_DIR; }" EXIT
-
-# prepare python2
-# fix https://github.com/nwjs/nw-gyp/issues/122
-ln -sf "$(which python2)" "$TEMP_DIR/python"
-export PATH=$TEMP_DIR:$PATH
-
-node_modules="$NW_PACKAGE_DIR/node_modules"
-dry_run="n"
-package_dir="$NW_PACKAGE_DIR"
-
-if [ ! -d "$node_modules" ]; then
- echo -e "\e[1;31m$node_modules is not exist\e[0m" >&2
- exit 1
-fi
-
-# 以下原封复制
-# 代理处理
-echo "尝试取消所有代理"
-unset http_proxy
-unset HTTP_PROXY
-unset https_proxy
-unset HTTPS_PROXY
-unset socket_proxy
-unset SOCKET_PROXY
-unset all_proxy
-unset ALL_PROXY
-
-echo -e "\033[42;37m ######## 版本信息 $(date '+%Y-%m-%d %H:%M:%S') ########\033[0m"
-echo "NW VERSION: $NW_VERSION"
-echo "nw-gyp version: $( nw-gyp --version )"
-echo "node version: $(node --version )"
-echo "npm version: $(npm --version )"
-python --version
-
-rm -fr "${package_dir}/node_modules/vscode-windows-ca-certs" # the module is only available in windows
-rm -fr "${package_dir}/node_modules/vscode-windows-registry" # the module is only available in windows
-rm -fr "${package_dir}/node_modules/vscode-windows-registry-node" # the module is only available in windows
-rm -fr "${package_dir}/node_modules/windows-process-tree" # the module is only available in windows
-
-rm -fr "${package_dir}/node_modules/vscode-ripgrep/bin" # redownload bin on linux
-
-rm -fr "${package_dir}/node_modules/node-pty" "${package_dir}/node_modules/node-pty-node" # the native module is not available in windows
-
-(cd "${package_dir}/node_modules" && find -name *.pdb | xargs -I{} rm -r {}) # remove pdb debugging file
-
-rm -fr "${package_dir}/node_modules_tmp" # remove previous hacking tmp
-mkdir -p "${package_dir}/node_modules_tmp"
-cp -fr "${package_dir}/node_modules" "${package_dir}/node_modules_tmp/node_modules"
-
-rm -fr "${package_dir}/node_modules_tmp/node_modules/node-pty"
-rm -fr "${package_dir}/node_modules_tmp/node_modules/node-pty-node"
-rm -fr "${package_dir}/node_modules_tmp/node_modules/native-watchdog"
-rm -fr "${package_dir}/node_modules_tmp/node_modules/oniguruma-node"
-rm -fr "${package_dir}/node_modules_tmp/node_modules/nodegit"
-rm -fr "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep"
-rm -fr "${package_dir}/node_modules_tmp/node_modules/spdlog"
-rm -fr "${package_dir}/node_modules_tmp/node_modules/spdlog-node"
-
-(cd "${package_dir}/node_modules_tmp" && npm install \
- extract-file-icon \
- native-keymap \
- node-pty \
- native-watchdog \
- oniguruma \
- spdlog@0.11.1 \
- trash \
- vscode-oniguruma \
- vscode-ripgrep \
- nodegit \
- --registry=https://registry.npm.taobao.org \
- --nodegit_binary_host_mirror=https://npm.taobao.org/mirrors/nodegit/v0.27.0/) # reinstall modules
-
-# rebuild
-cd "$package_dir/node_modules_tmp/node_modules/node-pty" && nw-gyp rebuild --arch=x64 "--target=$NW_VERSION" --dist-url=https://registry.npmmirror.com/-/binary/nwjs
-(cp -fr "${package_dir}/node_modules_tmp/node_modules/node-pty" "${package_dir}/node_modules_tmp/node_modules/node-pty-node")
-rm -rf "${package_dir}/node_modules/node-pty" "${package_dir}/node_modules/node-pty-node"
-cp -fr "${package_dir}/node_modules_tmp/node_modules/node-pty" "${package_dir}/node_modules"
-(cp -fr "${package_dir}/node_modules/node-pty" "${package_dir}/node_modules/node-pty-node")
-
-cd "$package_dir/node_modules_tmp/node_modules/native-watchdog" && nw-gyp rebuild --arch=x64 "--target=$NW_VERSION" --dist-url=https://registry.npmmirror.com/-/binary/nwjs
-rm -rf "${package_dir}/node_modules/native-watchdog" && cp -fr "${package_dir}/node_modules_tmp/node_modules/native-watchdog" "${package_dir}/node_modules"
-
-cd "${package_dir}/node_modules_tmp/node_modules/nodegit" && rm -rf .github include src lifecycleScripts vendor utils build/vendor build/Release/.deps
-cp -fr "${package_dir}/node_modules_tmp/node_modules/nodegit" "${package_dir}/node_modules"
-
-(cp -fr "${package_dir}/node_modules_tmp/node_modules/oniguruma" "${package_dir}/node_modules_tmp/node_modules/oniguruma-node")
-(cp -fr "${package_dir}/node_modules_tmp/node_modules/spdlog" "${package_dir}/node_modules_tmp/node_modules/spdlog-node")
-
-(cd "${package_dir}/node_modules_tmp/node_modules" && find -name ".deps" | xargs -I{} rm -rf {} && find -name "obj.target" | xargs -I{} rm -rf {} && find -name "*.a" -delete && find -name "*.lib" -delete && find -name "*.mk" -delete)
-(cd "${package_dir}/node_modules_tmp/node_modules" && find -name "*.node" | xargs -I{} \cp -rf {} ${package_dir}/node_modules/{})
-
-mkdir -p "${package_dir}/node_modules/vscode-ripgrep/bin"
-\cp -fr "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep/bin/rg" "${package_dir}/node_modules/vscode-ripgrep/bin/rg"
-
-(cd "${package_dir}/node_modules" && find -name ".deps" | xargs -I{} rm -rf {} && find -name "obj.target" | xargs -I{} rm -rf {} && find -name "*.a" -delete && find -name "*.lib" -delete && find -name "*.mk" -delete && find -name "*Makefile" -delete && find -name "*gyp*" -delete)
-rm -rf "${package_dir}/node_modules_tmp"
-
-# 移除旧配置
-# rm -fr ~/.config/wechat_devtools
diff --git a/rebuild-node-modules.sh b/rebuild-node-modules.sh
new file mode 100644
index 0000000..e58bca7
--- /dev/null
+++ b/rebuild-node-modules.sh
@@ -0,0 +1,115 @@
+#! /bin/bash
+
+set -e
+
+if [ -z "$NW_PACKAGE_DIR" ]; then
+ echo -e "\e[1;31m\$NW_PACKAGE_DIR is empty\e[0m" >&2
+ exit 1
+fi
+
+if [ -z "$NW_VERSION" ]; then
+ echo -e "\e[1;31m\$NW_VERSION is empty\e[0m" >&2
+ exit 1
+fi
+
+TEMP_DIR=$(mktemp -d)
+trap "{ rm -rf $TEMP_DIR; }" EXIT
+
+# prepare python2
+# fix https://github.com/nwjs/nw-gyp/issues/122
+ln -sf "$(which python2)" "$TEMP_DIR/python"
+export PATH=$TEMP_DIR:$PATH
+
+node_modules="$NW_PACKAGE_DIR/node_modules"
+dry_run="n"
+package_dir="$NW_PACKAGE_DIR"
+
+if [ ! -d "$node_modules" ]; then
+ echo -e "\e[1;31m$node_modules is not exist\e[0m" >&2
+ exit 1
+fi
+
+# 以下原封复制
+# 代理处理
+echo "尝试取消所有代理"
+unset http_proxy
+unset HTTP_PROXY
+unset https_proxy
+unset HTTPS_PROXY
+unset socket_proxy
+unset SOCKET_PROXY
+unset all_proxy
+unset ALL_PROXY
+
+echo -e "\033[42;37m ######## 版本信息 $(date '+%Y-%m-%d %H:%M:%S') ########\033[0m"
+echo "NW VERSION: $NW_VERSION"
+echo "nw-gyp version: $( nw-gyp --version )"
+echo "node version: $(node --version )"
+echo "npm version: $(npm --version )"
+python --version
+
+rm -fr "${package_dir}/node_modules/vscode-windows-ca-certs" # the module is only available in windows
+rm -fr "${package_dir}/node_modules/vscode-windows-registry" # the module is only available in windows
+rm -fr "${package_dir}/node_modules/vscode-windows-registry-node" # the module is only available in windows
+rm -fr "${package_dir}/node_modules/windows-process-tree" # the module is only available in windows
+
+rm -fr "${package_dir}/node_modules/vscode-ripgrep/bin" # redownload bin on linux
+
+rm -fr "${package_dir}/node_modules/node-pty" "${package_dir}/node_modules/node-pty-node" # the native module is not available in windows
+
+(cd "${package_dir}/node_modules" && find -name *.pdb | xargs -I{} rm -r {}) # remove pdb debugging file
+
+rm -fr "${package_dir}/node_modules_tmp" # remove previous hacking tmp
+mkdir -p "${package_dir}/node_modules_tmp"
+cp -fr "${package_dir}/node_modules" "${package_dir}/node_modules_tmp/node_modules"
+
+rm -fr "${package_dir}/node_modules_tmp/node_modules/node-pty"
+rm -fr "${package_dir}/node_modules_tmp/node_modules/node-pty-node"
+rm -fr "${package_dir}/node_modules_tmp/node_modules/native-watchdog"
+rm -fr "${package_dir}/node_modules_tmp/node_modules/oniguruma-node"
+rm -fr "${package_dir}/node_modules_tmp/node_modules/nodegit"
+rm -fr "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep"
+rm -fr "${package_dir}/node_modules_tmp/node_modules/spdlog"
+rm -fr "${package_dir}/node_modules_tmp/node_modules/spdlog-node"
+
+(cd "${package_dir}/node_modules_tmp" && npm install \
+ extract-file-icon \
+ native-keymap \
+ node-pty \
+ native-watchdog \
+ oniguruma \
+ spdlog@0.11.1 \
+ trash \
+ vscode-oniguruma \
+ vscode-ripgrep \
+ nodegit \
+ --registry=https://registry.npm.taobao.org \
+ --nodegit_binary_host_mirror=https://npm.taobao.org/mirrors/nodegit/v0.27.0/) # reinstall modules
+
+# rebuild
+cd "$package_dir/node_modules_tmp/node_modules/node-pty" && nw-gyp rebuild --arch=x64 "--target=$NW_VERSION" --dist-url=https://registry.npmmirror.com/-/binary/nwjs
+(cp -fr "${package_dir}/node_modules_tmp/node_modules/node-pty" "${package_dir}/node_modules_tmp/node_modules/node-pty-node")
+rm -rf "${package_dir}/node_modules/node-pty" "${package_dir}/node_modules/node-pty-node"
+cp -fr "${package_dir}/node_modules_tmp/node_modules/node-pty" "${package_dir}/node_modules"
+(cp -fr "${package_dir}/node_modules/node-pty" "${package_dir}/node_modules/node-pty-node")
+
+cd "$package_dir/node_modules_tmp/node_modules/native-watchdog" && nw-gyp rebuild --arch=x64 "--target=$NW_VERSION" --dist-url=https://registry.npmmirror.com/-/binary/nwjs
+rm -rf "${package_dir}/node_modules/native-watchdog" && cp -fr "${package_dir}/node_modules_tmp/node_modules/native-watchdog" "${package_dir}/node_modules"
+
+cd "${package_dir}/node_modules_tmp/node_modules/nodegit" && rm -rf .github include src lifecycleScripts vendor utils build/vendor build/Release/.deps
+cp -fr "${package_dir}/node_modules_tmp/node_modules/nodegit" "${package_dir}/node_modules"
+
+(cp -fr "${package_dir}/node_modules_tmp/node_modules/oniguruma" "${package_dir}/node_modules_tmp/node_modules/oniguruma-node")
+(cp -fr "${package_dir}/node_modules_tmp/node_modules/spdlog" "${package_dir}/node_modules_tmp/node_modules/spdlog-node")
+
+(cd "${package_dir}/node_modules_tmp/node_modules" && find -name ".deps" | xargs -I{} rm -rf {} && find -name "obj.target" | xargs -I{} rm -rf {} && find -name "*.a" -delete && find -name "*.lib" -delete && find -name "*.mk" -delete)
+(cd "${package_dir}/node_modules_tmp/node_modules" && find -name "*.node" | xargs -I{} \cp -rf {} ${package_dir}/node_modules/{})
+
+mkdir -p "${package_dir}/node_modules/vscode-ripgrep/bin"
+\cp -fr "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep/bin/rg" "${package_dir}/node_modules/vscode-ripgrep/bin/rg"
+
+(cd "${package_dir}/node_modules" && find -name ".deps" | xargs -I{} rm -rf {} && find -name "obj.target" | xargs -I{} rm -rf {} && find -name "*.a" -delete && find -name "*.lib" -delete && find -name "*.mk" -delete && find -name "*Makefile" -delete && find -name "*gyp*" -delete)
+rm -rf "${package_dir}/node_modules_tmp"
+
+# 移除旧配置
+# rm -fr ~/.config/wechat_devtools
diff --git a/wxvpkg_pack b/wxvpkg_pack
deleted file mode 100644
index 6918c52..0000000
--- a/wxvpkg_pack
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env node
-
-// https://gist.github.com/chemzqm/9f2334ca201dc2fbc363fdd757aa2ed4
-const path = require('path')
-const fs = require('fs')
-const { execSync } = require('child_process')
-
-const args = process.argv.slice(2);
-const from = args[0]
-const to = args[1]
-
-let file = to
-console.log(file)
-if (fs.existsSync(file)) {
- execSync(`rm -rf ${file}`)
-}
-
-let fd = fs.openSync(file, 'w')
-let dest = from
-
-function writeSync(buf, start) {
- fs.writeSync(fd, buf, 0, buf.length, start)
-}
-
-function writeInt32(number, start) {
- let buf = Buffer.alloc(4)
- buf.writeInt32BE(number, 0)
- writeSync(buf, start)
-}
-
-let files = fs.readdirSync(dest)
-let totalCount = files.length
-let buf = Buffer.alloc(4)
-buf.writeInt32BE(totalCount, 0)
-writeSync(buf, 14)
-let start = 18
-// 12 + /name.length
-let dataOffset = start
-for (let file of files) {
- let name = `/${file}`
- let buf = Buffer.from(name, 'utf8')
- dataOffset = dataOffset + 12 + buf.length
-}
-
-for (let file of files) {
- let nb = Buffer.from(`/${file}`, 'utf8')
- // write filename byte length
- writeInt32(nb.length, start)
- start += 4
- // write filename
- writeSync(nb, start)
- start += nb.length
- // write offset
- writeInt32(dataOffset, start)
- start += 4
- // write length
- let contentBuf = fs.readFileSync(path.join(dest, file))
- writeInt32(contentBuf.length, start)
- start += 4
- // write content
- writeSync(contentBuf, dataOffset)
- dataOffset += contentBuf.length
-}
-
-fs.closeSync(fd)
\ No newline at end of file
diff --git a/wxvpkg_pack.js b/wxvpkg_pack.js
new file mode 100644
index 0000000..6918c52
--- /dev/null
+++ b/wxvpkg_pack.js
@@ -0,0 +1,65 @@
+#!/usr/bin/env node
+
+// https://gist.github.com/chemzqm/9f2334ca201dc2fbc363fdd757aa2ed4
+const path = require('path')
+const fs = require('fs')
+const { execSync } = require('child_process')
+
+const args = process.argv.slice(2);
+const from = args[0]
+const to = args[1]
+
+let file = to
+console.log(file)
+if (fs.existsSync(file)) {
+ execSync(`rm -rf ${file}`)
+}
+
+let fd = fs.openSync(file, 'w')
+let dest = from
+
+function writeSync(buf, start) {
+ fs.writeSync(fd, buf, 0, buf.length, start)
+}
+
+function writeInt32(number, start) {
+ let buf = Buffer.alloc(4)
+ buf.writeInt32BE(number, 0)
+ writeSync(buf, start)
+}
+
+let files = fs.readdirSync(dest)
+let totalCount = files.length
+let buf = Buffer.alloc(4)
+buf.writeInt32BE(totalCount, 0)
+writeSync(buf, 14)
+let start = 18
+// 12 + /name.length
+let dataOffset = start
+for (let file of files) {
+ let name = `/${file}`
+ let buf = Buffer.from(name, 'utf8')
+ dataOffset = dataOffset + 12 + buf.length
+}
+
+for (let file of files) {
+ let nb = Buffer.from(`/${file}`, 'utf8')
+ // write filename byte length
+ writeInt32(nb.length, start)
+ start += 4
+ // write filename
+ writeSync(nb, start)
+ start += nb.length
+ // write offset
+ writeInt32(dataOffset, start)
+ start += 4
+ // write length
+ let contentBuf = fs.readFileSync(path.join(dest, file))
+ writeInt32(contentBuf.length, start)
+ start += 4
+ // write content
+ writeSync(contentBuf, dataOffset)
+ dataOffset += contentBuf.length
+}
+
+fs.closeSync(fd)
\ No newline at end of file
diff --git a/wxvpkg_unpack b/wxvpkg_unpack
deleted file mode 100644
index 14c46a5..0000000
--- a/wxvpkg_unpack
+++ /dev/null
@@ -1,50 +0,0 @@
-// Extract core.wxvpkg of current folder to dest folder
-const path = require('path')
-const fs = require('fs')
-
-const args = process.argv.slice(2);
-const from = args[0]
-const to = args[1]
-
-let dest = to
-fs.mkdirSync(dest, {recursive: true})
-let file = from
-let fd = fs.openSync(file, 'r')
-
-// read buffer
-function readSync(start, length) {
- const n = Buffer.alloc(length);
- fs.readSync(fd, n, 0, length, start)
- return n
-}
-
-const totalCount = readSync(14, 4).readInt32BE(0)
-const map = {};
-let n = 18;
-for (let i = 0; i < totalCount; i++) {
- const e = {};
- // byte length of filename
- const i = readSync(n, 4).readInt32BE(0);
- n += 4;
- e.name = readSync(n, i).toString();
- n += i;
- e.offset = readSync(n, 4).readInt32BE(0);
- n += 4;
- e.length = readSync(n, 4).readInt32BE(0);
- n += 4;
- map[e.name] = e
-}
-
-let created = []
-for (let item of Object.values(map)) {
- let dir = path.join(dest, path.dirname(item.name))
- if (created.indexOf(dir) == -1) {
- fs.mkdirSync(dir, {recursive: true})
- created.push(dir)
- }
- let buf = readSync(item.offset, item.length)
- let filepath = path.join(dest, item.name)
- fs.writeFileSync(filepath, buf.toString('utf8'), 'utf8')
-}
-
-fs.closeSync(fd)
\ No newline at end of file
diff --git a/wxvpkg_unpack.js b/wxvpkg_unpack.js
new file mode 100644
index 0000000..14c46a5
--- /dev/null
+++ b/wxvpkg_unpack.js
@@ -0,0 +1,50 @@
+// Extract core.wxvpkg of current folder to dest folder
+const path = require('path')
+const fs = require('fs')
+
+const args = process.argv.slice(2);
+const from = args[0]
+const to = args[1]
+
+let dest = to
+fs.mkdirSync(dest, {recursive: true})
+let file = from
+let fd = fs.openSync(file, 'r')
+
+// read buffer
+function readSync(start, length) {
+ const n = Buffer.alloc(length);
+ fs.readSync(fd, n, 0, length, start)
+ return n
+}
+
+const totalCount = readSync(14, 4).readInt32BE(0)
+const map = {};
+let n = 18;
+for (let i = 0; i < totalCount; i++) {
+ const e = {};
+ // byte length of filename
+ const i = readSync(n, 4).readInt32BE(0);
+ n += 4;
+ e.name = readSync(n, i).toString();
+ n += i;
+ e.offset = readSync(n, 4).readInt32BE(0);
+ n += 4;
+ e.length = readSync(n, 4).readInt32BE(0);
+ n += 4;
+ map[e.name] = e
+}
+
+let created = []
+for (let item of Object.values(map)) {
+ let dir = path.join(dest, path.dirname(item.name))
+ if (created.indexOf(dir) == -1) {
+ fs.mkdirSync(dir, {recursive: true})
+ created.push(dir)
+ }
+ let buf = readSync(item.offset, item.length)
+ let filepath = path.join(dest, item.name)
+ fs.writeFileSync(filepath, buf.toString('utf8'), 'utf8')
+}
+
+fs.closeSync(fd)
\ No newline at end of file