inquirer.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. const inquirer = require("inquirer");
  2. const files = require("./files");
  3. const common = require("./common");
  4. const Language = require("@shypes/language-translator");
  5. const globalVariables = require('../lib/globalVars');
  6. module.exports = {
  7. mainMenu: async () => {
  8. Language.setActiveLang(globalVariables.language)
  9. const questions = [{
  10. type: "list",
  11. name: "mainMenu",
  12. message: await Language.get('main-menu-question'),
  13. choices: [
  14. await Language.get('main-menu-item-1'),
  15. await Language.get('main-menu-item-2'),
  16. await Language.get('main-menu-item-3'),
  17. await Language.get('main-menu-item-4'),
  18. await Language.get('main-menu-item-5'),
  19. await Language.get('main-menu-item-6'),
  20. await Language.get('main-menu-item-7'),
  21. await Language.get('main-menu-item-8'),
  22. await Language.get('main-menu-item-9'),
  23. ],
  24. filter: function (val) {
  25. return val.toLowerCase();
  26. },
  27. },];
  28. return inquirer.prompt(questions);
  29. },
  30. LanguageSelect: async () => {
  31. langList = files.getLanguageFiles()
  32. langList = langList.map(s => s.slice(5, -5));
  33. const questions = [{
  34. type: "list",
  35. name: "selection",
  36. message: await Language.get('Select Language'),
  37. choices: langList,
  38. filter: function (val) {
  39. return val.toLowerCase();
  40. },
  41. },];
  42. return inquirer.prompt(questions);
  43. },
  44. connectionType: async () => {
  45. Language.setActiveLang(globalVariables.language)
  46. const questions = [{
  47. type: "list",
  48. name: "connection",
  49. message: await Language.get('connection-type-message'),
  50. choices: [
  51. "USB",
  52. "Wifi"
  53. ],
  54. filter: function (val) {
  55. return val.toLowerCase();
  56. },
  57. },];
  58. return inquirer.prompt(questions);
  59. },
  60. connectWifi: async () => {
  61. Language.setActiveLang(globalVariables.language)
  62. const questions = [{
  63. type: "input",
  64. name: "connectWifi",
  65. message: await Language.get('connect-wifi-message'),
  66. },];
  67. return inquirer.prompt(questions);
  68. },
  69. removeAppsList: async () => {
  70. Language.setActiveLang(globalVariables.language)
  71. const packages = await files.loadPackageList();
  72. const questions = [{
  73. type: "checkbox",
  74. name: "removeAppsList",
  75. message: await Language.get('restore-app-message'),
  76. choices: packages.apps,
  77. },];
  78. return inquirer.prompt(questions);
  79. },
  80. compatibleApps: async () => {
  81. Language.setActiveLang(globalVariables.language)
  82. const compatibleApps = await common.getCompatibleAppsList()
  83. const appList = []
  84. for (let element of compatibleApps) {
  85. appList.push(element.name)
  86. }
  87. const questions = [{
  88. type: "checkbox",
  89. name: "removeAppsList",
  90. message: await Language.get('install-compatible-apps-message'),
  91. choices: appList,
  92. },];
  93. return inquirer.prompt(questions);
  94. },
  95. installedApps: async (installedApps) => {
  96. Language.setActiveLang(globalVariables.language)
  97. const questions = [{
  98. type: "checkbox",
  99. name: "removeAppsList",
  100. message: await Language.get('remove-installed-apps-message'),
  101. choices: installedApps,
  102. },];
  103. return inquirer.prompt(questions);
  104. },
  105. restoreAnyApp: async () => {
  106. Language.setActiveLang(globalVariables.language)
  107. const questions = [{
  108. type: "input",
  109. name: "restoreAnyApp",
  110. message: await Language.get('restore-any-app-message'),
  111. },];
  112. return inquirer.prompt(questions);
  113. },
  114. removeAnyApp: async () => {
  115. Language.setActiveLang(globalVariables.language)
  116. const questions = [{
  117. type: "input",
  118. name: "removeAnyApp",
  119. message: await Language.get('remove-any-app-message'),
  120. },];
  121. return inquirer.prompt(questions);
  122. },
  123. };