Skip to content

Commit

Permalink
FEATURE PPP-66918 WappSpector detection for Sitejet
Browse files Browse the repository at this point in the history
  • Loading branch information
Sofiia Kulish committed Dec 10, 2024
1 parent fb30b55 commit 50166a3
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Command-line interface utility to analyze the file structure of a web hosting se
| PrestaShop | 1.6, 1.7.8, 8.0 | Existence and contents of `/config/settings.inc.php` |
| TYPO3 | 7.6, 8.7, 9, 10, 11, 12 | Existence and contents of `/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php` or `/typo3/sysext/core/Classes/Information/Typo3Version.php` or `/t3lib/config_default.php` |

### Site builders
| Name | Check type |
|---------|---------------------------------------------------------------------------------------|
| Sitejet | The file `index.html` exists and contains `ed-element` and `webcard.apiHost=` strings |

## How to build phar
```shell
composer global require clue/phar-composer
Expand Down
12 changes: 12 additions & 0 deletions src/MatchResult/Sitejet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);


namespace Plesk\Wappspector\MatchResult;

class Sitejet extends MatchResult
{
public const ID = 'sitejet';
public const NAME = 'Sitejet';
}
33 changes: 33 additions & 0 deletions src/Matchers/Sitejet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Plesk\Wappspector\Matchers;

use League\Flysystem\Filesystem;
use Plesk\Wappspector\MatchResult\EmptyMatchResult;
use Plesk\Wappspector\MatchResult\MatchResultInterface;
use Plesk\Wappspector\MatchResult\Sitejet as MatchResult;

class Sitejet implements MatcherInterface
{
public function match(Filesystem $fs, string $path): MatchResultInterface
{
$indexHtmlPath = rtrim($path, '/') . '/index.html';
if (!$fs->fileExists($indexHtmlPath)) {
return new EmptyMatchResult();
}

$fileContent = $fs->read($indexHtmlPath);

return $this->fileContentContainsString($fileContent, 'ed-element')
&& $this->fileContentContainsString($fileContent, 'webcard.apiHost=')
? new MatchResult($path)
: new EmptyMatchResult();
}

private function fileContentContainsString(string $fileContent, string $searchString): bool
{
return strpos($fileContent, $searchString) !== false;
}
}
1 change: 1 addition & 0 deletions src/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Matchers\Ruby::class,
Matchers\Python::class,
Matchers\NodeJs::class,
Matchers\Sitejet::class,

// Low priority wrappers. Should go last.
Matchers\Composer::class,
Expand Down
19 changes: 19 additions & 0 deletions test-data/sitejet/index.html

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions tests/Matchers/SitejetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);


namespace Test\Matchers;

use PHPUnit\Framework\Attributes\CoversClass;
use Plesk\Wappspector\Matchers\MatcherInterface;
use Plesk\Wappspector\Matchers\Sitejet;
use Plesk\Wappspector\MatchResult\Sitejet as MatchResult;

#[CoversClass(Sitejet::class)]
class SitejetTest extends AbstractMatcherTestCase
{
protected function getMatcherObj(): MatcherInterface
{
return new Sitejet();
}

protected function getMatchResultClassname(): string
{
return MatchResult::class;
}

public static function detectablePathsProvider(): array
{
return [
['sitejet', null],
];
}
}

0 comments on commit 50166a3

Please sign in to comment.