inquirer.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. const settings = require("settings-store");
  7. module.exports = {
  8. mainMenu: async () => {
  9. Language.setActiveLang(await settings.value("Lang"))
  10. const questions = [{
  11. type: "list",
  12. name: "mainMenu",
  13. message: await Language.get('main-menu-question'),
  14. choices: [
  15. '-----------------------',
  16. await Language.get('main-menu-item-1'),
  17. await Language.get('main-menu-item-12'),
  18. await Language.get('main-menu-item-11'),
  19. await Language.get('main-menu-item-4'),
  20. await Language.get('main-menu-item-5'),
  21. await Language.get('main-menu-item-6'),
  22. await Language.get('main-menu-item-7'),
  23. await Language.get('main-menu-item-8'),
  24. await Language.get('main-menu-item-10'),
  25. await Language.get('main-menu-item-9'),
  26. ],
  27. filter: function (val) {
  28. return val.toLowerCase();
  29. },
  30. },];
  31. return inquirer.prompt(questions);
  32. },
  33. LanguageSelect: async () => {
  34. langList = files.getLanguageFiles()
  35. langList = langList.map(s => s.slice(5, -5));
  36. const questions = [{
  37. type: "list",
  38. name: "selection",
  39. message: await Language.get('Select Language'),
  40. choices: langList,
  41. filter: function (val) {
  42. return val.toLowerCase();
  43. },
  44. },];
  45. return inquirer.prompt(questions);
  46. },
  47. connectionType: async () => {
  48. Language.setActiveLang(await settings.value("Lang"))
  49. const questions = [{
  50. type: "list",
  51. name: "connection",
  52. message: await Language.get('connection-type-message'),
  53. choices: [
  54. "USB",
  55. "Wifi"
  56. ],
  57. filter: function (val) {
  58. return val.toLowerCase();
  59. },
  60. },];
  61. return inquirer.prompt(questions);
  62. },
  63. connectWifi: async () => {
  64. Language.setActiveLang(await settings.value("Lang"))
  65. const questions = [{
  66. type: "input",
  67. name: "connectWifi",
  68. message: await Language.get('connect-wifi-message'),
  69. },];
  70. return inquirer.prompt(questions);
  71. },
  72. setDPI: async () => {
  73. Language.setActiveLang(await settings.value("Lang"))
  74. const questions = [{
  75. type: "input",
  76. name: "setDPI",
  77. message: await Language.get('set-dpi-message'),
  78. },];
  79. return inquirer.prompt(questions);
  80. },
  81. xiaomiAppsList: async () => {
  82. Language.setActiveLang(await settings.value("Lang"))
  83. const packages = await files.loadPackageList();
  84. let appList = []
  85. packages.forEach(element => {
  86. appList.push(element.name)
  87. });
  88. const questions = [{
  89. type: "checkbox",
  90. name: "appList",
  91. message: await Language.get('restore-app-message'),
  92. choices: appList,
  93. },];
  94. return inquirer.prompt(questions);
  95. },
  96. compatibleApps: async () => {
  97. Language.setActiveLang(await settings.value("Lang"))
  98. const compatibleApps = await common.getCompatibleAppsList()
  99. const appList = []
  100. for (let element of compatibleApps) {
  101. appList.push(element.name)
  102. }
  103. const questions = [{
  104. type: "checkbox",
  105. name: "removeAppsList",
  106. message: await Language.get('install-compatible-apps-message'),
  107. choices: appList,
  108. },];
  109. return inquirer.prompt(questions);
  110. },
  111. installedApps: async (installedApps) => {
  112. Language.setActiveLang(await settings.value("Lang"))
  113. const questions = [{
  114. type: "checkbox",
  115. name: "removeAppsList",
  116. message: await Language.get('remove-installed-apps-message'),
  117. choices: installedApps,
  118. },];
  119. return inquirer.prompt(questions);
  120. },
  121. restoreAnyApp: async () => {
  122. Language.setActiveLang(await settings.value("Lang"))
  123. const questions = [{
  124. type: "input",
  125. name: "restoreAnyApp",
  126. message: await Language.get('restore-any-app-message'),
  127. },];
  128. return inquirer.prompt(questions);
  129. },
  130. removeAnyApp: async () => {
  131. Language.setActiveLang(await settings.value("Lang"))
  132. const questions = [{
  133. type: "input",
  134. name: "removeAnyApp",
  135. message: await Language.get('remove-any-app-message'),
  136. },];
  137. return inquirer.prompt(questions);
  138. },
  139. globalMenu: async () => {
  140. Language.setActiveLang(await settings.value("Lang"))
  141. const questions = [{
  142. type: "list",
  143. name: "globalSelection",
  144. message: await Language.get('main-menu-item-11'),
  145. choices: [
  146. await Language.get('enable-global-theme'),
  147. await Language.get('disable-global-theme')
  148. ],
  149. filter: function (val) {
  150. return val.toLowerCase();
  151. },
  152. },];
  153. return inquirer.prompt(questions);
  154. },
  155. xiaomiMenu: async () => {
  156. Language.setActiveLang(await settings.value("Lang"))
  157. const questions = [{
  158. type: "list",
  159. name: "xiaomiSelection",
  160. message: await Language.get('main-menu-item-12'),
  161. choices: [
  162. await Language.get('main-menu-item-2'),
  163. await Language.get('main-menu-item-3')
  164. ],
  165. filter: function (val) {
  166. return val.toLowerCase();
  167. },
  168. },];
  169. return inquirer.prompt(questions);
  170. },
  171. };