Skip to content

Commit 53e7f84

Browse files
chore: Update code quality packages; Add .editorconfig; Reformat files
1 parent 05f0729 commit 53e7f84

18 files changed

+371
-350
lines changed

.editorconfig

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# Top-most EditorConfig file
4+
root = true
5+
6+
# All files
7+
[*]
8+
charset = utf-8
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
indent_style = tab
13+
indent_size = 4
14+
15+
# Markdown files
16+
[*.md]
17+
trim_trailing_whitespace = false
18+
19+
[*.{yaml,yml}]
20+
indent_size = 2
21+
indent_style = space

composer.json

+55-53
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
11
{
2-
"name": "fostercommerce/meilisearch-connect",
3-
"type": "craft-plugin",
4-
"license": "proprietary",
5-
"version": "0.1.0",
6-
"support": {
7-
"email": "[email protected]",
8-
"issues": "https://github.com/fostercommerce/meilisearch-connect/issues?state=open",
9-
"source": "https://github.com/fostercommerce/meilisearch-connect",
10-
"docs": "https://github.com/fostercommerce/meilisearch-connect",
11-
"rss": "https://github.com/fostercommerce/meilisearch-connect/releases.atom"
12-
},
13-
"require": {
14-
"php": ">=8.1",
15-
"craftcms/cms": "^4.6.0|^5.0.0",
16-
"meilisearch/meilisearch-php": "^1.6.0"
17-
},
18-
"require-dev": {
19-
"roave/security-advisories": "dev-latest",
20-
"fostercommerce/ecs": "dev-main",
21-
"fostercommerce/phpstan": "dev-main",
22-
"fostercommerce/rector": "dev-main"
23-
},
24-
"autoload": {
25-
"psr-4": {
26-
"fostercommerce\\meilisearch\\": "src/"
27-
}
28-
},
29-
"extra": {
30-
"handle": "meilisearch-connect",
31-
"name": "Meilisearch Connect",
32-
"developer": "Foster Commerce",
33-
"documentationUrl": "https://github.com/fostercommerce/meilisearch-connect"
34-
},
35-
"scripts": {
36-
"phpstan": "phpstan --memory-limit=1G",
37-
"ecs-check": "ecs check --ansi --memory-limit=1G",
38-
"ecs-fix": "ecs check --ansi --fix --memory-limit=1G",
39-
"rector": "rector process --config rector.php",
40-
"rector-dry-run": "rector process --dry-run --config rector.php"
41-
},
42-
"minimum-stability": "dev",
43-
"prefer-stable": true,
44-
"config": {
45-
"sort-packages": true,
46-
"platform": {
47-
"php": "8.1"
48-
},
49-
"allow-plugins": {
50-
"yiisoft/yii2-composer": true,
51-
"craftcms/plugin-installer": true,
52-
"php-http/discovery": true
53-
}
54-
}
2+
"name": "fostercommerce/meilisearch-connect",
3+
"type": "craft-plugin",
4+
"license": "proprietary",
5+
"version": "0.1.0",
6+
"support": {
7+
"email": "[email protected]",
8+
"issues": "https://github.com/fostercommerce/meilisearch-connect/issues?state=open",
9+
"source": "https://github.com/fostercommerce/meilisearch-connect",
10+
"docs": "https://github.com/fostercommerce/meilisearch-connect",
11+
"rss": "https://github.com/fostercommerce/meilisearch-connect/releases.atom"
12+
},
13+
"require": {
14+
"php": ">=8.1",
15+
"craftcms/cms": "^4.6.0|^5.0.0",
16+
"meilisearch/meilisearch-php": "^1.6.0"
17+
},
18+
"require-dev": {
19+
"roave/security-advisories": "dev-latest",
20+
"craftcms/phpstan": "dev-main",
21+
"craftcms/rector": "dev-main",
22+
"fostercommerce/ecs": "dev-main",
23+
"fostercommerce/phpstan": "dev-main",
24+
"fostercommerce/rector": "dev-main"
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"fostercommerce\\meilisearch\\": "src/"
29+
}
30+
},
31+
"extra": {
32+
"handle": "meilisearch-connect",
33+
"name": "Meilisearch Connect",
34+
"developer": "Foster Commerce",
35+
"documentationUrl": "https://github.com/fostercommerce/meilisearch-connect"
36+
},
37+
"scripts": {
38+
"phpstan": "phpstan --memory-limit=1G",
39+
"ecs-check": "ecs check --ansi --memory-limit=1G",
40+
"ecs-fix": "ecs check --ansi --fix --memory-limit=1G",
41+
"rector": "rector process --config rector.php",
42+
"rector-dry-run": "rector process --dry-run --config rector.php"
43+
},
44+
"minimum-stability": "dev",
45+
"prefer-stable": true,
46+
"config": {
47+
"sort-packages": true,
48+
"platform": {
49+
"php": "8.1"
50+
},
51+
"allow-plugins": {
52+
"yiisoft/yii2-composer": true,
53+
"craftcms/plugin-installer": true,
54+
"php-http/discovery": true
55+
}
56+
}
5557
}

ecs.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use fostercommerce\ecs\ECSConfig;
66

77
return ECSConfig::configure()
8-
->withPaths([
9-
__DIR__ . '/src',
10-
__FILE__,
11-
]);
8+
->withPaths([
9+
__DIR__ . '/src',
10+
__FILE__,
11+
]);

phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- vendor/fostercommerce/phpstan/phpstan.neon
2+
- vendor/craftcms/phpstan/phpstan.neon
33

44
parameters:
55
paths:

rector.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@
1010
__DIR__ . '/src',
1111
__FILE__,
1212
])
13-
->withSets([
14-
SetList::CRAFT_CMS_40
15-
]);
13+
->withSets([SetList::CRAFT_CMS_40]);

src/Plugin.php

+24-24
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,31 @@
2323
*/
2424
class Plugin extends BasePlugin
2525
{
26-
public static function config(): array
27-
{
28-
return [
29-
'components' => [
30-
'search' => Search::class,
31-
'sync' => Sync::class,
32-
],
33-
];
34-
}
26+
public static function config(): array
27+
{
28+
return [
29+
'components' => [
30+
'search' => Search::class,
31+
'sync' => Sync::class,
32+
],
33+
];
34+
}
3535

36-
public function init(): void
37-
{
38-
parent::init();
36+
public function init(): void
37+
{
38+
parent::init();
3939

40-
Event::on(CraftVariable::class, CraftVariable::EVENT_INIT, static function (Event $event): void {
41-
$variable = $event->sender;
42-
$variable->set('meilisearch', SearchVariable::class);
43-
});
44-
}
40+
Event::on(CraftVariable::class, CraftVariable::EVENT_INIT, static function (Event $event): void {
41+
$variable = $event->sender;
42+
$variable->set('meilisearch', SearchVariable::class);
43+
});
44+
}
4545

46-
/**
47-
* @throws InvalidConfigException
48-
*/
49-
protected function createSettingsModel(): ?Model
50-
{
51-
return Craft::createObject(Settings::class);
52-
}
46+
/**
47+
* @throws InvalidConfigException
48+
*/
49+
protected function createSettingsModel(): ?Model
50+
{
51+
return Craft::createObject(Settings::class);
52+
}
5353
}

src/config.php

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
<?php
22

33
return [
4-
// e.g. http://localhost:7700
5-
'meiliHostUrl' => getenv('MEILI_HOST_URL'),
6-
'meiliAdminApiKey' => getenv('MEILI_ADMIN_API_KEY'),
7-
'meiliSearchUrl' => getenv('MEILI_SEARCH_URL'),
8-
'meiliSearchApiKey' => getenv('MEILI_SEARCH_API_KEY'),
9-
'indices' => [
10-
'<index name>' => [
11-
'settings' => [
12-
'ranking' => [
13-
'customRanking:desc',
14-
'words',
15-
'exactness',
16-
'proximity',
17-
'attribute',
18-
'date:desc',
19-
'sort',
20-
'typo',
21-
],
22-
'searchableAttributes' => [
23-
'title',
24-
],
25-
'filterableAttributes' => [
26-
],
27-
'faceting' => [
28-
'maxValuesPerFacet' => 300,
29-
],
30-
],
31-
'fetch' => static fn (?int $id): array => [
4+
// e.g. http://localhost:7700
5+
'meiliHostUrl' => getenv('MEILI_HOST_URL'),
6+
'meiliAdminApiKey' => getenv('MEILI_ADMIN_API_KEY'),
7+
'meiliSearchUrl' => getenv('MEILI_SEARCH_URL'),
8+
'meiliSearchApiKey' => getenv('MEILI_SEARCH_API_KEY'),
9+
'indices' => [
10+
'<index name>' => [
11+
'settings' => [
12+
'ranking' => [
13+
'customRanking:desc',
14+
'words',
15+
'exactness',
16+
'proximity',
17+
'attribute',
18+
'date:desc',
19+
'sort',
20+
'typo',
21+
],
22+
'searchableAttributes' => [
23+
'title',
24+
],
25+
'filterableAttributes' => [
26+
],
27+
'faceting' => [
28+
'maxValuesPerFacet' => 300,
29+
],
30+
],
31+
'fetch' => static fn (?int $id): array => [
3232

33-
],
34-
],
35-
],
33+
],
34+
],
35+
],
3636
];

src/console/controllers/SyncController.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@
1111
*/
1212
class SyncController extends Controller
1313
{
14-
public $defaultAction = 'all';
14+
public $defaultAction = 'all';
1515

16-
public function actionSettings(): int
17-
{
18-
Plugin::getInstance()->sync->syncSettings();
19-
return ExitCode::OK;
20-
}
16+
public function actionSettings(): int
17+
{
18+
Plugin::getInstance()->sync->syncSettings();
19+
return ExitCode::OK;
20+
}
2121

22-
public function actionAll(): int
23-
{
24-
Plugin::getInstance()->sync->syncIndices();
25-
return ExitCode::OK;
26-
}
22+
public function actionAll(): int
23+
{
24+
Plugin::getInstance()->sync->syncIndices();
25+
return ExitCode::OK;
26+
}
2727

28-
public function actionIndex(string $indexName): int
29-
{
30-
Plugin::getInstance()->sync->syncIndices($indexName);
31-
return ExitCode::OK;
32-
}
28+
public function actionIndex(string $indexName): int
29+
{
30+
Plugin::getInstance()->sync->syncIndices($indexName);
31+
return ExitCode::OK;
32+
}
3333

34-
public function actionRefreshAll(): int
35-
{
36-
Plugin::getInstance()->sync->refreshIndices();
37-
return ExitCode::OK;
38-
}
34+
public function actionRefreshAll(): int
35+
{
36+
Plugin::getInstance()->sync->refreshIndices();
37+
return ExitCode::OK;
38+
}
3939
}

src/controllers/SyncController.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
class SyncController extends Controller
1010
{
11-
public $defaultAction = 'all';
11+
public $defaultAction = 'all';
1212

13-
protected array|int|bool $allowAnonymous = self::ALLOW_ANONYMOUS_NEVER;
13+
protected array|int|bool $allowAnonymous = self::ALLOW_ANONYMOUS_NEVER;
1414

15-
/**
16-
* @throws ForbiddenHttpException
17-
*/
18-
public function actionAll(): void
19-
{
20-
$this->requireAdmin();
21-
Plugin::getInstance()->sync->syncIndices();
22-
}
15+
/**
16+
* @throws ForbiddenHttpException
17+
*/
18+
public function actionAll(): void
19+
{
20+
$this->requireAdmin();
21+
Plugin::getInstance()->sync->syncIndices();
22+
}
2323
}

src/jobs/Delete.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77

88
class Delete extends BaseJob
99
{
10-
public ?string $indexName = null;
10+
public ?string $indexName = null;
1111

12-
public mixed $identifier;
12+
public mixed $identifier;
1313

14-
public function execute($queue): void
15-
{
16-
Plugin::getInstance()->sync->delete($this->identifier, $this->indexName);
17-
}
14+
public function execute($queue): void
15+
{
16+
Plugin::getInstance()->sync->delete($this->identifier, $this->indexName);
17+
}
1818

19-
protected function defaultDescription(): ?string
20-
{
21-
$description = "Deleting {$this->identifier} from";
22-
if ($this->indexName === null) {
23-
return "{$description} all indices";
24-
}
19+
protected function defaultDescription(): ?string
20+
{
21+
$description = "Deleting {$this->identifier} from";
22+
if ($this->indexName === null) {
23+
return "{$description} all indices";
24+
}
2525

26-
return "{$description} {$this->indexName}";
27-
}
26+
return "{$description} {$this->indexName}";
27+
}
2828
}

0 commit comments

Comments
 (0)