list.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. const iPhoneBackup = require('../util/iphone_backup.js').iPhoneBackup
  2. const fs = require('fs-extra')
  3. const chalk = require('chalk')
  4. module.exports.name = 'list'
  5. module.exports.description = 'List of all backups. alias for -l'
  6. // Specify this reporter requires a backup.
  7. // The second parameter to func() is now a backup instead of the path to one.
  8. module.exports.requiresBackup = false
  9. // Specify this reporter supports the promises API for allowing chaining of reports.
  10. module.exports.usesPromises = true
  11. module.exports.func = function (program, base, resolve, reject) {
  12. var items = fs.readdirSync(base, { encoding: 'utf8' })
  13. .filter(el => (el !== '.DS_Store'))
  14. .map(file => iPhoneBackup.fromID(file, base))
  15. .filter(el => el.manifest && el.status)
  16. var output = program.formatter.format(items, {
  17. program: program,
  18. columns: {
  19. 'UDID': el => el.id,
  20. 'Encryption': el => el.manifest ? (el.manifest.IsEncrypted ? 'encrypted' : 'not encrypted') : 'unknown',
  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. resolve(output)
  29. }