safari_bookmarks.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. }
  52. /*
  53. module.exports.func = function (program, backup, resolve, reject) {
  54. backup.getSafariBookmarks()
  55. .then((items) => {
  56. // Use the configured formatter to print the rows.
  57. const result = program.formatter.format(items, {
  58. // Color formatting?
  59. program: program,
  60. // Columns to be displayed in human-readable printouts.
  61. // Some formatters, like raw or CSV, ignore these.
  62. columns: {
  63. 'id': el => el.id,
  64. 'title': el => el.title ? el.title.trim() : '',
  65. 'url': el => el.url ? el.url.trim() : '',
  66. 'parent': el => el.parent_title
  67. }
  68. })
  69. resolve(result)
  70. })
  71. .catch(reject)
  72. }
  73. */