strapi-plugin-meilisearch
strapi-plugin-meilisearch copied to clipboard
Strapi v5
Pull Request
Related issue
Fixes #<issue_number>
What does this PR do?
- ...
PR checklist
Please check if your PR fulfills the following requirements:
- [ ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [ ] Have you read the contributing guidelines?
- [ ] Have you made sure that the title is accurate and descriptive of the changes?
Thank you so much for contributing to Meilisearch!
Hi @curquiza this PR is ready for basic review. This continues on the #958, and updates the codebase to strapi v5. Unit and e2e tests are passing locally (e2e test has passed on git also https://github.com/zoran995/strapi-plugin-meilisearch/actions/runs/11147207734).
Important: The playground no longer uses symlink but should actually use yalc as described here https://docs.strapi.io/dev-docs/plugins/development/create-a-plugin. Another option would be to convert the codebase to monorepo where one package would be plugin and one package would be playground. It might be beneficial to have it in monorepo so the changes to e2e test doesn't restart entire server. Also with monorepo it will be directly symlinked in node_modules so we wouldn't need to deal with yalc or other ways to link package both locally and in CI. But it is your call, let me know what you think
Still left to update documentation, on building and configuration. Edit: one more question in strapi in version 5 will list both draft and published records, what will be the best approach to handle this? If you check the categories index you will that there it says that 6 entries exist but actually there are 3 that can be indexed
@zoran995 It's fantastic work 👏🏼 !! I'll review it in soon
Hello @zoran995
thank you for your PR! And thank you in advance @candidosales for your review, this is really important to have the community collaborating on it. Thank you both of you ❤️
Once you will have review, @brunoocasali will take a look at it to ensure a release as soon as we can 😊 We are a small team so we have a lot of priorities but we will do our best for this
Hey @zoran995, I like the monorepo idea, but I think it would be too much for a single PR!
Yeah, I can do it as a follow-up PR
@candidosales did you maybe have time to test this against your implementation of strapi?
I'm sorry, guys. I'm currently very busy, as I'm participating in interviews and preparing for them. When I have some free time, I'll review it.
Hi, a week has passed since @candidosales's comment, can I kindly ask for an update?
Will this PR be reviewed and merged soon?
@zoran995 and @Matb85 , I did a review, and I found this bug:
- ✅ Build: strapi-plugin-meilisearch
- ✅ Build: strapi
- ✅ Run: strapi
- ⚠️ Access the
http://localhost:1337/admin/plugins/meilisearchdoesn't work
I'm using Strapi 5.1.1. I assume the issue relates to Page.Protect at App.jsx and something associated with React Router.
My package.json below:
{
"name": "my-strapi-5",
"version": "0.1.0",
"private": true,
"description": "A Strapi application",
"scripts": {
"build": "strapi build",
"deploy": "strapi deploy",
"develop": "strapi develop",
"seed:example": "node ./scripts/seed.js",
"start": "strapi start",
"strapi": "strapi"
},
"dependencies": {
"@strapi/plugin-cloud": "5.1.1",
"@strapi/plugin-users-permissions": "5.1.1",
"@strapi/strapi": "5.1.1",
"better-sqlite3": "9.4.3",
"fs-extra": "^10.0.0",
"mime-types": "^2.1.27",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^6.0.0",
"styled-components": "^6.0.0"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"typescript": "^5"
},
"engines": {
"node": ">=18.0.0 <=20.x.x",
"npm": ">=6.0.0"
},
"strapi": {
"uuid": "09438d55-3aa4-4fd6-aed7-24587b08b1ea"
}
}
How to reproduce
- I created a new project Strapi 5 project
npx create-strapi@latest my-strapi-5; - Imported the plugin via
git clone https://github.com/zoran995/strapi-plugin-meilisearchat./src/plugins; - Changed to the branch
git checkout strapi-v5-upgradeand update locally; - Added the config below at
config/plugins.ts
export default ({ env }) => ({
meilisearch: {
enabled: true,
config: {
// Your meili host
host: env('MEILISEARCH_HOST'),
// Your master key or private key
apiKey: env('MEILISEARCH_API_KEY_MASTER'),
article: {
transformEntry({ entry }) {
return {
id: entry.id,
title: entry.title,
slug: entry.slug,
description: entry.description
};
},
},
},
resolve: './src/plugins/strapi-plugin-meilisearch',
},
});
- Build the plugin:
cd src/plugins/strapi-plugin-meilisearch && npm install && npm run build; - Back to the root folder and start the project:
cd ../../.. && npm run start
I had the same issue as @candidosales, @zoran995. Can you check it, please? Or let me know what I did wrong :D
Hi @candidosales @brunoocasali I just tried the steps you provided, the only difference is that I used npm run develop to start the project and everything runs without issue. According to strapi docs the new way to test plugins while developing locally is using yalc, you can check more details here https://docs.strapi.io/dev-docs/plugins/development/create-a-plugin#linking-the-plugin-to-your-project.
The steps that work for me are:
- create new Strapi 5 project
npx create-strapi@latest my-strapi-5; - clone the repo
git clone https://github.com/zoran995/strapi-plugin-meilisearchin a separate directory - change the branch in plugin repo
git checkout strapi-v5-upgrade - run
npm run watch:linkto build the meilisearch plugin and make it available for linking usingyalc. It will write out the command for linking the plugin - run the command copied above in Strapi 5 project
npx yalc add strapi-plugin-meilisearch && npx yalc link strapi-plugin-meilisearch && npm install - run strapi 5 project using
npm run developor usingnpm run buildand thennpm start
I have also tried using verdaccio to create a local release and it worked.
Let me know if the above works for you, if not I will look further into it
@zoran995 , I'll try in soon. Thanks for double check
Hi @zoran995, I took those steps, and they work well 🎉 .
I have a minor issue with the number of documents. I have five articles published, and the table shows 10.
@candidosales for the number of records I mentioned that above
one more question in strapi in version 5 will list both draft and published records, what will be the best approach to handle this? If you check the categories index you will see that it says that 6 entries exist but actually there are 3 that can be indexed
It is happening because Strapi added native support to draft/modified/published versions of records and I wasn't sure of the best way to filter those. I just added a filtering on this method hopefully it works correctly now
@zoran995, it's working! Thanks for the fantastic work! @brunoocasali , could you review it?
As a suggestion, I think it is better to increase the version of the package.json to 1.0.0 because this refactor has so many break changes. @zoran995 and @brunoocasali , what do you think?
It's approved for me!
Hi @candidosales thank you very much for the review and of course thank you @zoran995 🥇 you are amazing folks!
I'm going to take a look at it but I will probably not test it myself, my agenda is pretty busy this week I just came back from holidays 😅 so I have other important stuff to work on.
About the package turning stable we were pretty "against" that policy over the years because of the amount of changes we used to have when the engine was not stable which is not the case anymore. I will think about it, but so far let's keep it this way ok?
bors merge
bors merge
bors cancel
Information need to be shared with Strapi team. Still new plugin is not available on Strapi plugin marketplace
@candidosales & @zoran995 Thank you very much for your work 🙌🏽 It unblocks a lot of folks in the community, I would be glad to send you some swag. If anything interests you on our swag shop, we would be glad to send something for you. Can you send me an email with the product you'd like, your address & your size please :) thomas at meilisearch dot com