-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from iranimij/first-test-branch
Initialize module.xml
- Loading branch information
Showing
6 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Iranimij\GitExtensionChecker\Console\Command; | ||
|
||
use Magento\Framework\Filesystem\DirectoryList; | ||
use SebastianFeldmann\Git\Repository; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Magento\Framework\Serialize\SerializerInterface; | ||
use Iranimij\GitExtensionChecker\Model\Scan; | ||
|
||
class ScanCommand extends Command | ||
{ | ||
private Scan $scan; | ||
|
||
private SerializerInterface $serializer; | ||
|
||
public function __construct( | ||
Scan $scan, | ||
SerializerInterface $serializer, | ||
private readonly DirectoryList $dir, | ||
$name = null, | ||
) { | ||
parent::__construct($name); | ||
$this->scan = $scan; | ||
$this->serializer = $serializer; | ||
} | ||
|
||
protected function configure() | ||
{ | ||
$this->setName('Iranimij_GitExtensionChecker:scan') | ||
->setDescription('Scan a specific Magento module'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$gitRepository = new Repository($this->dir->getRoot()); | ||
$currentBranch = $gitRepository->getInfoOperator()->getCurrentBranch(); | ||
$diff = $gitRepository->getDiffOperator()->compare('main', $currentBranch); | ||
|
||
foreach ($diff as $item) { | ||
$explodedItem = explode('/', $item->getName()); | ||
|
||
if (empty($explodedItem[0]) || empty($explodedItem[1]) || empty($explodedItem[2])) { | ||
continue; | ||
} | ||
|
||
$appModule = $this->dir->getRoot() | ||
. "/$explodedItem[0]/$explodedItem[1]/$explodedItem[2]/$explodedItem[3]/registration.php"; | ||
$customModule = $this->dir->getRoot() | ||
. "/$explodedItem[0]/$explodedItem[1]/$explodedItem[2]/registration.php"; | ||
if ( | ||
!file_exists($appModule) | ||
&& !file_exists($customModule) | ||
) { | ||
continue; | ||
} | ||
$module = file_exists($appModule) ? $appModule : $customModule; | ||
$content = file_get_contents($module); | ||
|
||
if (empty($content)) { | ||
continue; | ||
} | ||
|
||
preg_match("/'([^']+)'/", $content, $matches); | ||
$moduleName = $matches[1] ?: ''; | ||
$greetInput = new ArrayInput([ | ||
'command' => 'yireo_extensionchecker:scan', | ||
'--module' => $moduleName, | ||
]); | ||
$this->getApplication()->doRun($greetInput, $output); | ||
} | ||
|
||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Iranimij\GitExtensionChecker\Model; | ||
|
||
class Scan | ||
{ | ||
public function performScan(string $moduleName, string $modulePath): array | ||
{ | ||
// Implement the scan logic here | ||
return [ | ||
'module' => $moduleName, | ||
'path' => $modulePath, | ||
'status' => 'success' | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\Framework\Console\CommandList"> | ||
<arguments> | ||
<argument name="commands" xsi:type="array"> | ||
<item name="Iranimij_GitExtensionChecker:scan" xsi:type="object">Iranimij\GitExtensionChecker\Console\Command\ScanCommand</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Example_Module" setup_version="1.0.0"/> | ||
<module name="Iranimij_GitExtensionChecker" setup_version="1.0.0"> | ||
<sequence> | ||
<module name="Magento_Framework"/> | ||
<module name="Yireo_ExtensionChecker"/> | ||
</sequence> | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters