ghost 4.22.3 → 4.22.4

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 (101) hide show
  1. package/.c8rc.json +24 -0
  2. package/Gruntfile.js +0 -1
  3. package/content/public/README.md +3 -0
  4. package/core/boot.js +18 -13
  5. package/core/built/assets/{chunk.3.324fd0cc598c73650219.js → chunk.3.8f95b516d88ff4eec64c.js} +18 -18
  6. package/core/built/assets/{ghost-dark-39fb496d051565531062d7e047d1c0b1.css → ghost-dark-42cf6e0c730578940ec069bda45aea41.css} +1 -1
  7. package/core/built/assets/{ghost.min-7da921f6c6cac3fe10da1ba104575440.js → ghost.min-2e3e64eb258cf424c59c3e308b4bc6e6.js} +134 -101
  8. package/core/built/assets/{ghost.min-4207edfc1ae0a3f9f6505ca00d20b0c0.css → ghost.min-fcf6a0738421f86c47c55f20d00c5ba9.css} +1 -1
  9. package/core/built/assets/icons/powered-by-tenor.svg +35 -0
  10. package/core/built/assets/icons/tenor.svg +7 -0
  11. package/core/built/assets/{vendor.min-413f887176a041e6dbf88214ca9a7481.js → vendor.min-c9002845b6c30ac978abdadde9f33d7c.js} +2860 -2403
  12. package/core/frontend/apps/amp/lib/views/amp.hbs +104 -0
  13. package/core/frontend/apps/private-blogging/lib/router.js +1 -1
  14. package/core/frontend/services/card-assets/service.js +7 -7
  15. package/core/frontend/services/routing/CollectionRouter.js +4 -5
  16. package/core/frontend/services/routing/EmailRouter.js +1 -1
  17. package/core/frontend/services/routing/ParentRouter.js +0 -8
  18. package/core/frontend/services/routing/PreviewRouter.js +1 -1
  19. package/core/frontend/services/routing/StaticPagesRouter.js +1 -1
  20. package/core/frontend/services/routing/StaticRoutesRouter.js +4 -4
  21. package/core/frontend/services/routing/TaxonomyRouter.js +3 -3
  22. package/core/frontend/services/routing/{middlewares → middleware}/index.js +0 -0
  23. package/core/frontend/services/routing/{middlewares → middleware}/page-param.js +0 -0
  24. package/core/frontend/services/routing/router-manager.js +7 -2
  25. package/core/frontend/services/rss/generate-feed.js +2 -1
  26. package/core/frontend/src/cards/css/bookmark.css +66 -48
  27. package/core/frontend/src/cards/css/callout.css +41 -3
  28. package/core/frontend/src/cards/css/gallery.css +8 -13
  29. package/core/frontend/src/cards/css/nft.css +20 -11
  30. package/core/frontend/src/cards/css/toggle.css +47 -0
  31. package/core/frontend/src/cards/js/toggle.js +16 -0
  32. package/core/frontend/web/middleware/serve-public-file.js +14 -8
  33. package/core/frontend/web/site.js +12 -12
  34. package/core/server/api/canary/authentication.js +1 -1
  35. package/core/server/api/canary/utils/serializers/output/config.js +1 -1
  36. package/core/server/api/v2/authentication.js +1 -1
  37. package/core/server/api/v3/authentication.js +1 -1
  38. package/core/server/data/db/connection.js +7 -0
  39. package/core/server/data/importer/importers/data/data-importer.js +3 -3
  40. package/core/server/data/migrations/init/2-create-fixtures.js +3 -20
  41. package/core/server/data/migrations/versions/1.21/1-add-contributor-role.js +5 -5
  42. package/core/server/data/migrations/versions/2.15/2-insert-zapier-integration.js +3 -3
  43. package/core/server/data/migrations/versions/2.2/3-insert-admin-integration-role.js +5 -5
  44. package/core/server/data/migrations/versions/2.27/1-insert-ghost-db-backup-role.js +5 -6
  45. package/core/server/data/migrations/versions/2.27/2-insert-db-backup-integration.js +3 -4
  46. package/core/server/data/migrations/versions/2.28/3-insert-ghost-scheduler-role.js +7 -7
  47. package/core/server/data/migrations/versions/2.28/4-insert-scheduler-integration.js +3 -3
  48. package/core/server/data/schema/fixtures/fixture-manager.js +340 -0
  49. package/core/server/data/schema/fixtures/index.js +8 -2
  50. package/core/server/services/mega/post-email-serializer.js +5 -1
  51. package/core/server/services/mega/segment-parser.js +1 -2
  52. package/core/server/services/mega/template.js +48 -37
  53. package/core/server/services/nft-oembed.js +7 -21
  54. package/core/server/services/oembed.js +4 -0
  55. package/core/server/services/public-config/config.js +1 -1
  56. package/core/server/services/url/Resources.js +8 -2
  57. package/core/server/services/url/UrlGenerator.js +23 -20
  58. package/core/server/services/url/UrlService.js +89 -45
  59. package/core/server/services/url/index.js +3 -2
  60. package/core/server/web/admin/app.js +6 -6
  61. package/core/server/web/admin/views/default-prod.html +3 -3
  62. package/core/server/web/admin/views/default.html +3 -3
  63. package/core/server/web/api/app.js +1 -1
  64. package/core/server/web/api/canary/admin/app.js +4 -4
  65. package/core/server/web/api/canary/admin/middleware.js +6 -6
  66. package/core/server/web/api/canary/admin/routes.js +5 -5
  67. package/core/server/web/api/canary/content/app.js +4 -4
  68. package/core/server/web/api/canary/content/middleware.js +3 -3
  69. package/core/server/web/api/v2/admin/app.js +4 -4
  70. package/core/server/web/api/v2/admin/middleware.js +6 -6
  71. package/core/server/web/api/v2/admin/routes.js +5 -5
  72. package/core/server/web/api/v2/content/app.js +4 -4
  73. package/core/server/web/api/v2/content/middleware.js +3 -3
  74. package/core/server/web/api/v3/admin/app.js +4 -4
  75. package/core/server/web/api/v3/admin/middleware.js +6 -6
  76. package/core/server/web/api/v3/admin/routes.js +5 -5
  77. package/core/server/web/api/v3/content/app.js +4 -4
  78. package/core/server/web/api/v3/content/middleware.js +3 -3
  79. package/core/server/web/members/app.js +7 -7
  80. package/core/server/web/oauth/app.js +1 -1
  81. package/core/server/web/parent/app.js +2 -3
  82. package/core/server/web/parent/frontend.js +1 -1
  83. package/core/server/web/shared/index.js +2 -2
  84. package/core/server/web/shared/{middlewares → middleware}/api/index.js +0 -0
  85. package/core/server/web/shared/{middlewares → middleware}/api/spam-prevention.js +0 -0
  86. package/core/server/web/shared/{middlewares → middleware}/brute.js +0 -0
  87. package/core/server/web/shared/{middlewares → middleware}/cache-control.js +0 -0
  88. package/core/server/web/shared/{middlewares → middleware}/error-handler.js +0 -0
  89. package/core/server/web/shared/{middlewares → middleware}/index.js +0 -0
  90. package/core/server/web/shared/{middlewares → middleware}/maintenance.js +0 -0
  91. package/core/server/web/shared/{middlewares → middleware}/pretty-urls.js +0 -0
  92. package/core/server/web/shared/{middlewares → middleware}/uncapitalise.js +0 -0
  93. package/core/server/web/shared/{middlewares → middleware}/url-redirects.js +0 -0
  94. package/core/shared/config/defaults.json +7 -1
  95. package/core/shared/config/helpers.js +42 -0
  96. package/core/shared/config/loader.js +1 -1
  97. package/loggingrc.js +19 -20
  98. package/package.json +26 -26
  99. package/yarn.lock +600 -295
  100. package/core/server/data/schema/fixtures/utils.js +0 -321
  101. package/core/server/web/parent/vhost-utils.js +0 -39
@@ -0,0 +1,47 @@
1
+ .kg-toggle-card[data-kg-toggle-state="close"] .kg-toggle-content{
2
+ visibility: hidden;
3
+ opacity: 0;
4
+ height: 0;
5
+ padding: 0;
6
+ }
7
+
8
+ .kg-toggle-card[data-kg-toggle-state="close"] svg {
9
+ transform: unset;
10
+ }
11
+
12
+ .kg-toggle-card {
13
+ border: 1px solid rgba(127, 127, 127, 0.15);
14
+ border-radius: 4px;
15
+ padding: 20px;
16
+ }
17
+
18
+ .kg-toggle-heading {
19
+ font-size: 2rem;
20
+ font-weight: 600;
21
+ cursor: pointer;
22
+ display: flex;
23
+ justify-content: space-between;
24
+ align-items: flex-start;
25
+ }
26
+
27
+ .kg-toggle-card-icon {
28
+ height: 24px;
29
+ width: 24px;
30
+ display: flex;
31
+ justify-content: center;
32
+ align-items: center;
33
+ margin-left: 16px;
34
+ }
35
+
36
+ .kg-toggle-heading svg {
37
+ width: 14px;
38
+ color: rgba(127, 127, 127, 0.4);
39
+ transition: transform 0.3s;
40
+ transform: rotate(180deg);
41
+ }
42
+
43
+ .kg-toggle-content {
44
+ display: flex;
45
+ transition: opacity 0.3s;
46
+ padding-top: 8px;
47
+ }
@@ -0,0 +1,16 @@
1
+ const toggleHeadingElements = document.getElementsByClassName("kg-toggle-heading");
2
+
3
+ const toggleFn = function(event) {
4
+ const targetElement = event.target;
5
+ const parentElement = targetElement.closest('.kg-toggle-card');
6
+ var toggleState = parentElement.getAttribute("data-kg-toggle-state");
7
+ if (toggleState === 'close') {
8
+ parentElement.setAttribute('data-kg-toggle-state', 'open');
9
+ } else {
10
+ parentElement.setAttribute('data-kg-toggle-state', 'close');
11
+ }
12
+ };
13
+
14
+ for (let i = 0; i < toggleHeadingElements.length; i++) {
15
+ toggleHeadingElements[i].addEventListener('click', toggleFn, false);
16
+ }
@@ -11,10 +11,16 @@ const messages = {
11
11
  fileNotFound: 'File not found'
12
12
  };
13
13
 
14
- function createPublicFileMiddleware(file, type, maxAge) {
14
+ function createPublicFileMiddleware(location, file, mime, maxAge) {
15
15
  let content;
16
- const publicFilePath = config.get('paths').publicFilePath;
17
- const filePath = file.match(/^public/) ? path.join(publicFilePath, file.replace(/^public/, '')) : path.join(publicFilePath, file);
16
+ // These files are provided by Ghost, and therefore live inside of the core folder
17
+ const staticFilePath = config.get('paths').publicFilePath;
18
+ // These files are built on the fly, and must be saved in the content folder
19
+ const builtFilePath = config.getContentPath('public');
20
+
21
+ let locationPath = location === 'static' ? staticFilePath : builtFilePath;
22
+
23
+ const filePath = file.match(/^public/) ? path.join(locationPath, file.replace(/^public/, '')) : path.join(locationPath, file);
18
24
  const blogRegex = /(\{\{blog-url\}\})/g;
19
25
 
20
26
  return function servePublicFileMiddleware(req, res, next) {
@@ -24,7 +30,7 @@ function createPublicFileMiddleware(file, type, maxAge) {
24
30
  }
25
31
 
26
32
  // send image files directly and let express handle content-length, etag, etc
27
- if (type.match(/^image/)) {
33
+ if (mime.match(/^image/)) {
28
34
  return res.sendFile(filePath, (err) => {
29
35
  if (err && err.status === 404) {
30
36
  // ensure we're triggering basic asset 404 and not a templated 404
@@ -57,13 +63,13 @@ function createPublicFileMiddleware(file, type, maxAge) {
57
63
 
58
64
  let str = buf.toString();
59
65
 
60
- if (type === 'text/xsl' || type === 'text/plain' || type === 'application/javascript') {
66
+ if (mime === 'text/xsl' || mime === 'text/plain' || mime === 'application/javascript') {
61
67
  str = str.replace(blogRegex, urlUtils.urlFor('home', true).replace(/\/$/, ''));
62
68
  }
63
69
 
64
70
  content = {
65
71
  headers: {
66
- 'Content-Type': type,
72
+ 'Content-Type': mime,
67
73
  'Content-Length': Buffer.from(str).length,
68
74
  ETag: `"${crypto.createHash('md5').update(str, 'utf8').digest('hex')}"`,
69
75
  'Cache-Control': `public, max-age=${maxAge}`
@@ -78,8 +84,8 @@ function createPublicFileMiddleware(file, type, maxAge) {
78
84
 
79
85
  // ### servePublicFile Middleware
80
86
  // Handles requests to robots.txt and favicon.ico (and caches them)
81
- function servePublicFile(file, type, maxAge) {
82
- const publicFileMiddleware = createPublicFileMiddleware(file, type, maxAge);
87
+ function servePublicFile(location, file, type, maxAge) {
88
+ const publicFileMiddleware = createPublicFileMiddleware(location, file, type, maxAge);
83
89
 
84
90
  return function servePublicFileMiddleware(req, res, next) {
85
91
  if (req.path === '/' + file) {
@@ -104,15 +104,15 @@ module.exports = function setupSiteApp(options = {}) {
104
104
  siteApp.use(mw.serveFavicon());
105
105
 
106
106
  // Serve sitemap.xsl file
107
- siteApp.use(mw.servePublicFile('sitemap.xsl', 'text/xsl', constants.ONE_DAY_S));
107
+ siteApp.use(mw.servePublicFile('static', 'sitemap.xsl', 'text/xsl', constants.ONE_DAY_S));
108
108
 
109
109
  // Serve stylesheets for default templates
110
- siteApp.use(mw.servePublicFile('public/ghost.css', 'text/css', constants.ONE_HOUR_S));
111
- siteApp.use(mw.servePublicFile('public/ghost.min.css', 'text/css', constants.ONE_YEAR_S));
110
+ siteApp.use(mw.servePublicFile('static', 'public/ghost.css', 'text/css', constants.ONE_HOUR_S));
111
+ siteApp.use(mw.servePublicFile('static', 'public/ghost.min.css', 'text/css', constants.ONE_YEAR_S));
112
112
 
113
113
  // Card assets
114
- siteApp.use(mw.servePublicFile('public/cards.min.css', 'text/css', constants.ONE_YEAR_S));
115
- siteApp.use(mw.servePublicFile('public/cards.min.js', 'text/js', constants.ONE_YEAR_S));
114
+ siteApp.use(mw.servePublicFile('built', 'public/cards.min.css', 'text/css', constants.ONE_YEAR_S));
115
+ siteApp.use(mw.servePublicFile('built', 'public/cards.min.js', 'text/js', constants.ONE_YEAR_S));
116
116
 
117
117
  // Serve blog images using the storage adapter
118
118
  siteApp.use(STATIC_IMAGE_URL_PREFIX, mw.handleImageSizes, storage.getStorage('images').serve());
@@ -147,26 +147,26 @@ module.exports = function setupSiteApp(options = {}) {
147
147
  debug('Themes done');
148
148
 
149
149
  // Serve robots.txt if not found in theme
150
- siteApp.use(mw.servePublicFile('robots.txt', 'text/plain', constants.ONE_HOUR_S));
150
+ siteApp.use(mw.servePublicFile('static', 'robots.txt', 'text/plain', constants.ONE_HOUR_S));
151
151
 
152
152
  // site map - this should probably be refactored to be an internal app
153
153
  sitemapHandler(siteApp);
154
154
  debug('Internal apps done');
155
155
 
156
156
  // send 503 error page in case of maintenance
157
- siteApp.use(shared.middlewares.maintenance);
157
+ siteApp.use(shared.middleware.maintenance);
158
158
 
159
159
  // Add in all trailing slashes & remove uppercase
160
160
  // must happen AFTER asset loading and BEFORE routing
161
- siteApp.use(shared.middlewares.prettyUrls);
161
+ siteApp.use(shared.middleware.prettyUrls);
162
162
 
163
163
  // ### Caching
164
164
  siteApp.use(function (req, res, next) {
165
165
  // Site frontend is cacheable UNLESS request made by a member or blog is in private mode
166
166
  if (req.member || res.isPrivateBlog) {
167
- return shared.middlewares.cacheControl('private')(req, res, next);
167
+ return shared.middleware.cacheControl('private')(req, res, next);
168
168
  } else {
169
- return shared.middlewares.cacheControl('public', {maxAge: config.get('caching:frontend:maxAge')})(req, res, next);
169
+ return shared.middleware.cacheControl('public', {maxAge: config.get('caching:frontend:maxAge')})(req, res, next);
170
170
  }
171
171
  });
172
172
 
@@ -179,7 +179,7 @@ module.exports = function setupSiteApp(options = {}) {
179
179
  siteApp.use(SiteRouter);
180
180
 
181
181
  // ### Error handlers
182
- siteApp.use(shared.middlewares.errorHandler.pageNotFound);
182
+ siteApp.use(shared.middleware.errorHandler.pageNotFound);
183
183
  config.get('apps:internal').forEach((appName) => {
184
184
  const app = require(path.join(config.get('paths').internalAppPath, appName));
185
185
 
@@ -187,7 +187,7 @@ module.exports = function setupSiteApp(options = {}) {
187
187
  app.setupErrorHandling(siteApp);
188
188
  }
189
189
  });
190
- siteApp.use(shared.middlewares.errorHandler.handleThemeResponse);
190
+ siteApp.use(shared.middleware.errorHandler.handleThemeResponse);
191
191
 
192
192
  debug('Site setup end');
193
193
 
@@ -163,7 +163,7 @@ module.exports = {
163
163
  options = Object.assign(options, {context: {internal: true}});
164
164
  return auth.passwordreset.doReset(options, tokenParts, api.settings)
165
165
  .then((params) => {
166
- web.shared.middlewares.api.spamPrevention.userLogin().reset(frame.options.ip, `${tokenParts.email}login`);
166
+ web.shared.middleware.api.spamPrevention.userLogin().reset(frame.options.ip, `${tokenParts.email}login`);
167
167
  return params;
168
168
  });
169
169
  });
@@ -22,7 +22,7 @@ module.exports = {
22
22
  ];
23
23
 
24
24
  if (labs.isSet('gifsCard')) {
25
- keys.push('tenorApiKey');
25
+ keys.push('tenor');
26
26
  }
27
27
 
28
28
  frame.response = {
@@ -145,7 +145,7 @@ module.exports = {
145
145
  options = Object.assign(options, {context: {internal: true}});
146
146
  return auth.passwordreset.doReset(options, tokenParts, api.settings)
147
147
  .then((params) => {
148
- web.shared.middlewares.api.spamPrevention.userLogin().reset(frame.options.ip, `${tokenParts.email}login`);
148
+ web.shared.middleware.api.spamPrevention.userLogin().reset(frame.options.ip, `${tokenParts.email}login`);
149
149
  return params;
150
150
  });
151
151
  });
@@ -146,7 +146,7 @@ module.exports = {
146
146
  options = Object.assign(options, {context: {internal: true}});
147
147
  return auth.passwordreset.doReset(options, tokenParts, api.settings)
148
148
  .then((params) => {
149
- web.shared.middlewares.api.spamPrevention.userLogin().reset(frame.options.ip, `${tokenParts.email}login`);
149
+ web.shared.middleware.api.spamPrevention.userLogin().reset(frame.options.ip, `${tokenParts.email}login`);
150
150
  return params;
151
151
  });
152
152
  });
@@ -17,6 +17,13 @@ function configure(dbConfig) {
17
17
  dbConfig.pool = {
18
18
  afterCreate(conn, cb) {
19
19
  conn.run('PRAGMA foreign_keys = ON', cb);
20
+
21
+ // These two are meant to improve performance at the cost of reliability
22
+ // Should be safe for tests. We add them here and leave them on
23
+ if (config.get('env').startsWith('testing')) {
24
+ conn.run('PRAGMA synchronous = OFF;');
25
+ conn.run('PRAGMA journal_mode = TRUNCATE;');
26
+ }
20
27
  }
21
28
  };
22
29
 
@@ -112,7 +112,7 @@ DataImporter = {
112
112
  });
113
113
  });
114
114
 
115
- sequence(ops)
115
+ return sequence(ops)
116
116
  .then(function () {
117
117
  results.forEach(function (promise) {
118
118
  if (!promise.isFulfilled()) {
@@ -121,9 +121,9 @@ DataImporter = {
121
121
  });
122
122
 
123
123
  if (errors.length === 0) {
124
- transacting.commit();
124
+ return;
125
125
  } else {
126
- transacting.rollback(errors);
126
+ throw errors;
127
127
  }
128
128
  });
129
129
  }).then(function () {
@@ -1,26 +1,9 @@
1
- const Promise = require('bluebird');
2
- const _ = require('lodash');
3
- const fixtures = require('../../schema/fixtures');
4
- const logging = require('@tryghost/logging');
1
+ const {fixtureManager} = require('../../schema/fixtures');
5
2
 
6
3
  module.exports.config = {
7
4
  transaction: true
8
5
  };
9
6
 
10
- module.exports.up = async (options) => {
11
- const localOptions = _.merge({
12
- context: {internal: true},
13
- migrating: true
14
- }, options);
15
-
16
- await Promise.mapSeries(fixtures.models, async (model) => {
17
- logging.info('Model: ' + model.name);
18
-
19
- await fixtures.utils.addFixturesForModel(model, localOptions);
20
- });
21
-
22
- await Promise.mapSeries(fixtures.relations, async (relation) => {
23
- logging.info('Relation: ' + relation.from.model + ' to ' + relation.to.model);
24
- await fixtures.utils.addFixturesForRelation(relation, localOptions);
25
- });
7
+ module.exports.up = async function insertFixtures(options) {
8
+ return await fixtureManager.addAllFixtures(options);
26
9
  };
@@ -1,19 +1,19 @@
1
1
  const merge = require('lodash/merge');
2
- const utils = require('../../../schema/fixtures/utils');
2
+ const {fixtureManager} = require('../../../schema/fixtures');
3
3
  const models = require('../../../../models');
4
4
  const permissions = require('../../../../services/permissions');
5
5
  const logging = require('@tryghost/logging');
6
6
  const _private = {};
7
7
 
8
8
  _private.addRole = function addRole(options) {
9
- const contributorRole = utils.findModelFixtureEntry('Role', {name: 'Contributor'});
9
+ const contributorRole = fixtureManager.findModelFixtureEntry('Role', {name: 'Contributor'});
10
10
  const message = 'Adding "Contributor" role to roles table';
11
11
 
12
12
  return models.Role.findOne({name: contributorRole.name}, options)
13
13
  .then((role) => {
14
14
  if (!role) {
15
15
  logging.info(message);
16
- return utils.addFixturesForModel({name: 'Role', entries: [contributorRole]}, options);
16
+ return fixtureManager.addFixturesForModel({name: 'Role', entries: [contributorRole]}, options);
17
17
  }
18
18
 
19
19
  logging.warn(message);
@@ -22,10 +22,10 @@ _private.addRole = function addRole(options) {
22
22
  };
23
23
 
24
24
  _private.addContributorPermissions = function getPermissions(options) {
25
- const relations = utils.findRelationFixture('Role', 'Permission');
25
+ const relations = fixtureManager.findRelationFixture('Role', 'Permission');
26
26
  const message = 'Adding permissions_roles fixtures for the contributor role';
27
27
 
28
- return utils.addFixturesForRelation({
28
+ return fixtureManager.addFixturesForRelation({
29
29
  from: relations.from,
30
30
  to: relations.to,
31
31
  entries: {
@@ -1,7 +1,7 @@
1
1
  const logging = require('@tryghost/logging');
2
2
  const merge = require('lodash/merge');
3
3
  const models = require('../../../../models');
4
- const utils = require('../../../schema/fixtures/utils');
4
+ const {fixtureManager} = require('../../../schema/fixtures');
5
5
 
6
6
  const _private = {};
7
7
 
@@ -15,12 +15,12 @@ _private.printResult = function printResult(result, message) {
15
15
 
16
16
  _private.addZapierIntegration = (options) => {
17
17
  const message = 'Adding "Zapier" integration';
18
- const fixtureIntegration = utils.findModelFixtureEntry('Integration', {slug: 'zapier'});
18
+ const fixtureIntegration = fixtureManager.findModelFixtureEntry('Integration', {slug: 'zapier'});
19
19
 
20
20
  return models.Integration.findOne({slug: fixtureIntegration.slug}, options)
21
21
  .then((integration) => {
22
22
  if (!integration) {
23
- return utils.addFixturesForModel({
23
+ return fixtureManager.addFixturesForModel({
24
24
  name: 'Integration',
25
25
  entries: [fixtureIntegration]
26
26
  }, options).then(result => _private.printResult(result, message));
@@ -1,7 +1,7 @@
1
1
  const logging = require('@tryghost/logging');
2
2
  const merge = require('lodash/merge');
3
3
  const models = require('../../../../models');
4
- const utils = require('../../../schema/fixtures/utils');
4
+ const {fixtureManager} = require('../../../schema/fixtures');
5
5
 
6
6
  const _private = {};
7
7
 
@@ -15,12 +15,12 @@ _private.printResult = function printResult(result, message) {
15
15
 
16
16
  _private.addApiKeyRole = (options) => {
17
17
  const message = 'Adding "Admin Integration" role to roles table';
18
- const apiKeyRole = utils.findModelFixtureEntry('Role', {name: 'Admin Integration'});
18
+ const apiKeyRole = fixtureManager.findModelFixtureEntry('Role', {name: 'Admin Integration'});
19
19
 
20
20
  return models.Role.findOne({name: apiKeyRole.name}, options)
21
21
  .then((role) => {
22
22
  if (!role) {
23
- return utils.addFixturesForModel({
23
+ return fixtureManager.addFixturesForModel({
24
24
  name: 'Role',
25
25
  entries: [apiKeyRole]
26
26
  }, options).then(result => _private.printResult(result, message));
@@ -32,9 +32,9 @@ _private.addApiKeyRole = (options) => {
32
32
 
33
33
  _private.addApiKeyPermissions = (options) => {
34
34
  const message = 'Adding permissions for the "Admin Integration" role';
35
- const relations = utils.findRelationFixture('Role', 'Permission');
35
+ const relations = fixtureManager.findRelationFixture('Role', 'Permission');
36
36
 
37
- return utils.addFixturesForRelation({
37
+ return fixtureManager.addFixturesForRelation({
38
38
  from: relations.from,
39
39
  to: relations.to,
40
40
  entries: {
@@ -1,7 +1,7 @@
1
1
  const logging = require('@tryghost/logging');
2
2
  const merge = require('lodash/merge');
3
3
  const models = require('../../../../models');
4
- const utils = require('../../../schema/fixtures/utils');
4
+ const {fixtureManager} = require('../../../schema/fixtures');
5
5
 
6
6
  const _private = {};
7
7
 
@@ -15,12 +15,12 @@ _private.printResult = function printResult(result, message) {
15
15
 
16
16
  _private.addApiKeyRole = (options) => {
17
17
  const message = 'Adding "DB Backup Integration" role to roles table';
18
- const apiKeyRole = utils.findModelFixtureEntry('Role', {name: 'DB Backup Integration'});
18
+ const apiKeyRole = fixtureManager.findModelFixtureEntry('Role', {name: 'DB Backup Integration'});
19
19
 
20
20
  return models.Role.findOne({name: apiKeyRole.name}, options)
21
21
  .then((role) => {
22
22
  if (!role) {
23
- return utils.addFixturesForModel({
23
+ return fixtureManager.addFixturesForModel({
24
24
  name: 'Role',
25
25
  entries: [apiKeyRole]
26
26
  }, options).then(result => _private.printResult(result, message));
@@ -32,9 +32,9 @@ _private.addApiKeyRole = (options) => {
32
32
 
33
33
  _private.addApiKeyPermissions = (options) => {
34
34
  const message = 'Adding permissions for the "DB Backup Integration" role';
35
- const relations = utils.findRelationFixture('Role', 'Permission');
35
+ const relations = fixtureManager.findRelationFixture('Role', 'Permission');
36
36
 
37
- return utils.addFixturesForRelation({
37
+ return fixtureManager.addFixturesForRelation({
38
38
  from: relations.from,
39
39
  to: relations.to,
40
40
  entries: {
@@ -81,4 +81,3 @@ module.exports.down = (options) => {
81
81
 
82
82
  return _private.removeApiKeyPermissionsAndRole(localOptions);
83
83
  };
84
-
@@ -1,7 +1,7 @@
1
1
  const logging = require('@tryghost/logging');
2
2
  const merge = require('lodash/merge');
3
3
  const models = require('../../../../models');
4
- const utils = require('../../../schema/fixtures/utils');
4
+ const {fixtureManager} = require('../../../schema/fixtures');
5
5
 
6
6
  const _private = {};
7
7
 
@@ -15,12 +15,12 @@ _private.printResult = function printResult(result, message) {
15
15
 
16
16
  _private.addGhostBackupIntegration = (options) => {
17
17
  const message = 'Adding "Ghost Backup DB" integration';
18
- const fixtureIntegration = utils.findModelFixtureEntry('Integration', {slug: 'ghost-backup'});
18
+ const fixtureIntegration = fixtureManager.findModelFixtureEntry('Integration', {slug: 'ghost-backup'});
19
19
 
20
20
  return models.Integration.findOne({slug: fixtureIntegration.slug}, options)
21
21
  .then((integration) => {
22
22
  if (!integration) {
23
- return utils.addFixturesForModel({
23
+ return fixtureManager.addFixturesForModel({
24
24
  name: 'Integration',
25
25
  entries: [fixtureIntegration]
26
26
  }, options).then(result => _private.printResult(result, message));
@@ -67,4 +67,3 @@ module.exports.down = (options) => {
67
67
 
68
68
  return _private.removeGhostBackupIntegration(localOptions);
69
69
  };
70
-
@@ -1,7 +1,7 @@
1
1
  const logging = require('@tryghost/logging');
2
2
  const merge = require('lodash/merge');
3
3
  const models = require('../../../../models');
4
- const utils = require('../../../schema/fixtures/utils');
4
+ const {fixtureManager} = require('../../../schema/fixtures');
5
5
 
6
6
  const resource = 'post';
7
7
  const _private = {};
@@ -16,12 +16,12 @@ _private.printResult = function printResult(result, message) {
16
16
 
17
17
  _private.addSchedulerRole = (options) => {
18
18
  const message = 'Adding "Scheduler Integration" role to roles table';
19
- const apiKeyRole = utils.findModelFixtureEntry('Role', {name: 'Scheduler Integration'});
19
+ const apiKeyRole = fixtureManager.findModelFixtureEntry('Role', {name: 'Scheduler Integration'});
20
20
 
21
21
  return models.Role.findOne({name: apiKeyRole.name}, options)
22
22
  .then((role) => {
23
23
  if (!role) {
24
- return utils.addFixturesForModel({
24
+ return fixtureManager.addFixturesForModel({
25
25
  name: 'Role',
26
26
  entries: [apiKeyRole]
27
27
  }, options).then(result => _private.printResult(result, message));
@@ -32,19 +32,19 @@ _private.addSchedulerRole = (options) => {
32
32
  };
33
33
 
34
34
  _private.addPublishPermission = (options) => {
35
- const modelToAdd = utils.findModelFixtures('Permission', {object_type: resource, action_type: 'publish'});
35
+ const modelToAdd = fixtureManager.findModelFixtures('Permission', {object_type: resource, action_type: 'publish'});
36
36
 
37
- return utils.addFixturesForModel(modelToAdd, options)
37
+ return fixtureManager.addFixturesForModel(modelToAdd, options)
38
38
  .then(result => _private.printResult(result, `Adding "publish" permissions fixtures for ${resource}s`));
39
39
  };
40
40
 
41
41
  _private.removeApiKeyPermissionsAndRole = (options) => {
42
42
  const message = 'Rollback: Removing "Scheduler Integration" role and permissions';
43
43
 
44
- const modelToRemove = utils.findModelFixtures('Permission', {object_type: resource, action_type: 'publish'});
44
+ const modelToRemove = fixtureManager.findModelFixtures('Permission', {object_type: resource, action_type: 'publish'});
45
45
 
46
46
  // permission model automatically cleans up permissions_roles on .destroy()
47
- return utils.removeFixturesForModel(modelToRemove, options)
47
+ return fixtureManager.removeFixturesForModel(modelToRemove, options)
48
48
  .then(result => _private.printResult(result, `Removing "publish" permissions fixtures for ${resource}s`))
49
49
  .then(() => models.Role.findOne({name: 'Scheduler Integration'}, options))
50
50
  .then((role) => {
@@ -1,7 +1,7 @@
1
1
  const logging = require('@tryghost/logging');
2
2
  const merge = require('lodash/merge');
3
3
  const models = require('../../../../models');
4
- const utils = require('../../../schema/fixtures/utils');
4
+ const {fixtureManager} = require('../../../schema/fixtures');
5
5
 
6
6
  const _private = {};
7
7
 
@@ -15,12 +15,12 @@ _private.printResult = function printResult(result, message) {
15
15
 
16
16
  _private.addGhostSchedulerIntegration = (options) => {
17
17
  const message = 'Adding "Ghost Scheduler" integration';
18
- const fixtureIntegration = utils.findModelFixtureEntry('Integration', {slug: 'ghost-scheduler'});
18
+ const fixtureIntegration = fixtureManager.findModelFixtureEntry('Integration', {slug: 'ghost-scheduler'});
19
19
 
20
20
  return models.Integration.findOne({slug: fixtureIntegration.slug}, options)
21
21
  .then((integration) => {
22
22
  if (!integration) {
23
- return utils.addFixturesForModel({
23
+ return fixtureManager.addFixturesForModel({
24
24
  name: 'Integration',
25
25
  entries: [fixtureIntegration]
26
26
  }, options).then(result => _private.printResult(result, message));