-
Notifications
You must be signed in to change notification settings - Fork 21
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 #419 from jolicode/feat/composer-castor-json
feat(import): use a composer file directly
- Loading branch information
Showing
39 changed files
with
450 additions
and
384 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
.castor.stub.php | ||
/.php-cs-fixer.cache | ||
/.phpunit.cache | ||
/castor.* | ||
/my-app.* | ||
/var/ | ||
/vendor/ | ||
/tests/Examples/fixtures/**/.castor.stub.php | ||
/castor.* | ||
!/castor.php | ||
!/castor.composer.json | ||
!/castor.composer.lock |
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,31 @@ | ||
{ | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"replace": { | ||
"castor\/castor": "v0.15.0" | ||
}, | ||
"require": { | ||
"pyrech\/castor-example": "^1.0", | ||
"pyrech\/castor-example-package-not-published": "*", | ||
"pyrech\/foobar": "v1" | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "vcs", | ||
"url": "https:\/\/github.com\/pyrech\/castor-example-package-not-published.git" | ||
}, | ||
{ | ||
"type": "package", | ||
"package": { | ||
"name": "pyrech\/foobar", | ||
"version": "v1", | ||
"source": { | ||
"url": "https:\/\/github.com\/pyrech\/castor-example-misc.git", | ||
"type": "git", | ||
"reference": "main" | ||
} | ||
} | ||
} | ||
] | ||
} |
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
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,53 @@ | ||
<?php | ||
|
||
namespace Castor\Console\Command; | ||
|
||
use Castor\Console\Input\GetRawTokenTrait; | ||
use Castor\Import\Remote\Composer; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\DependencyInjection\Attribute\Autowire; | ||
|
||
/** @internal */ | ||
#[AsCommand( | ||
name: 'castor:composer', | ||
description: 'Interact with built-in Composer for castor', | ||
aliases: ['composer'], | ||
)] | ||
final class ComposerCommand extends Command | ||
{ | ||
use GetRawTokenTrait; | ||
|
||
public function __construct( | ||
private readonly string $rootDir, | ||
#[Autowire(lazy: true)] | ||
private readonly Composer $composer, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this | ||
->ignoreValidationErrors() | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$extra = array_filter($this->getRawTokens($input), fn ($item) => 'composer' !== $item); | ||
|
||
$vendorDirectory = $this->rootDir . Composer::VENDOR_DIR; | ||
|
||
if (!file_exists($file = $this->rootDir . '/castor.composer.json') && !file_exists($file = $this->rootDir . '/.castor/castor.composer.json')) { | ||
// Default to the root directory (so someone can do a composer init by example) | ||
$file = $this->rootDir . '/castor.composer.json'; | ||
} | ||
|
||
$this->composer->run($file, $vendorDirectory, $extra, $output, true); | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
Oops, something went wrong.