Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reading of the project details from the root package. #4

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CustomizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Composer\Command\BaseCommand;
use Composer\Console\Input\InputOption;
use Composer\Factory;
use Composer\IO\NullIO;
use Composer\Package\RootPackageInterface;
use Composer\Util\Filesystem;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Helper\TableSeparator;
Expand Down Expand Up @@ -56,6 +59,11 @@ class CustomizeCommand extends BaseCommand {
*/
protected Filesystem $fs;

/**
* Root package.
*/
protected RootPackageInterface $package;

/**
* Question definitions.
*
Expand Down Expand Up @@ -119,7 +127,7 @@ protected function questions(): array {
protected function configure(): void {
$this
->setName('customize')
->setDescription(sprintf('Customize %s project', static::$project))
->setDescription('Customize project')
->setDefinition([
new InputOption('answers', NULL, InputOption::VALUE_REQUIRED, 'Answers to questions passed as a JSON string.'),
]);
Expand All @@ -132,8 +140,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->io = $this->initIo($input, $output);
$this->cwd = (string) getcwd();
$this->fs = new Filesystem();
$this->package = (Factory::create(new NullIO(), $this->cwd . '/composer.json'))->getPackage();

$this->io->title(sprintf('Welcome to %s project customizer', static::$project));
$this->io->title(sprintf('Welcome to %s project customizer', $this->package->getName()));

$this->io->block([
'Please answer the following questions to customize your project.',
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/Functional/CreateProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testCreateProjectNoInstall(): void {

$this->composerCreateProject(['--no-install' => TRUE]);

$this->assertComposerCommandSuccessOutputContains('Welcome to your_project project customizer');
$this->assertComposerCommandSuccessOutputContains('Welcome to yourorg/yourpackage project customizer');
$this->assertComposerCommandSuccessOutputContains('Project was customized');
}

Expand All @@ -31,6 +31,7 @@ public function testCreateProjectNoInstallCancel(): void {

$this->composerCreateProject(['--no-install' => TRUE]);

$this->assertComposerCommandSuccessOutputContains('Welcome to yourorg/yourpackage project customizer');
$this->assertComposerCommandSuccessOutputContains('No changes were made.');
}

Expand Down