Skip to content

Commit

Permalink
fix: missing permanent option, ignore vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Oct 2, 2024
1 parent d89c1ae commit 46732f5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/Command/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Pmu\Command;

use Composer\Command\BaseCommand;
use Composer\Console\Input\InputOption;
use Pmu\Composer\BaseDirTrait;
use Pmu\Config;
use Pmu\Dependencies;
Expand All @@ -26,16 +27,24 @@ final class CheckCommand extends BaseCommand

protected function configure(): void
{
$this->setName('check-dependencies')->setDescription('Checks the monorepo dependencies.');
$this->setName('check-dependencies')
->setDescription('Checks the monorepo dependencies.')
->setDefinition([
new InputOption('working-directory', 'wd', InputOption::VALUE_REQUIRED, "Defaults to SERVER['PWD']"),
]);
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$autoload = getcwd() . '/vendor/autoload.php';
if (file_exists($autoload)) {
require_once $autoload;
$wd = $input->getOption('working-directory') ?? $_SERVER['PWD'] ?? null;
$autoload = $wd . '/vendor/autoload.php';

if (!file_exists($autoload)) {
$output->writeln(sprintf('No autoload at path "%s".', $autoload));
return 1;
}

require_once $autoload;
$composer = $this->requireComposer();
$config = Config::create($composer);
$repo = $composer->getRepositoryManager();
Expand Down
5 changes: 5 additions & 0 deletions src/Command/LinkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected function configure(): void
->setDefinition([
new InputArgument('path', InputArgument::OPTIONAL, 'Path to link.'),
new InputOption('working-directory', 'wd', InputOption::VALUE_REQUIRED, "Defaults to SERVER['PWD']"),
new InputOption('permanent', 'p', InputOption::VALUE_NONE, "Permanent composer change, does not revert backups."),
]);
}

Expand Down Expand Up @@ -127,6 +128,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (\Exception $e) {
}

if ($input->getOption('permanent')) {
return 0;
}

foreach ($revert as $file => $backup) {
rename($backup, $file);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static function collectProjectsData(Config $config, RepositoryManager $re
}

if ($computeClassMap) {
$classMapGenerator->scanPaths(dirname($composerFile));
$classMapGenerator->scanPaths(dirname($composerFile), null, 'classmap', null, ['vendor']);
foreach ($classMapGenerator->getClassMap()->getMap() as $class => $path) {
foreach ($namespaces as $ns) {
foreach ($config->exclude as $g) {
Expand Down

0 comments on commit 46732f5

Please sign in to comment.