Commit Graph

13394 Commits

Author SHA1 Message Date
Daniel Lockyer
6eba445f23
Fixed canary build after yarn command changes
refs 7e6800b2b8

- referenced commit deprecated `grunt main` in favor of `yarn main` but
  this wasn't updated so we never installed dependencies for Admin,
  which caused the build to break
- this commit switches to the new command
2021-07-06 10:22:07 +01:00
Kevin Ansfield
541fb4d2db
🐛 Fixed potential for partial content re-generation in 4.0 migrations (#13120)
no issue

- incorrect syntax was used in the error handlers inside of the `for` loop, by using `return` when logging the whole for-loop was aborted whereas we want to log and continue processing the rest of the items
2021-07-06 10:15:32 +01:00
Kevin Ansfield
05b317af9d
🐛 Fixed incorrectly stored URLs after migration from 3.x to 4.6.1-4.8.4 (#13109)
refs https://github.com/TryGhost/Team/issues/853

A refactor of `urlUtils` usage in 4.6.1 left a buggy 4.0 migration that did not transform URLs inside of mobiledoc cards. Anyone upgrading from 3.x to 4.6.1-4.8.4 would end up with inconsistent URL formats and potentially broken images.

- fixed 4.0 migration by passing our mobiledoc cards list in when transforming mobiledoc urls
- added a new migration that re-applies the missed URL transforms and content re-generation for any site that did a 3.x upgrade to a buggy 4.x version
2021-07-06 10:15:00 +01:00
Naz
2c1ae2e9af 🐛 Fixed a 500 error for incorrect fields parameter in API
refs 8a1fd1f57f
refs 5584430ddc

- The change to async/await in the original commit 558443 was causing problems in downstream dependencies (create-error package) where it was loosing a context of "this". It's not a direct dependency so I didn't go yak shaving into where exacly the context is lost.
- The fix to keep a correct context of "this" was sticking to an existing pattern using regular function returning promises. Once we need to redo them into async/await we can investigate if there's a way around create-error's context prolbem
2021-07-06 11:58:37 +04:00
Rishabh
ec7cf99279 Updated missing yarn lock changes
no refs

- cleans up the yarn lock file with missing dependency changes from previous commits.
2021-07-06 13:15:56 +05:30
Hannah Wolfe
8c2687c24e
Fixed yarn dev
refs: 7e6800b2b8

- I kept flip-flopping on making grunt dev into grunt and removing it so we have to remember to use `yarn dev` and fucked it up entirely
- Do the simple thing for now - and think about how we can make grunt dev better overall
2021-07-06 08:23:52 +01:00
Hannah Wolfe
7e6800b2b8
Improved dev tooling (#13118)
This commit achieves a few things:

- ☑️  No longer having to remember whether a command is yarn something or grunt something
- ☑️  Simplification of tools hopefully making them easier to remember and use 
- ☑️  Complete removal of the need for grunt from our test tooling

Several of the tools still use grunt under the hood, but the **entrypoint** should aways be `yarn xxx`.

- `grunt main` -> `yarn main`
- `grunt dev` -> `yarn dev`
- `grunt build` -> `yarn build`
- `grunt test:file-or-folder` -> `yarn test file-or-folder`
- `grunt test-unit` -> `yarn test:unit`
- `grunt test-acceptance` -> `yarn test:acceptance`
- `grunt test-regression` -> `yarn test:regression`
- `grunt validate` -> removed due to lack of use

There is now also `yarn test:all` to run all 3 classes of tests

This PR also reorders & restructures the Gruntfile extensively so that:

- The remaining useful commands are all at the top of the file
- Config and other blah happens after all the useful commands
- All release-only config happens in the release task at the very end of the file

---

DONE:

* Removed all references to npm/bower
* Removed all references to lint / deprecated command
* Moved debug to yarn dev:debug
* Removed all references to travis
* Removed broken help task + useless comment
* Removed unused knex-migrator and clean:test setup tasks
* Added new test commands, removed grunt validate
* Moved stubClientFiles to test utility and use in the few tests that need it
* Used mocha in yarn directly except grunt test:x
* Swapped grunt test for yarn test
* extensive cleanup and reshuffling
2021-07-05 20:02:22 +01:00
Daniel Lockyer
8a1fd1f57f
Revert "🐛 Fixed a 500 error for incorrect fields parameter in API"
- this reverts commit 5584430ddc until we
  can investigate why tests are failing
2021-07-05 17:36:44 +01:00
Naz
5584430ddc 🐛 Fixed a 500 error for incorrect fields parameter in API
closes https://github.com/TryGhost/Team/issues/817
refs 6d083ee00e/packages/bookshelf-pagination/lib/bookshelf-pagination.js (L256)

- The 500 error is not the best we can do in this situation and throwing a 400 just like we doo in a referenced commit would keep the convention
- The underlying problem of the bug is bigger - we allow the fields named the same way as relations to leak into the db query and that causes an incorrect SQL syntax. It's a bigger problem which would need a separate, holistic approach
2021-07-05 18:46:02 +04:00
Thibaut Patel
9c2cfb5d00 Added cache invalidation to the POST authentication/setup route
issue https://github.com/TryGhost/Team/issues/859
2021-07-05 16:01:25 +02:00
Rishabh
50eddaa208 Updated default content cta for restricted post/page access to custom filters
refs https://github.com/TryGhost/Team/issues/849

With multiple products, we have re-enabled segmentation by product for posts behind alpha feature flag. This change handles the default content cta to show custom message if the post's access is restricted to specific products when behind the flag.
2021-07-05 17:10:45 +05:30
Rishabh
3e9a23355f Handled visibility filter in post/page API
refs https://github.com/TryGhost/Team/issues/849

As part of work for segmented post access with multiple products, the custom filter for post access is stored in `visibility` field on posts but passed with `visibility_filter` property on API. This change -

- updates input serializer of posts to transform `visibility` and `visibility_filter` properties correctly
- updates output serializer for canary to transform and send `visibility_filter` attribute with filter value
- updates output serializer for v3 to ignore any custom filter on visibility and return `paid` instead as v3 didn't have a concept of custom filter
2021-07-05 17:10:45 +05:30
Rishabh
d413b3d654 Updated visibility validator for page/posts
refs https://github.com/TryGhost/Team/issues/849

Custom post visibility (behind alpha flag) is added to the API using new `visibility_filter` attribute that stores the custom filter. This change -

- updates validator for visibility to check new `visibility_filter` property
- cleans usage of i18n in favor of tpl
2021-07-05 17:10:45 +05:30
Rishabh
6988dadb1e Added visibility filter string to post/page admin schema
refs https://github.com/TryGhost/Team/issues/849

With multiple products back behind alpha flag, we want to bring back segmented post access for members which allows site owners to set post access to specific products. This change -

- updates admin-api-schema to allow `visibility_filter` attribute to post/page response
2021-07-05 17:10:45 +05:30
Renovate Bot
fec534f833
Pin dependency mocha-slow-test-reporter to 0.1.2 2021-07-05 09:53:57 +00:00
Hannah Wolfe
8f496fb447
Added yarn test:slow tool to show slow tests
- We have a lot of tests, so it can be hard to see if any are problematic
- We have a problem with some tests being too slow, this highlights these in particular
- Very slow tests that take seconds are not really unit tests, we should look for different ways to run these
- Also we should tailor our mocha settings more, so that we have more lenient settings for acceptance/regression tests but not for unit tests
- Note: You have to wait for all tests to run to see the output
2021-07-05 10:42:27 +01:00
Renovate Bot
4a27096af5 Update dependency nock to v13.1.1 2021-07-05 08:45:28 +01:00
Renovate Bot
4ae5cff740 Update dependency @tryghost/helpers to v1.1.49 2021-07-05 08:43:21 +01:00
Renovate Bot
0a032acf99 Update dependency @tryghost/social-urls to v0.1.25 2021-07-05 08:43:02 +01:00
Renovate Bot
ecc33f63de Lock file maintenance 2021-07-05 02:55:08 +00:00
Renovate Bot
d5f457fbb6
Update Test & linting packages 2021-07-05 00:37:17 +00:00
Kevin Ansfield
c756cf5feb Removed psmRedesign from allows labs flags
refs https://github.com/TryGhost/Team/issues/840

- redesign in Admin is now in `main` without flag
2021-07-02 19:06:42 +01:00
Naz
0f49e19127 Removed unneded i18n and logging parametes from update check
refs https://github.com/TryGhost/Team/issues/727

- @tryghost/update-check-service v0.2.0 does not require either i18n or logging parameters - makes things less tangled up!
2021-07-02 19:07:13 +04:00
Naz
703827b4c2 Changed update check's API version to use default one
refs https://github.com/TryGhost/Team/issues/727

- The version was forgotten to get a bump durin g 4.0 release. The API version used by update check should be the same as internal default.
- Because the current internal default is mistakenly set to v3 API it's still not optimal but will need a holistic solution in the future
2021-07-02 19:07:13 +04:00
renovate[bot]
4c551fcde6
Added detection of conditional partials in themes
closes https://github.com/TryGhost/Team/issues/781
refs 076ad99593
refs https://github.com/TryGhost/Ghost/commit/2b73d0f66
refs https://github.com/TryGhost/Ghost/commit/bab12ca3d

- With refs 076ad99593 
landing in main there is no more 500 error stopping us from bumping the version
- Previous versions of gscan wasn't able to detect partial usage inside
of a helper, e.g.: "{{#if author}}{{> "missing_partial"}}{{/if}}". It's
important to be able to detect these on theme upload/validation stage to
avoid errors during the runtime.
- The updated version provides additional information about used and
unused partials and helpers.
- With this change users might start seeing a "fatal" error during an
upload/activation of a theme previously passing validation. Currently
active themes with partials used in the context will still allow for a
 boot, but will log a 422 error pointing to missing partial.
2021-07-02 22:43:35 +12:00
Naz
076ad99593 Removed 500 error during production boot \w a theme error
refs https://github.com/TryGhost/Team/issues/781
refs 813d288eb2#

- The 500 error was introduced through a refed commit long time ago when (probably?) there were no other safeguards preventing from serving content through a theme with errors. Since than we have multiple safeguards when aploading/activating the theme with errors and the default handling when such error occurs is more graceful - a 400 with specific error details is shown
- We need this change to land before bumping gscan that introduces more suphisticated error detaction in theme templates. Otherwise, people upgrading to new version and having an error on an unused template or somewhere undetected previously woul end up with a bricked site showing a generic 500 - not a great experience!
2021-07-02 14:31:45 +04:00
Thibaut Patel
3ca4cd99f1 Moved the gated email card feature behing an alpha flag
issue https://github.com/TryGhost/Team/issues/842
2021-07-02 12:15:03 +02:00
Naz
607623211a Corrected deprecation comment
no issue

- Ghost 4.0 didn't contain any breaking changes. Breaks like this one will be introduced in 5.0
2021-07-02 13:50:11 +04:00
Hannah Wolfe
84c2154cbe
Fixed missing renames getExcerpt -> generateExcerpt
refs: fbf0636936

- I renamed this pattern in a bunch of places, but missed a few, leaving the code messy and confusing
- This makes the naming consistent
2021-07-02 09:44:18 +01:00
Matt Hanley
4ac89c0176
Added webp image support (#13105)
refs https://github.com/TryGhost/Ghost/issues/9448
refs https://github.com/TryGhost/Ghost/issues/2591

Added API support for webp image files.
2021-07-02 09:37:54 +01:00
Rishabh
86fbb14033 Added subscription price data for logged-in member
no refs

- adds `price` data on subscription from related `stripe_price` on updating a member via frontend
- removes inconsistency between `GET` and `PUT` data for logged in member on a site
2021-07-01 23:30:14 +05:30
Naz
df5290089b Fixed lint error 2021-07-01 21:02:06 +04:00
Naz
380c0dad2c Fixed email batch partitioning when only one card used
refs https://github.com/TryGhost/Team/issues/828

- Previous method had a bug where it didn't take into account cases when onlya single card with a segment filter has been used leaving the members not covered by that filter without an email
2021-07-01 20:58:24 +04:00
Naz
986a7526f5 Added member partitioner based on segment
refs https://github.com/TryGhost/Team/issues/828

- Before sending out batches with members we need to partition all members based on the segment they belong to. Special segment "unsegmented" is used in case none of the segments used in the emal cards cover part of the members set (for example only free members card used when emailing all members)
2021-07-01 20:58:24 +04:00
Kevin Ansfield
1b0aa0abd8
Fixed feature_image_caption needing triple-curlies in themes (#13107)
refs https://github.com/TryGhost/Team/issues/845
refs 517d2abc5c

- updated router response formatting functions and `{{#get}}` helper response handling to make any `feature_image_caption` properties in the response a `SafeString` instance so triple-curlies are not needed when using the property in themes
2021-07-01 17:55:44 +01:00
Thibaut Patel
2d95c1b8d7 Reverted a bad change from a previous commit
commit b94c8bcfd4
2021-07-01 16:39:36 +02:00
Hannah Wolfe
6f1a3e1774
Removed usages of new Error & i18n in legacy code
- cleaning up a handful of usages of i18n and new Error in some really old codepaths
- pushing our new patterns forward wherever we can
2021-07-01 12:53:06 +01:00
Thibaut Patel
b94c8bcfd4 Render an email correctly according to the associated member segment
issue https://github.com/TryGhost/Team/issues/829
2021-07-01 13:36:42 +02:00
Hannah Wolfe
af4bfb8862
Changed meta filenames to correct casing
- purely for cleanliness!
- we use kebabcase by default
- tests should be kebab-case-file_spec.js (one day we want this to be .test.js)
2021-07-01 12:30:25 +01:00
Hannah Wolfe
1785611db9
Refactored meta index
- The main aim here is to end up with a simple and clear public API for the meta module
- Secondarily, we want to make it a bit clearer which bits don't really belong here so we can see what to do with them
- To achieve this, the main logic has been moved into get-meta (although there's still some logic here which needs moving further)
- The index.js now has a small clear public API, and the proxy, which is the only way this is consumed, is able to use the public API directly
2021-07-01 11:58:40 +01:00
Hannah Wolfe
9fbc0b7f2b
Moved post excerpt logic to an excerpt file
- This is content negotiation logic and shouldn't be inline
- TODO: this needs tests
2021-07-01 11:47:30 +01:00
Hannah Wolfe
fbf0636936
Renamed meta/excerpt meta/generate-excerpt
- This function is quite different to the others, as it generates an excerpt from HTML (truncating)
- Most functions in the meta data folder just contain content negotiation logic, like if post then feature_image else cover_image type things
- This function is more like a library and shouldn't live in Ghost, it should probably be in @tryghost/helpers
- It's definitely something we'd love to rewrite to work better tooooo
2021-07-01 11:47:29 +01:00
Kevin Ansfield
29af4b93a0 Fixed linter errors
refs 517d2abc5c

- forgot to remove now-unused labs requires
2021-07-01 10:59:40 +01:00
Kevin Ansfield
517d2abc5c Added feature_image_{alt/caption} to the v4 posts API
refs https://github.com/TryGhost/Team/issues/839

It's now possible to set alt and caption for post feature images using `feature_image_alt` and `feature_image_caption` fields on a post resource.

- `feature_image_alt` - plain text, limited to 191 chars (alt text is not recommended to be longer than 125 chars, screen readers may cut the description off at that point)
- `feature_image_caption` - basic HTML, limited to 65535 chars

Alt and caption will be automatically used inside of newsletter content, for your website content make sure your theme is updated to use the v4 API and make use of the new properties.

---

- removed `featureImageMeta` labs flag
2021-07-01 10:53:55 +01:00
Hannah Wolfe
884f39d045
Moved meta + sitemap tests out of data folder
- we moved the meta folder out of data a really long time ago
- we also moved the sitemap out of data/xml into a service
- this moves the tests to roughly match
2021-06-30 17:08:28 +01:00
Hannah Wolfe
ac07703f17
Changed app/loader to use @tryghost/errors
- getting rid of instances of new Error as we should always use @tryghost/errors
- Whilst here, got rid of i18n but discovered the messages were missing!
- This is my fault, they disappeared when I removed external apps and clearly removed too much: 8c1a0b8d0c (diff-0f5cc40aa8906a1be1bad2002a35361bbf9e766e46b3b29be10f4f479265426a)
- Therefore, I have restored these messages in the places where they were used, except amp_content, where I have written a new message, as the message that was there was not relevant
2021-06-30 16:05:54 +01:00
Hannah Wolfe
df51da5f7e
Updated eslint rules for plugin v2.4.0
refs: 10d02e8343
refs: 83a30775bf
refs: 3355f627c4
refs: 0e9b950558

- In eslint-plugin-ghost 2.4.0 I moved some of the rules implmented in Ghost as they are global rules, including:
   - no new Error()  - use @tryghost/errors
   - forcing index.js to be under 50 chars as a leading indicator for misuse of index files
- I also added new rules to check for tpl('literal string') and the deprecated ghost-ignition package
- Because the new Error and tpl rules are both implemented with no-restricted-syntax, the local rules overrode the global one
- Removing the rule here allows the global ones to work
- Have to think about how to do this long term
2021-06-30 15:51:48 +01:00
Hannah Wolfe
bd597db829
Moved settings/cache to shared/settings-cache
- This is part of the quest to separate the frontend and server & get rid of all the places where there are cross-requires
- At the moment the settings cache is one big shared cache used by the frontend and server liberally
- This change doesn't really solve the fundamental problems, as we still depend on events, and requires from inside frontend
- However it allows us to control the misuse slightly better by getting rid of restricted requires and turning on that eslint ruleset
2021-06-30 15:49:10 +01:00
Hannah Wolfe
3ea6df819c
Refactored SettingsCache to get events through DI
- requiring lib/common/events makes the settings cache tightly coupled to the server
- moving this up to settings index means the cache itself can be moved to a shared component/moved out of Ghost
- the index then becomes the settings manager
- questionable whether the event listeners & updater part of this shouldn't be part of a manager, independent of the actual cache 🤔
2021-06-30 15:40:41 +01:00
Naz
d33baf9ba4 Added member_segment persistance to email_batches
refs https://github.com/TryGhost/Team/issues/828

- We need a way to recreate a filter that was used to create an email content for specific email_recipient. By saving member_segment value for each email_batch we can traverse back to the filter that was applied during email creation.
2021-06-30 18:32:31 +04:00