Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
gennadigennadigennadi committed Jul 24, 2024
1 parent 02dd89e commit 2788afe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ composer-dependency-analyser: ## Performs static code analysis using composer-de

.PHONY: deptrac
deptrac: ## Analyses own architecture using the default config confile
bin/deptrac analyse -c deptrac.config.php --cache-file=./.cache/deptrac.cache --no-progress --ansi
bin/deptrac analyse -c deptrac.php --no-progress --ansi

#generate-changelog: ## Generates a changelog file based on changes compared to remote origin
# gem install github_changelog_generator
Expand Down
8 changes: 5 additions & 3 deletions deptrac.config.php → deptrac.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
return static function (DeptracConfig $config, ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(IgnoreDependenciesOnContract::class)
->tag('kernel.event_subscriber');
->tag('kernel.event_subscriber')
;

$config
->paths('src')
->cacheFile('.cache/deptrac.cache')
->analyser(
AnalyserConfig::create()
->internalTag( '@internal' )
->internalTag('@internal')
->types(
EmitterType::CLASS_TOKEN,
EmitterType::CLASS_SUPERGLOBAL_TOKEN,
Expand Down Expand Up @@ -114,5 +115,6 @@
->groups('Contract', $contract)
->groups('Supportive', $supportive, $file, $symfony, $console, $dependencyInjection, $outputFormatter, $time)
->groups('Core', $analyser, $ast, $dependency, $inputCollector, $layer)
);
)
;
};
19 changes: 11 additions & 8 deletions src/Supportive/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ protected function getDefaultInputDefinition(): InputDefinition
null,
InputOption::VALUE_REQUIRED,
'Location where cache file will be stored',
null
),
new InputOption(
'--config-file',
'-c',
InputOption::VALUE_REQUIRED,
'Location of Depfile containing the configuration',
getcwd().DIRECTORY_SEPARATOR.'deptrac.yaml'
),
]);

Expand All @@ -95,28 +93,33 @@ public function doRun(InputInterface $input, OutputInterface $output): int
return parent::doRun($input, $output);
}

/** @var string|numeric|null $configFile */
$configFile = $input->getOption('config-file');
$config = $input->hasOption('config-file')
? (string) $configFile
: $currentWorkingDirectory.DIRECTORY_SEPARATOR.'deptrac.yaml';
/** @var ?string $config */
$config = $input->getParameterOption(['--config-file', '-c'], null);
$config ??= $currentWorkingDirectory.DIRECTORY_SEPARATOR.'deptrac.yaml';

/** @var ?string $cache */
$cache = $input->getParameterOption('--cache-file', null);

$factory = new ServiceContainerBuilder($currentWorkingDirectory);

if (!in_array($input->getArgument('command'), ['init', 'list', 'help', 'completion'], true)) {
$factory = $factory->withConfig($config);
}

$noCache = $input->hasParameterOption('--no-cache', true);

try {
$container = $factory->build($noCache ? false : $cache, $input->hasParameterOption('--clear-cache', true));
$container = $factory->build(
$noCache ? false : $cache,
$input->hasParameterOption('--clear-cache', true)
);

$commandLoader = $container->get('console.command_loader');

if (!$commandLoader instanceof CommandLoaderInterface) {
throw new RuntimeException('CommandLoader not initialized. Commands can not be registered.');
}

$this->setCommandLoader($commandLoader);
$this->setDefaultCommand('analyse');
} catch (CannotLoadConfiguration $e) {
Expand Down

0 comments on commit 2788afe

Please sign in to comment.