MiWatchKleaner/lib/inquirer.js

95 lines
2.4 KiB
JavaScript
Raw Normal View History

2020-04-25 11:11:10 +01:00
const inquirer = require("inquirer");
const files = require("./files");
2020-08-27 10:28:54 +01:00
const common = require("./common");
2020-04-26 10:10:29 +01:00
2020-08-27 10:28:54 +01:00
// let compatibleApps
2020-04-24 20:42:45 +01:00
module.exports = {
2020-04-25 11:11:10 +01:00
mainMenu: () => {
2020-04-26 10:10:29 +01:00
const questions = [{
type: "list",
name: "mainMenu",
message: "What do you want to do?",
choices: [
2020-08-27 16:45:49 +01:00
// "Connect to MiWatch",
2020-08-26 17:22:31 +01:00
"1-Click Karl0ss Klean",
2020-04-26 10:10:29 +01:00
"Remove Xiaomi Apps",
"Restore Xiaomi Apps",
"Install Compatible Apps",
2020-08-27 10:28:54 +01:00
"Restore ANY app",
2020-08-27 18:16:39 +01:00
"Batch Install APKs",
"Batch Remove Installed Apps",
2020-04-26 10:10:29 +01:00
"Quit"
],
filter: function (val) {
return val.toLowerCase();
2020-04-25 11:11:10 +01:00
},
2020-04-26 10:10:29 +01:00
}, ];
2020-04-25 11:11:10 +01:00
return inquirer.prompt(questions);
},
2020-08-27 16:45:49 +01:00
connectionType: () => {
const questions = [{
type: "list",
name: "connection",
message: "How do you want to connect?",
choices: [
"USB",
"Wifi"
],
filter: function (val) {
return val.toLowerCase();
},
}, ];
return inquirer.prompt(questions);
},
2020-04-25 11:11:10 +01:00
connectWifi: () => {
2020-04-26 10:10:29 +01:00
const questions = [{
type: "input",
name: "connectWifi",
message: "What is your MiWatch IpAdress?",
}, ];
2020-04-25 11:11:10 +01:00
return inquirer.prompt(questions);
},
removeAppsList: async () => {
const packages = await files.loadPackageList();
2020-04-25 10:44:12 +01:00
2020-04-26 10:10:29 +01:00
const questions = [{
type: "checkbox",
name: "removeAppsList",
2020-04-30 08:23:35 +01:00
message: "What apps do you want to restore?",
2020-04-26 10:10:29 +01:00
choices: packages.apps,
}, ];
2020-04-25 11:11:10 +01:00
return inquirer.prompt(questions);
},
2020-04-25 15:35:15 +01:00
compatibleApps: async () => {
2020-08-27 10:28:54 +01:00
const compatibleApps = await common.getCompatibleAppsList()
2020-04-25 15:35:15 +01:00
const appList = []
for (let element of compatibleApps) {
2020-04-26 10:10:29 +01:00
appList.push(element.name)
}
const questions = [{
type: "checkbox",
name: "removeAppsList",
2020-04-27 15:21:52 +01:00
message: "What apps do you want to Install?",
2020-04-26 10:10:29 +01:00
choices: appList,
}, ];
2020-04-25 15:35:15 +01:00
return inquirer.prompt(questions);
},
installedApps: async (installedApps) => {
const questions = [{
type: "checkbox",
name: "removeAppsList",
2020-08-27 10:28:54 +01:00
message: "What Installed apps do you want to remove?",
choices: installedApps,
}, ];
return inquirer.prompt(questions);
},
2020-08-27 10:28:54 +01:00
restoreAnyApp: async () => {
const questions = [{
type: "input",
name: "restoreAnyApp",
message: "What App do you want to restore?",
}, ];
return inquirer.prompt(questions);
},
2020-04-26 10:10:29 +01:00
};