process.switch

This commit is contained in:
karl.hudgell 2020-04-26 12:24:50 +01:00
parent c509ab8969
commit 042df8b69e
2 changed files with 151 additions and 67 deletions

View File

@ -8,9 +8,15 @@ module.exports = {
installApk: async () => {
await module.exports.getListOfAPk()
for (let element of this.apkListToInstall) {
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'))
},

View File

@ -58,9 +58,15 @@ module.exports = {
for (let element of apkList) {
console.log('Installing ' + element)
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) {
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) {
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,6 +113,7 @@ module.exports = {
common.header('Connect Wifi')
if (miwatchData.ipAddress !== "") {
console.log('Trying to connect with stored ipAddress')
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'))
@ -123,9 +142,40 @@ module.exports = {
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
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'))
@ -152,6 +202,34 @@ module.exports = {
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 () => {