safari_bookmarks.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. module.exports.name = 'safari_bookmarks'
  2. module.exports.description = 'List all Safari bookmarks'
  3. // Specify this reporter requires a backup.
  4. // The second parameter to func() is now a backup instead of the path to one.
  5. module.exports.requiresBackup = true
  6. // Specify this reporter supports the promises API for allowing chaining of reports.
  7. module.exports.usesPromises = true
  8. // Specify this only works for iOS 7+
  9. module.exports.supportedVersions = '>=7.0'
  10. // You can also provide an array of functions instead of using `module.exports.func`.
  11. // These functions *should* be independent ranges to ensure reliable execution
  12. module.exports.functions = {
  13. '>=11.0': function (program, backup, resolve, reject) {
  14. // This function would be called for iOS 10+
  15. backup.getSafariBookmarks()
  16. .then((items) => {
  17. var result = program.formatter.format(items, {
  18. program: program,
  19. // Columns to be displayed in human-readable printouts.
  20. // Some formatters, like raw or CSV, ignore these.
  21. columns: {
  22. 'id': el => el.id,
  23. 'title': el => el.title ? el.title.trim() : '',
  24. 'url': el => el.url ? el.url.trim() : '',
  25. 'parent': el => el.parent_title
  26. }
  27. })
  28. resolve(result)
  29. })
  30. .catch(reject)
  31. },
  32. '>=7.0,<11.0': function (program, backup, resolve, reject) {
  33. // This function would be called for all iOS 7+.
  34. backup.getSafariBookmarksiOS7()
  35. .then((items) => {
  36. var result = program.formatter.format(items, {
  37. program: program,
  38. // Columns to be displayed in human-readable printouts.
  39. // Some formatters, like raw or CSV, ignore these.
  40. columns: {
  41. 'id': el => el.id,
  42. 'title': el => el.title ? el.title.trim() : '',
  43. 'url': el => el.url ? el.url.trim() : '',
  44. 'parent': el => el.parent_title
  45. }
  46. })
  47. resolve(result)
  48. })
  49. .catch(reject)
  50. }
  51. }