ghost 5.36.1 → 5.37.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 (177) hide show
  1. package/components/tryghost-adapter-cache-memory-ttl-5.37.0.tgz +0 -0
  2. package/components/tryghost-adapter-cache-redis-5.37.0.tgz +0 -0
  3. package/components/tryghost-adapter-manager-5.37.0.tgz +0 -0
  4. package/components/tryghost-api-framework-5.37.0.tgz +0 -0
  5. package/components/tryghost-api-version-compatibility-service-5.37.0.tgz +0 -0
  6. package/components/tryghost-audience-feedback-5.37.0.tgz +0 -0
  7. package/components/tryghost-bootstrap-socket-5.37.0.tgz +0 -0
  8. package/components/tryghost-constants-5.37.0.tgz +0 -0
  9. package/components/{tryghost-custom-theme-settings-service-5.36.1.tgz → tryghost-custom-theme-settings-service-5.37.0.tgz} +0 -0
  10. package/components/tryghost-data-generator-5.37.0.tgz +0 -0
  11. package/components/tryghost-domain-events-5.37.0.tgz +0 -0
  12. package/components/tryghost-dynamic-routing-events-5.37.0.tgz +0 -0
  13. package/components/tryghost-email-analytics-provider-mailgun-5.37.0.tgz +0 -0
  14. package/components/tryghost-email-analytics-service-5.37.0.tgz +0 -0
  15. package/components/tryghost-email-content-generator-5.37.0.tgz +0 -0
  16. package/components/tryghost-email-events-5.37.0.tgz +0 -0
  17. package/components/{tryghost-email-service-5.36.1.tgz → tryghost-email-service-5.37.0.tgz} +0 -0
  18. package/components/tryghost-email-suppression-list-5.37.0.tgz +0 -0
  19. package/components/tryghost-event-aware-cache-wrapper-5.37.0.tgz +0 -0
  20. package/components/{tryghost-express-dynamic-redirects-5.36.1.tgz → tryghost-express-dynamic-redirects-5.37.0.tgz} +0 -0
  21. package/components/tryghost-external-media-inliner-5.37.0.tgz +0 -0
  22. package/components/tryghost-extract-api-key-5.37.0.tgz +0 -0
  23. package/components/tryghost-html-to-plaintext-5.37.0.tgz +0 -0
  24. package/components/tryghost-i18n-5.37.0.tgz +0 -0
  25. package/components/tryghost-importer-handler-content-files-5.37.0.tgz +0 -0
  26. package/components/tryghost-importer-revue-5.37.0.tgz +0 -0
  27. package/components/{tryghost-job-manager-5.36.1.tgz → tryghost-job-manager-5.37.0.tgz} +0 -0
  28. package/components/tryghost-link-redirects-5.37.0.tgz +0 -0
  29. package/components/tryghost-link-replacer-5.37.0.tgz +0 -0
  30. package/components/tryghost-link-tracking-5.37.0.tgz +0 -0
  31. package/components/tryghost-magic-link-5.37.0.tgz +0 -0
  32. package/components/tryghost-mailgun-client-5.37.0.tgz +0 -0
  33. package/components/{tryghost-member-attribution-5.36.1.tgz → tryghost-member-attribution-5.37.0.tgz} +0 -0
  34. package/components/tryghost-member-events-5.37.0.tgz +0 -0
  35. package/components/tryghost-members-api-5.37.0.tgz +0 -0
  36. package/components/tryghost-members-csv-5.37.0.tgz +0 -0
  37. package/components/{tryghost-members-events-service-5.36.1.tgz → tryghost-members-events-service-5.37.0.tgz} +0 -0
  38. package/components/tryghost-members-importer-5.37.0.tgz +0 -0
  39. package/components/{tryghost-members-offers-5.36.1.tgz → tryghost-members-offers-5.37.0.tgz} +0 -0
  40. package/components/tryghost-members-payments-5.37.0.tgz +0 -0
  41. package/components/{tryghost-members-ssr-5.36.1.tgz → tryghost-members-ssr-5.37.0.tgz} +0 -0
  42. package/components/tryghost-members-stripe-service-5.37.0.tgz +0 -0
  43. package/components/tryghost-milestones-5.37.0.tgz +0 -0
  44. package/components/tryghost-minifier-5.37.0.tgz +0 -0
  45. package/components/tryghost-mw-api-version-mismatch-5.37.0.tgz +0 -0
  46. package/components/tryghost-mw-cache-control-5.37.0.tgz +0 -0
  47. package/components/tryghost-mw-error-handler-5.37.0.tgz +0 -0
  48. package/components/tryghost-mw-session-from-token-5.37.0.tgz +0 -0
  49. package/components/tryghost-mw-update-user-last-seen-5.37.0.tgz +0 -0
  50. package/components/tryghost-mw-version-match-5.37.0.tgz +0 -0
  51. package/components/tryghost-mw-vhost-5.37.0.tgz +0 -0
  52. package/components/tryghost-oembed-service-5.37.0.tgz +0 -0
  53. package/components/tryghost-package-json-5.37.0.tgz +0 -0
  54. package/components/tryghost-referrers-5.37.0.tgz +0 -0
  55. package/components/tryghost-security-5.37.0.tgz +0 -0
  56. package/components/tryghost-session-service-5.37.0.tgz +0 -0
  57. package/components/tryghost-settings-path-manager-5.37.0.tgz +0 -0
  58. package/components/tryghost-slack-notifications-5.37.0.tgz +0 -0
  59. package/components/{tryghost-staff-service-5.36.1.tgz → tryghost-staff-service-5.37.0.tgz} +0 -0
  60. package/components/tryghost-stats-service-5.37.0.tgz +0 -0
  61. package/components/tryghost-tiers-5.37.0.tgz +0 -0
  62. package/components/tryghost-update-check-service-5.37.0.tgz +0 -0
  63. package/components/tryghost-verification-trigger-5.37.0.tgz +0 -0
  64. package/components/tryghost-version-notifications-data-service-5.37.0.tgz +0 -0
  65. package/components/tryghost-webmentions-5.37.0.tgz +0 -0
  66. package/content/themes/casper/assets/built/screen.css +1 -1
  67. package/content/themes/casper/assets/built/screen.css.map +1 -1
  68. package/content/themes/casper/assets/css/screen.css +44 -30
  69. package/content/themes/casper/default.hbs +2 -2
  70. package/content/themes/casper/error.hbs +2 -2
  71. package/content/themes/casper/package.json +1 -1
  72. package/core/boot.js +4 -2
  73. package/core/built/admin/assets/chunk.143.27cd10a38f877e715b35.js +49 -0
  74. package/core/built/admin/assets/chunk.178.dd6cf17fb0986acf19d6.js +10 -0
  75. package/core/built/admin/assets/{chunk.502.800e1515996bcc900013.js → chunk.652.bb618bc5abf23bed4e87.js} +855 -784
  76. package/core/built/admin/assets/{chunk.79.53e8aa9671b2d5dae8ba.js → chunk.79.4a959c324df25480b90e.js} +191 -184
  77. package/core/built/admin/assets/{ghost-b828e9e3c161aae92909c2e163656bb1.js → ghost-2948791640be026b987b88f89034bc85.js} +260 -238
  78. package/core/built/admin/assets/ghost-dark-6ea4b338f17a43c204b7c1e207b90cd7.css +1 -0
  79. package/core/built/admin/assets/ghost-efbe4dcc249d119a955b038aae5c980d.css +1 -0
  80. package/core/built/admin/assets/{vendor-c4684647d4f5213e5dbb6763de430e7e.js → vendor-b982e3bf1020bff77b2a3c44d5f59e55.js} +176 -191
  81. package/core/built/admin/index.html +6 -6
  82. package/core/frontend/apps/amp/lib/helpers/amp_content.js +1 -5
  83. package/core/frontend/meta/asset-url.js +9 -0
  84. package/core/server/api/endpoints/db.js +17 -0
  85. package/core/server/api/endpoints/mentions.js +2 -1
  86. package/core/server/api/endpoints/utils/serializers/output/posts.js +2 -2
  87. package/core/server/data/db/backup.js +13 -13
  88. package/core/server/data/importer/handlers/image.js +2 -2
  89. package/core/server/data/importer/import-manager.js +56 -4
  90. package/core/server/data/importer/importers/ContentFileImporter.js +128 -0
  91. package/core/server/data/schema/commands.js +21 -10
  92. package/core/server/models/mention.js +13 -0
  93. package/core/server/run-update-check.js +3 -1
  94. package/core/server/services/media-inliner/index.js +1 -0
  95. package/core/server/services/media-inliner/service.js +16 -0
  96. package/core/server/services/members/stats/members-stats.js +13 -9
  97. package/core/server/services/mentions/BookshelfMentionRepository.js +12 -1
  98. package/core/server/services/mentions/MentionController.js +7 -1
  99. package/core/server/services/mentions/WebmentionMetadata.js +3 -2
  100. package/core/server/services/mentions/service.js +1 -4
  101. package/core/server/{analytics-events.js → services/segment/index.js} +4 -3
  102. package/core/server/services/stripe/config.js +4 -0
  103. package/core/server/update-check.js +5 -3
  104. package/core/server/web/api/endpoints/admin/app.js +5 -4
  105. package/core/server/web/api/endpoints/admin/routes.js +6 -0
  106. package/core/server/web/api/middleware/index.js +1 -2
  107. package/core/shared/config/overrides.json +34 -0
  108. package/core/shared/labs.js +3 -2
  109. package/package.json +153 -148
  110. package/yarn.lock +765 -820
  111. package/components/tryghost-adapter-cache-memory-ttl-5.36.1.tgz +0 -0
  112. package/components/tryghost-adapter-cache-redis-5.36.1.tgz +0 -0
  113. package/components/tryghost-adapter-manager-5.36.1.tgz +0 -0
  114. package/components/tryghost-api-framework-5.36.1.tgz +0 -0
  115. package/components/tryghost-api-version-compatibility-service-5.36.1.tgz +0 -0
  116. package/components/tryghost-audience-feedback-5.36.1.tgz +0 -0
  117. package/components/tryghost-bootstrap-socket-5.36.1.tgz +0 -0
  118. package/components/tryghost-constants-5.36.1.tgz +0 -0
  119. package/components/tryghost-data-generator-5.36.1.tgz +0 -0
  120. package/components/tryghost-domain-events-5.36.1.tgz +0 -0
  121. package/components/tryghost-dynamic-routing-events-5.36.1.tgz +0 -0
  122. package/components/tryghost-email-analytics-provider-mailgun-5.36.1.tgz +0 -0
  123. package/components/tryghost-email-analytics-service-5.36.1.tgz +0 -0
  124. package/components/tryghost-email-content-generator-5.36.1.tgz +0 -0
  125. package/components/tryghost-email-events-5.36.1.tgz +0 -0
  126. package/components/tryghost-email-suppression-list-5.36.1.tgz +0 -0
  127. package/components/tryghost-event-aware-cache-wrapper-5.36.1.tgz +0 -0
  128. package/components/tryghost-extract-api-key-5.36.1.tgz +0 -0
  129. package/components/tryghost-html-to-plaintext-5.36.1.tgz +0 -0
  130. package/components/tryghost-i18n-5.36.1.tgz +0 -0
  131. package/components/tryghost-importer-revue-5.36.1.tgz +0 -0
  132. package/components/tryghost-link-redirects-5.36.1.tgz +0 -0
  133. package/components/tryghost-link-replacer-5.36.1.tgz +0 -0
  134. package/components/tryghost-link-tracking-5.36.1.tgz +0 -0
  135. package/components/tryghost-magic-link-5.36.1.tgz +0 -0
  136. package/components/tryghost-mailgun-client-5.36.1.tgz +0 -0
  137. package/components/tryghost-member-events-5.36.1.tgz +0 -0
  138. package/components/tryghost-members-api-5.36.1.tgz +0 -0
  139. package/components/tryghost-members-csv-5.36.1.tgz +0 -0
  140. package/components/tryghost-members-importer-5.36.1.tgz +0 -0
  141. package/components/tryghost-members-payments-5.36.1.tgz +0 -0
  142. package/components/tryghost-members-stripe-service-5.36.1.tgz +0 -0
  143. package/components/tryghost-milestones-5.36.1.tgz +0 -0
  144. package/components/tryghost-minifier-5.36.1.tgz +0 -0
  145. package/components/tryghost-mw-api-version-mismatch-5.36.1.tgz +0 -0
  146. package/components/tryghost-mw-cache-control-5.36.1.tgz +0 -0
  147. package/components/tryghost-mw-error-handler-5.36.1.tgz +0 -0
  148. package/components/tryghost-mw-session-from-token-5.36.1.tgz +0 -0
  149. package/components/tryghost-mw-update-user-last-seen-5.36.1.tgz +0 -0
  150. package/components/tryghost-mw-vhost-5.36.1.tgz +0 -0
  151. package/components/tryghost-oembed-service-5.36.1.tgz +0 -0
  152. package/components/tryghost-package-json-5.36.1.tgz +0 -0
  153. package/components/tryghost-referrers-5.36.1.tgz +0 -0
  154. package/components/tryghost-security-5.36.1.tgz +0 -0
  155. package/components/tryghost-session-service-5.36.1.tgz +0 -0
  156. package/components/tryghost-settings-path-manager-5.36.1.tgz +0 -0
  157. package/components/tryghost-slack-notifications-5.36.1.tgz +0 -0
  158. package/components/tryghost-stats-service-5.36.1.tgz +0 -0
  159. package/components/tryghost-tiers-5.36.1.tgz +0 -0
  160. package/components/tryghost-update-check-service-5.36.1.tgz +0 -0
  161. package/components/tryghost-verification-trigger-5.36.1.tgz +0 -0
  162. package/components/tryghost-version-notifications-data-service-5.36.1.tgz +0 -0
  163. package/components/tryghost-webmentions-5.36.1.tgz +0 -0
  164. package/core/built/admin/assets/chunk.143.26ea9f26571d656653f0.js +0 -49
  165. package/core/built/admin/assets/chunk.178.dd71b3a764b73facc400.js +0 -11
  166. package/core/built/admin/assets/ghost-7ecf5c7934d90798485ee5ac2956f7fe.css +0 -1
  167. package/core/built/admin/assets/ghost-dark-e50717df8e57d3e7fee67a0bcea895ad.css +0 -1
  168. package/core/frontend/src/cards/css/before-after.css +0 -81
  169. package/core/frontend/src/cards/js/before-after.js +0 -36
  170. package/core/server/data/importer/importers/image.js +0 -76
  171. package/core/server/data/schema/clients/index.js +0 -7
  172. package/core/server/data/schema/clients/mysql.js +0 -34
  173. package/core/server/data/schema/clients/sqlite3.js +0 -39
  174. package/core/server/services/mentions/WebmentionRequest.js +0 -20
  175. package/core/server/web/admin/middleware.js +0 -17
  176. package/core/server/web/api/middleware/version-match.js +0 -31
  177. /package/core/built/admin/assets/{chunk.502.800e1515996bcc900013.js.LICENSE.txt → chunk.652.bb618bc5abf23bed4e87.js.LICENSE.txt} +0 -0
@@ -1,81 +0,0 @@
1
- .kg-before-after-card > div {
2
- position: relative;
3
- margin: 0 auto;
4
- }
5
-
6
- .kg-before-after-card-image-before {
7
- position: absolute;
8
- overflow: hidden;
9
- top: 0;
10
- left: 0;
11
- height: 100%;
12
- }
13
-
14
- .kg-before-after-card .kg-before-after-card-image-after img {
15
- width: 100%;
16
- }
17
-
18
- .kg-before-after-card .kg-before-after-card-image-before img {
19
- max-width: none;
20
- object-fit: cover;
21
- }
22
-
23
- .kg-before-after-card input {
24
- position: absolute;
25
- top: 0;
26
- -webkit-appearance: none;
27
- appearance: none;
28
- width: 100%;
29
- height: 100%;
30
- background: rgba(0, 0, 0, 0);
31
- outline: none;
32
- margin: 0;
33
- }
34
-
35
- .kg-before-after-card input::-webkit-slider-thumb {
36
- -webkit-appearance: none;
37
- appearance: none;
38
- width: 5px;
39
- height: 100%;
40
- background: white;
41
- cursor: pointer;
42
- }
43
-
44
- .kg-before-after-card input::-moz-range-thumb {
45
- width: 5px;
46
- height: 100%;
47
- background: white;
48
- cursor: pointer;
49
- }
50
-
51
- .kg-before-after-card-slider-handle {
52
- pointer-events: none;
53
- position: absolute;
54
- width: 30px;
55
- height: 30px;
56
- border-radius: 50%;
57
- background-color: white;
58
- left: calc(50% - 18px);
59
- top: calc(50% - 18px);
60
- display: flex;
61
- justify-content: center;
62
- align-items: center;
63
- }
64
-
65
- .kg-before-after-card-slider-handle:after {
66
- transform: rotate(-45deg);
67
- content: '';
68
- padding: 3px;
69
- display: inline-block;
70
- border: solid #5D5D5D;
71
- border-width: 0 2px 2px 0;
72
- }
73
-
74
- .kg-before-after-card-slider-handle:before {
75
- transform: rotate(135deg);
76
- content: '';
77
- padding: 3px;
78
- display: inline-block;
79
- border: solid #5D5D5D;
80
- border-width: 0 2px 2px 0;
81
- }
@@ -1,36 +0,0 @@
1
- (function () {
2
- const beforeAfterCards = [...document.querySelectorAll('.kg-before-after-card')];
3
-
4
- for (let card of beforeAfterCards) {
5
- const input = card.querySelector('input');
6
- const overlay = card.querySelector('.kg-before-after-card-image-before');
7
- const button = card.querySelector('.kg-before-after-card-slider-button');
8
- const images = [...card.querySelectorAll('img')];
9
-
10
- function updateSlider() {
11
- overlay.setAttribute('style', `width: ${input.value}%`);
12
- button.setAttribute('style', `left: calc(${input.value}% - 18px`);
13
- }
14
-
15
- function updateDimensions() {
16
- const imageWidth = getComputedStyle(images[0]).getPropertyValue('width');
17
-
18
- images[1].setAttribute('style', `width: ${imageWidth}`);
19
- }
20
-
21
- input.addEventListener('input', function () {
22
- updateSlider();
23
- });
24
-
25
- input.addEventListener('change', function () {
26
- input.blur();
27
- });
28
-
29
- window.addEventListener('resize', function () {
30
- updateDimensions();
31
- });
32
-
33
- updateDimensions();
34
- updateSlider();
35
- }
36
- })();
@@ -1,76 +0,0 @@
1
- const _ = require('lodash');
2
- const storage = require('../../../adapters/storage');
3
- let replaceImage;
4
- let ImageImporter;
5
- let preProcessPosts;
6
- let preProcessTags;
7
- let preProcessUsers;
8
-
9
- replaceImage = function (markdown, image) {
10
- if (!markdown) {
11
- return;
12
- }
13
-
14
- // Normalizes to include a trailing slash if there was one
15
- const regex = new RegExp('(/)?' + image.originalPath, 'gm');
16
-
17
- return markdown.replace(regex, image.newPath);
18
- };
19
-
20
- preProcessPosts = function (data, image) {
21
- _.each(data.posts, function (post) {
22
- post.markdown = replaceImage(post.markdown, image);
23
- if (post.html) {
24
- post.html = replaceImage(post.html, image);
25
- }
26
- if (post.feature_image) {
27
- post.feature_image = replaceImage(post.feature_image, image);
28
- }
29
- });
30
- };
31
-
32
- preProcessTags = function (data, image) {
33
- _.each(data.tags, function (tag) {
34
- if (tag.feature_image) {
35
- tag.feature_image = replaceImage(tag.feature_image, image);
36
- }
37
- });
38
- };
39
-
40
- preProcessUsers = function (data, image) {
41
- _.each(data.users, function (user) {
42
- if (user.cover_image) {
43
- user.cover_image = replaceImage(user.cover_image, image);
44
- }
45
- if (user.profile_image) {
46
- user.profile_image = replaceImage(user.profile_image, image);
47
- }
48
- });
49
- };
50
-
51
- ImageImporter = {
52
- type: 'images',
53
- preProcess: function (importData) {
54
- if (importData.images && importData.data) {
55
- _.each(importData.images, function (image) {
56
- preProcessPosts(importData.data.data, image);
57
- preProcessTags(importData.data.data, image);
58
- preProcessUsers(importData.data.data, image);
59
- });
60
- }
61
-
62
- importData.preProcessedByImage = true;
63
- return importData;
64
- },
65
- doImport: function (imageData) {
66
- const store = storage.getStorage('images');
67
-
68
- return Promise.all(imageData.map(function (image) {
69
- return store.save(image, image.targetDir).then(function (result) {
70
- return {originalPath: image.originalPath, newPath: image.newPath, stored: result};
71
- });
72
- }));
73
- }
74
- };
75
-
76
- module.exports = ImageImporter;
@@ -1,7 +0,0 @@
1
- const sqlite3 = require('./sqlite3');
2
- const mysql = require('./mysql');
3
-
4
- module.exports = {
5
- sqlite3: sqlite3,
6
- mysql2: mysql
7
- };
@@ -1,34 +0,0 @@
1
- const _ = require('lodash');
2
- const db = require('../../../data/db');
3
-
4
- const doRawAndFlatten = function doRaw(query, transaction = db.knex, flattenFn) {
5
- return transaction.raw(query).then(function (response) {
6
- return _.flatten(flattenFn(response));
7
- });
8
- };
9
-
10
- const getTables = function getTables(transaction) {
11
- return doRawAndFlatten('show tables', transaction, function (response) {
12
- return _.map(response[0], function (entry) {
13
- return _.values(entry);
14
- });
15
- });
16
- };
17
-
18
- const getIndexes = function getIndexes(table, transaction) {
19
- return doRawAndFlatten('SHOW INDEXES from ' + table, transaction, function (response) {
20
- return _.map(response[0], 'Key_name');
21
- });
22
- };
23
-
24
- const getColumns = function getColumns(table, transaction) {
25
- return doRawAndFlatten('SHOW COLUMNS FROM ' + table, transaction, function (response) {
26
- return _.map(response[0], 'Field');
27
- });
28
- };
29
-
30
- module.exports = {
31
- getTables: getTables,
32
- getIndexes: getIndexes,
33
- getColumns: getColumns
34
- };
@@ -1,39 +0,0 @@
1
- const _ = require('lodash');
2
- const db = require('../../../data/db');
3
-
4
- const doRaw = function doRaw(query, transaction, fn) {
5
- if (!fn) {
6
- fn = transaction;
7
- transaction = null;
8
- }
9
-
10
- return (transaction || db.knex).raw(query).then(function (response) {
11
- return fn(response);
12
- });
13
- };
14
-
15
- const getTables = function getTables(transaction) {
16
- return doRaw('select * from sqlite_master where type = "table"', transaction, function (response) {
17
- return _.reject(_.map(response, 'tbl_name'), function (name) {
18
- return name === 'sqlite_sequence';
19
- });
20
- });
21
- };
22
-
23
- const getIndexes = function getIndexes(table, transaction) {
24
- return doRaw('pragma index_list("' + table + '")', transaction, function (response) {
25
- return _.flatten(_.map(response, 'name'));
26
- });
27
- };
28
-
29
- const getColumns = function getColumns(table, transaction) {
30
- return doRaw('pragma table_info("' + table + '")', transaction, function (response) {
31
- return _.flatten(_.map(response, 'name'));
32
- });
33
- };
34
-
35
- module.exports = {
36
- getTables: getTables,
37
- getIndexes: getIndexes,
38
- getColumns: getColumns
39
- };
@@ -1,20 +0,0 @@
1
- const logging = require('@tryghost/logging');
2
- const oembedService = require('../oembed');
3
-
4
- module.exports = class WebmentionRequest {
5
- /**
6
- * @param {URL} url
7
- * @returns {Promise<{html: string}>}
8
- */
9
- async fetch(url) {
10
- try {
11
- const data = await oembedService.fetchPageHtml(url.href);
12
- return {
13
- html: data.body
14
- };
15
- } catch (err) {
16
- logging.warn(err);
17
- return null;
18
- }
19
- }
20
- };
@@ -1,17 +0,0 @@
1
- const urlUtils = require('../../../shared/url-utils');
2
-
3
- function redirectAdminUrls(req, res, next) {
4
- const subdir = urlUtils.getSubdir();
5
- const ghostPathRegex = new RegExp(`^${subdir}/ghost/(.+)`);
6
- const ghostPathMatch = req.originalUrl.match(ghostPathRegex);
7
-
8
- if (ghostPathMatch) {
9
- return res.redirect(urlUtils.urlJoin(urlUtils.urlFor('admin'), '#', ghostPathMatch[1]));
10
- }
11
-
12
- next();
13
- }
14
-
15
- module.exports = [
16
- redirectAdminUrls
17
- ];
@@ -1,31 +0,0 @@
1
- const semver = require('semver');
2
- const errors = require('@tryghost/errors');
3
- const tpl = require('@tryghost/tpl');
4
-
5
- const messages = {
6
- versionMismatch: 'Client request for {clientVersion} does not match server version {serverVersion}.'
7
- };
8
-
9
- function checkVersionMatch(req, res, next) {
10
- const clientVersion = req.get('X-Ghost-Version');
11
- // can contain pre-release suffix, you should be able to use e.g. 1.19.0-pre [server] with 1.18.0 [client]
12
- const serverVersion = res.locals.version.match(/^(\d+\.)?(\d+\.)?(\d+)/)[0];
13
- const constraint = '^' + clientVersion + '.0';
14
-
15
- // no error when client is on an earlier minor version than server
16
- // error when client is on a later minor version than server
17
- // always error when the major version is different
18
-
19
- if (clientVersion && !semver.satisfies(serverVersion, constraint)) {
20
- return next(new errors.VersionMismatchError({
21
- message: tpl(messages.versionMismatch, {
22
- clientVersion: clientVersion,
23
- serverVersion: serverVersion
24
- })
25
- }));
26
- }
27
-
28
- next();
29
- }
30
-
31
- module.exports = checkVersionMatch;