-
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.
add new command, generator and test for creating standalone plugins (#3)
* add new command, generator and test for creating standalone plugins * Fix when latest dockware version is SW5 Version * add simple phpunit test setup * add files for phpunit * fix shopware version * change resolver * add command for run php unit * require phpstan * update shopware version * update skeleton for plugin * add phpstan * update plugin readme Co-authored-by: Peter Roj <[email protected]>
- Loading branch information
1 parent
ee69be7
commit cf24008
Showing
23 changed files
with
1,101 additions
and
3 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,6 @@ | ||
parameters: | ||
level: 8 | ||
paths: | ||
- ./src | ||
excludePaths: | ||
- ./src/Resources/* |
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,57 @@ | ||
<?php | ||
|
||
namespace Pureware\PurewareCli\Command\Common; | ||
|
||
use Pureware\PurewareCli\Maker\Entity\EntityMaker; | ||
use Pureware\PurewareCli\Maker\Entity\HydratorMaker; | ||
use Pureware\PurewareCli\Maker\Entity\Many2ManyMaker; | ||
use Pureware\PurewareCli\Maker\Entity\TranslationMaker; | ||
use Pureware\PurewareCli\Maker\Migration\MigrationMaker; | ||
use Pureware\PurewareCli\Resolver\NamespaceResolverInterface; | ||
use Pureware\TemplateGenerator\TreeBuilder\Directory\Directory; | ||
use Pureware\TemplateGenerator\TreeBuilder\Directory\DirectoryCollection; | ||
use Pureware\TemplateGenerator\TreeBuilder\File\File; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Helper\Table; | ||
use Symfony\Component\Console\Helper\TableSeparator; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use Symfony\Component\Process\Process; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
class RunPhpStanCommand extends \Pureware\PurewareCli\Command\AbstractMakeCommand | ||
{ | ||
protected static $defaultName = 'phpstan'; | ||
|
||
public function __construct(string $name = null) | ||
{ | ||
parent::__construct($name); | ||
} | ||
|
||
protected function configure() | ||
{ | ||
$this | ||
->setName(self::$defaultName) | ||
->setDescription('Run PHP stan for src and tests') | ||
->addOption('options', null, InputOption::VALUE_OPTIONAL, 'The options that are added to the phpstan command as string i.e. --options="-c phpstan.neo"', '-c phpstan.neon'); | ||
parent::configure(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$command = sprintf('vendor/bin/phpstan analyse src Tests -c phpstan.neon %s', $input->getOption('options')); | ||
|
||
$cli = Process::fromShellCommandline($command, null, null, null, 240); | ||
$cli->setTty(true); | ||
|
||
$cli->run(function ($type, $line) use ($output) { | ||
$output->write($line); | ||
}); | ||
|
||
return Command::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Pureware\PurewareCli\Command\Common; | ||
|
||
use Pureware\PurewareCli\Maker\Entity\EntityMaker; | ||
use Pureware\PurewareCli\Maker\Entity\HydratorMaker; | ||
use Pureware\PurewareCli\Maker\Entity\Many2ManyMaker; | ||
use Pureware\PurewareCli\Maker\Entity\TranslationMaker; | ||
use Pureware\PurewareCli\Maker\Migration\MigrationMaker; | ||
use Pureware\PurewareCli\Resolver\NamespaceResolverInterface; | ||
use Pureware\TemplateGenerator\TreeBuilder\Directory\Directory; | ||
use Pureware\TemplateGenerator\TreeBuilder\Directory\DirectoryCollection; | ||
use Pureware\TemplateGenerator\TreeBuilder\File\File; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Helper\Table; | ||
use Symfony\Component\Console\Helper\TableSeparator; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use Symfony\Component\Process\Process; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
class RunPhpUnitCommand extends \Pureware\PurewareCli\Command\AbstractMakeCommand | ||
{ | ||
protected static $defaultName = 'test:phpunit'; | ||
|
||
public function __construct(string $name = null) | ||
{ | ||
parent::__construct($name); | ||
} | ||
|
||
protected function configure() | ||
{ | ||
$this | ||
->setName(self::$defaultName) | ||
->setDescription('Run PHP Unit inside the docker container') | ||
->addArgument('pluginName', InputArgument::OPTIONAL, 'The name of the plugin you want to test. (optional, default will be the current plugin)', null) | ||
->addOption('container', 'c', InputOption::VALUE_OPTIONAL , 'The docker container name', 'shop_plugin') | ||
->addOption('options', null, InputOption::VALUE_OPTIONAL , 'The options that are added to the phpunit command as string i.e. --options="--testdox"', '--colors=always --testdox'); | ||
parent::configure(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
|
||
$pluginName = $input->getArgument('pluginName'); | ||
if (!$input->getArgument('pluginName')) { | ||
$resolver = $this->getNamespaceResolver(); | ||
$pluginName = $resolver->getPluginName(); | ||
} | ||
|
||
$command = sprintf('docker exec %s vendor/bin/phpunit --configuration="%s" %s', $input->getOption('container'), 'custom/plugins/' . $pluginName, $input->getOption('options')); | ||
|
||
$cli = Process::fromShellCommandline($command, null, null, null, 240); | ||
$cli->setTty(true); | ||
|
||
$cli->run(function ($type, $line) use ($output) { | ||
$output->write($line); | ||
}); | ||
|
||
|
||
|
||
return Command::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
namespace Pureware\PurewareCli\Command\New; | ||
|
||
use Pureware\PurewareCli\Generator\Plugin\PluginGenerator; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class NewPluginCommand extends Command | ||
{ | ||
private array $allowedTypes = ['plugin', 'project']; | ||
|
||
protected function configure() | ||
{ | ||
$this | ||
->setName('new:plugin') | ||
->addArgument('pluginName', InputArgument::OPTIONAL, 'The name of a plugin', null) | ||
->addOption('shopwareVersion', 's', InputArgument::OPTIONAL, sprintf('Shopware version i.e. %s. If not set the latest Shopware tag will be used', PluginGenerator::DEFAULT_VERSION), null) | ||
->addOption('force', 'f', InputOption::VALUE_NONE, 'Override files. Be careful when using!') | ||
->addOption('workingDir', null, InputOption::VALUE_OPTIONAL, 'The path were you want to create the new plugin', null) | ||
->addOption('git', null, InputOption::VALUE_NONE, 'Initialize a git repo and first commit with a branch. Set a remote url afterwards.') | ||
->addOption('branch', null, InputOption::VALUE_OPTIONAL, 'Init branch name for git', 'main') | ||
->setDescription('Create a new standalone plugin with a ready to use boilerplate.'); | ||
parent::configure(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$output->writeln(PHP_EOL."<fg=blue> | ||
_____ _ _ _____ ______ | ||
| __ \| | | | __ \| ____| | ||
| |__) | | | | |__) | |__ | ||
| ___/| | | | _ /| __| | ||
| | | |__| | | \ \| |____ | ||
|_| \____/|_| \_\______| </>".PHP_EOL.PHP_EOL); | ||
|
||
$output->writeln('Pure installer'); | ||
|
||
return (new PluginGenerator())->generate($input, $output); | ||
|
||
return self::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Pureware\PurewareCli\Generator; | ||
|
||
use Symfony\Component\Console\Input\Input; | ||
use Symfony\Component\Console\Output\Output; | ||
|
||
interface GeneratorInterface | ||
{ | ||
public function generate(Input $input, Output $output): int; | ||
} |
Oops, something went wrong.