Prechádzať zdrojové kódy

working install/uninstall

karl.hudgell 4 rokov pred
rodič
commit
d1b5adb8aa
2 zmenil súbory, kde vykonal 18 pridanie a 3 odobranie
  1. 1 1
      lib/inquirer.js
  2. 17 2
      pages/pages.js

+ 1 - 1
lib/inquirer.js

@@ -27,7 +27,7 @@ module.exports = {
 
         const questions = [  {
             type: 'checkbox',
-            name: 'Remove Apps List',
+            name: 'removeAppsList',
             message: 'What apps do you want to remove?',
             choices: packages.apps
           }]

+ 17 - 2
pages/pages.js

@@ -4,12 +4,24 @@ const inquirer = require('../lib/inquirer');
 const shellExec = require('shell-exec')
 const files = require('../lib/files')
 
-
 module.exports = {
     removeApps: async () => {
         common.header('Remove Apps')
         const value = await inquirer.removeAppsList();
-        console.log(value)
+        value.removeAppsList.forEach(element => {
+            shellExec('adb shell pm uninstall -k --user 0 ' + element).then(async function (result) {
+                console.log('Removing ' + element + ' - ' + result.stdout)
+            }).catch()
+        });
+    },
+    restoreApps: async () => {
+        common.header('Restore Apps')
+        const value = await inquirer.removeAppsList();
+        value.removeAppsList.forEach(element => {
+            shellExec('adb shell cmd package install-existing ' + element).then(async function (result) {
+                console.log('Installing ' + element + ' - ' + result.stdout)
+            }).catch()
+        });
     },
     connectWifi: async () => {
         common.header('Connect Wifi')
@@ -46,6 +58,9 @@ module.exports = {
             case 'remove install xiaomi apps':
                 module.exports.removeApps()
                 break;
+            case 'restore uninstalled apps':
+                module.exports.restoreApps()
+                break;
             default:
                 // code block
         }