list.js 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. const stripAnsi = require('strip-ansi')
  2. const iPhoneBackup = require('../util/iphone_backup.js').iPhoneBackup
  3. const normalizeCols = require('../util/normalize.js')
  4. const chalk = require('chalk')
  5. const fs = require('fs-extra')
  6. module.exports.name = 'list'
  7. module.exports.description = 'List of all backups. alias for -l'
  8. module.exports.func = function (program, base) {
  9. var items = fs.readdirSync(base, { encoding: 'utf8' })
  10. .filter(el => (el !== '.DS_Store'))
  11. .map(file => iPhoneBackup.fromID(file, base))
  12. .filter(el => el.manifest && el.status)
  13. program.formatter.format(items, {
  14. color: program.color,
  15. columns: {
  16. 'UDID': el => el.id,
  17. 'Encryption': el => el.manifest ? el.manifest.IsEncrypted
  18. ? chalk.green('encrypted')
  19. : chalk.red('not encrypted')
  20. : 'unknown encryption',
  21. 'Date': el => el.status ? new Date(el.status.Date).toLocaleString() : '',
  22. 'Device Name': el => el.manifest ? el.manifest.Lockdown.DeviceName : 'Unknown Device',
  23. 'Serial #': el => el.manifest.Lockdown.SerialNumber,
  24. 'iOS Version': el => el.manifest ? el.manifest.Lockdown.ProductVersion : '?',
  25. 'Backup Version': el => el.status ? el.status.Version : '?'
  26. }
  27. })
  28. }