Skip to content

Commit

Permalink
update 2024-04-14
Browse files Browse the repository at this point in the history
  • Loading branch information
gennadigennadigennadi authored Apr 14, 2024
1 parent bdce2f0 commit 5da9063
Show file tree
Hide file tree
Showing 1,626 changed files with 13,540 additions and 13,181 deletions.
37 changes: 0 additions & 37 deletions .editorconfig

This file was deleted.

15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ your project are truly independent of each other to make them easier to reuse.

Deptrac can be used in a CI pipeline to make sure a pull request does not
violate any of the architectural rules you defined. With the optional Graphviz
formatter you can visualize your layers, rules and violations.
or Mermaidjs formatter you can visualize your layers, rules and violations.

## Documentation

Expand All @@ -20,20 +20,15 @@ https://qossmic.github.io/deptrac
## Getting Started

You can install Deptrac via Composer. We recommend using the
[deptrac-shim](https://github.com/qossmic/deptrac-shim) package for this:
[deptrac](https://github.com/qossmic/deptrac) package for this:

```Shell
composer require --dev qossmic/deptrac-shim
```console
composer require --dev qossmic/deptrac
```

Alternatively, you can also use [PHIVE](docs/index.md#phive) or download the
[PHAR](docs/index.md#phar) attached to each release on GitHub.
We strongly advise against using the deptrac package directly as a composer dependency.
We update dependencies regularly, which might cause disruptions in your project.

Once you have downloaded/installed deptrac, you will need to create a
[configuration file](docs/index.md#configuration), where you define your layers and
communication ruleset. This configuration file is written in YAML and, by default,
communication ruleset. This configuration file is written in YAML or php and, by default,
is stored with the name `deptrac.yaml` in your project's root directory.

Deptrac can generate a template for you, using the `init` command.
Expand Down
4 changes: 2 additions & 2 deletions bin/deptrac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
namespace DEPTRAC_202403;
namespace DEPTRAC_202404;

use DEPTRAC_202403\Composer\XdebugHandler\XdebugHandler;
use DEPTRAC_202404\Composer\XdebugHandler\XdebugHandler;
use Qossmic\Deptrac\Supportive\Console\Application;
if (\PHP_VERSION_ID < 80100) {
echo 'Required at least PHP version 8.1.0, your version: ' . \PHP_VERSION . "\n";
Expand Down
8 changes: 4 additions & 4 deletions config/cache.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php

declare (strict_types=1);
namespace DEPTRAC_202403;
namespace DEPTRAC_202404;

use Qossmic\Deptrac\Core\Ast\Parser\Cache\AstFileReferenceCacheInterface;
use Qossmic\Deptrac\Core\Ast\Parser\Cache\AstFileReferenceDeferredCacheInterface;
use Qossmic\Deptrac\Core\Ast\Parser\Cache\AstFileReferenceFileCache;
use Qossmic\Deptrac\Core\Ast\Parser\Cache\CacheableFileSubscriber;
use Qossmic\Deptrac\Supportive\Console\Application;
use DEPTRAC_202403\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function DEPTRAC_202403\Symfony\Component\DependencyInjection\Loader\Configurator\service;
use DEPTRAC_202404\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function DEPTRAC_202404\Symfony\Component\DependencyInjection\Loader\Configurator\service;
return static function (ContainerConfigurator $container) : void {
$services = $container->services();
$services->defaults()->public();
$services->set(AstFileReferenceFileCache::class)->args(['%deptrac.cache_file%', Application::VERSION]);
$services->set(AstFileReferenceFileCache::class)->args(['%cache_file%', Application::VERSION]);
$services->alias(AstFileReferenceDeferredCacheInterface::class, AstFileReferenceFileCache::class);
$services->alias(AstFileReferenceCacheInterface::class, AstFileReferenceDeferredCacheInterface::class);
$services->set(CacheableFileSubscriber::class)->args([service(AstFileReferenceFileCache::class)])->tag('kernel.event_subscriber');
Expand Down
30 changes: 18 additions & 12 deletions config/services.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

declare (strict_types=1);
namespace DEPTRAC_202403;
namespace DEPTRAC_202404;

use DEPTRAC_202403\PhpParser\Lexer;
use DEPTRAC_202403\PhpParser\Parser;
use DEPTRAC_202403\PhpParser\ParserFactory;
use DEPTRAC_202403\Psr\EventDispatcher\EventDispatcherInterface;
use DEPTRAC_202404\PhpParser\Lexer;
use DEPTRAC_202404\PhpParser\Parser;
use DEPTRAC_202404\PhpParser\ParserFactory;
use DEPTRAC_202404\Psr\EventDispatcher\EventDispatcherInterface;
use Qossmic\Deptrac\Contract\Analyser\EventHelper;
use Qossmic\Deptrac\Contract\Config\CollectorType;
use Qossmic\Deptrac\Contract\Config\EmitterType;
Expand Down Expand Up @@ -80,6 +80,8 @@
use Qossmic\Deptrac\Core\Layer\LayerResolverInterface;
use Qossmic\Deptrac\Supportive\Console\Command\AnalyseCommand;
use Qossmic\Deptrac\Supportive\Console\Command\AnalyseRunner;
use Qossmic\Deptrac\Supportive\Console\Command\ChangedFilesCommand;
use Qossmic\Deptrac\Supportive\Console\Command\ChangedFilesRunner;
use Qossmic\Deptrac\Supportive\Console\Command\DebugDependenciesCommand;
use Qossmic\Deptrac\Supportive\Console\Command\DebugDependenciesRunner;
use Qossmic\Deptrac\Supportive\Console\Command\DebugLayerCommand;
Expand All @@ -105,14 +107,15 @@
use Qossmic\Deptrac\Supportive\OutputFormatter\GraphVizOutputImageFormatter;
use Qossmic\Deptrac\Supportive\OutputFormatter\JsonOutputFormatter;
use Qossmic\Deptrac\Supportive\OutputFormatter\JUnitOutputFormatter;
use Qossmic\Deptrac\Supportive\OutputFormatter\MermaidJSOutputFormatter;
use Qossmic\Deptrac\Supportive\OutputFormatter\TableOutputFormatter;
use Qossmic\Deptrac\Supportive\OutputFormatter\XMLOutputFormatter;
use DEPTRAC_202403\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use DEPTRAC_202403\Symfony\Component\EventDispatcher\EventDispatcher;
use function DEPTRAC_202403\Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function DEPTRAC_202403\Symfony\Component\DependencyInjection\Loader\Configurator\service;
use function DEPTRAC_202403\Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator;
use function DEPTRAC_202403\Symfony\Component\DependencyInjection\Loader\Configurator\tagged_locator;
use DEPTRAC_202404\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use DEPTRAC_202404\Symfony\Component\EventDispatcher\EventDispatcher;
use function DEPTRAC_202404\Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function DEPTRAC_202404\Symfony\Component\DependencyInjection\Loader\Configurator\service;
use function DEPTRAC_202404\Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator;
use function DEPTRAC_202404\Symfony\Component\DependencyInjection\Loader\Configurator\tagged_locator;
return static function (ContainerConfigurator $container) : void {
$services = $container->services();
$services->defaults()->autowire();
Expand Down Expand Up @@ -165,7 +168,7 @@
/*
* Layer
*/
$services->set(LayerResolver::class)->args(['$layers' => param('layers')]);
$services->set(LayerResolver::class)->args(['$layersConfig' => param('layers')]);
$services->alias(LayerResolverInterface::class, LayerResolver::class);
$services->set(CollectorProvider::class)->args(['$collectorLocator' => tagged_locator('collector', 'type')]);
$services->set(CollectorResolver::class);
Expand Down Expand Up @@ -227,12 +230,15 @@
$services->set(GraphVizOutputDotFormatter::class)->tag('output_formatter');
$services->set(GraphVizOutputHtmlFormatter::class)->tag('output_formatter');
$services->set(CodeclimateOutputFormatter::class)->tag('output_formatter');
$services->set(MermaidJSOutputFormatter::class)->tag('output_formatter');
/*
* Console
*/
$services->set(InitCommand::class)->autowire()->tag('console.command');
$services->set(AnalyseRunner::class)->autowire();
$services->set(AnalyseCommand::class)->autowire()->tag('console.command');
$services->set(ChangedFilesRunner::class)->autowire();
$services->set(ChangedFilesCommand::class)->autowire()->tag('console.command');
$services->set(DebugLayerRunner::class)->autowire()->args(['$layers' => param('layers')]);
$services->set(DebugLayerCommand::class)->autowire()->tag('console.command');
$services->set(DebugTokenRunner::class)->autowire();
Expand Down
20 changes: 0 additions & 20 deletions deptrac.config.php

This file was deleted.

Binary file modified deptrac.phar
Binary file not shown.
10 changes: 5 additions & 5 deletions deptrac.phar.asc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-----BEGIN PGP SIGNATURE-----

iJMEABYKADsWIQRXy1VvJC/I1P1IPCxHQ2WH2CxKOQUCZfLQwh0cZ2VubmFkaS5t
Y2tlbHZleUBxb3NzbWljLmNvbQAKCRBHQ2WH2CxKOYVRAP0crfIO32Tt9G1U2QI5
ebOmFt3wvPWx+eA2yl4aQ2BtfQEAuFRE9CsTgXubdKi7pTNIqTX3HdLCgI2YwiXm
ZBXuIg8=
=58M9
iJMEABYKADsWIQRXy1VvJC/I1P1IPCxHQ2WH2CxKOQUCZhuSAx0cZ2VubmFkaS5t
Y2tlbHZleUBxb3NzbWljLmNvbQAKCRBHQ2WH2CxKOYb7AP9VqfjDdZp6+6G7MoYd
xMZ+Ljn0rxpyK0emLLUQjP2hdQD+LcLK+e6qnaYcJhTxPhA+TZ78bRRoKEWr2rNT
9PPeoQI=
=nYZA
-----END PGP SIGNATURE-----
2 changes: 1 addition & 1 deletion docs/collectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ deptrac:
value: src/Domain/.*
must_not:
- type: layer
layer: SubDomain
value: SubDomain
```

## `method` Collector
Expand Down
4 changes: 2 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ Deptrac provides parameters that can be user in your configuration.

* `%currentWorkingDirectory%` The path Deptrac runs in
* `%projectDirectory%` The path where the configuration is stored.
* `%deptrac.cache_file%` contains the filename and path for the cache file.
Note: This parameter is set by `--cache-file=` and will be overwritten.
* `%cache_file%` contains the filename and path for the cache file.
Note: This parameter is overwritten by `--cache-file=` if it is set.

You can specify your own parameters and reuse them in your configuration:

Expand Down
38 changes: 33 additions & 5 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ With the `debug:layer`-command you can list all tokens which are matched in
a specific layer. This command only shows tokens that would be emitted by your analyser configuration.

```console
$ php deptrac.phar debug:layer --config-file=examples/DirectoryLayer.depfile.yaml Layer1

examples\Layer1\AnotherClassLikeAController
examples\Layer1\SomeClass
examples\Layer1\SomeClass2
$ php deptrac.phar debug:layer --config-file=deptrac.config.php Time

---------------------------------------------------- ------------
Time Token Type
---------------------------------------------------- ------------
/src/Supportive/Time/Period.php file
/src/Supportive/Time/StartedPeriod.php file
/src/Supportive/Time/Stopwatch.php file
/src/Supportive/Time/StopwatchException.php file
Qossmic\Deptrac\Supportive\Time\Period class-like
Qossmic\Deptrac\Supportive\Time\StartedPeriod class-like
Qossmic\Deptrac\Supportive\Time\Stopwatch class-like
Qossmic\Deptrac\Supportive\Time\StopwatchException class-like
---------------------------------------------------- ------------
```

## `debug:token`
Expand Down Expand Up @@ -80,3 +89,22 @@ $ php deptrac.phar debug:unused --limit=10
InputCollector layer is dependent File layer 3 times
OutputFormatter layer is dependent DependencyInjection layer 1 times
```

## `changed-files`

> [!CAUTION]
> This command in experimental and is not covered by
> the [BC policy](bc_policy.md).
This command list the layers corresponding to the passed files. Optionally it
can also list all the layers that depend on those layers.

```console
$ php deptrac.phar changed-files --with-dependencies src/Supportive/File/FileReader.php

File
Console;Ast;InputCollector;Analyser;Dependency;Layer
```

For a discussion as to why that information might be useful, refer to
the [90DaysOfDevOps Presentation](https://github.com/MichaelCade/90DaysOfDevOps/pull/472).
81 changes: 81 additions & 0 deletions docs/formatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,87 @@ Will produce the following graph:
#### Pointing to groups instead of nodes
With `formatters.graphviz.pointToGroups` set to `true`, when you have a node inside a groups with the same name as the group itself, edges pointing to that node will point to the group instead. This might be useful for example if you want to provide a "public API" for a module defined by a group.

## MermaidJS Formatter

The MermaidJS formatter is a console formatter, which generates a mermaid.js compatible graph definition. It can be activated with `--formatter=mermaidjs`.
With the -o option you can specify the output file.

Available options:

```
--formatter=mermaidjs
--output= path to a dumped file
```
With this example
Yaml Config:

```yaml
deptrac:
layers:
- User Frontend
- User Backend
- Admin Frontend
- Admin Backend
formatters:
mermaidjs:
direction: TD
groups:
User:
- User Frontend
- User Backend
Admin:
- Admin Frontend
- Admin Backend
```

This will produce the following graph:

```mermaid
flowchart TD;
subgraph ContractGroup;
Contract;
end;
subgraph SupportiveGroup;
Supportive;
File;
end;
subgraph SymfonyGroup;
Console;
DependencyInjection;
OutputFormatter;
end;
subgraph CoreGroup;
Analyser;
Ast;
Dependency;
InputCollector;
Layer;
end;
Contract -->|6| Symfony;
InputCollector -->|3| File;
InputCollector -->|7| Symfony;
Dependency -->|36| Ast;
Layer -->|68| Ast;
Layer -->|8| Symfony;
Analyser -->|18| Ast;
Analyser -->|23| Dependency;
Analyser -->|6| Layer;
Analyser -->|10| Symfony;
Ast -->|3| Symfony;
Ast -->|3| InputCollector;
Ast -->|7| File;
OutputFormatter -->|5| Symfony;
OutputFormatter -->|1| DependencyInjection;
File -->|9| Symfony;
DependencyInjection -->|37| Symfony;
Console -->|66| Symfony;
Console -->|2| DependencyInjection;
Console -->|16| Analyser;
Console -->|5| File;
Console -->|4| OutputFormatter;
Console -->|4| Time;
```

## JSON Formatter

By default, Json formatter dumps information to *STDOUT*. It can be activated
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/Analyser/PostProcessEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Qossmic\Deptrac\Contract\Analyser;

use DEPTRAC_202403\Symfony\Contracts\EventDispatcher\Event;
use DEPTRAC_202404\Symfony\Contracts\EventDispatcher\Event;
/**
* Event fired after the analysis is complete.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/Analyser/ProcessEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Qossmic\Deptrac\Contract\Ast\TokenReferenceInterface;
use Qossmic\Deptrac\Contract\Dependency\DependencyInterface;
use DEPTRAC_202403\Symfony\Contracts\EventDispatcher\Event;
use DEPTRAC_202404\Symfony\Contracts\EventDispatcher\Event;
/**
* Event that is triggered on every found dependency.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/Analyser/ViolationCreatingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Qossmic\Deptrac\Contract\Analyser;

use DEPTRAC_202403\Symfony\Component\EventDispatcher\EventSubscriberInterface;
use DEPTRAC_202404\Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Every rule that can create a Violation has to implement this interface.
*
Expand Down
Loading

0 comments on commit 5da9063

Please sign in to comment.