Commit Graph

17 Commits

Author SHA1 Message Date
Hannah Wolfe
6161f94910
Updated to use assert/strict everywhere (#17047)
refs: https://github.com/TryGhost/Toolbox/issues/595

We're rolling out new rules around the node assert library, the first of which is enforcing the use of assert/strict. This means we don't need to use the strict version of methods, as the standard version will work that way by default.

This caught some gotchas in our existing usage of assert where the lack of strict mode had unexpected results:
- Url matching needs to be done on `url.href` see aa58b354a4
- Null and undefined are not the same thing,  there were a few cases of this being confused
- Particularly questionable changes in [PostExporter tests](c1a468744b) tracked [here](https://github.com/TryGhost/Team/issues/3505).
- A typo see eaac9c293a

Moving forward, using assert strict should help us to catch unexpected behaviour, particularly around nulls and undefineds during implementation.
2023-06-21 09:56:59 +01:00
Fabien "egg" O'Carroll
104f84f252 Added eslint rule for file naming convention
As discussed with the product team we want to enforce kebab-case file names for
all files, with the exception of files which export a single class, in which
case they should be PascalCase and reflect the class which they export.

This will help find classes faster, and should push better naming for them too.

Some files and packages have been excluded from this linting, specifically when
a library or framework depends on the naming of a file for the functionality
e.g. Ember, knex-migrator, adapter-manager
2023-05-09 12:34:34 -04:00
Naz
96a64b4982
Added error rethrow to update check run as a job
closes https://github.com/TryGhost/Toolbox/issues/525

- When the update check is run as an offloaded job (in a worker thread) the errors that are handled over "logger.error" do not get bubbled up to the job manager to be handled fully. With an optional "rethrowErrors" flag it's not possible to throw errors when the update check is run as a "job" and handle as usual when run in the main thread (through the admin route trigger)
2023-02-27 19:48:42 +08:00
Daniel Lockyer
aa00fe5474 Cleaned up unused test utils
- cleans up one boilerplate test and some utils that aren't used
2022-08-18 11:55:49 +02:00
Sam Lord
d407fd1325 @tryghost/update-check-service: Don't allow logging to be passed in to constructor
refs: https://github.com/TryGhost/Toolbox/issues/146
2021-12-07 10:48:01 +00:00
Naz
20fc1649f4 Fixed alert notifications being sent out to non-active users
refs https://linear.app/tryghost/issue/CORE-63/restrict-update-service-notifications-to-active-admins

- It only makes sense to notify active users about a notification of 'alert' or any other type really.
2021-10-06 22:31:06 +02:00
Naz
98a64ed0f8 Removed i18n dependency from update check constructor
refs https://github.com/TryGhost/Team/issues/727

- The latest code standards require using tpl module in combination with local messages object instead of i18n  injected in the constructor
2021-07-02 18:48:12 +04:00
Naz
bc3ea7e12e Skipped notificaiton processing when no valid data
refs https://github.com/TryGhost/Team/issues/754

- When there are no message objects coming from the external update check service in the response there is no need to continue to process the data and fire off unneeded queries
2021-06-23 19:14:47 +04:00
Naz
fd4e0a44c4 Fixed tests
refs TryGhost/Team#728

- After history migration the tests were referencing modules using
previous folder structure
2021-06-02 18:22:54 +04:00
Naz
cb2c40d2cb Merged update-check-service files and histry from TryGhost/Ghost 2021-06-02 18:19:30 +04:00
Naz
494880778d Added update check service initial commit
refs https://github.com/TryGhost/Team/issues/728
2021-06-02 18:17:56 +04:00
Naz
7121efb010 Removed GhostMailer parameter from UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary parameter data makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- Instead of passing in a whole GhostMailer instance passing only an email sending function, which again - makes things way more manageable to reason about
- The end of refactor, next will be a move of the UpdateCheckService into a separate module in tryghost/core
2021-06-02 15:18:32 +04:00
Naz
a4e5436df7 Removed ghostVersion parameter from UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary parameter data makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- Burned ghostVersion module passing in vafor of just one additional config parameter. Now the module along with unit tests can be easily extracted out of the codebase!
2021-06-02 15:08:26 +04:00
Naz
796e2caaff Removed urlFor parameter from UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary API endpoint function makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- Substituted a parameter with already existing 'siteUrl' config value. No need to duplicate work!
2021-06-02 14:37:29 +04:00
Naz
7ce5ab27c3 Limited the API surface of the UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary API endpoint function makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- Limited urlUtils to only one function as that's all the UpdateCheck uses. Next step will be removing the function completely as and passing a 'blogURL' as a config value (way better readability this way)
2021-06-02 14:31:07 +04:00
Naz
94700863a4 Limited the API surface of the UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary API endpoint function makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- There are 8 different configs that NotificationService depends upon it will need some further investigation around which ones are even needed anymore and the naming is not the best. To keep the time cap at bay leaving it at what it is.
2021-06-02 14:08:29 +04:00
Naz
1fd689ba45 Renamed update check test suite
refs https://github.com/TryGhost/Team/issues/728

- Previous name was after the do-all-the-things mega module that have now become an "initializer" for the UpdateCheckService class. The unit tests are testing the latter, so the rename is a cleanup from the previous ways
2021-06-01 17:53:46 +04:00