ghost 5.2.2 → 5.3.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 (259) hide show
  1. package/content/themes/casper/assets/built/screen.css +1 -1
  2. package/content/themes/casper/assets/built/screen.css.map +1 -1
  3. package/content/themes/casper/assets/css/screen.css +31 -1
  4. package/content/themes/casper/default.hbs +1 -0
  5. package/content/themes/casper/package.json +1 -1
  6. package/content/themes/casper/partials/icons/search.hbs +1 -0
  7. package/core/boot.js +3 -1
  8. package/core/bridge.js +7 -0
  9. package/core/built/assets/codemirror/{codemirror-d25c379b87ec8b33d54ac7149bc0b6ae.js → codemirror-30201ab2cff61db847193fc9f5ed922d.js} +1 -1
  10. package/core/built/assets/ghost-dark-9e5d1f0dfae41232e5e34e4d0df53ae0.css +1 -0
  11. package/core/built/assets/ghost.min-e7cfbd1800f8e99b9158f74f1e39cd76.css +1 -0
  12. package/core/built/assets/{ghost.min-971a0ff706bbf9e24f0b0a5770c8fc41.js → ghost.min-f4bba3a2a5ef256b82641345505d4f0f.js} +69 -66
  13. package/core/built/assets/icons/activity-placeholder.svg +3 -0
  14. package/core/built/assets/simplemde/{simplemde-3ffc0ec9e9fecf29b9a499db678c9e65.js → simplemde-fb4527da6e489b34dc24b28ea870b286.js} +1 -1
  15. package/core/built/assets/{vendor.min-ea369e6487643585f35409d474b06789.js → vendor.min-4076498ccd6c8412365f43b156084ed8.js} +119 -117
  16. package/core/built/assets/{vendor.min-ba66b98f7c24fa40e061c7ffc94f4e23.css → vendor.min-4a6661c574707ceca220aa2e76558995.css} +2 -1
  17. package/core/frontend/helpers/comment_count.js +25 -0
  18. package/core/frontend/helpers/comments.js +67 -0
  19. package/core/frontend/helpers/date.js +3 -1
  20. package/core/frontend/helpers/ghost_head.js +13 -0
  21. package/core/frontend/services/admin-auth-assets/index.js +4 -0
  22. package/core/frontend/services/admin-auth-assets/service.js +93 -0
  23. package/core/frontend/services/comment-counts-assets/index.js +4 -0
  24. package/core/frontend/services/comment-counts-assets/service.js +59 -0
  25. package/core/frontend/services/theme-engine/middleware/update-global-template-options.js +5 -1
  26. package/core/frontend/src/admin-auth/index.html +5 -0
  27. package/core/frontend/src/admin-auth/message-handler.js +75 -0
  28. package/core/frontend/src/comment-counts/js/comment-counts.js +71 -0
  29. package/core/frontend/web/site.js +3 -0
  30. package/core/server/api/{canary → endpoints}/actions.js +0 -0
  31. package/core/server/api/{canary → endpoints}/authentication.js +0 -0
  32. package/core/server/api/{canary → endpoints}/authors-public.js +0 -0
  33. package/core/server/api/endpoints/comments-comments.js +247 -0
  34. package/core/server/api/endpoints/comments.js +25 -0
  35. package/core/server/api/{canary → endpoints}/config.js +0 -0
  36. package/core/server/api/{canary → endpoints}/custom-theme-settings.js +0 -0
  37. package/core/server/api/{canary → endpoints}/db.js +0 -0
  38. package/core/server/api/{canary → endpoints}/email-post.js +0 -0
  39. package/core/server/api/{canary → endpoints}/email-previews.js +0 -0
  40. package/core/server/api/{canary → endpoints}/emails.js +0 -0
  41. package/core/server/api/endpoints/explore.js +12 -0
  42. package/core/server/api/{canary → endpoints}/files.js +0 -0
  43. package/core/server/api/{canary → endpoints}/identities.js +0 -0
  44. package/core/server/api/{canary → endpoints}/images.js +0 -0
  45. package/core/server/api/{canary → endpoints}/index.js +16 -0
  46. package/core/server/api/{canary → endpoints}/integrations.js +0 -0
  47. package/core/server/api/{canary → endpoints}/invites.js +0 -0
  48. package/core/server/api/{canary → endpoints}/labels.js +0 -0
  49. package/core/server/api/{canary → endpoints}/mail.js +0 -0
  50. package/core/server/api/{canary → endpoints}/media.js +0 -0
  51. package/core/server/api/{canary → endpoints}/member-signin-urls.js +0 -0
  52. package/core/server/api/{canary → endpoints}/members-stripe-connect.js +0 -0
  53. package/core/server/api/{canary → endpoints}/members.js +0 -0
  54. package/core/server/api/{canary → endpoints}/newsletters-public.js +0 -0
  55. package/core/server/api/{canary → endpoints}/newsletters.js +0 -0
  56. package/core/server/api/{canary → endpoints}/notifications.js +0 -0
  57. package/core/server/api/{canary → endpoints}/oembed.js +0 -0
  58. package/core/server/api/{canary → endpoints}/offers-public.js +0 -0
  59. package/core/server/api/{canary → endpoints}/offers.js +0 -0
  60. package/core/server/api/{canary → endpoints}/pages-public.js +0 -0
  61. package/core/server/api/{canary → endpoints}/pages.js +0 -0
  62. package/core/server/api/{canary → endpoints}/posts-public.js +0 -0
  63. package/core/server/api/{canary → endpoints}/posts.js +0 -0
  64. package/core/server/api/{canary → endpoints}/previews.js +0 -0
  65. package/core/server/api/{canary → endpoints}/redirects.js +0 -0
  66. package/core/server/api/{canary → endpoints}/roles.js +0 -0
  67. package/core/server/api/{canary → endpoints}/schedules.js +0 -0
  68. package/core/server/api/{canary → endpoints}/session.js +0 -0
  69. package/core/server/api/{canary → endpoints}/settings-public.js +0 -0
  70. package/core/server/api/{canary → endpoints}/settings.js +0 -0
  71. package/core/server/api/{canary → endpoints}/site.js +0 -0
  72. package/core/server/api/{canary → endpoints}/slack.js +0 -0
  73. package/core/server/api/{canary → endpoints}/slugs.js +0 -0
  74. package/core/server/api/{canary → endpoints}/snippets.js +0 -0
  75. package/core/server/api/{canary → endpoints}/stats.js +0 -0
  76. package/core/server/api/{canary → endpoints}/tags-public.js +0 -0
  77. package/core/server/api/{canary → endpoints}/tags.js +0 -0
  78. package/core/server/api/{canary → endpoints}/themes.js +0 -0
  79. package/core/server/api/{canary → endpoints}/tiers-public.js +0 -0
  80. package/core/server/api/{canary → endpoints}/tiers.js +0 -0
  81. package/core/server/api/{canary → endpoints}/users.js +0 -0
  82. package/core/server/api/{canary → endpoints}/utils/index.js +0 -0
  83. package/core/server/api/{canary → endpoints}/utils/permissions.js +3 -3
  84. package/core/server/api/{canary → endpoints}/utils/serializers/index.js +0 -0
  85. package/core/server/api/{canary → endpoints}/utils/serializers/input/authors.js +1 -1
  86. package/core/server/api/{canary → endpoints}/utils/serializers/input/db.js +1 -1
  87. package/core/server/api/{canary → endpoints}/utils/serializers/input/index.js +0 -0
  88. package/core/server/api/{canary → endpoints}/utils/serializers/input/integrations.js +1 -1
  89. package/core/server/api/{canary → endpoints}/utils/serializers/input/media.js +0 -0
  90. package/core/server/api/{canary → endpoints}/utils/serializers/input/members.js +1 -1
  91. package/core/server/api/{canary → endpoints}/utils/serializers/input/pages.js +1 -1
  92. package/core/server/api/{canary → endpoints}/utils/serializers/input/posts.js +1 -1
  93. package/core/server/api/{canary → endpoints}/utils/serializers/input/settings.js +2 -1
  94. package/core/server/api/{canary → endpoints}/utils/serializers/input/tags.js +1 -1
  95. package/core/server/api/{canary → endpoints}/utils/serializers/input/tiers.js +0 -0
  96. package/core/server/api/{canary → endpoints}/utils/serializers/input/users.js +1 -1
  97. package/core/server/api/{canary → endpoints}/utils/serializers/input/utils/slug-filter-order.js +0 -0
  98. package/core/server/api/{canary → endpoints}/utils/serializers/input/utils/url.js +0 -0
  99. package/core/server/api/{canary → endpoints}/utils/serializers/input/webhooks.js +1 -1
  100. package/core/server/api/{canary → endpoints}/utils/serializers/output/all.js +1 -1
  101. package/core/server/api/{canary → endpoints}/utils/serializers/output/authentication.js +1 -1
  102. package/core/server/api/endpoints/utils/serializers/output/comments.js +5 -0
  103. package/core/server/api/{canary → endpoints}/utils/serializers/output/config.js +1 -1
  104. package/core/server/api/{canary → endpoints}/utils/serializers/output/custom-theme-settings.js +0 -0
  105. package/core/server/api/{canary → endpoints}/utils/serializers/output/db.js +1 -1
  106. package/core/server/api/{canary → endpoints}/utils/serializers/output/default.js +1 -1
  107. package/core/server/api/{canary → endpoints}/utils/serializers/output/email-posts.js +0 -0
  108. package/core/server/api/endpoints/utils/serializers/output/explore.js +11 -0
  109. package/core/server/api/{canary → endpoints}/utils/serializers/output/files.js +0 -0
  110. package/core/server/api/{canary → endpoints}/utils/serializers/output/images.js +1 -1
  111. package/core/server/api/{canary → endpoints}/utils/serializers/output/index.js +8 -0
  112. package/core/server/api/{canary → endpoints}/utils/serializers/output/mail.js +1 -1
  113. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/actions.js +0 -0
  114. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/authors.js +0 -0
  115. package/core/server/api/endpoints/utils/serializers/output/mappers/comments.js +50 -0
  116. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/emails.js +0 -0
  117. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/images.js +0 -0
  118. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/index.js +1 -0
  119. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/integrations.js +0 -0
  120. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/newsletters.js +0 -0
  121. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/pages.js +0 -0
  122. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/posts.js +0 -0
  123. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/settings.js +0 -0
  124. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/snippets.js +0 -0
  125. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/tags.js +0 -0
  126. package/core/server/api/{canary → endpoints}/utils/serializers/output/mappers/users.js +0 -0
  127. package/core/server/api/{canary → endpoints}/utils/serializers/output/media.js +0 -0
  128. package/core/server/api/{canary → endpoints}/utils/serializers/output/members-stripe-connect.js +0 -0
  129. package/core/server/api/{canary → endpoints}/utils/serializers/output/members.js +1 -1
  130. package/core/server/api/{canary → endpoints}/utils/serializers/output/notifications.js +1 -1
  131. package/core/server/api/{canary → endpoints}/utils/serializers/output/oembed.js +1 -1
  132. package/core/server/api/{canary → endpoints}/utils/serializers/output/offers.js +1 -1
  133. package/core/server/api/{canary → endpoints}/utils/serializers/output/pages.js +1 -1
  134. package/core/server/api/{canary → endpoints}/utils/serializers/output/posts.js +1 -1
  135. package/core/server/api/{canary → endpoints}/utils/serializers/output/previews.js +0 -0
  136. package/core/server/api/{canary → endpoints}/utils/serializers/output/redirects.js +0 -0
  137. package/core/server/api/{canary → endpoints}/utils/serializers/output/roles.js +1 -1
  138. package/core/server/api/{canary → endpoints}/utils/serializers/output/schedules.js +0 -0
  139. package/core/server/api/{canary → endpoints}/utils/serializers/output/session.js +1 -1
  140. package/core/server/api/{canary → endpoints}/utils/serializers/output/settings.js +0 -0
  141. package/core/server/api/{canary → endpoints}/utils/serializers/output/site.js +1 -1
  142. package/core/server/api/{canary → endpoints}/utils/serializers/output/slack.js +1 -1
  143. package/core/server/api/{canary → endpoints}/utils/serializers/output/slugs.js +1 -1
  144. package/core/server/api/{canary → endpoints}/utils/serializers/output/themes.js +1 -1
  145. package/core/server/api/{canary → endpoints}/utils/serializers/output/tiers.js +1 -1
  146. package/core/server/api/{canary → endpoints}/utils/serializers/output/users.js +1 -1
  147. package/core/server/api/{canary → endpoints}/utils/serializers/output/utils/clean.js +2 -1
  148. package/core/server/api/{canary → endpoints}/utils/serializers/output/utils/date.js +0 -0
  149. package/core/server/api/endpoints/utils/serializers/output/utils/extra-attrs.js +67 -0
  150. package/core/server/api/{canary → endpoints}/utils/serializers/output/utils/post-gating.js +0 -0
  151. package/core/server/api/{canary → endpoints}/utils/serializers/output/utils/url.js +1 -1
  152. package/core/server/api/{canary → endpoints}/utils/validators/index.js +0 -0
  153. package/core/server/api/{canary → endpoints}/utils/validators/input/files.js +0 -0
  154. package/core/server/api/{canary → endpoints}/utils/validators/input/images.js +0 -0
  155. package/core/server/api/{canary → endpoints}/utils/validators/input/index.js +0 -0
  156. package/core/server/api/{canary → endpoints}/utils/validators/input/invitations.js +1 -1
  157. package/core/server/api/{canary → endpoints}/utils/validators/input/invites.js +0 -0
  158. package/core/server/api/{canary → endpoints}/utils/validators/input/labels.js +0 -0
  159. package/core/server/api/{canary → endpoints}/utils/validators/input/media.js +0 -0
  160. package/core/server/api/{canary → endpoints}/utils/validators/input/members.js +0 -0
  161. package/core/server/api/{canary → endpoints}/utils/validators/input/oembed.js +0 -0
  162. package/core/server/api/{canary → endpoints}/utils/validators/input/pages.js +0 -0
  163. package/core/server/api/{canary → endpoints}/utils/validators/input/password_reset.js +1 -1
  164. package/core/server/api/{canary → endpoints}/utils/validators/input/posts.js +0 -0
  165. package/core/server/api/{canary → endpoints}/utils/validators/input/settings.js +0 -0
  166. package/core/server/api/{canary → endpoints}/utils/validators/input/setup.js +1 -1
  167. package/core/server/api/{canary → endpoints}/utils/validators/input/snippets.js +0 -0
  168. package/core/server/api/{canary → endpoints}/utils/validators/input/tags.js +0 -0
  169. package/core/server/api/{canary → endpoints}/utils/validators/input/tiers.js +0 -0
  170. package/core/server/api/{canary → endpoints}/utils/validators/input/users.js +1 -1
  171. package/core/server/api/{canary → endpoints}/utils/validators/input/webhooks.js +0 -0
  172. package/core/server/api/{canary → endpoints}/utils/validators/output/index.js +0 -0
  173. package/core/server/api/{canary → endpoints}/utils/validators/utils/json-schema.js +0 -0
  174. package/core/server/api/{canary → endpoints}/webhooks.js +0 -0
  175. package/core/server/api/index.js +1 -1
  176. package/core/server/data/exporter/table-lists.js +4 -2
  177. package/core/server/data/migrations/versions/5.3/2022-07-04-13-49-add-comments-table.js +13 -0
  178. package/core/server/data/migrations/versions/5.3/2022-07-05-09-36-add-comments-likes-table.js +9 -0
  179. package/core/server/data/migrations/versions/5.3/2022-07-05-09-47-add-comments-reports-table.js +10 -0
  180. package/core/server/data/migrations/versions/5.3/2022-07-05-10-00-add-comment-related-fields-to-members.js +21 -0
  181. package/core/server/data/migrations/versions/5.3/2022-07-05-12-55-add-comments-crud-permissions.js +68 -0
  182. package/core/server/data/migrations/versions/5.3/2022-07-05-15-35-add-comment-notifications-field-to-users-table.js +7 -0
  183. package/core/server/data/migrations/versions/5.3/2022-07-06-07-26-add-comments-enabled-setting.js +8 -0
  184. package/core/server/data/migrations/versions/5.3/2022-07-06-07-58-add-ghost-explore-integration-role.js +31 -0
  185. package/core/server/data/migrations/versions/5.3/2022-07-06-09-13-add-ghost-explore-integration-role-permissions.js +11 -0
  186. package/core/server/data/migrations/versions/5.3/2022-07-06-09-17-add-ghost-explore-integration.js +38 -0
  187. package/core/server/data/migrations/versions/5.3/2022-07-06-09-26-add-ghost-explore-integration-api-key.js +73 -0
  188. package/core/server/data/schema/default-settings/default-settings.json +14 -0
  189. package/core/server/data/schema/fixtures/fixtures.json +65 -2
  190. package/core/server/data/schema/schema.js +31 -1
  191. package/core/server/models/base/plugins/crud.js +15 -0
  192. package/core/server/models/comment-like.js +34 -0
  193. package/core/server/models/comment.js +163 -0
  194. package/core/server/models/member.js +2 -1
  195. package/core/server/models/user.js +2 -1
  196. package/core/server/services/auth/session/express-session.js +1 -1
  197. package/core/server/services/comments/email-templates/new-comment-reply.hbs +199 -0
  198. package/core/server/services/comments/email-templates/new-comment-reply.txt.js +14 -0
  199. package/core/server/services/comments/email-templates/new-comment.hbs +199 -0
  200. package/core/server/services/comments/email-templates/new-comment.txt.js +14 -0
  201. package/core/server/services/comments/emails.js +164 -0
  202. package/core/server/services/comments/index.js +26 -0
  203. package/core/server/services/comments/service.js +24 -0
  204. package/core/server/services/explore/index.js +18 -0
  205. package/core/server/services/explore/service.js +55 -0
  206. package/core/server/services/members/middleware.js +4 -4
  207. package/core/server/services/members/utils.js +2 -1
  208. package/core/server/services/permissions/can-this.js +18 -5
  209. package/core/server/services/permissions/parse-context.js +5 -0
  210. package/core/server/services/permissions/providers.js +17 -1
  211. package/core/server/services/posts/posts-service.js +14 -0
  212. package/core/server/services/users.js +84 -1
  213. package/core/server/web/admin/app.js +4 -0
  214. package/core/server/web/admin/views/default-prod.html +5 -5
  215. package/core/server/web/admin/views/default.html +5 -5
  216. package/core/server/web/api/app.js +2 -2
  217. package/core/server/web/api/{canary → endpoints}/admin/app.js +4 -4
  218. package/core/server/web/api/{canary → endpoints}/admin/middleware.js +1 -0
  219. package/core/server/web/api/{canary → endpoints}/admin/routes.js +6 -1
  220. package/core/server/web/api/{canary → endpoints}/content/app.js +4 -4
  221. package/core/server/web/api/{canary → endpoints}/content/middleware.js +0 -0
  222. package/core/server/web/api/{canary → endpoints}/content/routes.js +1 -1
  223. package/core/server/web/api/testmode/routes.js +1 -1
  224. package/core/server/web/comments/index.js +1 -0
  225. package/core/server/web/comments/routes.js +28 -0
  226. package/core/server/web/members/app.js +5 -0
  227. package/core/server/web/parent/frontend.js +1 -0
  228. package/core/shared/config/defaults.json +16 -6
  229. package/core/shared/config/env/config.testing.json +4 -0
  230. package/core/shared/config/overrides.json +1 -0
  231. package/core/shared/labs.js +2 -1
  232. package/core/shared/settings-cache/public.js +2 -1
  233. package/package.json +20 -20
  234. package/yarn.lock +425 -275
  235. package/Gruntfile.js +0 -384
  236. package/core/built/assets/ghost-dark-923c90399aa560625a983a6ae9abb38c.css +0 -1
  237. package/core/built/assets/ghost.min-c74f50609022cebf13ad28810def68b6.css +0 -1
  238. package/core/built/assets/img/contributors/AileenCGN-bf8b9ffbb34c0fd93beb8136af07771b.jpeg +0 -0
  239. package/core/built/assets/img/contributors/ErisDS-c958ccb9e3597320dee745a42f478569.jpeg +0 -0
  240. package/core/built/assets/img/contributors/GeorginaLusby-6cea5defddee3c4ea7320e580521e832.jpeg +0 -0
  241. package/core/built/assets/img/contributors/JohnONolan-47041b80c35c6341b9b929b03139aecc.jpeg +0 -0
  242. package/core/built/assets/img/contributors/acburdine-d9777fe2601dc215afb6723315829c89.jpeg +0 -0
  243. package/core/built/assets/img/contributors/bnookala-5896fcdd2f477495323e420efe890657.jpeg +0 -0
  244. package/core/built/assets/img/contributors/cobbspur-07ded67009757d12517621fc856eba62.jpeg +0 -0
  245. package/core/built/assets/img/contributors/dbalders-452347a406c2ca23657daea9100878f3.jpeg +0 -0
  246. package/core/built/assets/img/contributors/disordinary-b9997e5debb59b7aadc79ba90955b662.jpeg +0 -0
  247. package/core/built/assets/img/contributors/felixrieseberg-ecf29e8eadc58fab999c507049f898cf.jpeg +0 -0
  248. package/core/built/assets/img/contributors/frantzypants-637b03f85dff89700a661fde79daea5c.jpeg +0 -0
  249. package/core/built/assets/img/contributors/halfdan-00d6783e5fba2900ee1380939297d8ee.jpeg +0 -0
  250. package/core/built/assets/img/contributors/jaswilli-8cc9a8d2539ca03239d113dfb25ff5c2.jpeg +0 -0
  251. package/core/built/assets/img/contributors/kevinansfield-925606c55bc2f3f2f05c0fa58b953ad1.jpeg +0 -0
  252. package/core/built/assets/img/contributors/kevinkucharczyk-3c7dfe2a103a83737b9d5ee8e19d67f8.jpeg +0 -0
  253. package/core/built/assets/img/contributors/kirrg001-79823418f2ca21e81719653f0286f95b.jpeg +0 -0
  254. package/core/built/assets/img/contributors/mixonic-1ff87736dd02cfa080ae109b45131aa6.png +0 -0
  255. package/core/built/assets/img/contributors/rwjblue-5c7cc009cda45baca2d45f0d1ed19e48.jpeg +0 -0
  256. package/core/built/assets/img/contributors/sebgie-0fb02df00ee7834dbcc8beba84aec81e.png +0 -0
  257. package/core/built/assets/img/contributors/tgriesser-d871cbf74a871c0fb6d855e76a893f7e.png +0 -0
  258. package/core/server/api/canary/utils/serializers/output/utils/extra-attrs.js +0 -33
  259. package/urls.json +0 -597
package/Gruntfile.js DELETED
@@ -1,384 +0,0 @@
1
- const config = require('./core/shared/config');
2
- const fs = require('fs-extra');
3
- const path = require('path');
4
-
5
- // Utility for outputting messages indicating that the admin is building, as it can take a while.
6
- let hasBuiltAdmin = false;
7
- const logBuildingAdmin = function (grunt) {
8
- if (!hasBuiltAdmin) {
9
- grunt.log.writeln('Building admin app... (can take ~1min)');
10
- setTimeout(logBuildingAdmin, 5000, grunt);
11
- }
12
- };
13
-
14
- module.exports = function (grunt) {
15
- // grunt dev - use yarn dev instead!
16
- // - Start a server & build assets on the fly whilst developing
17
- grunt.registerTask('dev', 'Dev Mode; watch files and restart server on changes', function () {
18
- if (grunt.option('admin')) {
19
- grunt.task.run(['clean:built', 'bgShell:admin']);
20
- } else if (grunt.option('server')) {
21
- grunt.task.run(['express:dev', 'watch']);
22
- } else {
23
- grunt.task.run(['clean:built', 'bgShell:admin', 'express:dev', 'watch']);
24
- }
25
- });
26
-
27
- // grunt build -- use yarn build instead!
28
- // - Builds the admin without a watch task
29
- grunt.registerTask('build', 'Build admin app in development mode',
30
- ['subgrunt:init', 'clean:tmp', 'ember']);
31
-
32
- // Helpers for common deprecated tasks
33
- grunt.registerTask('main', function () {
34
- grunt.log.error('@deprecated: Run `yarn main` instead');
35
- });
36
-
37
- grunt.registerTask('validate', function () {
38
- grunt.log.error('@deprecated: Run `yarn test` instead');
39
- });
40
-
41
- // --- Sub Commands
42
- // Used to make other commands work
43
-
44
- // Updates submodules, then installs and builds the admin for you
45
- grunt.registerTask('init', 'Prepare the project for development',
46
- ['update_submodules:pinned', 'build']);
47
-
48
- // Runs ember dev
49
- grunt.registerTask('ember', 'Build JS & templates for development',
50
- ['subgrunt:dev']);
51
-
52
- // Production asset build
53
- grunt.registerTask('prod', 'Build JS & templates for production',
54
- ['subgrunt:prod', 'postcss:prod']);
55
-
56
- // --- Configuration
57
- const cfg = {
58
- // grunt-contrib-watch
59
- // Watch files and livereload in the browser during development.
60
- // See the grunt dev task for how this is used.
61
- watch: grunt.option('no-server-watch') ? {files: []} : {
62
- livereload: {
63
- files: [
64
- 'content/themes/casper/assets/css/*.css',
65
- 'content/themes/casper/assets/js/*.js'
66
- ],
67
- options: {
68
- livereload: true,
69
- interval: 500
70
- }
71
- },
72
- express: {
73
- files: [
74
- 'core/server/**/*.js',
75
- 'core/shared/**/*.js',
76
- 'core/frontend/**/*.js',
77
- 'core/frontend/src/**/*.css',
78
- 'core/*.js',
79
- 'index.js',
80
- 'config.*.json',
81
- '!config.testing.json'
82
- ],
83
- tasks: ['express:dev'],
84
- options: {
85
- spawn: false,
86
- livereload: true,
87
- interval: 500
88
- }
89
- }
90
- },
91
-
92
- // grunt-express-server
93
- // Start a Ghost express server for use in development and testing
94
- express: {
95
- dev: {
96
- options: {
97
- script: 'index.js',
98
- output: 'Ghost is running'
99
- }
100
- }
101
- },
102
-
103
- // grunt-bg-shell
104
- // Tools for building the admin
105
- bgShell: {
106
- admin: {
107
- cmd: function () {
108
- logBuildingAdmin(grunt);
109
- return 'grunt subgrunt:watch';
110
- },
111
- bg: grunt.option('admin') ? false : true,
112
- stdout: function (chunk) {
113
- // hide certain output to prevent confusion when running alongside server
114
- const filter = grunt.option('admin') ? false : [
115
- /> ghost-admin/,
116
- /^Livereload/,
117
- /^Serving on/
118
- ].some(function (regexp) {
119
- return regexp.test(chunk);
120
- });
121
-
122
- if (!filter) {
123
- grunt.log.write(chunk);
124
- }
125
-
126
- if (chunk.indexOf('Slowest Nodes') !== -1) {
127
- hasBuiltAdmin = true;
128
- }
129
- },
130
- stderr: function (chunk) {
131
- const skipFilter = grunt.option('admin') ? false : [
132
- /- building/
133
- ].some(function (regexp) {
134
- return regexp.test(chunk);
135
- });
136
-
137
- const errorFilter = grunt.option('admin') ? false : [
138
- /^>>/
139
- ].some(function (regexp) {
140
- return regexp.test(chunk);
141
- });
142
-
143
- if (!skipFilter) {
144
- hasBuiltAdmin = errorFilter ? hasBuiltAdmin : true;
145
- grunt.log.error(chunk);
146
- }
147
- }
148
- }
149
- },
150
-
151
- // grunt-shell
152
- // Command line tools where it's easier to run a command directly than configure a grunt plugin
153
- shell: {
154
- main: {
155
- command: function () {
156
- const upstream = grunt.option('upstream') || process.env.GHOST_UPSTREAM || 'upstream';
157
- grunt.log.writeln('Pulling down the latest main from ' + upstream);
158
- return `
159
- git submodule sync && \
160
- git submodule update
161
-
162
- if ! git diff --exit-code --quiet --ignore-submodules=untracked; then
163
- echo "Working directory is not clean, do you have uncommitted changes? Please commit, stash or discard changes to continue."
164
- exit 1
165
- fi
166
-
167
- git checkout main
168
-
169
- if git config remote.${upstream}.url > /dev/null; then
170
- git pull ${upstream} main
171
- else
172
- git pull origin main
173
- fi
174
-
175
- yarn && \
176
- git submodule foreach "
177
- git checkout main
178
-
179
- if git config remote.${upstream}.url > /dev/null; then
180
- git pull ${upstream} main
181
- else
182
- git pull origin main
183
- fi
184
- "
185
- `;
186
- }
187
- }
188
- },
189
-
190
- // grunt-contrib-clean
191
- // Clean up files as part of other tasks
192
- clean: {
193
- built: {
194
- src: [
195
- 'core/built/**'
196
- ]
197
- },
198
- tmp: {
199
- src: ['.tmp/**']
200
- }
201
- },
202
-
203
- // grunt-update-submodules
204
- // Grunt task to update git submodules
205
- update_submodules: {
206
- pinned: {
207
- options: {
208
- params: '--init'
209
- }
210
- }
211
- },
212
-
213
- // @lodder/grunt-postcss
214
- // Generate processed, minified css files
215
- postcss: {
216
- prod: {
217
- options: {
218
- processors: [
219
- require('cssnano')() // minify the result
220
- ]
221
- },
222
- files: {
223
- 'core/frontend/public/ghost.min.css': 'core/frontend/public/ghost.css'
224
- }
225
- }
226
- },
227
-
228
- // grunt-subgrunt
229
- // Run grunt tasks in submodule Gruntfiles
230
- subgrunt: {
231
- options: {
232
- npmInstall: false,
233
- npmPath: 'yarn'
234
- },
235
-
236
- init: {
237
- options: {
238
- npmInstall: true
239
- },
240
- projects: {
241
- 'core/admin': 'init'
242
- }
243
- },
244
-
245
- dev: {
246
- 'core/admin': 'shell:ember:dev'
247
- },
248
-
249
- prod: {
250
- 'core/admin': 'shell:ember:prod'
251
- },
252
-
253
- watch: {
254
- projects: {
255
- 'core/admin': ['shell:ember:watch', '--live-reload-base-url="' + config.getSubdir() + '/ghost/"']
256
- }
257
- }
258
- },
259
-
260
- // grunt-contrib-symlink
261
- // Create symlink for git hooks
262
- symlink: {
263
- githooks: {
264
- // Enable overwrite to delete symlinks before recreating them
265
- overwrite: false,
266
- // Enable force to overwrite symlinks outside the current working directory
267
- force: false,
268
- // Expand to all files in /hooks
269
- expand: true,
270
- cwd: '.github/hooks',
271
- src: ['*'],
272
- dest: '.git/hooks'
273
- }
274
- }
275
- };
276
-
277
- // --- Grunt Initialisation
278
-
279
- // Load all grunt tasks
280
- grunt.loadNpmTasks('@lodder/grunt-postcss');
281
- grunt.loadNpmTasks('grunt-bg-shell');
282
- grunt.loadNpmTasks('grunt-contrib-clean');
283
- grunt.loadNpmTasks('grunt-contrib-compress');
284
- grunt.loadNpmTasks('grunt-contrib-copy');
285
- grunt.loadNpmTasks('grunt-contrib-symlink');
286
- grunt.loadNpmTasks('grunt-contrib-watch');
287
- grunt.loadNpmTasks('grunt-express-server');
288
- grunt.loadNpmTasks('grunt-shell');
289
- grunt.loadNpmTasks('grunt-subgrunt');
290
- grunt.loadNpmTasks('grunt-update-submodules');
291
-
292
- // This little bit of weirdness gives the express server chance to shutdown properly
293
- const waitBeforeExit = () => {
294
- setTimeout(() => {
295
- process.exit(0);
296
- }, 1000);
297
- };
298
-
299
- process.on('SIGINT', waitBeforeExit);
300
- process.on('SIGTERM', waitBeforeExit);
301
-
302
- // Load the configuration
303
- grunt.initConfig(cfg);
304
-
305
- // --- Release Tooling
306
-
307
- // grunt release
308
- // - create a Ghost release zip file.
309
- // Uses the files specified by `.npmignore` to know what should and should not be included.
310
- // Runs the asset generation tasks for production and duplicates default-prod.html to default.html
311
- grunt.registerTask('release',
312
- 'Release task - creates a final built zip\n' +
313
- ' - Do our standard build steps \n' +
314
- ' - Copy files to release-folder/#/#{version} directory\n' +
315
- ' - Clean out unnecessary files (.git*, etc)\n' +
316
- ' - Zip files in release-folder to dist-folder/#{version} directory',
317
- function () {
318
- const escapeChar = process.platform.match(/^win/) ? '^' : '\\';
319
- const cwd = process.cwd().replace(/( |\(|\))/g, escapeChar + '$1');
320
- const buildDirectory = path.resolve(cwd, '.build');
321
- const distDirectory = path.resolve(cwd, '.dist');
322
-
323
- // Common paths used by release
324
- grunt.config.set('paths', {
325
- build: buildDirectory,
326
- releaseBuild: path.join(buildDirectory, 'release'),
327
- dist: distDirectory,
328
- releaseDist: path.join(distDirectory, 'release')
329
- });
330
-
331
- // Load package.json so that we can create correctly versioned releases.
332
- grunt.config.set('pkg', grunt.file.readJSON('package.json'));
333
-
334
- // grunt-contrib-copy
335
- grunt.config.set('copy.release', {
336
- expand: true,
337
- // A list of files and patterns to include when creating a release zip.
338
- // This is read from the `.npmignore` file and all patterns are inverted as we want to define what to include
339
- src: fs.readFileSync('.npmignore', 'utf8').split('\n').filter(Boolean).map(function (pattern) {
340
- return pattern[0] === '!' ? pattern.slice(1) : '!' + pattern;
341
- }),
342
- dest: '<%= paths.releaseBuild %>/'
343
- });
344
-
345
- grunt.config.set('copy.admin_html', {
346
- files: [{
347
- cwd: '.',
348
- src: 'core/server/web/admin/views/default-prod.html',
349
- dest: 'core/server/web/admin/views/default.html'
350
- }]
351
- });
352
-
353
- // grunt-contrib-compress
354
- grunt.config.set('compress.release', {
355
- options: {
356
- archive: '<%= paths.releaseDist %>/Ghost-<%= pkg.version %>.zip'
357
- },
358
- expand: true,
359
- cwd: '<%= paths.releaseBuild %>/',
360
- src: ['**']
361
- });
362
-
363
- // grunt-contrib-clean
364
- grunt.config.set('clean.release', {
365
- src: ['<%= paths.releaseBuild %>/**']
366
- });
367
-
368
- if (!grunt.option('skip-update')) {
369
- grunt.task
370
- .run('update_submodules:pinned')
371
- .run('subgrunt:init');
372
- }
373
-
374
- grunt.task
375
- .run('clean:built')
376
- .run('clean:tmp')
377
- .run('prod')
378
- .run('clean:release')
379
- .run('copy:admin_html')
380
- .run('copy:release')
381
- .run('compress:release');
382
- }
383
- );
384
- };