common.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const chalk = require('chalk');
  2. const clear = require('clear');
  3. const figlet = require('figlet');
  4. const fs = require('fs')
  5. var pjson = require('../package.json');
  6. const fetch = require('node-fetch');
  7. module.exports = {
  8. header: (page) => {
  9. clear();
  10. console.log(
  11. chalk.red(
  12. figlet.textSync('MiWatch Kleaner', {
  13. horizontalLayout: 'full'
  14. })
  15. )
  16. );
  17. console.log(chalk.red(' ' + pjson.version));
  18. console.log();
  19. console.log(
  20. chalk.red(
  21. '-------------------------------------------------------------------------------------------------------'
  22. )
  23. )
  24. console.log(chalk.blue(page))
  25. module.exports.ipCheck()
  26. console.log(chalk.red('----------'))
  27. },
  28. pause: async (time) => {
  29. await new Promise(resolve => setTimeout(resolve, time));
  30. },
  31. ipCheck: async () => {
  32. const miwatchData = JSON.parse(fs.readFileSync('./data/MiWatch.json', 'utf8'));
  33. if (miwatchData.ipAddress === "") {
  34. console.log(chalk.white('MiWatch IP: ') + chalk.red('Not Connected'))
  35. } else {
  36. console.log(chalk.white('MiWatch IP: ' + chalk.green(miwatchData.ipAddress)))
  37. }
  38. },
  39. downloadFile: async (url) => {
  40. let settings = { method: "Get" };
  41. const response = await fetch(url, settings)
  42. .then(res => res.json())
  43. return response
  44. }
  45. }