Skip to content

Commit

Permalink
Merge pull request #1 from KoNekoD/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
KoNekoD authored Nov 5, 2024
2 parents ef6bb1a + 0fe39e2 commit 819211b
Show file tree
Hide file tree
Showing 675 changed files with 8,325 additions and 16,574 deletions.
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,31 @@ The depfile is the config file for this tool, in this file you define (mainly) t
Here is an example depfile:

```yaml
# depfile.yaml
paths:
- ./src
exclude_files:
- .*test.*
layers:
- name: Controller
collectors:
- type: directory
regex: .*Controller.*
- name: Repository
collectors:
- type: directory
regex: .*Repository.*
- name: Service
collectors:
- type: directory
regex: .*Service.*
ruleset:
Controller:
- Service
Service:
- Repository
Repository: ~
# deptrac.yaml
deptrac:
paths:
- ./src
exclude_files:
- .*test.*
layers:
- name: Controller
collectors:
- type: directory
value: .*Controller.*
- name: Repository
collectors:
- type: directory
value: .*Repository.*
- name: Service
collectors:
- type: directory
value: .*Service.*
ruleset:
Controller:
- Service
Service:
- Repository
Repository: ~
```
#### Explanation
Expand Down Expand Up @@ -78,7 +79,7 @@ go-deptrac was only tested on Linux and should also work on OS X. Probably it do
To run the tool, simply pass the path of the depfile:

```shell script
go-deptrac ./examples/simple-mvc/depfile.yaml
go_deptrac ./examples/simple_mvc/deptrac.yaml
```

## Contributing
Expand Down
9 changes: 0 additions & 9 deletions cmd/go-deptrac/main.go

This file was deleted.

23 changes: 0 additions & 23 deletions cmd/go-deptrac/main_test.go

This file was deleted.

9 changes: 9 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"github.com/KoNekoD/go-deptrac/pkg/infrastructure/app"
)

func main() {
app.Run()
}
131 changes: 14 additions & 117 deletions deptrac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ services:

deptrac:
paths:
- ./pkg/src
- ./pkg

analyser:
internal_tag: "@internal"
types:
- class
- class_superglobal
- file
- file_supportive
- function
- function_superglobal
- function_call
- use

formatters:
graphviz:
Expand All @@ -39,126 +40,22 @@ deptrac:

layers:
# Domains
- name: Analyser
- name: domain
collectors:
- type: directory
value: pkg/src/core/Analyser/.*
- name: Ast
value: pkg/domain/.*
- name: application
collectors:
- type: directory
value: pkg/src/core/Ast/.*
- type: composer
private: true
composerPath: composer.json
composerLockPath: composer.lock
packages:
- phpstan/phpdoc-parser
- nikic/php-parser
- phpdocumentor/type-resolver
- name: Console
value: pkg/application/.*
- name: infrastructure
collectors:
- type: directory
value: pkg/src/supportive/Console/.*
- name: Dependency
collectors:
- type: directory
value: pkg/src/core/Dependency/.*
- name: DependencyInjection
collectors:
- type: directory
value: pkg/src/supportive/DependencyInjection/.*
- name: Contract
collectors:
- type: directory
value: pkg/src/contract/.*
- name: InputCollector
collectors:
- type: directory
value: pkg/src/core/InputCollector/.*
- name: Layer
collectors:
- type: directory
value: pkg/src/core/Layer/.*
- name: OutputFormatter
collectors:
- type: directory
value: pkg/src/supportive/OutputFormatter/.*
- type: composer
private: true
composerPath: composer.json
composerLockPath: composer.lock
packages:
- phpdocumentor/graphviz
- name: File
collectors:
- type: directory
value: pkg/src/supportive/File/.*
- name: Time
collectors:
- type: directory
value: pkg/src/supportive/Time/.*
- name: Supportive
collectors:
- type: bool
must_not:
- type: directory
value: pkg/src/supportive/.*/.*
must:
- type: directory
value: pkg/src/supportive/.*
- name: Symfony
collectors:
- type: composer
composerPath: composer.json
composerLockPath: composer.lock
packages:
- symfony/config
- symfony/console
- symfony/dependency-injection
- symfony/event-dispatcher
- symfony/filesystem
- symfony/finder
- symfony/yaml
value: pkg/infrastructure/.*

ruleset:
Layer:
- Ast
- Symfony
- Contract
Console:
- Analyser
- OutputFormatter
- DependencyInjection
- File
- Time
- Symfony
- Contract
Dependency:
- Ast
- Contract
Analyser:
- Layer
- Dependency
- Ast
- Symfony
- Contract
OutputFormatter:
- DependencyInjection
- Symfony
- Contract
Ast:
- File
- InputCollector
- Symfony
- Contract
InputCollector:
- File
- Symfony
DependencyInjection:
- Symfony
- Console
- Contract
Contract:
- Symfony
File:
- Symfony
application:
- domain
infrastructure:
- application
- domain
34 changes: 34 additions & 0 deletions examples/run_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package examples

import (
"flag"
"github.com/KoNekoD/go-deptrac/pkg/infrastructure/app"
_ "github.com/KoNekoD/go-deptrac/resources"
"os"
"testing"
)

func TestRunSimpleCleanarch(t *testing.T) {
t.Parallel()

t.Run("simple_clean_arch", func(t *testing.T) {
configArg := "--config=examples/simple_clean_arch/deptrac.yaml"
os.Args = []string{"", configArg, "analyse"}
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
app.NewApp().Run()
})

t.Run("simple_invalid_mvc", func(t *testing.T) {
configArg := "--config=examples/simple_invalid_mvc/deptrac.yaml"
os.Args = []string{"", configArg, "analyse"}
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
app.NewApp().Run()
})

t.Run("simple_mvc", func(t *testing.T) {
configArg := "--config=examples/simple_mvc/deptrac.yaml"
os.Args = []string{"", configArg, "analyse"}
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
app.NewApp().Run()
})
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app

import (
"github.com/KoNekoD/go-deptrac/pkg/test_projects/examples/simple-cleanarch/domain"
"simple-cleanarch/domain"
)

type App interface {
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions examples/simple_clean_arch/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module simple-cleanarch

go 1.22
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package infrastructure

import (
"github.com/KoNekoD/go-deptrac/pkg/test_projects/examples/simple-cleanarch/domain"
"simple-cleanarch/domain"
)

type kvStore struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package controller

import (
"github.com/KoNekoD/go-deptrac/pkg/test_projects/examples/simple-invalid-mvc/repository"
)
import "github.com/KoNekoD/go-deptrac/examples/simple_invalid_mvc/repository"

type Controller interface{}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package simple_cleanarch

import (
"flag"
"github.com/KoNekoD/go-deptrac/pkg/src/supportive/Console/Application"
"github.com/KoNekoD/go-deptrac/pkg/infrastructure/app"
_ "github.com/KoNekoD/go-deptrac/resources"
"os"
"testing"
Expand All @@ -11,7 +11,7 @@ import (
func TestRun(t *testing.T) {
os.Args = []string{
"",
"--config-file=pkg/test_projects/examples/simple-mvc/depfile.yaml",
"--config=pkg/test_projects/examples/simple_invalid_mvc/deptrac.yaml",
"analyse",
}

Expand All @@ -21,7 +21,6 @@ func TestRun(t *testing.T) {
// t.Fatal(err)
//}

Application.
NewApplication().
app.NewApp().
Run()
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package controller

import (
"github.com/KoNekoD/go-deptrac/pkg/test_projects/examples/simple-mvc/service"
)
import "github.com/KoNekoD/go-deptrac/examples/simple_mvc/service"

type Controller interface{}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package simple_cleanarch

import (
"flag"
"github.com/KoNekoD/go-deptrac/pkg/src/supportive/Console/Application"
"github.com/KoNekoD/go-deptrac/pkg/infrastructure/app"
_ "github.com/KoNekoD/go-deptrac/resources"
"os"
"testing"
Expand All @@ -11,7 +11,7 @@ import (
func TestRun(t *testing.T) {
os.Args = []string{
"",
"--config-file=pkg/test_projects/examples/simple-cleanarch/depfile.yaml",
"--config=pkg/test_projects/examples/simple_mvc/deptrac.yaml",
"analyse",
}

Expand All @@ -21,7 +21,6 @@ func TestRun(t *testing.T) {
// t.Fatal(err)
//}

Application.
NewApplication().
app.NewApp().
Run()
}
Loading

0 comments on commit 819211b

Please sign in to comment.