Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(gatsby-source-wordpress): Add searchAndReplace #31091

Merged
merged 17 commits into from
May 11, 2021
Merged

feat(gatsby-source-wordpress): Add searchAndReplace #31091

merged 17 commits into from
May 11, 2021

Conversation

jooola
Copy link
Contributor

@jooola jooola commented Apr 28, 2021

All credits should go to @philmuze, I just cherry picked his work at gatsbyjs/gatsby-source-wordpress-experimental#129

But I don't know how to properly test this feature, didn't see any obvious testing framework.

Description

Add a search and replace feature to replace strings or regex rule with a substitute string.

Documentation

See changes in the docs/ folder.

Related Issues

gatsbyjs/gatsby-source-wordpress-experimental#129

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Apr 28, 2021
@jooola
Copy link
Contributor Author

jooola commented Apr 28, 2021

Also the format function in the main package.json is failing, co couldn't enforce formatting. How should I fix the formatting issue ?

@philippmunzert
Copy link

Great @jooola! Thanks for transferring it to the main repo.

@LekoArts LekoArts added topic: source-wordpress Related to Gatsby's integration with WordPress and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 3, 2021
@LekoArts
Copy link
Contributor

LekoArts commented May 3, 2021

The lint check is currently failing on

/home/circleci/project/packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/process-node.js
  263:74  error  Insert `⏎··········`                      prettier/prettier
  264:1   error  Delete `··`                               prettier/prettier
  534:13  error  Insert `··`                               prettier/prettier
  536:1   error  Insert `··`                               prettier/prettier
  563:11  error  Delete `··`                               prettier/prettier
  564:1   error  Delete `··`                               prettier/prettier
  565:11  error  Delete `··`                               prettier/prettier
  566:1   error  Delete `··`                               prettier/prettier
  567:11  error  Delete `··`                               prettier/prettier
  568:11  error  Delete `··`                               prettier/prettier
  569:1   error  Replace `············` with `··········`  prettier/prettier
  571:13  error  Insert `··`                               prettier/prettier
  573:1   error  Insert `··`                               prettier/prettier
  648:23  error  Insert `⏎··········`                      prettier/prettier
  649:1   error  Delete `··`                               prettier/prettier
  853:56  error  Delete `⏎`                                prettier/prettier
  856:46  error  Strings must use backtick                 quotes

All credits should go to @philmuze, I just cherry picked his work at gatsbyjs/gatsby-source-wordpress-experimental#129
@jooola
Copy link
Contributor Author

jooola commented May 3, 2021

Just rebased on master and formatted code.

jooola added 3 commits May 5, 2021 14:35
I replaced the regex literal with a string because
prettier could not handle it and Joi does not have
a Literal expression type.
@jooola
Copy link
Contributor Author

jooola commented May 5, 2021

If a rebase is need on my side, simply ping me, I'll do it asap.

Copy link
Contributor

@TylerBarnes TylerBarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work here :D just a couple tiny changes and then LGTM!

jooola and others added 5 commits May 10, 2021 21:00
Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
Filters are run in order one at a time and if we run it at the end
we'll have already done a bunch of image/file processing
and manipulation of the node data.
Putting this at the end means we wont be able to rewrite
our WP URL to a CDN url before Gatsby pulls all the images
in from WP.
@jooola
Copy link
Contributor Author

jooola commented May 10, 2021

@TylerBarnes I added a small note about using regular expression literal in the documentation, but somehow I feel this it not enough.

So I think it is ready to be merged, but might need some documentation improvement in the future regarding using regular expression literal.

@TylerBarnes TylerBarnes self-requested a review May 10, 2021 19:19
TylerBarnes
TylerBarnes previously approved these changes May 10, 2021
Copy link
Contributor

@TylerBarnes TylerBarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making those changes :) LGTM

@TylerBarnes TylerBarnes added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label May 10, 2021
jooola and others added 2 commits May 10, 2021 21:28
Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
TylerBarnes
TylerBarnes previously approved these changes May 10, 2021
@jooola
Copy link
Contributor Author

jooola commented May 11, 2021

@TylerBarnes I missed some useless escape chars, so lint failed again. I just fixed it.

@TylerBarnes
Copy link
Contributor

TylerBarnes commented May 11, 2021

The failing tests appear to be unrelated to this PR. Thanks @jooola and @philmuze for this!

@TylerBarnes TylerBarnes merged commit fd7cee1 into gatsbyjs:master May 11, 2021
@jooola jooola deleted the feature_wordpress_search_replace_links branch May 13, 2021 09:22
axe312ger pushed a commit that referenced this pull request May 20, 2021
Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes topic: source-wordpress Related to Gatsby's integration with WordPress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants