Commit Graph

809 Commits

Author SHA1 Message Date
Naz
d81accdebf Changed require declaration to be more readable
no issue

-  When adding more methods under test to this file the require statement will becom difficult to read in one long line. Multiline statement is way nicer to track in git history too
2022-04-08 11:24:03 +08:00
Renovate Bot
cca620cb35 Update dependency knex to v1.0.5 2022-04-04 21:38:20 +00:00
Sam Lord
c742848f57 Published new versions
- @tryghost/mw-error-handler@0.1.8
2022-04-04 17:16:15 +01:00
Sam Lord
5537942bdf Updated @tryghost/errors
no issue

Prevents errors with `hideStack: true` from displaying the stack
2022-04-04 17:13:13 +01:00
Daniel Lockyer
43f559690b Published new versions
- @tryghost/package-json@1.0.18
2022-04-01 14:13:28 +01:00
Daniel Lockyer
d29b8e65ec Fixed symlinked directories ignored when reading packages
refs bd6a295674

- earlier this week I refactored this block of code to get rid of
  explicit `stat` calls, to make the fs operations a little more
  lightweight
- I inadvertantly forgot that readdir doesn't follow symlinks, and we
  were previously use stat that does, so it was ignoring themes that were
  symlinked into `content/themes`
- instead of rolling back my change, I've added an if-statement to call
  `fs.stat` and check the origin of the symlink to see if it's a
  directory
- also added a test that fails without this change
2022-04-01 14:07:04 +01:00
Daniel Lockyer
22d13193e8 Deeleted unused module
- this was an experiment that didn't pan out, and I don't plan on using
  it again
2022-04-01 12:47:16 +01:00
Daniel Lockyer
a19fe06baf Published new versions
- @tryghost/knex-sqlite3@0.1.1
2022-03-29 08:44:38 +01:00
Daniel Lockyer
f39a1ce06c Added sqlite3 as an optional dependency
refs https://github.com/TryGhost/Toolbox/issues/213

- this bundles SQLite so it is abstracted away from consumers of this
  package
2022-03-29 08:43:29 +01:00
Daniel Lockyer
03ba3a4d43 Published new versions
- @tryghost/knex-sqlite3@0.1.0
2022-03-28 21:59:44 +01:00
Daniel Lockyer
cf334a6b57 Added @tryghost/knex-sqlite3 package
refs https://github.com/TryGhost/Toolbox/issues/213

- this package exports a custom dialect that extends `sqlite3` but uses
  the original `node-sqlite3` module
2022-03-28 21:59:18 +01:00
Daniel Lockyer
1a6eaff799 Published new versions
- @tryghost/database-info@0.3.0
 - @tryghost/image-transform@1.0.29
 - @tryghost/package-json@1.0.17
 - @tryghost/zip@1.1.22
2022-03-28 13:59:37 +01:00
Daniel Lockyer
aad55e83d9 Added helper methods for detecting database from config
refs https://github.com/TryGhost/Toolbox/issues/213

- this means we can remove some more hardcoded strings and refactor
  database code to be more abstract
2022-03-28 13:54:50 +01:00
Renovate Bot
446deab43b Update dependency fs-extra to v10 2022-03-28 11:32:09 +01:00
Daniel Lockyer
bd6a295674 Refactored to more efficient fs call for reading packages
- we don't need to do both a `fs.readdir` and a `fs.stat` because
  `fs.readdir` has the `withFileTypes` which returns the directory entry
  info and so this avoids an extra stat syscall
2022-03-28 11:31:45 +01:00
Daniel Lockyer
14a087536f Published new versions
- @tryghost/minifier@0.1.12
 - @tryghost/mw-error-handler@0.1.7
 - @tryghost/update-check-service@0.3.2
 - @tryghost/zip@1.1.21
2022-03-24 11:02:25 +00:00
Renovate Bot
6a805a436d Update dependency @tryghost/errors to v1 2022-03-24 10:39:08 +00:00
Daniel Lockyer
4b1db9d998 Unpinned dependencies
- libraries should have dependencies unpinned so we can rely on
  lockfiles and reduce duplicates
- this commit unpins a handful of dependencies
2022-03-24 10:31:31 +00:00
Daniel Lockyer
52365c6f99 Published new versions
- @tryghost/mw-error-handler@0.1.6
2022-03-24 10:10:26 +00:00
Daniel Lockyer
10e97cad23 Handled unknown errors when preparing user message
- in the event we get an unknown error bubble up, we don't handle the
  templating on the error name
- `@tryghost/tpl` throws an error because we pass an undefined string:
  `Cannot read properties of undefined (reading 'replace')`
- this commit adds handling to fallback to a different user message in
  that event so we don't cause a 500 error
2022-03-24 10:06:55 +00:00
Sam Lord
866c746455 Published new versions
- @tryghost/database-info@0.2.5
 - @tryghost/mw-error-handler@0.1.5
2022-03-21 09:38:38 +00:00
Sam Lord
d65ba072f9 Split prepareError from prepareStack
no issue

Change to error handling caused all theme errors to be reported in Sentry, this fix (and a respective fix in Ghost) allows the error to be prepared for sentry before replacing the stack
2022-03-21 09:38:05 +00:00
Renovate Bot
33948553e3 Update dependency knex to v1.0.4 2022-03-14 00:34:06 +00:00
Sam Lord
432ebed27c Published new versions
- @tryghost/job-manager@0.8.21
 - @tryghost/mw-error-handler@0.1.4
2022-03-11 10:48:00 +00:00
Sam Lord
51588c6a24 Ensure Sentry is triggered before replacing the stack trace
refs: https://github.com/TryGhost/Team/issues/1369

If we prepare the error for users to view before using Sentry, then the error passed to Sentry will have the stack trace removed for production environments.

@tryghost/errors@1.2.5 also made it so that the error is not mutated, but cloned and a new one is returned.
2022-03-11 10:47:26 +00:00
Renovate Bot
10e29837e5 Update dependency @sinonjs/fake-timers to v9.1.1 2022-03-07 01:24:01 +00:00
Daniel Lockyer
3675dbd3d7 Published new versions
- @tryghost/database-info@0.2.4
2022-03-02 14:31:00 +01:00
Daniel Lockyer
4acf78a08e Added basic tests for @tryghost/database-info
- these check a few of the imports and static functions
2022-03-02 14:29:16 +01:00
Daniel Lockyer
f77983061e Refactored exports into a class
- following internal feedback, a class with static methods makes more
  sense
2022-03-02 14:27:35 +01:00
Daniel Lockyer
ce5da19189 Published new versions
- @tryghost/database-info@0.2.3
2022-03-02 12:13:38 +01:00
Daniel Lockyer
032e9db2f1 Updated call signature of database-info lib
refs https://github.com/TryGhost/Toolbox/issues/174

- ok, iteration 3 on how this library should work
- 95% of my use cases just need to pass an knex instance and return if
  it's mysql/sqlite
- i don't want to have to initialize the class in this library to get
  that
- this commit reworks the public interface to return a function with
  some simple `is*` functions for those uses cases, or to return the
  class otherwise
2022-03-02 12:11:18 +01:00
Daniel Lockyer
3e9c584589 Published new versions
- @tryghost/database-info@0.2.2
2022-03-01 16:07:02 +01:00
Daniel Lockyer
d8d77ed0ba Added connection method to database info lib
- this allows you to pass in a different DB instance than the one that
  the library is initialized with
2022-03-01 16:05:27 +01:00
Daniel Lockyer
bb04fc49da Published new versions
- @tryghost/database-info@0.2.1
2022-03-01 09:05:02 +01:00
Daniel Lockyer
52eb3181ee Fixed undefined variable references
- this was missed during the previous refactoring
2022-03-01 09:04:05 +01:00
Daniel Lockyer
3324ffc788 Published new versions
- @tryghost/adapter-manager@0.2.28
 - @tryghost/bootstrap-socket@0.2.17
 - @tryghost/config-url-helpers@0.1.5
 - @tryghost/constants@1.0.2
 - @tryghost/database-info@0.2.0
 - @tryghost/image-transform@1.0.28
 - @tryghost/job-manager@0.8.20
 - @tryghost/limit-service@1.0.10
 - @tryghost/minifier@0.1.11
 - @tryghost/moleculer-service-from-class@0.2.23
 - @tryghost/mw-error-handler@0.1.3
 - @tryghost/mw-session-from-token@0.1.28
 - @tryghost/mw-update-user-last-seen@0.1.3
 - @tryghost/package-json@1.0.16
 - @tryghost/pretty-cli@1.2.24
 - @tryghost/promise@0.1.15
 - @tryghost/release-utils@0.7.12
 - @tryghost/security@0.2.15
 - @tryghost/session-service@0.1.38
 - @tryghost/settings-path-manager@0.1.4
 - @tryghost/vhost-middleware@1.0.22
 - @tryghost/zip@1.1.20
2022-03-01 08:40:52 +01:00
Daniel Lockyer
fbc2fc7f65 Altered function usage of @tryghost/database-info
refs https://github.com/TryGhost/Toolbox/issues/174

- this exposes `isMySQL` and `isSQLite` functions which can be used
  within Ghost to figure out which DB we are using
- also cleans up public properties of the class
2022-03-01 08:37:06 +01:00
Daniel Lockyer
3259994e4f Added --all flag to c8 commands
refs https://github.com/TryGhost/Toolbox/issues/203

- without `--all`, c8 will ignore files that aren't covered in tests, so
  they won't pull the test coverage down
- this means we have artificially high coverage scores
- this commit adds `--all` where previously missing
2022-02-21 12:50:26 +01:00
Renovate Bot
b7af869669 Update dependency express to v4.17.3 2022-02-17 03:48:16 +00:00
Daniel Lockyer
5bdc756dec Moved @tryghost/errors to Framework monorepo
refs https://github.com/TryGhost/Toolbox/issues/212

- we've moved `@tryghost/errors` to the Framework monorepo so this
  commit deletes the remaining files in Utils
2022-02-16 09:14:03 +01:00
Renovate Bot
14f37b4932 Update dependency sharp to ^0.30.0 2022-02-16 07:16:50 +01:00
Renovate Bot
3da7577a3a Update dependency folder-hash to v4.0.2 2022-02-16 00:22:11 +00:00
Daniel Lockyer
cfb1ded0d0 Published new versions
- @tryghost/job-manager@0.8.19
 - @tryghost/release-utils@0.7.11
 - @tryghost/update-check-service@0.3.1
 - @tryghost/vhost-middleware@1.0.21
2022-02-04 14:27:23 +01:00
Daniel Lockyer
81458ab4be Updated default changelog content if no emojis exist
no issue

- taken from internal feedback
2022-02-04 14:25:44 +01:00
Renovate Bot
30527371fc Update dependency @sinonjs/fake-timers to v9.1.0 2022-02-03 12:13:52 +00:00
Renovate Bot
6885cdbc90 Update dependency @sinonjs/fake-timers to v9 2022-01-28 14:08:17 +00:00
Daniel Lockyer
636d884322 Moved @tryghost/update-check-service from Core monorepo
no issue

- this packages belongs in here and means we can archive the Core repo
  once complete
2022-01-20 15:25:00 +00:00
Renovate Bot
d9ebfa3a37 Update Test & linting packages 2022-01-20 15:18:35 +00:00
Renovate Bot
765ac29f2b Update dependency emoji-regex to v10 2022-01-20 14:48:11 +00:00
Renovate Bot
3df67f8353 Update dependency supertest to v6.2.2 2022-01-18 23:06:28 +00:00
Daniel Lockyer
19d2411f2b Published new versions
- @tryghost/adapter-manager@0.2.27
 - @tryghost/bootstrap-socket@0.2.16
 - @tryghost/config-url-helpers@0.1.4
 - @tryghost/constants@1.0.1
 - @tryghost/database-info@0.1.0
 - @tryghost/errors@1.2.1
 - @tryghost/image-transform@1.0.27
 - @tryghost/job-manager@0.8.18
 - @tryghost/limit-service@1.0.9
 - @tryghost/minifier@0.1.10
 - @tryghost/moleculer-service-from-class@0.2.22
 - @tryghost/mw-error-handler@0.1.2
 - @tryghost/mw-session-from-token@0.1.27
 - @tryghost/mw-update-user-last-seen@0.1.2
 - @tryghost/package-json@1.0.15
 - @tryghost/pretty-cli@1.2.23
 - @tryghost/promise@0.1.14
 - @tryghost/release-utils@0.7.10
 - @tryghost/security@0.2.14
 - @tryghost/session-service@0.1.37
 - @tryghost/settings-path-manager@0.1.3
 - @tryghost/vhost-middleware@1.0.20
 - @tryghost/zip@1.1.19
2022-01-18 09:08:09 +00:00
Daniel Lockyer
70ecba06ca Added @trghost/database-info package
refs https://github.com/TryGhost/Toolbox/issues/175

- this library is a small utility around `knex` that returns info on the
  database used - particularly, the version used
- this will initially be used within Ghost but it can be extended to
  other databases and projects if needed
2022-01-18 09:06:44 +00:00
Renovate Bot
0f7a0b2964 Update dependency supertest to v6.2.1 2022-01-11 23:51:03 +00:00
Vikas Potluri
ea6d9d42bc Fixed unhandledRejectionError when fs.stat fails (#155) 2022-01-11 12:52:59 +00:00
Renovate Bot
e75bf5e847 Update dependency supertest to v6.2.0 2022-01-11 00:32:14 +00:00
John O'Nolan
fd9bbf906e 2022 2022-01-06 10:17:41 +00:00
John O'Nolan
279ce66e71 2022 2022-01-06 09:52:35 +00:00
Renovate Bot
4c288fa50e Update dependency c8 to v7.11.0 2021-12-30 16:28:02 +00:00
Renovate Bot
e0551bd32e Update dependency date-fns to v2.28.0 2021-12-28 16:35:23 +00:00
Renovate Bot
86d5d4b868 Update dependency express to v4.17.2 2021-12-17 05:58:56 +00:00
Sam Lord
b014df7b21 Published new versions
- @tryghost/adapter-manager@0.2.26
 - @tryghost/errors@1.2.0
 - @tryghost/image-transform@1.0.26
 - @tryghost/limit-service@1.0.8
 - @tryghost/minifier@0.1.9
 - @tryghost/mw-error-handler@0.1.1
 - @tryghost/package-json@1.0.14
 - @tryghost/release-utils@0.7.9
 - @tryghost/session-service@0.1.36
2021-12-14 14:24:31 +00:00
Sam Lord
6a5ea251a5 Fix usage of member function for errors
no issue
2021-12-14 14:07:07 +00:00
Sam Lord
cda07b2009 Replace stack member with a util function
no issue
Will allow the use of `prepareStackForUser` everywhere that the latest @tryghost/errors is used
2021-12-14 12:03:32 +00:00
Sam Lord
8455101b27 Published new versions
- @tryghost/mw-error-handler@0.1.0
2021-12-07 18:43:00 +00:00
Sam Lord
4ef7c974a3 Add @tryghost/mw-error-handler
refs: https://github.com/TryGhost/Toolbox/issues/137
Package includes same logic as was in the Ghost codebase but needs Sentry injected
2021-12-07 18:40:46 +00:00
Sam Lord
4d4847144f Published new versions
- @tryghost/update-check-service@0.3.0
2021-12-07 10:49:05 +00: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
Sam Lord
bdcd205791 Published new versions
- @tryghost/adapter-manager@0.2.25
 - @tryghost/errors@1.1.1
 - @tryghost/image-transform@1.0.25
 - @tryghost/limit-service@1.0.7
 - @tryghost/minifier@0.1.8
 - @tryghost/package-json@1.0.13
 - @tryghost/release-utils@0.7.8
 - @tryghost/session-service@0.1.35
2021-12-06 16:53:49 +00:00
Sam Lord
976a232dc0 Add ConflictError (HTTP 409) to @tryghost/errors
no issue
2021-12-06 16:51:20 +00:00
renovate[bot]
feabbc2fca Update dependency @tryghost/logging to v2 (#63)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-06 12:58:06 +00:00
Sam Lord
90e6e8b37d Published new versions
- @tryghost/bootstrap-socket@0.2.15
 - @tryghost/job-manager@0.8.17
2021-12-06 11:28:22 +00:00
Sam Lord
565790083e job-manager should support logging to parent process
refs: https://github.com/TryGhost/Toolbox/issues/146
2021-12-06 11:27:44 +00:00
Sam Lord
c4009fd4cf Published new versions
- @tryghost/bootstrap-socket@0.2.14
 - @tryghost/job-manager@0.8.16
2021-12-02 13:45:25 +00:00
Sam Lord
a98ae3734f @tryghost/job-manager: Switch to @tryghost/logging from injected argument
refs: https://github.com/TryGhost/Toolbox/issues/146
2021-12-02 13:40:02 +00:00
Sam Lord
cd9e295ec8 @tryghost/bootstrap-socket: Switch to @tryghost/logging from injected arg
refs: https://github.com/TryGhost/Toolbox/issues/146
2021-12-02 12:35:36 +00:00
Sam Lord
e1cc803ca3 Published new versions
- @tryghost/adapter-manager@0.2.24
 - @tryghost/errors@1.1.0
 - @tryghost/image-transform@1.0.24
 - @tryghost/limit-service@1.0.6
 - @tryghost/minifier@0.1.7
 - @tryghost/package-json@1.0.12
 - @tryghost/release-utils@0.7.7
 - @tryghost/session-service@0.1.34
2021-12-01 17:29:28 +00:00
Sam Lord
d8ee09d0fa @tryghost/errors Add stack related functions
refs: https://github.com/TryGhost/Toolbox/issues/147

Correctly prepares the stack when wrapping another error, and adds a new method on errors to create an error which can be shown to the user (i.e. remove the stack trace in production)
2021-12-01 17:28:42 +00:00
Sam Lord
e66cba66f1 Published new versions
- @tryghost/adapter-manager@0.2.23
 - @tryghost/errors@1.0.4
 - @tryghost/image-transform@1.0.23
 - @tryghost/limit-service@1.0.5
 - @tryghost/minifier@0.1.6
 - @tryghost/package-json@1.0.11
 - @tryghost/release-utils@0.7.6
 - @tryghost/session-service@0.1.33
2021-11-30 17:12:21 +00:00
Sam Lord
d240eb7d4c Legacy error support in @tryghost/errors
no issue
2021-11-30 17:11:47 +00:00
Sam Lord
8ae35ccfa1 Published new versions
- @tryghost/adapter-manager@0.2.22
 - @tryghost/errors@1.0.3
 - @tryghost/image-transform@1.0.22
 - @tryghost/limit-service@1.0.4
 - @tryghost/minifier@0.1.5
 - @tryghost/package-json@1.0.10
 - @tryghost/release-utils@0.7.5
 - @tryghost/session-service@0.1.32
2021-11-30 16:37:15 +00:00
Sam Lord
c5acbeae31 Add missing dependency from @tryghost/errors 2021-11-30 16:36:49 +00:00
Sam Lord
6576313a3b Published new versions
- @tryghost/adapter-manager@0.2.21
 - @tryghost/errors@1.0.2
 - @tryghost/image-transform@1.0.21
 - @tryghost/limit-service@1.0.3
 - @tryghost/minifier@0.1.4
 - @tryghost/package-json@1.0.9
 - @tryghost/release-utils@0.7.4
 - @tryghost/session-service@0.1.31
2021-11-30 14:41:30 +00:00
Sam Lord
932ba4e969 @tryghost/errors: Added NoContentError
refs: https://github.com/TryGhost/Toolbox/issues/147

Used in Ghost as a GhostError construction
2021-11-30 14:23:06 +00:00
Sam Lord
ac6cbf3d58 Published new versions
- @tryghost/adapter-manager@0.2.20
 - @tryghost/errors@1.0.1
 - @tryghost/image-transform@1.0.20
 - @tryghost/job-manager@0.8.15
 - @tryghost/limit-service@1.0.2
 - @tryghost/minifier@0.1.3
 - @tryghost/package-json@1.0.8
 - @tryghost/release-utils@0.7.3
 - @tryghost/session-service@0.1.30
2021-11-30 13:59:24 +00:00
Sam Lord
4414857e4d Fix @tryghost/error utils
refs: https://github.com/TryGhost/Toolbox/issues/147
2021-11-30 13:58:33 +00:00
Renovate Bot
6f97bc9063 Update dependency date-fns to v2.27.0 2021-11-30 11:32:47 +00:00
Sam Lord
ffde968c47 Published new versions
- @tryghost/adapter-manager@0.2.19
 - @tryghost/errors@1.0.0
 - @tryghost/image-transform@1.0.19
 - @tryghost/job-manager@0.8.14
 - @tryghost/limit-service@1.0.1
 - @tryghost/minifier@0.1.2
 - @tryghost/package-json@1.0.7
 - @tryghost/release-utils@0.7.2
 - @tryghost/session-service@0.1.29
2021-11-30 11:31:51 +00:00
Sam Lord
ee7b1e4dc6 Combine @tryghost/ignition-errors with @tryghost/errors
refs: https://github.com/TryGhost/Toolbox/issues/147
2021-11-30 11:31:10 +00:00
Hannah Wolfe
a5559d44b6 Published new versions
- @tryghost/job-manager@0.8.13
 - @tryghost/minifier@0.1.1
2021-11-19 12:52:05 +00:00
Hannah Wolfe
0ffeee6712 🐛 Ensured directory exists before attempting write
- Currently, nothing happens if the file doesn't exist, the error is swallowed
- This module should ensure the directory exists at the point of write, else Ghost has to do too much
- TODO: improve the testing and error handling here as well
2021-11-19 12:50:54 +00:00
Renovate Bot
78559033cd Update dependency date-fns to v2.26.0 2021-11-19 08:48:53 +00:00
Sam Lord
57d3097c2a Published new versions
- @tryghost/mw-update-user-last-seen@0.1.1
2021-11-17 10:39:36 +00:00
Sam Lord
b6074c08f6 Empty change for version bump
no issue
2021-11-17 10:38:50 +00:00
Sam Lord
d931c9cf38 Published new versions
- @tryghost/mw-update-user-last-seen@0.1.0
2021-11-16 15:54:46 +00:00
Sam Lord
a92c61ab49 Add @tryghost/mw-update-user-last-seen
no issue
2021-11-16 15:48:52 +00:00
Naz
a5f304d9a7 Published new versions
- @tryghost/constants@1.0.0
2021-11-05 18:15:59 +04:00
Naz
1b15cd0f45 Added files url prefix
refs https://github.com/TryGhost/Toolbox/issues/114

- This new URL prefix is needed for generic files stored in Ghost
2021-11-05 18:14:36 +04:00
Daniel Lockyer
d03f9b4e90 Published new versions
- @tryghost/image-transform@1.0.18
 - @tryghost/job-manager@0.8.12
2021-11-05 12:03:16 +00:00
Daniel Lockyer
eef85bba90 Disabled Sharp's internal cache to improve memory usage
refs https://sharp.pixelplumbing.com/api-utility#cache

- Sharp has a 50MB cache by default, used within libvips, to increase
  the performance of transforming images
- this isn't relevant to us because we should never be optimizing the
  same image as we check if the optimized image already exists
- I presume there is also some extra overhead of using the cache because
  the memory doesn't seem to grow by 50MB
- the memory usage comparison in Ghost is pretty drastic - uploading 10
  images in serial w/ jemalloc:
  - with cache (default) = peak of 480MB, settles down to 330MB
  - disabling cache = peak of 270MB, settles down to 161MB
- this commit disables the cache
- also adds stubbing for the function in tests
2021-11-05 11:59:39 +00:00
Renovate Bot
5872147193 Update dependency @sinonjs/fake-timers to v8.1.0 2021-11-03 14:32:11 +00:00