directus-template-cli 0.3.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/README.md +5 -2
  2. package/dist/commands/apply.d.ts +1 -1
  3. package/dist/commands/apply.js +80 -50
  4. package/dist/commands/extract.d.ts +1 -2
  5. package/dist/commands/extract.js +13 -18
  6. package/dist/lib/extract/extract-assets.d.ts +182 -2
  7. package/dist/lib/extract/extract-assets.js +25 -32
  8. package/dist/lib/extract/extract-collections.d.ts +4 -0
  9. package/dist/lib/extract/extract-collections.js +24 -0
  10. package/dist/lib/extract/extract-content.d.ts +1 -1
  11. package/dist/lib/extract/extract-content.js +18 -18
  12. package/dist/lib/extract/extract-dashboards.d.ts +8 -0
  13. package/dist/lib/extract/extract-dashboards.js +42 -0
  14. package/dist/lib/extract/extract-fields.d.ts +4 -0
  15. package/dist/lib/extract/extract-fields.js +30 -0
  16. package/dist/lib/extract/extract-files.js +11 -34
  17. package/dist/lib/extract/extract-flows.d.ts +8 -0
  18. package/dist/lib/extract/extract-flows.js +42 -0
  19. package/dist/lib/extract/extract-folders.d.ts +1 -1
  20. package/dist/lib/extract/extract-folders.js +12 -13
  21. package/dist/lib/extract/extract-permissions.d.ts +1 -1
  22. package/dist/lib/extract/extract-permissions.js +13 -13
  23. package/dist/lib/extract/extract-presets.js +15 -11
  24. package/dist/lib/extract/extract-relations.d.ts +4 -0
  25. package/dist/lib/extract/extract-relations.js +33 -0
  26. package/dist/lib/extract/extract-roles.js +11 -22
  27. package/dist/lib/extract/extract-schema.js +14 -14
  28. package/dist/lib/extract/extract-settings.d.ts +4 -0
  29. package/dist/lib/extract/extract-settings.js +22 -0
  30. package/dist/lib/extract/extract-translations.d.ts +4 -0
  31. package/dist/lib/extract/extract-translations.js +24 -0
  32. package/dist/lib/extract/extract-users.d.ts +1 -1
  33. package/dist/lib/extract/extract-users.js +14 -36
  34. package/dist/lib/extract/index.d.ts +1 -1
  35. package/dist/lib/extract/index.js +27 -32
  36. package/dist/lib/interfaces.d.ts +1 -1
  37. package/dist/lib/load/index.d.ts +1 -1
  38. package/dist/lib/load/index.js +33 -44
  39. package/dist/lib/load/load-collections.d.ts +4 -0
  40. package/dist/lib/load/load-collections.js +66 -0
  41. package/dist/lib/load/load-dashboards.d.ts +2 -1
  42. package/dist/lib/load/load-dashboards.js +33 -3
  43. package/dist/lib/load/load-data.d.ts +1 -1
  44. package/dist/lib/load/load-data.js +87 -60
  45. package/dist/lib/load/load-files.d.ts +1 -1
  46. package/dist/lib/load/load-files.js +23 -20
  47. package/dist/lib/load/load-flows.d.ts +2 -2
  48. package/dist/lib/load/load-flows.js +43 -9
  49. package/dist/lib/load/load-folders.js +15 -11
  50. package/dist/lib/load/load-permissions.d.ts +1 -1
  51. package/dist/lib/load/load-permissions.js +22 -21
  52. package/dist/lib/load/load-presets.d.ts +1 -2
  53. package/dist/lib/load/load-presets.js +16 -19
  54. package/dist/lib/load/load-relations.d.ts +4 -0
  55. package/dist/lib/load/load-relations.js +33 -0
  56. package/dist/lib/load/load-roles.d.ts +1 -1
  57. package/dist/lib/load/load-roles.js +20 -10
  58. package/dist/lib/load/load-schema.d.ts +14 -2
  59. package/dist/lib/load/load-schema.js +85 -10
  60. package/dist/lib/load/load-settings.d.ts +1 -1
  61. package/dist/lib/load/load-settings.js +10 -4
  62. package/dist/lib/load/load-translations.d.ts +1 -0
  63. package/dist/lib/load/load-translations.js +21 -0
  64. package/dist/lib/load/load-users.d.ts +1 -2
  65. package/dist/lib/load/load-users.js +19 -8
  66. package/dist/lib/sdk.d.ts +13 -0
  67. package/dist/lib/sdk.js +26 -0
  68. package/dist/lib/utils/auth.d.ts +2 -2
  69. package/dist/lib/utils/auth.js +12 -11
  70. package/dist/lib/utils/check-template.d.ts +1 -0
  71. package/dist/lib/utils/check-template.js +32 -0
  72. package/dist/lib/utils/filter-fields.js +5 -5
  73. package/dist/lib/utils/get-role-ids.d.ts +55 -0
  74. package/dist/lib/utils/get-role-ids.js +14 -0
  75. package/dist/lib/utils/log-error.d.ts +14 -0
  76. package/dist/lib/utils/log-error.js +25 -0
  77. package/dist/lib/utils/path.d.ts +7 -0
  78. package/dist/lib/utils/path.js +20 -0
  79. package/dist/lib/utils/read-file.d.ts +0 -1
  80. package/dist/lib/utils/read-file.js +7 -9
  81. package/dist/lib/utils/read-templates.js +2 -2
  82. package/dist/lib/utils/system-fields.d.ts +20 -0
  83. package/dist/lib/utils/system-fields.js +159 -0
  84. package/dist/lib/utils/template-defaults.js +8 -11
  85. package/dist/lib/utils/transform-github-url.d.ts +1 -0
  86. package/dist/lib/utils/transform-github-url.js +15 -0
  87. package/dist/lib/utils/validate-url.js +1 -1
  88. package/dist/lib/utils/write-to-file.js +4 -4
  89. package/oclif.manifest.json +34 -16
  90. package/package.json +25 -23
  91. package/dist/lib/api.d.ts +0 -15
  92. package/dist/lib/api.js +0 -37
  93. package/dist/lib/extract/extract-from-endpoint.d.ts +0 -4
  94. package/dist/lib/extract/extract-from-endpoint.js +0 -23
  95. package/dist/lib/load/load-operations.d.ts +0 -1
  96. package/dist/lib/load/load-operations.js +0 -29
  97. package/dist/lib/load/load-panels.d.ts +0 -0
  98. package/dist/lib/load/load-panels.js +0 -0
  99. package/dist/lib/utils/delete-items.d.ts +0 -1
  100. package/dist/lib/utils/delete-items.js +0 -15
  101. package/dist/lib/utils/load-to-destination.d.ts +0 -1
  102. package/dist/lib/utils/load-to-destination.js +0 -14
  103. package/templates/agencyos/README.md +0 -11
  104. package/templates/agencyos/package.json +0 -11
  105. package/templates/agencyos/src/assets/08177527-b867-47e9-b5d5-eab146b3cdba.jpg +0 -0
  106. package/templates/agencyos/src/assets/08242513-ca8f-471f-b69b-82703a19d1e5.svg +0 -14
  107. package/templates/agencyos/src/assets/0dfe66dd-ceba-4dca-8907-03b2dda49443.svg +0 -1
  108. package/templates/agencyos/src/assets/12e02b82-b4a4-4aaf-8ca4-e73c20a41c26.jpeg +0 -0
  109. package/templates/agencyos/src/assets/1f19dd72-a433-481d-9b51-e3cc8e4f33d3.svg +0 -1
  110. package/templates/agencyos/src/assets/1f69c0b8-19b7-49d7-b420-bedad577a079.png +0 -0
  111. package/templates/agencyos/src/assets/21e179ab-72c3-4350-b46a-fadd16f5652e.svg +0 -1
  112. package/templates/agencyos/src/assets/270fa8d1-45a3-4fcb-87d2-27a0248f1daf.jpg +0 -0
  113. package/templates/agencyos/src/assets/27f55be1-7ef5-47c4-87ba-ab9a060ab270.jpeg +0 -0
  114. package/templates/agencyos/src/assets/2b4a0ba0-52c7-4e10-b191-c803d8da6a36.png +0 -0
  115. package/templates/agencyos/src/assets/35a67f1b-d401-4300-a503-b8e583186f2a.svg +0 -11
  116. package/templates/agencyos/src/assets/3eff7dc2-445a-47c5-9503-3f600ecdb5c6.jpeg +0 -0
  117. package/templates/agencyos/src/assets/44a4e780-d59b-4fa5-9b26-1c4b447474d2.jpg +0 -0
  118. package/templates/agencyos/src/assets/4b31c98e-ec03-4b91-bb18-ef55dd199638.jpg +0 -0
  119. package/templates/agencyos/src/assets/5419bf05-9ab2-484b-a69d-d09b18602cf1.svg +0 -1
  120. package/templates/agencyos/src/assets/5a6dfe1e-7e5b-4a5f-9f6c-983777a67c05.svg +0 -1
  121. package/templates/agencyos/src/assets/643faffb-d41d-48ad-9050-881cf495cbb6.jpg +0 -0
  122. package/templates/agencyos/src/assets/6464e61f-455a-4b47-b623-bb12e5251dfe.jpeg +0 -0
  123. package/templates/agencyos/src/assets/6789bc72-ab83-40bf-8152-d6f2bafbc2a8.png +0 -0
  124. package/templates/agencyos/src/assets/68103296-6634-4d66-918a-04b09afe6621.jpeg +0 -0
  125. package/templates/agencyos/src/assets/690c2042-e3ad-46f4-9cd8-095a7b3a1df7.svg +0 -3
  126. package/templates/agencyos/src/assets/6a1ca349-d7ab-4f43-9284-c61671e145f2.svg +0 -22
  127. package/templates/agencyos/src/assets/6dad2008-3af5-407e-827e-da5744223181.svg +0 -1
  128. package/templates/agencyos/src/assets/6ff389c5-3ecb-4219-8f72-f10326aab421.jpg +0 -0
  129. package/templates/agencyos/src/assets/7647f4c2-9880-433a-bb8e-69b0c30ae31e.svg +0 -1
  130. package/templates/agencyos/src/assets/7775c53a-6c2c-453d-8c22-8b5445121d10.jpeg +0 -0
  131. package/templates/agencyos/src/assets/793e9bf7-c646-4588-8865-fe22556070ff.svg +0 -1
  132. package/templates/agencyos/src/assets/87fc0e81-45e4-4c05-8e9a-8e5c759d7aae.png +0 -0
  133. package/templates/agencyos/src/assets/88b95737-7ff4-4a09-8523-362d42caa9f9.jpg +0 -0
  134. package/templates/agencyos/src/assets/8f748634-d77b-4985-b27e-7e1f3559881a.jpeg +0 -0
  135. package/templates/agencyos/src/assets/a104c031-6ad2-4148-ace6-052e28cfda0b.svg +0 -1
  136. package/templates/agencyos/src/assets/ac905071-0643-4337-8f53-48ed45b1ccf2.jpg +0 -0
  137. package/templates/agencyos/src/assets/b1a3fd77-8e62-4678-9d44-333a30eec13b.jpg +0 -0
  138. package/templates/agencyos/src/assets/b210ecec-860f-4057-bab9-18c044b6e129.jpg +0 -0
  139. package/templates/agencyos/src/assets/b9db00d9-535f-4e24-8a46-5f7e5fc65bf2.jpg +0 -0
  140. package/templates/agencyos/src/assets/c0253924-38cd-4ca0-9989-9c0a57ec076a.png +0 -0
  141. package/templates/agencyos/src/assets/ce0b845f-f8d8-4856-b0af-1df4e3a838cc.jpg +0 -0
  142. package/templates/agencyos/src/assets/d0130348-9ead-49d0-b8e7-871cd43921a0.svg +0 -1
  143. package/templates/agencyos/src/assets/d4fd6edc-4cc5-48c1-8bc7-e646924bbdca.jpeg +0 -0
  144. package/templates/agencyos/src/assets/d598a4c0-4e9a-44a3-a72e-49564e34a432.jpg +0 -0
  145. package/templates/agencyos/src/assets/d94c9355-d89e-4229-941a-62b8525fd69a.png +0 -0
  146. package/templates/agencyos/src/assets/df0745c2-b6e3-4b37-b64d-55a4eb0033ab.avif +0 -0
  147. package/templates/agencyos/src/assets/df979753-946b-4d93-954e-e24367388d2c.svg +0 -1
  148. package/templates/agencyos/src/assets/dfa90758-9700-49e4-8fa2-b6cd074811b7.png +0 -0
  149. package/templates/agencyos/src/assets/e15ca910-1567-4f15-b5a0-b802da67f228.jpg +0 -0
  150. package/templates/agencyos/src/assets/eef7d7b1-3bf9-4647-90c1-a16c24161335.svg +0 -4
  151. package/templates/agencyos/src/assets/f1693c44-52e4-4fae-a7d2-b3153a34eb72.jpg +0 -0
  152. package/templates/agencyos/src/assets/f81e1a85-5a9c-41ef-9ef3-6a9349722daa.jpg +0 -0
  153. package/templates/agencyos/src/assets/fbae19f3-8739-4048-a20f-89ebbf59b032.jpg +0 -0
  154. package/templates/agencyos/src/collections.json +0 -3007
  155. package/templates/agencyos/src/content/block_button.json +0 -50
  156. package/templates/agencyos/src/content/block_button_group.json +0 -27
  157. package/templates/agencyos/src/content/block_columns.json +0 -18
  158. package/templates/agencyos/src/content/block_columns_rows.json +0 -47
  159. package/templates/agencyos/src/content/block_cta.json +0 -9
  160. package/templates/agencyos/src/content/block_divider.json +0 -14
  161. package/templates/agencyos/src/content/block_faqs.json +0 -90
  162. package/templates/agencyos/src/content/block_form.json +0 -26
  163. package/templates/agencyos/src/content/block_gallery.json +0 -19
  164. package/templates/agencyos/src/content/block_gallery_files.json +0 -102
  165. package/templates/agencyos/src/content/block_hero.json +0 -20
  166. package/templates/agencyos/src/content/block_html.json +0 -1
  167. package/templates/agencyos/src/content/block_logocloud.json +0 -24
  168. package/templates/agencyos/src/content/block_logocloud_logos.json +0 -50
  169. package/templates/agencyos/src/content/block_quote.json +0 -14
  170. package/templates/agencyos/src/content/block_richtext.json +0 -58
  171. package/templates/agencyos/src/content/block_step_items.json +0 -47
  172. package/templates/agencyos/src/content/block_steps.json +0 -24
  173. package/templates/agencyos/src/content/block_team.json +0 -14
  174. package/templates/agencyos/src/content/block_testimonial_slider_items.json +0 -42
  175. package/templates/agencyos/src/content/block_testimonials.json +0 -13
  176. package/templates/agencyos/src/content/block_video.json +0 -10
  177. package/templates/agencyos/src/content/categories.json +0 -38
  178. package/templates/agencyos/src/content/contacts.json +0 -46
  179. package/templates/agencyos/src/content/conversations.json +0 -1
  180. package/templates/agencyos/src/content/forms.json +0 -129
  181. package/templates/agencyos/src/content/globals.json +0 -52
  182. package/templates/agencyos/src/content/help_articles.json +0 -1
  183. package/templates/agencyos/src/content/help_collections.json +0 -20
  184. package/templates/agencyos/src/content/help_feedback.json +0 -122
  185. package/templates/agencyos/src/content/inbox.json +0 -15
  186. package/templates/agencyos/src/content/messages.json +0 -1
  187. package/templates/agencyos/src/content/navigation.json +0 -34
  188. package/templates/agencyos/src/content/navigation_items.json +0 -185
  189. package/templates/agencyos/src/content/organization_addresses.json +0 -18
  190. package/templates/agencyos/src/content/organizations.json +0 -50
  191. package/templates/agencyos/src/content/organizations_contacts.json +0 -14
  192. package/templates/agencyos/src/content/os_activities.json +0 -23
  193. package/templates/agencyos/src/content/os_activity_contacts.json +0 -7
  194. package/templates/agencyos/src/content/os_deal_contacts.json +0 -9
  195. package/templates/agencyos/src/content/os_deal_stages.json +0 -68
  196. package/templates/agencyos/src/content/os_deals.json +0 -27
  197. package/templates/agencyos/src/content/os_email_templates.json +0 -13
  198. package/templates/agencyos/src/content/os_expenses.json +0 -22
  199. package/templates/agencyos/src/content/os_invoice_items.json +0 -65
  200. package/templates/agencyos/src/content/os_invoices.json +0 -29
  201. package/templates/agencyos/src/content/os_items.json +0 -17
  202. package/templates/agencyos/src/content/os_payment_terms.json +0 -18
  203. package/templates/agencyos/src/content/os_payments.json +0 -291
  204. package/templates/agencyos/src/content/os_project_contacts.json +0 -8
  205. package/templates/agencyos/src/content/os_project_files.json +0 -1
  206. package/templates/agencyos/src/content/os_project_templates.json +0 -467
  207. package/templates/agencyos/src/content/os_project_updates.json +0 -1
  208. package/templates/agencyos/src/content/os_projects.json +0 -50
  209. package/templates/agencyos/src/content/os_proposal_approvals.json +0 -1
  210. package/templates/agencyos/src/content/os_proposal_blocks.json +0 -134
  211. package/templates/agencyos/src/content/os_proposal_contacts.json +0 -8
  212. package/templates/agencyos/src/content/os_proposals.json +0 -33
  213. package/templates/agencyos/src/content/os_settings.json +0 -6
  214. package/templates/agencyos/src/content/os_task_files.json +0 -1
  215. package/templates/agencyos/src/content/os_tasks.json +0 -464
  216. package/templates/agencyos/src/content/os_tax_rates.json +0 -24
  217. package/templates/agencyos/src/content/page_blocks.json +0 -170
  218. package/templates/agencyos/src/content/pages.json +0 -96
  219. package/templates/agencyos/src/content/pages_blog.json +0 -7
  220. package/templates/agencyos/src/content/pages_projects.json +0 -6
  221. package/templates/agencyos/src/content/post_gallery_items.json +0 -32
  222. package/templates/agencyos/src/content/posts.json +0 -235
  223. package/templates/agencyos/src/content/redirects.json +0 -12
  224. package/templates/agencyos/src/content/seo.json +0 -52
  225. package/templates/agencyos/src/content/team.json +0 -128
  226. package/templates/agencyos/src/content/testimonials.json +0 -66
  227. package/templates/agencyos/src/dashboards.json +0 -64
  228. package/templates/agencyos/src/files.json +0 -1129
  229. package/templates/agencyos/src/flows.json +0 -451
  230. package/templates/agencyos/src/folders.json +0 -104
  231. package/templates/agencyos/src/operations.json +0 -717
  232. package/templates/agencyos/src/panels.json +0 -1019
  233. package/templates/agencyos/src/permissions.json +0 -5533
  234. package/templates/agencyos/src/presets.json +0 -2421
  235. package/templates/agencyos/src/public-permissions.json +0 -629
  236. package/templates/agencyos/src/roles.json +0 -46
  237. package/templates/agencyos/src/schema/snapshot.json +0 -39415
  238. package/templates/agencyos/src/settings.json +0 -99
  239. package/templates/agencyos/src/users.json +0 -147
  240. package/templates/website/README.md +0 -15
  241. package/templates/website/package.json +0 -11
  242. package/templates/website/src/assets/004e37f7-765e-4339-8d44-987729e47898.png +0 -0
  243. package/templates/website/src/assets/008b1c0e-bdd3-4c5f-a029-b9c07582a42d.jpg +0 -0
  244. package/templates/website/src/assets/08177527-b867-47e9-b5d5-eab146b3cdba.jpg +0 -0
  245. package/templates/website/src/assets/0dfe66dd-ceba-4dca-8907-03b2dda49443.svg +0 -1
  246. package/templates/website/src/assets/12e02b82-b4a4-4aaf-8ca4-e73c20a41c26.jpeg +0 -0
  247. package/templates/website/src/assets/18bf5269-9986-48c7-b607-01b77283df3b.png +0 -0
  248. package/templates/website/src/assets/1f19dd72-a433-481d-9b51-e3cc8e4f33d3.svg +0 -1
  249. package/templates/website/src/assets/270fa8d1-45a3-4fcb-87d2-27a0248f1daf.jpg +0 -0
  250. package/templates/website/src/assets/27f55be1-7ef5-47c4-87ba-ab9a060ab270.jpeg +0 -0
  251. package/templates/website/src/assets/284c190b-0ebb-4b3e-847d-c260b793b77c.png +0 -0
  252. package/templates/website/src/assets/35a67f1b-d401-4300-a503-b8e583186f2a.svg +0 -11
  253. package/templates/website/src/assets/3ac899c4-4bf9-4733-b2c4-b259c69faf46.png +0 -0
  254. package/templates/website/src/assets/3eff7dc2-445a-47c5-9503-3f600ecdb5c6.jpeg +0 -0
  255. package/templates/website/src/assets/40a0a417-231e-4819-86bf-66e96ec64852.svg +0 -3
  256. package/templates/website/src/assets/45140116-7656-4226-99b6-fd750722a083.svg +0 -3
  257. package/templates/website/src/assets/4b31c98e-ec03-4b91-bb18-ef55dd199638.jpg +0 -0
  258. package/templates/website/src/assets/57c6e801-9ba1-46eb-beb7-96cf7c497c92.svg +0 -1
  259. package/templates/website/src/assets/643faffb-d41d-48ad-9050-881cf495cbb6.jpg +0 -0
  260. package/templates/website/src/assets/6464e61f-455a-4b47-b623-bb12e5251dfe.jpeg +0 -0
  261. package/templates/website/src/assets/68103296-6634-4d66-918a-04b09afe6621.jpeg +0 -0
  262. package/templates/website/src/assets/68ee3ce3-bc8e-4901-b3a6-8a23afda0fa0.jpg +0 -0
  263. package/templates/website/src/assets/6dad2008-3af5-407e-827e-da5744223181.svg +0 -1
  264. package/templates/website/src/assets/72eea8c7-72fe-4ef2-9e57-524f7cb886a4.jpg +0 -0
  265. package/templates/website/src/assets/72f6f5a0-9a07-422f-b82f-b9e295ce5afa.svg +0 -4
  266. package/templates/website/src/assets/7775c53a-6c2c-453d-8c22-8b5445121d10.jpeg +0 -0
  267. package/templates/website/src/assets/7834aacc-d78c-4a55-ba92-d7b5d74188c1.png +0 -0
  268. package/templates/website/src/assets/7a5b47f6-d648-48f9-bf93-4bfafda48940.png +0 -0
  269. package/templates/website/src/assets/7c04cbdd-4b48-41aa-94d7-fc7c17373b1a.png +0 -0
  270. package/templates/website/src/assets/82b872b1-ff96-4af6-b7f1-878e60c3c448.png +0 -0
  271. package/templates/website/src/assets/840ec616-acad-412e-be79-485a702f9a55.svg +0 -1
  272. package/templates/website/src/assets/87fc0e81-45e4-4c05-8e9a-8e5c759d7aae.png +0 -0
  273. package/templates/website/src/assets/8bc1e7b3-b795-46af-bac4-34f7d90b902f.JPG +0 -0
  274. package/templates/website/src/assets/8f748634-d77b-4985-b27e-7e1f3559881a.jpeg +0 -0
  275. package/templates/website/src/assets/9778a2b4-27de-4035-af5a-f58897578787.png +0 -0
  276. package/templates/website/src/assets/a104c031-6ad2-4148-ace6-052e28cfda0b.svg +0 -1
  277. package/templates/website/src/assets/b626a403-5f09-4463-9715-44b2bd34eb26.jpg +0 -0
  278. package/templates/website/src/assets/c38f6e9e-7bb5-46c7-8266-b27ab96a1282.png +0 -0
  279. package/templates/website/src/assets/c983bd13-da09-4c90-8e65-ae6a92093df8.png +0 -0
  280. package/templates/website/src/assets/d0130348-9ead-49d0-b8e7-871cd43921a0.svg +0 -1
  281. package/templates/website/src/assets/d304528e-9000-4530-92cf-bb04891e8d5d.jpg +0 -0
  282. package/templates/website/src/assets/d4fd6edc-4cc5-48c1-8bc7-e646924bbdca.jpeg +0 -0
  283. package/templates/website/src/assets/d598a4c0-4e9a-44a3-a72e-49564e34a432.jpg +0 -0
  284. package/templates/website/src/assets/dfa90758-9700-49e4-8fa2-b6cd074811b7.png +0 -0
  285. package/templates/website/src/assets/e15ca910-1567-4f15-b5a0-b802da67f228.jpg +0 -0
  286. package/templates/website/src/assets/ea18cbf2-3c4f-488b-a68c-2d3a64cc9137.png +0 -0
  287. package/templates/website/src/assets/eb8e4c86-92ac-4697-9634-2e376f5d6015.png +0 -0
  288. package/templates/website/src/assets/f1693c44-52e4-4fae-a7d2-b3153a34eb72.jpg +0 -0
  289. package/templates/website/src/collections.json +0 -1788
  290. package/templates/website/src/content/block_cardgroup.json +0 -26
  291. package/templates/website/src/content/block_cardgroup_cards.json +0 -1
  292. package/templates/website/src/content/block_cardgroup_posts.json +0 -32
  293. package/templates/website/src/content/block_columns.json +0 -21
  294. package/templates/website/src/content/block_columns_rows.json +0 -47
  295. package/templates/website/src/content/block_cta.json +0 -15
  296. package/templates/website/src/content/block_faqs.json +0 -45
  297. package/templates/website/src/content/block_form.json +0 -26
  298. package/templates/website/src/content/block_gallery.json +0 -15
  299. package/templates/website/src/content/block_gallery_files.json +0 -38
  300. package/templates/website/src/content/block_hero.json +0 -145
  301. package/templates/website/src/content/block_html.json +0 -1
  302. package/templates/website/src/content/block_logocloud.json +0 -16
  303. package/templates/website/src/content/block_logocloud_files.json +0 -44
  304. package/templates/website/src/content/block_quote.json +0 -11
  305. package/templates/website/src/content/block_richtext.json +0 -32
  306. package/templates/website/src/content/block_steps.json +0 -14
  307. package/templates/website/src/content/block_steps_items.json +0 -26
  308. package/templates/website/src/content/block_team.json +0 -8
  309. package/templates/website/src/content/block_testimonials.json +0 -13
  310. package/templates/website/src/content/block_testimonials_items.json +0 -26
  311. package/templates/website/src/content/block_video.json +0 -10
  312. package/templates/website/src/content/blog_settings.json +0 -8
  313. package/templates/website/src/content/categories.json +0 -38
  314. package/templates/website/src/content/events.json +0 -1
  315. package/templates/website/src/content/forms.json +0 -92
  316. package/templates/website/src/content/globals.json +0 -57
  317. package/templates/website/src/content/inbox.json +0 -21
  318. package/templates/website/src/content/metrics.json +0 -1
  319. package/templates/website/src/content/navigation.json +0 -30
  320. package/templates/website/src/content/navigation_items.json +0 -140
  321. package/templates/website/src/content/pages.json +0 -123
  322. package/templates/website/src/content/pages_blocks.json +0 -310
  323. package/templates/website/src/content/posts.json +0 -120
  324. package/templates/website/src/content/projects.json +0 -48
  325. package/templates/website/src/content/projects_files.json +0 -44
  326. package/templates/website/src/content/projects_settings.json +0 -6
  327. package/templates/website/src/content/redirects.json +0 -12
  328. package/templates/website/src/content/seo.json +0 -278
  329. package/templates/website/src/content/team.json +0 -132
  330. package/templates/website/src/content/testimonials.json +0 -66
  331. package/templates/website/src/dashboards.json +0 -38
  332. package/templates/website/src/fields.json +0 -27761
  333. package/templates/website/src/files.json +0 -1100
  334. package/templates/website/src/flows.json +0 -131
  335. package/templates/website/src/folders.json +0 -52
  336. package/templates/website/src/operations.json +0 -214
  337. package/templates/website/src/panels.json +0 -433
  338. package/templates/website/src/permissions.json +0 -1556
  339. package/templates/website/src/presets.json +0 -1254
  340. package/templates/website/src/public-permissions.json +0 -511
  341. package/templates/website/src/roles.json +0 -70
  342. package/templates/website/src/schema/snapshot.json +0 -17018
  343. package/templates/website/src/settings.json +0 -66
  344. package/templates/website/src/users.json +0 -194
package/README.md CHANGED
@@ -9,14 +9,17 @@ A CLI tool to make applying or extracting Directus "templates" a little easier..
9
9
  - Templates are applied / extracted on an all or nothing basis – meaning that all the schema, content, and system settings are extracted or applied. We'd love to support more granular operations in the future. (PRs welcome 🙏)
10
10
  - If you are extracting or applying from a remote source, the script can take quite a while depending on the "size" of your instance (how many collections, how many items in each collection, number and size of assets, etc). The script applies a strict rate limit of 10 requests per second using bottleneck.
11
11
 
12
+ ## Breaking Changes in v0.4.0
13
+
14
+ - Templates are no longer being bundled with the CLI or included in this repository. Templates are stored in this repository - https://github.com/directus-community/directus-templates.
15
+ - When applying templates, the schema snapshot / schema diff is no longer used to create collections, fields, and relations. This allows support for loading multiple templates into a single instance.
16
+
12
17
  ## Usage
13
18
 
14
19
  Using the @latest tag ensures you're receiving the latest version of the packaged templates with the CLI. You can review [the specific versions on NPM](https://www.npmjs.com/package/directus-template-cli) and use @{version} syntax to apply the templates included with that version.
15
20
 
16
21
  ### Applying a Template
17
22
 
18
- **To avoid potential conflicts and bad outcomes, templates can only be applied to a blank instance currently.**
19
-
20
23
  1. Create a Directus instance on [Directus Cloud](https://directus.cloud) or using self-hosted version.
21
24
  2. Login and create a Static Access Token for the admin user.
22
25
  3. Copy the static token and your Directus URL.
@@ -1,4 +1,4 @@
1
- import { Command } from "@oclif/core";
1
+ import { Command } from '@oclif/core';
2
2
  export default class ApplyCommand extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
@@ -2,94 +2,124 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
- const core_2 = require("@oclif/core");
5
+ const giget_1 = require("giget");
6
6
  const inquirer = tslib_1.__importStar(require("inquirer"));
7
- const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
8
7
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
9
- const read_templates_1 = require("../lib/utils/read-templates");
10
- const api_1 = require("../lib/api");
11
8
  const load_1 = tslib_1.__importDefault(require("../lib/load/"));
12
9
  const auth_1 = require("../lib/utils/auth");
13
- const separator = "------------------";
10
+ const log_error_1 = tslib_1.__importDefault(require("../lib/utils/log-error"));
11
+ const path_1 = tslib_1.__importDefault(require("../lib/utils/path"));
12
+ const read_templates_1 = require("../lib/utils/read-templates");
13
+ const transform_github_url_1 = require("../lib/utils/transform-github-url");
14
+ const separator = '------------------';
14
15
  async function getTemplate() {
15
- const TEMPLATE_DIR = node_path_1.default.join(__dirname, "..", "..", "templates");
16
- const templates = await (0, read_templates_1.readAllTemplates)(TEMPLATE_DIR);
17
- const officialTemplateChoices = templates.map((template) => {
18
- return { name: template.templateName, value: template };
19
- });
20
16
  const templateType = await inquirer.prompt([
21
17
  {
22
- name: "templateType",
23
- message: "What type of template would you like to apply?",
24
- type: "list",
25
18
  choices: [
26
19
  {
27
- name: "Official templates",
28
- value: "official",
20
+ name: 'Official templates',
21
+ value: 'official',
22
+ },
23
+ {
24
+ name: 'From a local directory',
25
+ value: 'local',
29
26
  },
30
27
  {
31
- name: "From a local directory",
32
- value: "local",
28
+ name: 'From a GitHub repository',
29
+ value: 'github',
33
30
  },
34
- // {
35
- // name: "From a git repository",
36
- // value: "git",
37
- // },
38
31
  ],
32
+ message: 'What type of template would you like to apply?',
33
+ name: 'templateType',
34
+ type: 'list',
39
35
  },
40
36
  ]);
41
37
  let template;
42
- if (templateType.templateType === "official") {
38
+ if (templateType.templateType === 'official') {
39
+ // Get official templates
40
+ let templates = [];
41
+ // Resolve the path for downloading
42
+ const downloadDir = (0, path_1.default)(node_path_1.default.join(__dirname, '..', 'downloads', 'official'), false);
43
+ if (!downloadDir) {
44
+ throw new Error(`Invalid download directory: ${node_path_1.default.join(__dirname, '..', 'downloads', 'official')}`);
45
+ }
46
+ try {
47
+ const { dir } = await (0, giget_1.downloadTemplate)('github:directus-community/directus-templates', {
48
+ dir: downloadDir,
49
+ force: true,
50
+ preferOffline: true,
51
+ });
52
+ templates = await (0, read_templates_1.readAllTemplates)(dir);
53
+ }
54
+ catch (error) {
55
+ (0, log_error_1.default)(error, { fatal: true });
56
+ }
57
+ const officialTemplateChoices = templates.map((template) => ({ name: template.templateName, value: template }));
43
58
  template = await inquirer.prompt([
44
59
  {
45
- name: "template",
46
- message: "Select a template.",
47
- type: "list",
48
60
  choices: officialTemplateChoices,
61
+ message: 'Select a template.',
62
+ name: 'template',
63
+ type: 'list',
49
64
  },
50
65
  ]);
51
66
  }
52
- if (templateType.templateType === "local") {
53
- const localTemplateDir = await core_2.ux.prompt("What is the local template directory?");
54
- if (!node_fs_1.default.existsSync(localTemplateDir)) {
55
- core_2.ux.error("Directory does not exist.");
67
+ if (templateType.templateType === 'local') {
68
+ let localTemplateDir = await core_1.ux.prompt('What is the local template directory?');
69
+ localTemplateDir = (0, path_1.default)(localTemplateDir);
70
+ if (localTemplateDir) {
71
+ template = { template: await (0, read_templates_1.readTemplate)(localTemplateDir) };
56
72
  }
57
73
  else {
58
- template = { template: await (0, read_templates_1.readTemplate)(localTemplateDir) };
74
+ core_1.ux.error('Directory does not exist.');
75
+ }
76
+ }
77
+ if (templateType.templateType === 'github') {
78
+ const ghTemplateUrl = await core_1.ux.prompt('What is the public GitHub repository URL?');
79
+ try {
80
+ const ghString = await (0, transform_github_url_1.transformGitHubUrl)(ghTemplateUrl);
81
+ // Resolve the path for downloading
82
+ const downloadDir = (0, path_1.default)(node_path_1.default.join(__dirname, '..', 'downloads', 'github'), false);
83
+ if (!downloadDir) {
84
+ throw new Error(`Invalid download directory: ${node_path_1.default.join(__dirname, '..', 'downloads', 'github')}`);
85
+ }
86
+ // Download the template
87
+ const { dir } = await (0, giget_1.downloadTemplate)(ghString, {
88
+ dir: downloadDir,
89
+ force: true,
90
+ forceClean: true,
91
+ });
92
+ // Check if the directory exists after download
93
+ const resolvedDir = (0, path_1.default)(dir);
94
+ if (!resolvedDir) {
95
+ throw new Error(`Downloaded template directory does not exist: ${dir}`);
96
+ }
97
+ template = { template: await (0, read_templates_1.readTemplate)(dir) };
98
+ }
99
+ catch (error) {
100
+ (0, log_error_1.default)(error, { fatal: true });
59
101
  }
60
102
  }
61
103
  return template;
62
104
  }
63
105
  class ApplyCommand extends core_1.Command {
64
106
  async run() {
65
- const { flags } = await this.parse(ApplyCommand);
66
107
  const chosenTemplate = await getTemplate();
67
108
  this.log(`You selected ${chosenTemplate.template.templateName}`);
68
109
  this.log(separator);
69
110
  const directusUrl = await (0, auth_1.getDirectusUrl)();
70
- api_1.api.setBaseUrl(directusUrl);
71
- const directusToken = await (0, auth_1.getDirectusToken)(directusUrl);
72
- api_1.api.setAuthToken(directusToken);
111
+ await (0, auth_1.getDirectusToken)(directusUrl);
73
112
  this.log(separator);
74
- // Check if Directus instance is empty, if not, throw error
75
- const { data } = await api_1.api.get("/collections");
76
- // Look for collections that don't start with directus_
77
- const collections = data.data.filter((collection) => {
78
- return !collection.collection.startsWith("directus_");
79
- });
80
- if (collections.length > 0) {
81
- core_2.ux.error("Directus instance is not empty. Please use a blank instance. Copying a template into an existing instance is not supported at this time.");
82
- }
83
113
  // Run load script
84
- core_2.ux.action.start(`Applying template - ${chosenTemplate.template.templateName}`);
85
- await (0, load_1.default)(chosenTemplate.template.directoryPath, this);
86
- core_2.ux.action.stop();
114
+ core_1.ux.log(`Applying template - ${chosenTemplate.template.templateName} to ${directusUrl}`);
115
+ await (0, load_1.default)(chosenTemplate.template.directoryPath);
116
+ core_1.ux.action.stop();
87
117
  this.log(separator);
88
- this.log("Template applied successfully.");
118
+ this.log('Template applied successfully.');
89
119
  this.exit(0);
90
120
  }
91
121
  }
92
- exports.default = ApplyCommand;
93
- ApplyCommand.description = "Apply a template to a blank Directus instance.";
94
- ApplyCommand.examples = ["$ directus-template-cli apply"];
122
+ ApplyCommand.description = 'Apply a template to a blank Directus instance.';
123
+ ApplyCommand.examples = ['$ directus-template-cli apply'];
95
124
  ApplyCommand.flags = {};
125
+ exports.default = ApplyCommand;
@@ -1,7 +1,6 @@
1
- import { Command } from "@oclif/core";
1
+ import { Command } from '@oclif/core';
2
2
  export default class ExtractCommand extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
- static flags: {};
6
5
  run(): Promise<void>;
7
6
  }
@@ -2,19 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
- const core_2 = require("@oclif/core");
6
5
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
7
6
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
- const api_1 = require("../lib/api");
7
+ const slugify_1 = tslib_1.__importDefault(require("slugify"));
9
8
  const extract_1 = tslib_1.__importDefault(require("../lib/extract/"));
10
9
  const auth_1 = require("../lib/utils/auth");
11
10
  const template_defaults_1 = require("../lib/utils/template-defaults");
12
- const separator = "------------------";
11
+ const separator = '------------------';
13
12
  class ExtractCommand extends core_1.Command {
14
13
  async run() {
15
- const { flags } = await this.parse(ExtractCommand);
16
- const templateName = await core_2.ux.prompt("What is the name of the template?.");
17
- const directory = await core_2.ux.prompt("What directory would you like to extract the template to? If it doesn't exist, it will be created.");
14
+ const templateName = await core_1.ux.prompt('What is the name of the template?.');
15
+ const directory = await core_1.ux.prompt("What directory would you like to extract the template to? If it doesn't exist, it will be created.", { default: `templates/${(0, slugify_1.default)(templateName, { lower: true, strict: true })}` });
18
16
  this.log(`You selected ${directory}`);
19
17
  try {
20
18
  // Check if directory exists, if not, then create it.
@@ -25,8 +23,8 @@ class ExtractCommand extends core_1.Command {
25
23
  const packageJSONContent = (0, template_defaults_1.generatePackageJsonContent)(templateName);
26
24
  const readmeContent = (0, template_defaults_1.generateReadmeContent)(templateName);
27
25
  // Write the content to the specified directory
28
- const packageJSONPath = node_path_1.default.join(directory, "package.json");
29
- const readmePath = node_path_1.default.join(directory, "README.md");
26
+ const packageJSONPath = node_path_1.default.join(directory, 'package.json');
27
+ const readmePath = node_path_1.default.join(directory, 'README.md');
30
28
  node_fs_1.default.writeFileSync(packageJSONPath, packageJSONContent);
31
29
  node_fs_1.default.writeFileSync(readmePath, readmeContent);
32
30
  }
@@ -35,20 +33,17 @@ class ExtractCommand extends core_1.Command {
35
33
  }
36
34
  this.log(separator);
37
35
  const directusUrl = await (0, auth_1.getDirectusUrl)();
38
- api_1.api.setBaseUrl(directusUrl);
39
- const directusToken = await (0, auth_1.getDirectusToken)(directusUrl);
40
- api_1.api.setAuthToken(directusToken);
36
+ await (0, auth_1.getDirectusToken)(directusUrl);
41
37
  this.log(separator);
42
38
  // Run the extract script
43
- core_2.ux.action.start(`Extracting template - from ${directusUrl} to ${directory}`);
44
- await (0, extract_1.default)(directory, this);
45
- core_2.ux.action.stop();
39
+ core_1.ux.action.start(`Extracting template - from ${directusUrl} to ${directory}`);
40
+ await (0, extract_1.default)(directory);
41
+ core_1.ux.action.stop();
46
42
  this.log(separator);
47
- this.log("Template extracted successfully.");
43
+ this.log('Template extracted successfully.');
48
44
  this.exit(0);
49
45
  }
50
46
  }
47
+ ExtractCommand.description = 'Extract a template from a Directus instance.';
48
+ ExtractCommand.examples = ['$ directus-template-cli extract'];
51
49
  exports.default = ExtractCommand;
52
- ExtractCommand.description = "Extract a template from a Directus instance.";
53
- ExtractCommand.examples = ["$ directus-template-cli extract"];
54
- ExtractCommand.flags = {};
@@ -1,3 +1,183 @@
1
- export declare function getAssetList(): Promise<any>;
2
- export declare function downloadFile(file: any, dir: string): Promise<unknown>;
1
+ export declare function getAssetList(): Promise<import("@directus/sdk/dist/types-ZBNrmR-A").ax<import("@directus/sdk/dist/types-ZBNrmR-A").a8<{
2
+ id: string;
3
+ storage: string;
4
+ filename_disk: string;
5
+ filename_download: string;
6
+ title: string;
7
+ type: string;
8
+ folder: string | {
9
+ id: string;
10
+ name: string;
11
+ parent: any;
12
+ };
13
+ uploaded_by: string | {
14
+ id: string;
15
+ first_name: string;
16
+ last_name: string;
17
+ email: string;
18
+ password: string;
19
+ location: string;
20
+ title: string;
21
+ description: string;
22
+ tags: string[];
23
+ avatar: any;
24
+ language: string;
25
+ theme: string;
26
+ tfa_secret: string;
27
+ status: string;
28
+ role: string | {
29
+ id: string;
30
+ name: string;
31
+ icon: string;
32
+ description: string;
33
+ ip_access: string;
34
+ enforce_tfa: boolean;
35
+ admin_access: boolean;
36
+ app_access: boolean;
37
+ };
38
+ token: string;
39
+ last_access: "datetime";
40
+ last_page: string;
41
+ provider: string;
42
+ external_identifier: string;
43
+ auth_data: Record<string, any>;
44
+ email_notifications: boolean;
45
+ };
46
+ uploaded_on: "datetime";
47
+ modified_by: string | {
48
+ id: string;
49
+ first_name: string;
50
+ last_name: string;
51
+ email: string;
52
+ password: string;
53
+ location: string;
54
+ title: string;
55
+ description: string;
56
+ tags: string[];
57
+ avatar: any;
58
+ language: string;
59
+ theme: string;
60
+ tfa_secret: string;
61
+ status: string;
62
+ role: string | {
63
+ id: string;
64
+ name: string;
65
+ icon: string;
66
+ description: string;
67
+ ip_access: string;
68
+ enforce_tfa: boolean;
69
+ admin_access: boolean;
70
+ app_access: boolean;
71
+ };
72
+ token: string;
73
+ last_access: "datetime";
74
+ last_page: string;
75
+ provider: string;
76
+ external_identifier: string;
77
+ auth_data: Record<string, any>;
78
+ email_notifications: boolean;
79
+ };
80
+ modified_on: "datetime";
81
+ charset: string;
82
+ filesize: string;
83
+ width: number;
84
+ height: number;
85
+ duration: number;
86
+ embed: unknown;
87
+ description: string;
88
+ location: string;
89
+ tags: string[];
90
+ metadata: Record<string, any>;
91
+ }, "embed" | "type" | "location" | "description" | "id" | "duration" | "title" | "tags" | "storage" | "filename_disk" | "filename_download" | "folder" | "uploaded_by" | "uploaded_on" | "modified_by" | "modified_on" | "charset" | "filesize" | "width" | "height" | "metadata", import("@directus/sdk/dist/types-ZBNrmR-A").aI<import("../sdk").Schema, {
92
+ id: string;
93
+ storage: string;
94
+ filename_disk: string;
95
+ filename_download: string;
96
+ title: string;
97
+ type: string;
98
+ folder: string | {
99
+ id: string;
100
+ name: string;
101
+ parent: any;
102
+ };
103
+ uploaded_by: string | {
104
+ id: string;
105
+ first_name: string;
106
+ last_name: string;
107
+ email: string;
108
+ password: string;
109
+ location: string;
110
+ title: string;
111
+ description: string;
112
+ tags: string[];
113
+ avatar: any;
114
+ language: string;
115
+ theme: string;
116
+ tfa_secret: string;
117
+ status: string;
118
+ role: string | {
119
+ id: string;
120
+ name: string;
121
+ icon: string;
122
+ description: string;
123
+ ip_access: string;
124
+ enforce_tfa: boolean;
125
+ admin_access: boolean;
126
+ app_access: boolean;
127
+ };
128
+ token: string;
129
+ last_access: "datetime";
130
+ last_page: string;
131
+ provider: string;
132
+ external_identifier: string;
133
+ auth_data: Record<string, any>;
134
+ email_notifications: boolean;
135
+ };
136
+ uploaded_on: "datetime";
137
+ modified_by: string | {
138
+ id: string;
139
+ first_name: string;
140
+ last_name: string;
141
+ email: string;
142
+ password: string;
143
+ location: string;
144
+ title: string;
145
+ description: string;
146
+ tags: string[];
147
+ avatar: any;
148
+ language: string;
149
+ theme: string;
150
+ tfa_secret: string;
151
+ status: string;
152
+ role: string | {
153
+ id: string;
154
+ name: string;
155
+ icon: string;
156
+ description: string;
157
+ ip_access: string;
158
+ enforce_tfa: boolean;
159
+ admin_access: boolean;
160
+ app_access: boolean;
161
+ };
162
+ token: string;
163
+ last_access: "datetime";
164
+ last_page: string;
165
+ provider: string;
166
+ external_identifier: string;
167
+ auth_data: Record<string, any>;
168
+ email_notifications: boolean;
169
+ };
170
+ modified_on: "datetime";
171
+ charset: string;
172
+ filesize: string;
173
+ width: number;
174
+ height: number;
175
+ duration: number;
176
+ embed: unknown;
177
+ description: string;
178
+ location: string;
179
+ tags: string[];
180
+ metadata: Record<string, any>;
181
+ }>>, {}>[]>;
182
+ export declare function downloadFile(file: any, dir: string): Promise<void>;
3
183
  export declare function downloadAllFiles(dir: string): Promise<void>;
@@ -2,48 +2,41 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.downloadAllFiles = exports.downloadFile = exports.getAssetList = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const sdk_1 = require("@directus/sdk");
6
+ const core_1 = require("@oclif/core");
5
7
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
8
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
7
- const api_1 = require("../api");
9
+ const promises_1 = require("node:stream/promises");
10
+ const sdk_2 = require("../sdk");
8
11
  async function getAssetList() {
9
- const { data } = await api_1.api.get("/files", {
10
- params: {
11
- limit: "-1",
12
- },
13
- });
14
- return data.data;
12
+ const response = await sdk_2.api.client.request((0, sdk_1.readFiles)({ limit: -1 }));
13
+ return response;
15
14
  }
16
15
  exports.getAssetList = getAssetList;
17
16
  async function downloadFile(file, dir) {
18
- const response = await api_1.api.get(`assets/${file.id}`, {
19
- responseType: "stream",
20
- });
17
+ // Returned as ReadableStream<Uint8Array>
18
+ const response = await sdk_2.api.client.request((0, sdk_1.readAssetRaw)(file.id));
19
+ // Write the file to disk
20
+ const fullPath = node_path_1.default.join(dir, 'assets', file.filename_disk);
21
+ await (0, promises_1.pipeline)(
22
+ // @ts-ignore
23
+ response, node_fs_1.default.createWriteStream(fullPath));
24
+ }
25
+ exports.downloadFile = downloadFile;
26
+ async function downloadAllFiles(dir) {
21
27
  // Create assets folder if it doesn't exist
22
- const fullPath = node_path_1.default.join(dir, "assets");
28
+ const fullPath = node_path_1.default.join(dir, 'assets');
23
29
  if (node_path_1.default && !node_fs_1.default.existsSync(fullPath)) {
24
30
  node_fs_1.default.mkdirSync(fullPath, { recursive: true });
25
31
  }
26
- const writePath = node_path_1.default.resolve(dir, "assets", file.filename_disk);
27
- const writer = node_fs_1.default.createWriteStream(writePath);
28
- response.data.pipe(writer);
29
- return new Promise((resolve, reject) => {
30
- writer.on("finish", () => {
31
- // console.log(`Wrote ${file.filename_disk}`);
32
- resolve(null);
33
- });
34
- writer.on("error", reject);
35
- });
36
- }
37
- exports.downloadFile = downloadFile;
38
- async function downloadAllFiles(dir) {
32
+ // Get the list of files
39
33
  const fileList = await getAssetList();
40
- for (const file of fileList) {
41
- try {
42
- await downloadFile(file, dir);
43
- }
44
- catch (error) {
45
- console.log(`Error downloading ${file.filename_disk}`, error);
46
- }
47
- }
34
+ // Download all files
35
+ await Promise.all(fileList.map(file => downloadFile(file, dir).catch(error => {
36
+ core_1.ux.warn(`Error downloading ${file.filename_disk}`);
37
+ core_1.ux.warn(error.message);
38
+ })));
39
+ // Log message after all files have been downloaded
40
+ core_1.ux.log('All files have been downloaded.');
48
41
  }
49
42
  exports.downloadAllFiles = downloadAllFiles;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Extract collections from the Directus instance
3
+ */
4
+ export default function extractCollections(dir: string): Promise<void>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const sdk_1 = require("@directus/sdk");
5
+ const core_1 = require("@oclif/core");
6
+ const sdk_2 = require("../sdk");
7
+ const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"));
8
+ /**
9
+ * Extract collections from the Directus instance
10
+ */
11
+ async function extractCollections(dir) {
12
+ try {
13
+ const response = await sdk_2.api.client.request((0, sdk_1.readCollections)());
14
+ // Filter out system collections
15
+ const collections = response.filter(collection => !collection.collection.startsWith('directus_'));
16
+ await (0, write_to_file_1.default)('collections', collections, dir);
17
+ core_1.ux.log('Extracted collections');
18
+ }
19
+ catch (error) {
20
+ core_1.ux.warn('Error extracting Collections:');
21
+ core_1.ux.warn(error.message);
22
+ }
23
+ }
24
+ exports.default = extractCollections;
@@ -1,3 +1,3 @@
1
- export declare function getCollections(): Promise<any>;
1
+ export declare function getCollections(): Promise<string[]>;
2
2
  export declare function getDataFromCollection(collection: string, dir: string): Promise<void>;
3
3
  export declare function extractContent(dir: string): Promise<void>;
@@ -2,36 +2,36 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractContent = exports.getDataFromCollection = exports.getCollections = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const api_1 = require("../api");
5
+ const sdk_1 = require("@directus/sdk");
6
+ const core_1 = require("@oclif/core");
7
+ const sdk_2 = require("../sdk");
6
8
  const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"));
7
9
  async function getCollections() {
8
- const { data } = await api_1.api.get("/collections");
9
- const collections = data.data
10
- .filter((item) => !item.collection.startsWith("directus_", 0))
11
- .filter((item) => item.schema != null)
12
- .map((i) => i.collection);
10
+ const response = await sdk_2.api.client.request((0, sdk_1.readCollections)());
11
+ const collections = response
12
+ .filter(item => !item.collection.startsWith('directus_', 0))
13
+ .filter(item => item.schema != null)
14
+ .map(i => i.collection);
13
15
  return collections;
14
16
  }
15
17
  exports.getCollections = getCollections;
16
18
  async function getDataFromCollection(collection, dir) {
17
19
  try {
18
- const { data } = await api_1.api.get(`items/${collection}`, {
19
- params: {
20
- limit: -1,
21
- },
22
- });
23
- (0, write_to_file_1.default)(`${collection}`, data.data, `${dir}/content/`);
20
+ // @ts-ignore
21
+ const response = await sdk_2.api.client.request((0, sdk_1.readItems)(collection, {
22
+ limit: -1,
23
+ }));
24
+ (0, write_to_file_1.default)(`${collection}`, response, `${dir}/content/`);
25
+ core_1.ux.log('Extracted items from collection: ' + collection);
24
26
  }
25
- catch {
26
- console.log(`error getting items from ${collection}`);
27
- // Errors are thrown for 'folder' collections
27
+ catch (error) {
28
+ core_1.ux.warn(`Error extracting items from: ${collection}`);
29
+ core_1.ux.warn(error.message);
28
30
  }
29
31
  }
30
32
  exports.getDataFromCollection = getDataFromCollection;
31
33
  async function extractContent(dir) {
32
34
  const collections = await getCollections();
33
- for (const collection of collections) {
34
- await getDataFromCollection(collection, dir);
35
- }
35
+ await Promise.all(collections.map(collection => getDataFromCollection(collection, dir)));
36
36
  }
37
37
  exports.extractContent = extractContent;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Extract dashboards from the Directus instance
3
+ */
4
+ export declare function extractDashboards(dir: string): Promise<void>;
5
+ /**
6
+ * Extract panels from the Directus instance
7
+ */
8
+ export declare function extractPanels(dir: string): Promise<void>;