Merge branch '2.0' of Karl/MiWatchKleaner into master
This commit is contained in:
		
						commit
						198183d008
					
				
							
								
								
									
										14
									
								
								lib/adb.js
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								lib/adb.js
									
									
									
									
									
								
							@ -3,14 +3,20 @@ const shellExec = require('shell-exec')
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  getListOfAPk: () => {
 | 
			
		||||
   this.apkListToInstall = gfin('./data/apps', matchFiletypes = ["apk"], checkSubDirectories = false)
 | 
			
		||||
    this.apkListToInstall = gfin('./data/apps', matchFiletypes = ["apk"], checkSubDirectories = false)
 | 
			
		||||
  },
 | 
			
		||||
  installApk: async () => {
 | 
			
		||||
    await module.exports.getListOfAPk()
 | 
			
		||||
    for (let element of this.apkListToInstall) {
 | 
			
		||||
      await shellExec('adb install -r ' + element).then(function (result) {
 | 
			
		||||
        console.log('Installing ' + element + ' - ' + result.stdout);
 | 
			
		||||
      });
 | 
			
		||||
      if (process.platform === 'win32' || process.platform === 'win64') {
 | 
			
		||||
        await shellExec('adb install -r ' + element).then(function (result) {
 | 
			
		||||
          console.log('Installing ' + element + ' - ' + result.stdout);
 | 
			
		||||
        });
 | 
			
		||||
      } else {
 | 
			
		||||
        await shellExec('./adb install -r ' + element).then(function (result) {
 | 
			
		||||
          console.log('Installing ' + element + ' - ' + result.stdout);
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    // console.log(chalk.green('Removal Complete'))
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										797
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										797
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -5,7 +5,8 @@
 | 
			
		||||
  "main": "app.js",
 | 
			
		||||
  "bin": "app.js",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "test": "echo \"Error: no test specified\" && exit 1"
 | 
			
		||||
    "test": "echo \"Error: no test specified\" && exit 1",
 | 
			
		||||
    "buildRelease": "pkg package.json && mv miwatchkleaner2-* ./release && mv ./release/miwatchkleaner2-win-* ./release/Windows && mv ./release/miwatchkleaner2-linux-* ./release/Linux && mv ./release/miwatchkleaner2-macos-* ./release/MacOs && chmod 0777 ./release/**/adb && chmod 0777 ./release/**/miwatchkleaner2-*"
 | 
			
		||||
  },
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
@ -32,6 +33,11 @@
 | 
			
		||||
    "scripts": [],
 | 
			
		||||
    "assets": [
 | 
			
		||||
      "node_modules/figlet/fonts/Standard.flf"
 | 
			
		||||
    ],
 | 
			
		||||
    "targets": [
 | 
			
		||||
      "node12-linux-x86",
 | 
			
		||||
      "node12-macos-x64",
 | 
			
		||||
      "node12-win-x86"
 | 
			
		||||
    ]
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										204
									
								
								pages/pages.js
									
									
									
									
									
								
							
							
						
						
									
										204
									
								
								pages/pages.js
									
									
									
									
									
								
							@ -58,9 +58,15 @@ module.exports = {
 | 
			
		||||
 | 
			
		||||
        for (let element of apkList) {
 | 
			
		||||
            console.log('Installing ' + element)
 | 
			
		||||
            await shellExec('adb install -r ' + element).then(function (result) {
 | 
			
		||||
                console.log(element + ' - ' + result.stdout);
 | 
			
		||||
            });
 | 
			
		||||
            if (process.platform === 'win32' || process.platform === 'win64') {
 | 
			
		||||
                await shellExec('adb install -r ' + element).then(function (result) {
 | 
			
		||||
                    console.log(element + ' - ' + result.stdout);
 | 
			
		||||
                });
 | 
			
		||||
            } else {
 | 
			
		||||
                await shellExec('./adb install -r ' + element).then(function (result) {
 | 
			
		||||
                    console.log(element + ' - ' + result.stdout);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        console.log(chalk.green('Compatible Apps Installed'))
 | 
			
		||||
        await common.pause(2000)
 | 
			
		||||
@ -70,9 +76,15 @@ module.exports = {
 | 
			
		||||
        common.header('Remove Apps')
 | 
			
		||||
        const value = await inquirer.removeAppsList();
 | 
			
		||||
        for (let element of value.removeAppsList) {
 | 
			
		||||
            await shellExec('adb shell pm uninstall -k --user 0 ' + element).then(function (result) {
 | 
			
		||||
                console.log('Removing ' + element + ' - ' + result.stdout);
 | 
			
		||||
            });
 | 
			
		||||
            if (process.platform === 'win32' || process.platform === 'win64') {
 | 
			
		||||
                await shellExec('adb shell pm uninstall -k --user 0 ' + element).then(function (result) {
 | 
			
		||||
                    console.log('Removing ' + element + ' - ' + result.stdout);
 | 
			
		||||
                });
 | 
			
		||||
            } else {
 | 
			
		||||
                await shellExec('./adb shell pm uninstall -k --user 0 ' + element).then(function (result) {
 | 
			
		||||
                    console.log('Removing ' + element + ' - ' + result.stdout);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        console.log(chalk.green('Removal Complete'))
 | 
			
		||||
        await common.pause(2000)
 | 
			
		||||
@ -82,9 +94,15 @@ module.exports = {
 | 
			
		||||
        common.header('Restore Apps')
 | 
			
		||||
        const value = await inquirer.removeAppsList();
 | 
			
		||||
        for (let element of value.removeAppsList) {
 | 
			
		||||
            await shellExec('adb shell cmd package install-existing ' + element).then(function (result) {
 | 
			
		||||
                console.log('Restoring ' + element + ' - ' + result.stdout);
 | 
			
		||||
            });
 | 
			
		||||
            if (process.platform === 'win32' || process.platform === 'win64') {
 | 
			
		||||
                await shellExec('adb shell cmd package install-existing ' + element).then(function (result) {
 | 
			
		||||
                    console.log('Restoring ' + element + ' - ' + result.stdout);
 | 
			
		||||
                });
 | 
			
		||||
            } else {
 | 
			
		||||
                await shellExec('./adb shell cmd package install-existing ' + element).then(function (result) {
 | 
			
		||||
                    console.log('Restoring ' + element + ' - ' + result.stdout);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        console.log(chalk.green('Restore Complete'))
 | 
			
		||||
        await common.pause(2000)
 | 
			
		||||
@ -95,63 +113,123 @@ module.exports = {
 | 
			
		||||
        common.header('Connect Wifi')
 | 
			
		||||
        if (miwatchData.ipAddress !== "") {
 | 
			
		||||
            console.log('Trying to connect with stored ipAddress')
 | 
			
		||||
            shellExec('adb connect ' + miwatchData.ipAddress).then(async function (result) {
 | 
			
		||||
                if (result.stdout.includes('unable to connect')) {
 | 
			
		||||
                    console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                    await common.pause(2000)
 | 
			
		||||
                    console.log(chalk.white('Try Again'))
 | 
			
		||||
                    files.writeIpAddress('')
 | 
			
		||||
                    await common.pause(1000)
 | 
			
		||||
                    module.exports.connectWifi()
 | 
			
		||||
                } else if (result.stdout.includes('cannot connect')) {
 | 
			
		||||
                    console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                    await common.pause(2000)
 | 
			
		||||
                    console.log(chalk.white('Try Again'))
 | 
			
		||||
                    files.writeIpAddress('')
 | 
			
		||||
                    await common.pause(1000)
 | 
			
		||||
                    module.exports.connectWifi()
 | 
			
		||||
                } else if (result.stdout.includes('cannot resolve host')) {
 | 
			
		||||
                    console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                    await common.pause(2000)
 | 
			
		||||
                    console.log(chalk.white('Try Again'))
 | 
			
		||||
                    files.writeIpAddress('')
 | 
			
		||||
                    await common.pause(1000)
 | 
			
		||||
                    module.exports.connectWifi()
 | 
			
		||||
                } else {
 | 
			
		||||
                    console.log(chalk.green('MiWatch Connected'))
 | 
			
		||||
                    await common.pause(3000)
 | 
			
		||||
                    module.exports.mainMenu()
 | 
			
		||||
                }
 | 
			
		||||
            }).catch()
 | 
			
		||||
            if (process.platform === 'win32' || process.platform === 'win64') {
 | 
			
		||||
                shellExec('adb connect ' + miwatchData.ipAddress).then(async function (result) {
 | 
			
		||||
                    if (result.stdout.includes('unable to connect')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        files.writeIpAddress('')
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else if (result.stdout.includes('cannot connect')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        files.writeIpAddress('')
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else if (result.stdout.includes('cannot resolve host')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        files.writeIpAddress('')
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else {
 | 
			
		||||
                        console.log(chalk.green('MiWatch Connected'))
 | 
			
		||||
                        await common.pause(3000)
 | 
			
		||||
                        module.exports.mainMenu()
 | 
			
		||||
                    }
 | 
			
		||||
                }).catch()
 | 
			
		||||
            } else {
 | 
			
		||||
                shellExec('./adb connect ' + miwatchData.ipAddress).then(async function (result) {
 | 
			
		||||
                    if (result.stdout.includes('unable to connect')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        files.writeIpAddress('')
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else if (result.stdout.includes('cannot connect')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        files.writeIpAddress('')
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else if (result.stdout.includes('cannot resolve host')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        files.writeIpAddress('')
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else {
 | 
			
		||||
                        console.log(chalk.green('MiWatch Connected'))
 | 
			
		||||
                        await common.pause(3000)
 | 
			
		||||
                        module.exports.mainMenu()
 | 
			
		||||
                    }
 | 
			
		||||
                }).catch()
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            const value = await inquirer.connectWifi();
 | 
			
		||||
            const miWatchIpaddress = value.connectWifi
 | 
			
		||||
            shellExec('adb connect ' + miWatchIpaddress).then(async function (result) {
 | 
			
		||||
                if (result.stdout.includes('unable to connect')) {
 | 
			
		||||
                    console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                    await common.pause(2000)
 | 
			
		||||
                    console.log(chalk.white('Try Again'))
 | 
			
		||||
                    await common.pause(1000)
 | 
			
		||||
                    module.exports.connectWifi()
 | 
			
		||||
                } else if (result.stdout.includes('cannot connect')) {
 | 
			
		||||
                    console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                    await common.pause(2000)
 | 
			
		||||
                    console.log(chalk.white('Try Again'))
 | 
			
		||||
                    await common.pause(1000)
 | 
			
		||||
                    module.exports.connectWifi()
 | 
			
		||||
                } else if (result.stdout.includes('cannot resolve host')) {
 | 
			
		||||
                    console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                    await common.pause(2000)
 | 
			
		||||
                    console.log(chalk.white('Try Again'))
 | 
			
		||||
                    await common.pause(1000)
 | 
			
		||||
                    module.exports.connectWifi()
 | 
			
		||||
                } else {
 | 
			
		||||
                    console.log(chalk.green('MiWatch Connected'))
 | 
			
		||||
                    files.writeIpAddress(miWatchIpaddress)
 | 
			
		||||
                    await common.pause(3000)
 | 
			
		||||
                    module.exports.mainMenu()
 | 
			
		||||
                }
 | 
			
		||||
            }).catch()
 | 
			
		||||
            if (process.platform === 'win32' || process.platform === 'win64') {
 | 
			
		||||
                shellExec('adb connect ' + miWatchIpaddress).then(async function (result) {
 | 
			
		||||
                    if (result.stdout.includes('unable to connect')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else if (result.stdout.includes('cannot connect')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else if (result.stdout.includes('cannot resolve host')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else {
 | 
			
		||||
                        console.log(chalk.green('MiWatch Connected'))
 | 
			
		||||
                        files.writeIpAddress(miWatchIpaddress)
 | 
			
		||||
                        await common.pause(3000)
 | 
			
		||||
                        module.exports.mainMenu()
 | 
			
		||||
                    }
 | 
			
		||||
                }).catch()
 | 
			
		||||
            } else {
 | 
			
		||||
                shellExec('./adb connect ' + miWatchIpaddress).then(async function (result) {
 | 
			
		||||
                    if (result.stdout.includes('unable to connect')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else if (result.stdout.includes('cannot connect')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else if (result.stdout.includes('cannot resolve host')) {
 | 
			
		||||
                        console.log(chalk.red('MiWatch not found'))
 | 
			
		||||
                        await common.pause(2000)
 | 
			
		||||
                        console.log(chalk.white('Try Again'))
 | 
			
		||||
                        await common.pause(1000)
 | 
			
		||||
                        module.exports.connectWifi()
 | 
			
		||||
                    } else {
 | 
			
		||||
                        console.log(chalk.green('MiWatch Connected'))
 | 
			
		||||
                        files.writeIpAddress(miWatchIpaddress)
 | 
			
		||||
                        await common.pause(3000)
 | 
			
		||||
                        module.exports.mainMenu()
 | 
			
		||||
                    }
 | 
			
		||||
                }).catch()
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    mainMenu: async () => {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user