Skip to content

Commit b39b56e

Browse files
committed
Revert "Remove Meilisearch package from monorepo (#2347)"
This reverts commit 54816a3.
1 parent 5718f5f commit b39b56e

8 files changed

Lines changed: 154 additions & 1 deletion

File tree

.github/workflows/split_packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
package: ["admin", "core", "opayo", "paypal", "table-rate-shipping", "stripe", "search"]
15+
package: ["admin", "core", "opayo", "paypal", "table-rate-shipping", "stripe", "meilisearch", "search"]
1616
steps:
1717
- uses: actions/checkout@v4
1818
- uses: shivammathur/setup-php@v2

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"Lunar\\Database\\Factories\\": "packages/core/database/factories",
6666
"Lunar\\Database\\Seeders\\": "packages/core/database/seeders",
6767
"Lunar\\Database\\State\\": "packages/core/database/state",
68+
"Lunar\\Meilisearch\\": "packages/meilisearch/src/",
6869
"Lunar\\Opayo\\": "packages/opayo/src/",
6970
"Lunar\\Paypal\\": "packages/paypal/src/",
7071
"Lunar\\Search\\": "packages/search/src/",
@@ -92,6 +93,7 @@
9293
"Table Rate Shipping",
9394
"Opayo Payments",
9495
"Search",
96+
"Meilisearch",
9597
"Paypal Payments",
9698
"Stripe Payments"
9799
]
@@ -100,6 +102,7 @@
100102
"providers": [
101103
"Lunar\\Stripe\\StripePaymentsServiceProvider",
102104
"Lunar\\Paypal\\PaypalServiceProvider",
105+
"Lunar\\Meilisearch\\MeilisearchServiceProvider",
103106
"Lunar\\Search\\SearchServiceProvider",
104107
"Lunar\\Admin\\LunarPanelProvider",
105108
"Lunar\\Opayo\\OpayoServiceProvider",
@@ -111,6 +114,7 @@
111114
"replace": {
112115
"lunarphp/core": "self.version",
113116
"lunarphp/lunar": "self.version",
117+
"lunarphp/meilisearch": "self.version",
114118
"lunarphp/opayo": "self.version",
115119
"lunarphp/paypal": "self.version",
116120
"lunarphp/search": "self.version",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [lunar]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Close Pull Request
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: superbrothers/close-pull-request@v3
12+
with:
13+
comment: "Thank you for your pull request. However, you have submitted this PR on the Lunar Meilisearch Repo which is a read-only sub split of `lunarphp/lunar`. Please submit your PR on the https://github.com/lunarphp/lunar repository.<br><br>Thanks!"

packages/meilisearch/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Lunar Meilisearch
2+
3+
The package indexes filterable and sortable attributes on Meilisearch engine

packages/meilisearch/composer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "lunarphp/meilisearch",
3+
"description": "Meilisearch Addon",
4+
"keywords": ["lunarphp", "laravel", "ecommerce", "e-commerce", "headless", "store", "meilisearch"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Lunar",
9+
"homepage": "https://lunarphp.io/"
10+
}
11+
],
12+
"require": {
13+
"meilisearch/meilisearch-php": "^1.10"
14+
},
15+
"autoload": {
16+
"psr-4": {
17+
"Lunar\\Meilisearch\\": "src/"
18+
}
19+
},
20+
"extra": {
21+
"lunar": {
22+
"name": "Meilisearch"
23+
},
24+
"laravel": {
25+
"providers": [
26+
"Lunar\\Meilisearch\\MeilisearchServiceProvider"
27+
]
28+
}
29+
},
30+
"minimum-stability": "dev",
31+
"prefer-stable": true
32+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
namespace Lunar\Meilisearch\Console;
4+
5+
use Exception;
6+
use Illuminate\Console\Command;
7+
use Laravel\Scout\EngineManager;
8+
use Laravel\Scout\Engines\MeilisearchEngine;
9+
10+
class MeilisearchSetup extends Command
11+
{
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'lunar:meilisearch:setup';
18+
19+
/**
20+
* The console command description.
21+
*
22+
* @var string
23+
*/
24+
protected $description = 'Set up filterable and sortable attributes to Meilisearch';
25+
26+
/**
27+
* Meilisearch engine
28+
*/
29+
protected MeilisearchEngine $engine;
30+
31+
/**
32+
* Execute the console command.
33+
*/
34+
public function handle(EngineManager $engine): void
35+
{
36+
// Return the models we want to search on.
37+
$searchables = config('lunar.search.models', []);
38+
39+
$this->engine = $engine->createMeilisearchDriver();
40+
41+
// Make sure we have the relevant indexes ready to go.
42+
foreach ($searchables as $searchable) {
43+
$model = (new $searchable);
44+
45+
$indexName = $model->searchableAs();
46+
47+
try {
48+
$index = $this->engine->getIndex($indexName);
49+
$this->warn("Index {$indexName} found for {$searchable}");
50+
} catch (Exception $e) {
51+
$this->warn($e->getMessage());
52+
$this->info("Creating index {$indexName} for {$searchable}");
53+
54+
$task = $this->engine->createIndex($indexName);
55+
$this->engine->waitForTask($task['taskUid']);
56+
57+
$index = $this->engine->getIndex($indexName);
58+
}
59+
60+
$this->info("Update filterable fields to {$searchable}");
61+
$task = $index->updateFilterableAttributes(
62+
$model->getFilterableAttributes()
63+
);
64+
$this->engine->waitForTask($task['taskUid']);
65+
66+
$this->info("Update sortable fields to {$searchable}");
67+
$task = $index->updateSortableAttributes(
68+
$model->getSortableAttributes()
69+
);
70+
$this->engine->waitForTask($task['taskUid']);
71+
72+
$this->newLine();
73+
}
74+
}
75+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Lunar\Meilisearch;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Lunar\Meilisearch\Console\MeilisearchSetup;
7+
8+
class MeilisearchServiceProvider extends ServiceProvider
9+
{
10+
public function register()
11+
{
12+
//
13+
}
14+
15+
public function boot()
16+
{
17+
if ($this->app->runningInConsole()) {
18+
$this->commands([
19+
MeilisearchSetup::class,
20+
]);
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)