This repository has been archived by the owner on Dec 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MonorepoBuilder] Add init command [closes #1082]
- Loading branch information
1 parent
512625f
commit 88de2c8
Showing
20 changed files
with
173 additions
and
10 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
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
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,7 @@ | ||
services: | ||
_defaults: | ||
public: true | ||
autowire: true | ||
|
||
Symplify\MonorepoBuilder\Init\: | ||
resource: '../src' |
56 changes: 56 additions & 0 deletions
56
packages/MonorepoBuilder/packages/Init/src/Command/InitCommand.php
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,56 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Symplify\MonorepoBuilder\Init\Command; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symplify\PackageBuilder\Console\Command\CommandNaming; | ||
|
||
final class InitCommand extends Command | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private const OUTPUT = 'output'; | ||
|
||
/** | ||
* @var Filesystem | ||
*/ | ||
private $filesystem; | ||
|
||
/** | ||
* @var SymfonyStyle | ||
*/ | ||
private $symfonyStyle; | ||
|
||
public function __construct(Filesystem $filesystem, SymfonyStyle $symfonyStyle) | ||
{ | ||
parent::__construct(); | ||
$this->filesystem = $filesystem; | ||
$this->symfonyStyle = $symfonyStyle; | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this->setName(CommandNaming::classToName(self::class)); | ||
$this->addArgument(self::OUTPUT, InputArgument::REQUIRED, 'Directory to generate monorepo into.', getcwd()); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): void | ||
{ | ||
$output = $input->getArgument(self::OUTPUT); | ||
|
||
$this->filesystem->mirror(__DIR__ . '/../../templates/monorepo', $output); | ||
|
||
$this->symfonyStyle->success('Congrats! Your first monorepo is here.'); | ||
$this->symfonyStyle->note( | ||
'Now try the next step - merge composer.json files from packages to the root one: ' . | ||
PHP_EOL . | ||
'"vendor/bin/monorepo-builder merge"' | ||
); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/MonorepoBuilder/packages/Init/templates/monorepo/composer.json
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 @@ | ||
{ | ||
"name": "your-monorepo/your-monorepo", | ||
"require": { | ||
"php": "^7.1" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/MonorepoBuilder/packages/Init/templates/monorepo/monorepo-builder.yml
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,4 @@ | ||
parameters: | ||
data_to_append: | ||
require-dev: | ||
phpunit/phpunit: '^7.3' |
12 changes: 12 additions & 0 deletions
12
...ges/MonorepoBuilder/packages/Init/templates/monorepo/packages/first-package/composer.json
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,12 @@ | ||
{ | ||
"name": "your-monorepo/first-package", | ||
"require": { | ||
"php": "^7.1", | ||
"symfony/http-kernel": "^4.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"YourMonorepo\\FirstPackage\\": "src" | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...onorepoBuilder/packages/Init/templates/monorepo/packages/first-package/src/FirstClass.php
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,7 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace YourMonorepo\FirstPackage; | ||
|
||
final class FirstClass | ||
{ | ||
} |
12 changes: 12 additions & 0 deletions
12
...es/MonorepoBuilder/packages/Init/templates/monorepo/packages/second-package/composer.json
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,12 @@ | ||
{ | ||
"name": "your-monorepo/second-package", | ||
"require": { | ||
"php": "^7.1", | ||
"symfony/dependency-injection": "^4.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"YourMonorepo\\SecondPackage\\": "src" | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...orepoBuilder/packages/Init/templates/monorepo/packages/second-package/src/SecondClass.php
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,7 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace YourMonorepo\SecondPackage; | ||
|
||
final class SecondClass | ||
{ | ||
} |
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
25 changes: 25 additions & 0 deletions
25
packages/MonorepoBuilder/src/Console/MonorepoBuilderApplication.php
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,25 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Symplify\MonorepoBuilder\Console; | ||
|
||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Input\InputDefinition; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
final class MonorepoBuilderApplication extends Application | ||
{ | ||
protected function getDefaultInputDefinition(): InputDefinition | ||
{ | ||
$inputDefinition = parent::getDefaultInputDefinition(); | ||
|
||
$inputDefinition->addOption(new InputOption( | ||
'config', | ||
'c', | ||
InputOption::VALUE_REQUIRED, | ||
'Path to config file.', | ||
'monorepo-builder.(yml|yaml)' | ||
)); | ||
|
||
return $inputDefinition; | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
packages/MonorepoBuilder/src/Exception/MissingDirectoryException.php
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,9 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Symplify\MonorepoBuilder\Exception; | ||
|
||
use Exception; | ||
|
||
final class MissingDirectoryException extends Exception | ||
{ | ||
} |
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
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