inquirer.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const inquirer = require("inquirer");
  2. const files = require("./files");
  3. const fs = require('fs')
  4. module.exports = {
  5. mainMenu: () => {
  6. const questions = [
  7. {
  8. type: "list",
  9. name: "mainMenu",
  10. message: "What do you want to do?",
  11. choices: [
  12. "Connect to MiWatch via Wifi",
  13. "Remove Xiaomi Apps",
  14. "Restore Xiaomi Apps",
  15. "Install Compatible Apps",
  16. "Quit"
  17. ],
  18. filter: function (val) {
  19. return val.toLowerCase();
  20. },
  21. },
  22. ];
  23. return inquirer.prompt(questions);
  24. },
  25. connectWifi: () => {
  26. const questions = [
  27. {
  28. type: "input",
  29. name: "connectWifi",
  30. message: "What is your MiWatch IpAdress?",
  31. },
  32. ];
  33. return inquirer.prompt(questions);
  34. },
  35. removeAppsList: async () => {
  36. const packages = await files.loadPackageList();
  37. const questions = [
  38. {
  39. type: "checkbox",
  40. name: "removeAppsList",
  41. message: "What apps do you want to remove?",
  42. choices: packages.apps,
  43. },
  44. ];
  45. return inquirer.prompt(questions);
  46. },
  47. compatibleApps: async () => {
  48. const compatibleApps = JSON.parse(fs.readFileSync('./data/compatibleApps.json', 'utf8'));
  49. const appList = []
  50. for (let element of compatibleApps) {
  51. appList.push(element.name)
  52. }
  53. const questions = [
  54. {
  55. type: "checkbox",
  56. name: "removeAppsList",
  57. message: "What apps do you want to remove?",
  58. choices: appList,
  59. },
  60. ];
  61. return inquirer.prompt(questions);
  62. },
  63. };