Commit Graph

14888 Commits

Author SHA1 Message Date
Hannah Wolfe
f417c4c732
Merged our two maintenance middleware into one
- Reduced our maintenance middleware code down to the bare minimum!
  - We have an old maintenance middleware in place to handle when a site is forcibly put into maintenance mode, or the urlService hasn't finished booting
    - This maintenance middleware was mounted on every sub app, instead of globally for reasons I no longer remember
  - Recently, we introduced a new, static version of maintenence middleware to show during the boot process so we can get the server started earlier & not drop requests
    - This version has its own HTML template and doesn't depend on any of Ghost's error rendering code
  - To simplify and help with decoupling, this commit merges the two middleware, so that the new independent & static middleware renders its template for any one of the 3 possible maintenance modes
    - It only needs to exist in the top level app 🙌

TODO: move the maintenance middleware to its own file/package so it's not part of the app.js as that is weird
2021-11-24 11:27:18 +00:00
Renovate Bot
45b0b907e5
Update dependency sanitize-html to v2.6.0 2021-11-23 19:54:04 +00:00
Hannah Wolfe
6247aa4d8b
Added missing async/await calls
- throughout the theme activation flow there are several missing awaits and necessary async keywords
- we should be waiting on these processes, not letting them complete indeterministically
2021-11-23 17:24:50 +00:00
Hannah Wolfe
b98fd62a3d
Moved card-asset load to be last on activate
- I think this is the least important process, so it can go last
2021-11-23 17:24:49 +00:00
Hannah Wolfe
4c7330125f
Improved error handling in card-assets
refs bb47b9e327

- EACCESS error was previously caught to stop the boot process from failing with perms errors
- For clearFiless, we do not care if these files cannot be removed. Refactored to use allSettled which means we don't do them in sequence + can ignore the outcome
- For minifiy, this is now a legit error, however we don't need the activate method to fail for an EACCES error, we just need an error to be shown (I think)
2021-11-23 17:24:49 +00:00
Naz
aee949bbf4 Removed unused parameter from isFinished method
no issue

- The disableDbReadyEvent variable does nothing here, no need to keep junk around :)
2021-11-24 05:32:20 +13:00
Naz
6ee94f66b4 Fixed invalid settings file path configuration
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)

- There were two separate instances of the SettingsPathManager in route-settings and settings-loader causing the configured paths missmatching on test environment. Because of this missmatch, uploading and resetting the routes.yaml file didn't work!
2021-11-24 05:32:20 +13:00
Naz
04ab59c859 Rewrote reload routes.yaml test to use async/await
no issue
2021-11-24 05:32:20 +13:00
Naz
f0b8e9693f Fixed loadRouteSettingsSync stubs
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)

- Because "loadRouteSettingsSync" method is now a getter function these stubs had to be changed to use a different syntax
- It's a lot of maintenance to do such renames, so if someone has to touch this exact place again it might be worth abstracting this mocking into a separate utility of some sort.
2021-11-24 05:32:20 +13:00
Naz
2fed8dbbd5 Moved all settings module bootstrap logic into init method
refs refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- The initialization outside the init method is causing problems when the configs are mocked during the test setup
2021-11-24 05:32:20 +13:00
Naz
cbec6aa49e Refactored route settings module into class
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- It's a step to making the module follow class+DI pattern before fully extracting it into an external libarary
- Reminder, doing in Ghost repo instead of substituting big chunks all at once to have clear history of how the service evolved prior to the extraction into external lib!
2021-11-24 05:32:20 +13:00
Naz
a9d742c2d3 Extracted getBackupFilePath out of route settings module
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)

- The method is used in a similar fassion in redirects modules, so should be a gret target for extraction and reuse.
- Bonuses: we drop 'path' and 'moment-timezone' dependencies from route settings module!
2021-11-24 05:32:20 +13:00
Naz
6d6aa12afe Extracted routes.yaml path calculation into external package
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)

- The full logic for  file path calculation for routes.yaml has been duplicated in couple modules. It is aslo following similar pattern used in redirects services and should be reused there once those modules are touched
2021-11-24 05:32:20 +13:00
Thibaut Patel
5258e02fd1 Added support for theme card_asset config to GScan
refs https://github.com/TryGhost/Team/issues/1232

- Only require the right css rules depending on the `card_assets` configuration
- 🐛 removed `kg-width-wide` and `kg-width-full` from being considered as card asset, as they should always be defined in themes (it was only a problem in v4.11.x)
2021-11-23 14:29:39 +01:00
Hannah Wolfe
0ede559d5b
🐛 Fixed card asset init/reload behaviour
- Card asset reloading was incorrectly only happening if the API version changed 🙈
- In addition, having an init function was redundant, as theme activation happens on boot
- This meant that the card assets were being generated twice on boot
- Instead, we now only generate them on theme activation, which covers the boot case and simplifies all the logic
2021-11-23 12:53:58 +00:00
Hannah Wolfe
6e6a4822f2
Updated servePublicFile to honor v= cache keys
- Currently it's assumed that public files are 100% static
- With card assets, we're using it for files that are partially static, but can change between reboots and theme changes
- We already have a system for managing cache busting across theme changes and restarts - the ?v= key that is added via the asset helper
- This was already in place and used, but servePublicFile's internal cache didn't honor this key, and cached for the lifetime of boot
- This small change means that if a ?v= query param is present on a request for a public file, that we pay attention to it. Else we cache as before
2021-11-23 12:49:53 +00:00
Kevin Ansfield
1190ff1df0 Fixed errors being swallowed in oembed service
no issue

When switching the oembed service to async/await the error handling was not correctly refactored. `this.errorHandler(url)` was returning a curried function so it could be used as `.catch(this.errorHandler(url))` but that's not how it's being used after the async/await change meaning we were returning a function rather than the result of that function.

- `this.errorHandler(url)` is now only used in one place where `url` is available so removed the method and moved the body of the curried function inline into the `catch` handler
- added a message to the logged error so it's more clear what the log refers to
2021-11-23 10:58:52 +00:00
Rishabh
df8273f995 Updated default styles for accordion card
refs https://github.com/TryGhost/Team/issues/1209

- bumps kg default cards package to include accordion card changes
2021-11-23 15:29:18 +05:30
Naz
9c77abebb5 Removed force start from themes test
refs https://github.com/TryGhost/Toolbox/issues/135

- Looking closer into the reason why the test was failing without "forceStart" revealed that the server only start  was overoptimized - "initServicesForFrontend" should be a part of a backend as those are generic theme services.
2021-11-22 17:47:44 +04:00
Renovate Bot
8d1863e54b Update dependency gscan to v4.11.1 2021-11-22 14:04:18 +01:00
Naz
d3f899689a Removed unnecessary rewire call
no issue

- Having rewire here doens't do any difference and should not be used if absolutely needed. Usually using rewire gives a code "smell" so there's some sort of coupling that's going on and probably has to be addressed first
2021-11-22 14:53:16 +04:00
Naz
23ba543abd Removed forceStart in theme e2e tests
refs https://github.com/TryGhost/Toolbox/issues/135

- The reason the test **settings** test was failing when the force start flag was removed in the **custom themes** was the bridge! The bridge was trying to execute function on the frontend when the boot was done without initializing the frontend. The setting test was changing locale and the timezone which triggered events calling up on frontend components - we clearly don't want to do this when the instance is booted without the frontend
- To make event initialization conditional moved it to the "init". This way the event listeners are only set up when we boot with the "frontend" flag set to true
2021-11-22 14:51:23 +04:00
Thibaut Patel
3a6efc73b3 Added productCard labs flag
refs https://github.com/TryGhost/Team/issues/1233

- flag for the product card development
2021-11-22 11:46:28 +01:00
Sanne de Vries
9e513f334a Fixed callout card emoji alignment
Refs https://github.com/TryGhost/Team/issues/1206
2021-11-22 10:52:21 +01:00
Sanne de Vries
969921f444 Fixed accent color background in email callout cards
Refs https://github.com/TryGhost/Team/issues/1206
2021-11-22 10:45:03 +01:00
Naz
f0ae7592cf Removed unneeded mocks
refs https://github.com/TryGhost/Toolbox/issues/135

- These mocks were failing to execute but didn't make any difference in the test outcome
2021-11-22 21:56:32 +13:00
Naz
917641be4f Removed no backend optimization in boot
refs https://github.com/TryGhost/Toolbox/issues/135

- The expectation is to only skip monting the backend API routes instead of skipping creation of whole GhostServer
2021-11-22 21:56:32 +13:00
Naz
bbc93ff996 Renamed withBackend/withFrotned to backend/frontend
refs https://github.com/TryGhost/Toolbox/issues/135

- Shorter name still makes sense and the "with" might be causing confusion understanding what's gonig on during the boot time
2021-11-22 21:56:32 +13:00
Naz
149c100b4c Fixed frontend initialization in "mock-express" tests
refs https://github.com/TryGhost/Toolbox/issues/135

- Without sensible defaults the web app was not initializing either the backend nor the frontned parts of the application. Fixed the defaults so the problem doesn't happen again and optimized mock-express-style initialization to only initialize the frontend routing
2021-11-22 21:56:32 +13:00
Naz
d0dfac438d Changed /^testing/ regexp use to startsWith method
no issue

- `startsWith` method is way easier to read and understand. also, **probably** has better performance comparing to building up a regexp and then matching
2021-11-22 21:56:32 +13:00
Naz
ae397eecdf Fixed UrlService initialization
refs https://github.com/TryGhost/Toolbox/issues/135

- When there's no instance of cache available the code to retreive it should not execut. Duh!
2021-11-22 21:56:32 +13:00
Naz
9057ca0ee2 Skipped unnecessary frontend initialization
refs https://github.com/TryGhost/Toolbox/issues/135

- This optimization is expected to play a role in more consistent "backend-only" boot where the previous test state might have left over a different theme version which might cause in unwanted URL Services reainitializations.
- What has been happening here is the themes.test.js suite was uploading a theme with a v4 api and when the users api test suite loaded up it switched back to a default v2 theme, which caused routing reinitialization
- The root problem here  is the themese suite is leaving a mess behind so a "restartModeGhostStart" is not really possible anymore - this should be cleaned up separately
2021-11-22 21:56:32 +13:00
Naz
ae5dd8ad30 Fixed event listener pileup
refs https://github.com/TryGhost/Toolbox/issues/135

- When instantiating new Urls/Resources object in the UrlService's init on every test suite start it was loosing track of past events (softReset wasn't doing the cleanup properly). Not initializing new classes "fixes" the problem partially, by not loosing track of those event listeners. The real fix should be proper even listener cleanup on every soft reset!
2021-11-22 21:56:32 +13:00
Naz
34b0196c0f Added writeDisabled flag to URL file cache
refs https://github.com/TryGhost/Toolbox/issues/135

- Allows to turn off overwriting urls/resources JSON file caches on testing environment. This is needed to have predictable state when running multiple test suites that stop the Ghost process and try to persiste URL cache.
2021-11-22 21:56:32 +13:00
Naz
ee4d2dd1a8 Extracted a local file cache class for URLs
refs https://github.com/TryGhost/Toolbox/issues/135

- This extracts the file storage knowledge out of the URL Service an allows to have optional features based on the environment - for example turning off writing cache for when running tests
2021-11-22 21:56:32 +13:00
Naz
155e96b044 Fixed undefined error
refs https://github.com/TryGhost/Toolbox/issues/135

- Not all callers provide the parameter, so an empty object default saves from unecessary "undefined" errors
2021-11-22 21:56:32 +13:00
Naz
640296f74b Changed the test environment to load withFrontend
refs https://github.com/TryGhost/Toolbox/issues/135

- The global default should stay the same as it used to be and we can introduce an override for "withFrontend:false" on casa-by-case or area-by-area bases
2021-11-22 21:56:32 +13:00
Naz
03be383d8b Renamed testUtils.startGhost to localUtils.startGhost
refs https://github.com/TryGhost/Toolbox/issues/135

- Going though local utils allows to have the "withFrontend: false" flag applied only to the e2e-api test suites. This way we can gradually introduce the no-frontend change across all test suites
2021-11-22 21:56:32 +13:00
Naz
9359ae923d Moved startGhost function to local utils
refs https://github.com/TryGhost/Toolbox/issues/135

- Having the proxy in local utils allows to disable frontend gradually in test suites instead of all at once (the latter approach didn't work out as too many other suites still depend on full frontend initialization)
2021-11-22 21:56:32 +13:00
Naz
008b6e0fae Optimized e2e-api tests using boot with no frontend
refs https://github.com/TryGhost/Toolbox/issues/135

- When running e2e-API test in most cases there's no need to boot Ghost instance with full frontend. This should improve the boot time which should reflect on the speed of running test suites
- The tests where the "forceStart" and "withFrontend" are used together indicate that there's still some work to do to fully separate frontend/backend boot line. The force start is also unnecessary, but was needed to reinitialize all services properly - should be investigated!
2021-11-22 21:56:32 +13:00
Naz
3b390639c4 Introduced booting from fixture url cache in test environment
refs https://github.com/TryGhost/Toolbox/issues/135

- To be able to reliably start ghost instance without a frontend the process needs access to urls/resources caches
- Storing the configuration in "paths" for now as there's no better place for it untill we are able to mock the content folder in pre-boot
2021-11-22 21:56:32 +13:00
Naz
c12ae81ece Introduced "withFrontend" and "withBackend" flags in boot
refs https://github.com/TryGhost/Toolbox/issues/135

- These flags are meant to control initialization of sections of the boot sequence depending on the needs - with or without bakend (API)/frontend (public handlebars site)
- Ideally these flags should not be passed deep into the components, and if the are (like in the web/parent/app case) it's a smell that we need to move things up into the boot process!
2021-11-22 21:56:32 +13:00
Naz
5168d6a822 Updated urls/resources cache fixtures
refs https://github.com/TryGhost/Toolbox/issues/135

- These fixture had to be updated due to hardcoded ids introduced in the fixtures.json for test
- This allows to boot up a Ghost instance without recalculating urls for most common database states
2021-11-22 21:56:32 +13:00
Naz
8fd7733fdf Hardcoded id's in test fixtures
refs https://github.com/TryGhost/Toolbox/issues/135

- These fixtures needs id's to be able to form a stable urls and resources cache that would be used across all e2e tests when booting without a frontend
2021-11-22 21:56:32 +13:00
Naz
d7b7bd1b28 Updated Users API e2e tests to use 'posts' fixture
refs https://github.com/TryGhost/Toolbox/issues/135

- This way the test is performed on a "full" set of posts that will become unified within all e2e tests for performance optimization
2021-11-22 21:56:32 +13:00
Rishabh
b59330c392 Added labs flag for file upload cards
refs https://github.com/TryGhost/Team/issues/1229
refs https://github.com/TryGhost/Team/issues/1230
refs https://github.com/TryGhost/Team/issues/1231
2021-11-22 13:25:34 +05:30
Renovate Bot
ab51ce09dc Update dependency analytics-node to v6 2021-11-22 08:05:05 +01:00
Renovate Bot
fdfd16934b Update dependency @tryghost/job-manager to v0.8.13 2021-11-22 07:46:28 +01:00
Renovate Bot
12b4933c3e
Update metascraper to v5.25.2 2021-11-19 21:15:28 +00:00
djordje vlaisavljevic
c77059f645 Updated accordion frontend styles 2021-11-19 19:00:59 +01:00