process.switch
This commit is contained in:
		
							parent
							
								
									c509ab8969
								
							
						
					
					
						commit
						042df8b69e
					
				
							
								
								
									
										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'))
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										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