From beba93f761278ff3e20c8d1ea1701b3201c31ad3 Mon Sep 17 00:00:00 2001 From: Ou Date: Mon, 6 May 2024 14:12:39 +0800 Subject: [PATCH] chore: use shell script to cp database --- bun.lockb | Bin 19027 -> 6019 bytes package.json | 3 +-- scripts/adb.sh | 18 ++++++++++++++++++ src/adb.ts | 24 ------------------------ 4 files changed, 19 insertions(+), 26 deletions(-) create mode 100644 scripts/adb.sh delete mode 100644 src/adb.ts diff --git a/bun.lockb b/bun.lockb index 3841530633d9beb7d1d4877e2937389c44d26976..2f024105902a6c176e213e16f9b22f4ffa2672e1 100755 GIT binary patch delta 1001 zcmbVKUr19?7(eIUJ8g5iG0SabrERT*yzWl#opZWdD!Py!N<;cfPzKg;JxHa5ZH6R* zp?nb|$_O7M^I@=rq!)WgqQanhh@^*#dZ-Yy9#Yc!&h-v^>7@hb{Lb(D&i9?~eCPM_ zD!o)PAQp8DJnj^S5vP$eEYK0p61*XXpv4vOgcy;Z(=mdWg?tv# z4C}ZC7~l)6gCz(1J>yjYW3+PW^WN(ZAjyYmB`okNy#fJ2<$e+96hgEbCIpps!GfR~ z-(dySn2ADM@KYCb7*yH<69&~V!V$6umiVCY2kvC;%tOJ?`FL2ggt! z96c(DlISC(8$C>uOA(qpv!(Wp=JARWA=7X~ac)R!b1W*|i_9J$(*0gS=3!8A(sH<~ zIP=rWUFhxWX>au$T0K?7!(4?!PD?Z`N{)8<@D@odO^bN=X`zU0AZur9R}9OmG8eFn^gM}@ZN Zi5BSET?PB=@-^d)dNUjg9{_1<;twek(s%#> literal 19027 zcmeHPd0b7~+dpzhNF+kK8t8`3=`;^YhR~=)rixB=szdWRDMd0AGN(k5kP4Y1kxTU} z*O<9M#xkeOQYi29>~mJOi-z}o|G2-;$MV^py@v01J?mL(ueJ8t=SfvrGguI$>Bjfd zmbYPQGPo-CN_~L*DzD zvak5+dv9(WPUOdo}@8#zo#A7gGIx!ehP%gH!h_@Uh#@&Lr?mPj5VJ9g{ zj|bTU(w~CF{N+%t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a7549ec 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,13 @@ { "scripts": { "dev": "bun run src/index.ts", - "adb": "bun run src/adb.ts" + "adb": "bun scripts/adb.sh" }, "devDependencies": { "@types/bun": "^1.1.1", "@types/single-line-log": "^1.1.2" }, "dependencies": { - "@cspotcode/zx": "^6.1.2", "csv-stringify": "^6.4.6", "single-line-log": "^1.1.2" } diff --git a/scripts/adb.sh b/scripts/adb.sh new file mode 100644 index 0000000..a1cbcaa --- /dev/null +++ b/scripts/adb.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +databaseFolder=./database + +device=$(adb devices | tail -n +2 | cut -f1) + +if [ -z "$device" ]; then + echo "请安装 ADB,连接好手机,打开手机上的 USB 调试选项" + exit 1 +fi + +adb shell su -c "cp -rf /data/data/com.maimemo.android.momo/databases/momo.v*.db /sdcard/maimemo.db" +adb pull /sdcard/maimemo.db "$databaseFolder" +adb shell rm /sdcard/maimemo.db + +adb shell su -c "cp -rf /data/data/com.maimemo.android.momo/databases/notepad.db /sdcard/notepad.db" +adb pull /sdcard/notepad.db "$databaseFolder" +adb shell rm /sdcard/notepad.db diff --git a/src/adb.ts b/src/adb.ts deleted file mode 100644 index 2469724..0000000 --- a/src/adb.ts +++ /dev/null @@ -1,24 +0,0 @@ -import path from "node:path" -import { $ } from "@cspotcode/zx" -// 有 bug,adb shell 无法执行 -// import { $ } from "bun" - -// 必须要有 Root 权限 -async function getDatabaseFromPhone() { - try { - const device = (await $`adb devices`).toString() - if (!/device\s*$/.test(device)) - throw "请安装 ADB,连接好手机,打开手机上的 USB 调试选项" - const databaseFolder = path.resolve(__dirname, "..", "database") - await $`adb shell su -c "cp -rf /data/data/com.maimemo.android.momo/databases/momo.v*.db /sdcard/maimemo.db"` - await $`adb pull /sdcard/maimemo.db ${databaseFolder}` - await $`adb shell rm /sdcard/maimemo.db` - await $`adb shell su -c "cp -rf /data/data/com.maimemo.android.momo/databases/notepad.db /sdcard/notepad.db"` - await $`adb pull /sdcard/notepad.db ${databaseFolder}` - await $`adb shell rm /sdcard/notepad.db` - } catch (err) { - console.error(err) - } -} - -getDatabaseFromPhone()