metadataSorter.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { createRequire } from "node:module";
  2. import { writeFile } from "node:fs/promises";
  3. import glob from "glob";
  4. import { Metadata } from "./classes/PresenceCompiler.js";
  5. import { getLatestSchema } from "./util.js";
  6. const require = createRequire(import.meta.url),
  7. { url: latestSchema } = await getLatestSchema(),
  8. presences = glob.sync("websites/*/*/metadata.json", { absolute: true });
  9. for (const presence of presences) {
  10. const {
  11. altnames,
  12. author,
  13. apiVersion,
  14. category,
  15. color,
  16. contributors,
  17. description,
  18. iframe,
  19. iFrameRegExp,
  20. logo,
  21. readLogs,
  22. regExp,
  23. service,
  24. settings,
  25. thumbnail,
  26. tags,
  27. url,
  28. version,
  29. } = require(presence) as Metadata;
  30. await writeFile(
  31. presence,
  32. JSON.stringify(
  33. {
  34. $schema: latestSchema,
  35. apiVersion,
  36. author,
  37. contributors,
  38. service,
  39. altnames,
  40. description,
  41. url,
  42. regExp,
  43. version,
  44. logo,
  45. thumbnail,
  46. color,
  47. category,
  48. tags,
  49. iframe,
  50. iFrameRegExp,
  51. readLogs,
  52. settings,
  53. },
  54. null,
  55. "\t"
  56. )
  57. );
  58. }