Jelajahi Sumber

combative code for connections

karl.hudgell 4 tahun lalu
induk
melakukan
74fa89e795
2 mengubah file dengan 31 tambahan dan 20 penghapusan
  1. 4 6
      package.json
  2. 27 14
      pages/pages.js

+ 4 - 6
package.json

@@ -1,6 +1,6 @@
 {
   "name": "miwatchkleaner2.0",
-  "version": "2.0.2",
+  "version": "2.0.3",
   "description": "MiWatch Cleaning Tool",
   "main": "app.js",
   "bin": "app.js",
@@ -18,8 +18,6 @@
     "chalk": "^4.0.0",
     "clear": "^0.1.0",
     "clui": "^0.3.6",
-    "download-file": "^0.1.5",
-    "download-file-with-progressbar": "^1.2.3",
     "figlet": "^1.3.0",
     "get-files-in": "^1.2.0",
     "inquirer": "^7.1.0",
@@ -27,13 +25,13 @@
     "pkg": "^4.4.7",
     "request-promise-native": "^1.0.8",
     "shell-exec": "^1.0.2",
-    "shelljs": "^0.8.4",
-    "zip": "^1.2.0"
+    "shelljs": "^0.8.4"
   },
   "pkg": {
     "scripts": [],
     "assets": [
-      "node_modules/figlet/fonts/Standard.flf"
+      "node_modules/figlet/fonts/Standard.flf",
+      "data/packageList.json"
     ],
     "targets": [
       "node12-linux-x64",

+ 27 - 14
pages/pages.js

@@ -18,25 +18,37 @@ module.exports = {
         let installedAppList
         common.header('Remove Installed Apps')
         await shellExec(adbRun + ' shell pm list packages -3').then(async function (result) {
-            if (process.platform === 'win32' || process.platform === 'win64') {
-                installedAppList = result.stdout.split('\r\n'); // split string on comma space
+            if (result.stderr.includes('error')) {
+                console.log(chalk.red('Device not authorised'))
+                common.pause(3000)
+                await shellExec(adbRun + ' kill-server').then(async function (result) {
+                    console.log('Please reconnect to watch')
+                    common.pause(3000)
+                    module.exports.mainMenu()
+                })
             } else {
-                installedAppList = result.stdout.split('\n'); // split string on comma space
-            }
-            installedAppList.splice(-1, 1)
-        });
-        const value = await inquirer.installedApps(installedAppList);
+                if (process.platform === 'win32' || process.platform === 'win64') {
+                    installedAppList = result.stdout.split('\r\n'); // split string on comma space
+                    installedAppList.splice(-1, 1)
+                } else {
+                    installedAppList = result.stdout.split('\n'); // split string on comma space
+                    installedAppList.splice(-1, 1)
+                }
+                const value = await inquirer.installedApps(installedAppList);
 
-        for (let element of value.removeAppsList) {
-            console.log('Removing ' + element)
-            const package = element.substring(8)
-            await shellExec(adbRun + ' uninstall ' + package).then(async function (result) {
-                console.log(element + ' - ' + result.stdout);
-            });
-        }
+            for (let element of value.removeAppsList) {
+                console.log('Removing ' + element)
+                const package = element.substring(8)
+                await shellExec(adbRun + ' uninstall ' + package).then(async function (result) {
+                    console.log(element + ' - ' + result.stdout);
+                });
+            }
+        // });
         console.log(chalk.green('Removed Selected User Apps'))
         await common.pause(2000)
         module.exports.mainMenu()
+            }
+            })
     },
     compatibleApps: async () => {
         common.header('Install Compatible Apps')
@@ -133,6 +145,7 @@ module.exports = {
                 } else {
                     console.log(chalk.red('MiWatch not found'))
                     await common.pause(2000)
+                    files.writeIpAddress('')
                     console.log(chalk.white('Try Again'))
                     await common.pause(1000)
                     module.exports.connectWifi()