Commit Graph

3022 Commits

Author SHA1 Message Date
Daniel Lockyer
32b325eb4c Added codecov.io coverage uploader to CI
refs linear.app/tryghost/issue/CORE-74/improve-the-test-situation

- this commit adds the codecov GitHub Action into CI so we can upload
  coverage reports
- the coverage files need to be in XML for them to work with
  codecov, so this commit also adds cobertura (XML) as a reporter
2021-10-20 15:12:07 +02:00
Kevin Ansfield
59a6f040d2 Fixed custom theme settings being clobbered with duplicate-named themes
refs https://github.com/TryGhost/Team/issues/1149

Ghost allows different themes to have the same `name` value in `package.json` but gives them a custom name based on the zip file used to upload it. The custom theme settings service however was always using the package.json name meaning that when syncing a theme with a duplicate name it was overwriting the settings for all other themes.

- bumped `@tryghost/custom-theme-settings-service` which changes the `.activateTheme()` signature to accept a theme name as the first argument
- updated our calls to `.activateTheme()` to pass Ghost's known theme name as the first argument so we're always syncing with the correct `theme` field value in the `custom_theme_settings` table
2021-10-20 13:25:02 +01:00
Thibaut Patel
c273727b5f Added api validation for custom settings
refs https://github.com/TryGhost/Team/issues/1107 https://github.com/TryGhost/Team/issues/1106

- Replicates the gscan custom theme settings validation in the admin api.
2021-10-20 13:36:41 +02:00
Renovate Bot
5524509274 Update dependency nock to v13.1.4 2021-10-20 10:22:32 +02:00
Daniel Lockyer
1fd980ee9b Set global Luxon timezone override to UTC
refs https://linear.app/tryghost/issue/CORE-113/start-off-luxon-refactor

- we're planning on switching to Luxon for our date/timezone library,
  eventually replacing `moment` and `moment-timezone`
- the first step is to set the global timezone override to UTC, which is
  done in `core/server/overrides.js`
- also adds a test to ensure we're setting the timezone correctly
- this was mostly pulled from https://moment.github.io/luxon/#/zones?id=changing-the-default-zone
2021-10-20 09:19:29 +02:00
Fabien O'Carroll
d303c40248 Fixed editing Offer description via API
no-issue

We were only updating the Offer description if it was truthy - rather
than if it existing, this resulting in empty strings or null not working
correctly.
2021-10-19 11:11:02 +02:00
Thibaut Patel
2891898f94 Added a rule to forbid the custom theme setting image type to have a default
refs https://github.com/TryGhost/Team/issues/1108

- The default is something that the theme developpers should be coding in the template rather than using a default value
2021-10-19 09:41:35 +02:00
Fabien O'Carroll
c5856d04e4 Added support for redemption_count to Offers API
refs https://github.com/TryGhost/Team/issues/1132

This adds redemption_count to the Offers API so that we can display how
many times an Offer has been used. This also adds the storage mechanism
for Offer Redemptions - which ensure that everytime a Checkout Session
is completed - we will create the Offer Redemption in the database.

This means that manual usage of the underlying will not count toward the
Offer redemption count, this is considered an edge case.
2021-10-18 17:40:05 +02:00
Daniel Lockyer
f9f0fb34f2
Merged v4.19.1 into main
v4.19.1
2021-10-18 15:10:22 +02:00
Daniel Lockyer
5c5233afc0 v4.19.1 2021-10-18 14:09:17 +01:00
Fabien O'Carroll
67b517e1fb 🐛 Fixed handling of "incomplete" subscriptions
refs https://github.com/TryGhost/Team/issues/1156

When a payment fails but Stripe Checkout succeeds, a subscription is
created in the "incomplete" status. This would result in a Member not
being linked to the Product. When the subscription was later updated to
"active" or trialing - the Product would still not be added!

This updates the members-api to always link the Product to the Member
for active subscriptions - regardless of if they're new or not.
2021-10-18 14:39:28 +02:00
Renovate Bot
5d60b564af
Fixed double logging library initialization
- we have the `@tryghost/logging` library to manage logging across all
  our code
- this package is intended to be a singleton, otherwise we have multiple
  versions of logging loaded
- we sometimes have problems where dependencies also use
  `@tryghost/logging` but Ghost's yarn.lock is not regenerated to update
  this
- this means we have multiple versions of `@tryghost/logging` running
- this commit updates the dependency @tryghost/update-check-service to
  v0.2.4 to clean up the yarn.lock of multiple versions
2021-10-18 14:28:26 +02:00
Renovate Bot
c768133357 Update dependency jwks-rsa to v2.0.5 2021-10-18 08:29:43 +02:00
Daniel Lockyer
f4fb0fcbaa Improved Ghost boot time and memory usage by lazy loading routes
no issue

- right now, we mount all API endpoints (v2, v3 and canary), alongside some
  other routes, when Ghost is booting. This is wasteful because we don't
  necessarily need any of the endpoints to get Ghost up and running
- even when Admin is used, it uses `canary` so `v2` and `v3` sit in memory
- the better approach here is to lazy load these endpoints, so they only
  get mounted when needed
- this commit adds the `lazyUse` function into our Express lib,
  which takes a mount path and a module function to execute down the
  line. This gets passed to the wonderful `express-lazy-router` lib which
  detects when we're calling an unmounted module and will mount it for
  us
- from local testing, this speeds up boot time by about 18% and reduces
  initial memory usage by about 6% 🚀
2021-10-15 17:52:07 +02:00
Daniel Lockyer
cea17cfb31 v4.19.0 2021-10-15 16:23:19 +01:00
Renovate Bot
d44666fe11
Update dependency mocha to v9.1.3 2021-10-15 12:26:03 +00:00
Thibaut Patel
3d57ac4464 Moved the match helper to GA in gscan. Updated the custom theme select gscan rule to work with the updated match behavior.
refs 50134193be
refs c3b346bb1a
2021-10-14 18:45:00 +02:00
Renovate Bot
565ced555c Update dependency @tryghost/custom-theme-settings-service to v0.1.2 2021-10-14 17:11:58 +02:00
Renovate Bot
c8082c9c43 Update dependency @tryghost/metrics to v0.2.4 2021-10-14 17:11:27 +02:00
Thibaut Patel
2748ed6d0a Fixed a gscan check to force custom theme setting of type color to always have a default value
ref e6a477b3b5
2021-10-14 14:51:44 +02:00
Renovate Bot
107f519310 Update dependency @tryghost/request to v0.1.7 2021-10-14 14:41:34 +02:00
Renovate Bot
aa67e2d463 Pin dependency gscan to 4.7.0 2021-10-14 14:17:57 +02:00
Fabien O'Carroll
d3e291eea6 Fixed Offer usage with Stripe Checkout
no-issue

An update in the MembersAPI meant that coupons were not correctly being
passed to Stripe Checkout. This bump contains the fix to ensure they
are.
2021-10-14 12:09:58 +02:00
Thibaut Patel
a9be1d41c3 Added two gscan rules to validate defaults for custom theme settings of type boolean and color
ref f67fbdf2b4
2021-10-14 11:55:32 +02:00
Renovate Bot
78d322b935 Update dependency @tryghost/bookshelf-plugins to v0.3.3 2021-10-14 11:11:13 +02:00
Renovate Bot
edc12ea128 Update dependency @tryghost/version to v0.1.6 2021-10-14 11:11:01 +02:00
Renovate Bot
cfdd379ddd Update dependency @tryghost/metrics to v0.2.3 2021-10-14 10:04:49 +02:00
Renovate Bot
5438b32155 Update dependency @tryghost/debug to v0.1.8 2021-10-14 10:04:38 +02:00
Renovate Bot
7c4963b579 Update dependency @tryghost/tpl to v0.1.7 2021-10-14 10:04:08 +02:00
Renovate Bot
60adebd815 Update dependency @tryghost/validator to v0.1.7 2021-10-14 10:03:57 +02:00
Renovate Bot
3f9278943c Update dependency @tryghost/root-utils to v0.3.6 2021-10-14 10:03:34 +02:00
Renovate Bot
a3d202fee1 Update dependency @tryghost/logging to v0.2.2 2021-10-14 10:03:26 +02:00
Renovate Bot
2a58e72d10 Update dependency @tryghost/nodemailer to v0.3.5 2021-10-14 10:03:12 +02:00
Renovate Bot
7499641843
Update dependency sanitize-html to v2.5.2 2021-10-13 19:23:34 +00:00
Thibaut Patel
dc4694d8d3 Added a gscan check to prevent the declaration of unused custom theme setting
ref 136e02adfd
ref https://github.com/TryGhost/Team/issues/1105

- Custom theme settings are defined in package.json, this rule triggers an error if a defined rule doesn't appear in any handlebars templates.
2021-10-13 18:30:58 +02:00
Daniel Lockyer
64f2aa2af5
Updated @tryghost/metrics dependency
no issue

- this adds in some missing dependencies of `@tryghost/metrics`
2021-10-13 14:48:05 +02:00
Fabien O'Carroll
7722780539 Restricted archived Offers from being used for Checkout
refs https://github.com/TryGhost/Team/issues/1133

This updates the MembersAPI Checkout Session handling to 403 if an
attempt is made to create a Checkout Session using an archived Offer.
2021-10-13 11:23:05 +02:00
Fabien O'Carroll
a441825c3f Passed MembersAPI the OffersAPI over OfferRepository
no-issue

The MembersAPI using the OfferRepository coupled it to the internals of
the Offers Module - instead we pass the "external" API - so that we can
change the internals, and not have to update the MembersAPI's usage.
2021-10-13 11:17:32 +02:00
Naz
dbdf7160bf Simplified DynamicRedirectManager's constructor
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- This simplification allows to make the test for dependent services a lot more readable without a need to stub urlUtils
2021-10-13 10:04:55 +02:00
Fabien O'Carroll
b1914758b8 Added support for filter Offers by status
refs https://github.com/TryGhost/Team/issues/1131

This will allow Ghost Admin to display separate lists of active and
archived Offers! We must pass the options through so that the
OffersService is able to handle the filter passed in the request.
2021-10-12 18:39:25 +02:00
Thibaut Patel
836b5b4a0e Added a gscan check to make sure the match helper on custom settings of type select is used against specified options
refs 056928f7b9
refs https://github.com/TryGhost/Team/issues/1105
2021-10-12 18:35:02 +02:00
Fabien O'Carroll
dc3dad4524 Added initial support for Offer status
refs https://github.com/TryGhost/Team/issues/1131

This updates the Offers Service to include the `status` of an Offer,
which will be either 'active' or 'archived'. It also allows setting the
`status` of an Offer to one of these two values when adding & editing
Offers.
2021-10-12 17:15:26 +02:00
Sam Lord
a535cfdf16 Added metric-shipping to monitor boot-time
no issue
Boot-time metrics are really valuable for understanding how releases affect the performance of Ghost. The new @tryghost/metrics package lets us ship these metrics to different sources using the same configuration framework as @tryghost/logging introduced.
2021-10-12 15:01:50 +01:00
Thibaut Patel
f8b19f286a Added gscan checks for custom themes settings
refs https://github.com/TryGhost/Team/issues/1105

- checks package.json for the config.custom object shape
- checks for unknown custom theme settings
2021-10-12 14:52:50 +02:00
Renovate Bot
c5459db52e
Update dependency keypair to v1.0.4 2021-10-11 21:11:01 +00:00
Naz
421c71d4db Added debug output to the email analytics jobs
closes https://linear.app/tryghost/issue/CORE-91/add-email-analytics-job-unstalling-mechanism

- Additional debug stagements should give better visibility into what's going on with the internal services fetching email events.
- To see all email analytics related outputs use following DEBUG value:

DEBUG=@tryghost/email-analytics-provider-mailgun:email-analytics*
2021-10-11 19:11:23 +02:00
Renovate Bot
6dcad04dcc Update dependency @lodder/grunt-postcss to v3.1.0 2021-10-11 14:31:54 +02:00
Renovate Bot
361184fc1c
Update metascraper to v5.24.9 2021-10-11 09:05:09 +00:00
Kevin Ansfield
c33b596e9c
Added API tests for custom theme settings (#13519)
refs https://github.com/TryGhost/Team/issues/1104

- bumped `@tryghost/custom-theme-settings-service` so it throws a more appropriate `ValidationError` when setting keys don't exist or a select value is not known
- changed the custom theme settings service to have a `.init()` method which creates an instance of the service under `.api` so that we're able to create the instance at a particular point in the boot process when we know the models have been initialised
  - there were problems in tests because the service was being initialised through the require chain before models were initialised through the boot process
- fixed incorrect `camelCase` of resource name in API responses
2021-10-08 16:18:49 +01:00
Daniel Lockyer
7ad6dec0e0 v4.18.0 2021-10-08 16:00:26 +01:00