inquirer.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. const inquirer = require("inquirer");
  2. const files = require("./files");
  3. const rp = require('request-promise-native')
  4. let logger = require('perfect-logger');
  5. let compatibleApps
  6. module.exports = {
  7. mainMenu: () => {
  8. const questions = [{
  9. type: "list",
  10. name: "mainMenu",
  11. message: "What do you want to do?",
  12. choices: [
  13. "Connect to MiWatch via Wifi",
  14. "1-Click Karl0ss Klean",
  15. "Remove Xiaomi Apps",
  16. "Restore Xiaomi Apps",
  17. "Install Compatible Apps",
  18. "Remove Installed Apps",
  19. "Quit"
  20. ],
  21. filter: function (val) {
  22. return val.toLowerCase();
  23. },
  24. }, ];
  25. return inquirer.prompt(questions);
  26. },
  27. connectWifi: () => {
  28. const questions = [{
  29. type: "input",
  30. name: "connectWifi",
  31. message: "What is your MiWatch IpAdress?",
  32. }, ];
  33. return inquirer.prompt(questions);
  34. },
  35. removeAppsList: async () => {
  36. const packages = await files.loadPackageList();
  37. const questions = [{
  38. type: "checkbox",
  39. name: "removeAppsList",
  40. message: "What apps do you want to restore?",
  41. choices: packages.apps,
  42. }, ];
  43. return inquirer.prompt(questions);
  44. },
  45. compatibleApps: async () => {
  46. await module.exports.getCompatibleApps()
  47. const appList = []
  48. for (let element of compatibleApps) {
  49. appList.push(element.name)
  50. }
  51. const questions = [{
  52. type: "checkbox",
  53. name: "removeAppsList",
  54. message: "What apps do you want to Install?",
  55. choices: appList,
  56. }, ];
  57. return inquirer.prompt(questions);
  58. },
  59. installedApps: async (installedApps) => {
  60. const questions = [{
  61. type: "checkbox",
  62. name: "removeAppsList",
  63. message: "What Installed apps do you want to install?",
  64. choices: installedApps,
  65. }, ];
  66. return inquirer.prompt(questions);
  67. },
  68. getCompatibleApps: async () => {
  69. var options = {
  70. method: 'GET',
  71. uri: 'http://kithub.cf/Karl/MiWatchKleaner-APKs/raw/master/compatibleApps.json',
  72. };
  73. await rp(options)
  74. .then(function (response) {
  75. compatibleApps = JSON.parse(response)
  76. logger.info("Got compatilbe list")
  77. })
  78. .catch(function (err) {
  79. console.log('compatibleApps.json Not Found')
  80. });
  81. }
  82. };