list.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const fs = require('fs-extra')
  2. module.exports = {
  3. version: 4,
  4. name: 'backups.list',
  5. description: 'List of all backups',
  6. run (lib) {
  7. return new Promise(async (resolve, reject) => {
  8. let files = fs.readdirSync(lib.base, { encoding: 'utf8' })
  9. .filter(el => (el !== '.DS_Store'))
  10. var results = []
  11. // Iterate over the file list and try to get statuses for each backup.
  12. for (let id of files) {
  13. var result = { id }
  14. result.status = await lib.run('backup.status', { backup: id }).catch(() => {}) || {}
  15. result.info = await lib.run('backup.info', { backup: id }).catch(() => {}) || {}
  16. result.manifest = await lib.run('backup.manifest', { backup: id }).catch(() => {}) || {}
  17. results.push(result)
  18. }
  19. resolve(results)
  20. })
  21. },
  22. output: {
  23. udid: el => el.id,
  24. encrypted: el => el.manifest ? (!!el.manifest.IsEncrypted) : false,
  25. date: el => el.status ? new Date(el.status.date).toLocaleString() : '',
  26. deviceName: el => el.manifest && el.manifest.Lockdown ? el.manifest.Lockdown.DeviceName : 'Unknown Device',
  27. serialNumber: el => el.manifest && el.manifest.Lockdown ? el.manifest.Lockdown.SerialNumber : 'Unknown Serial #',
  28. iOSVersion: el => el.manifest && el.manifest.Lockdown ? el.manifest.Lockdown.ProductVersion : '?',
  29. backupVersion: el => el.status ? el.status.version : '?'
  30. }
  31. }