common.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. module.exports = {
  7. header: (page) => {
  8. clear();
  9. console.log(
  10. chalk.red(
  11. figlet.textSync('MiWatch Kleaner', {
  12. horizontalLayout: 'full'
  13. })
  14. )
  15. );
  16. console.log(chalk.red(' ' + pjson.version));
  17. console.log();
  18. console.log(
  19. chalk.red(
  20. '-------------------------------------------------------------------------------------------------------'
  21. )
  22. )
  23. console.log(chalk.blue(page))
  24. module.exports.ipCheck()
  25. console.log(chalk.red('----------'))
  26. },
  27. pause: async (time) => {
  28. await new Promise(resolve => setTimeout(resolve, time));
  29. },
  30. ipCheck: async () => {
  31. const miwatchData = JSON.parse(fs.readFileSync('./data/MiWatch.json', 'utf8'));
  32. if (miwatchData.ipAddress === "") {
  33. console.log(chalk.white('MiWatch IP: ') + chalk.red('Not Connected'))
  34. } else {
  35. console.log(chalk.white('MiWatch IP: ' + chalk.green(miwatchData.ipAddress)))
  36. }
  37. }
  38. }