Skip to content

Commit

Permalink
rename business rules to domain
Browse files Browse the repository at this point in the history
  • Loading branch information
teintinu committed Aug 14, 2022
1 parent a60d521 commit 59e8619
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ dist/
examples/new/a
examples/new/b

examples/clean-architecture/business-rules
examples/clean-architecture/domains
examples/clean-architecture/apps
examples/clean-architecture/adapters
4 changes: 2 additions & 2 deletions cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func init() {

var devCmd = &cobra.Command{
Use: "dev",
Short: "Test libraries and run executables in watch mode",
Long: `Test libraries and run executables in watch mode`,
Short: "Test libraries and run applications in watch mode",
Long: `Test libraries and run applications in watch mode`,
Args: cobra.RangeArgs(0, 0),
RunE: func(cmd *cobra.Command, args []string) error {
internal.Logger.LogFlagInit()
Expand Down
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func init() {
var runCmd = &cobra.Command{
Use: "run [flags] <executable...>",
Short: "Build and run",
Long: `Builds and runs one or more executables. If not specified will run all executables in repository`,
Long: `Builds and runs one or more applications. If not specified will run all applications in repository`,
//Args: cobra.MinimumNArgs(1),
// DisableFlagsInUseLine: true,
// SilenceErrors: true,
Expand Down
12 changes: 6 additions & 6 deletions docs/khayyam-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
},
{
"required": [
"business-rules"
"domains"
]
},
{
"required": [
"executables"
"applications"
]
},
{
Expand Down Expand Up @@ -85,15 +85,15 @@
},
"additionalProperties": false
},
"business-rules": {
"domains": {
"$id": "#/properties/packages",
"$ref": "#/definitions/packageList",
"title": "These Clean Architecture packages defines business-rules"
"title": "These Clean Architecture packages defines domains"
},
"executables": {
"applications": {
"$id": "#/properties/packages",
"$ref": "#/definitions/packageList",
"title": "These Clean Architecture packages defines executables"
"title": "These Clean Architecture packages defines applications"
},
"adapters": {
"$id": "#/properties/packages",
Expand Down
8 changes: 4 additions & 4 deletions examples/clean-architecture/khayyam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ workspace:
name: "todo"
version: "1.0.0"

business-rules:
"@todo/business-rules":
folder: "business-rules"
domains:
"@todo/domains":
folder: "domains"
publish: public

adapters:
Expand All @@ -16,7 +16,7 @@ adapters:
folder: "adapters/postgres-repository"
publish: public

executables:
applications:
"@todo/server":
folder: "apps/server"
publish: "no"
Expand Down
4 changes: 2 additions & 2 deletions internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ type Config struct {
Registry string
Workspace WorkspaceConfig
Packages map[string]PackageConfig
BusinessRules map[string]PackageConfig `yaml:"business-rules"`
Executables map[string]PackageConfig
Domains map[string]PackageConfig `yaml:"domains"`
Adapters map[string]PackageConfig
Applications map[string]PackageConfig
}

type WorkspaceConfig struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Dev(repo *Repository) error {
webterm := NewWebTerm()

wg.Add(1)
//devRunExecutables(repo, wg, webterm)
//devRunApplications(repo, wg, webterm)
devTestApps(repo, wg, webterm)

webterm.Start(DevPort)
Expand Down Expand Up @@ -97,7 +97,7 @@ func devTestApps(repo *Repository, wg *sync.WaitGroup, webterm *WebTerm) {
}()
}

func devRunExecutables(repo *Repository, wg *sync.WaitGroup, webterm *WebTerm) {
func devRunApplications(repo *Repository, wg *sync.WaitGroup, webterm *WebTerm) {
for _, pkg := range repo.Packages {
if pkg.Executable {
wg.Add(1)
Expand Down
14 changes: 7 additions & 7 deletions internal/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ type PackageLayer = int

const (
NormalLayer PackageLayer = iota
BusinessRulesLayer
ExecutablesLayer
DomainsLayer
ApplicationsLayer
AdaptersLayer
)

Expand Down Expand Up @@ -119,11 +119,11 @@ func LoadRepository(searchDir string, checkEntryPoints bool) (*Repository, error
if err != nil {
return nil, err
}
err = loadPackages(&repo, cfg.BusinessRules, BusinessRulesLayer, checkEntryPoints)
err = loadPackages(&repo, cfg.Domains, DomainsLayer, checkEntryPoints)
if err != nil {
return nil, err
}
err = loadPackages(&repo, cfg.Executables, ExecutablesLayer, checkEntryPoints)
err = loadPackages(&repo, cfg.Applications, ApplicationsLayer, checkEntryPoints)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func loadPackages(repo *Repository, packages map[string]PackageConfig, layer Pac
Description: packageConfig.Description,
Folder: packageConfig.Folder,
Layer: layer,
Executable: layer == ExecutablesLayer || (layer == NormalLayer && packageConfig.Executable),
Executable: layer == ApplicationsLayer || (layer == NormalLayer && packageConfig.Executable),
Dependencies: make(map[string]*Dependency),
devDependencies: make(map[string]*Dependency),
}
Expand Down Expand Up @@ -261,7 +261,7 @@ func MakeJobs(jobs *gjobs.GJobs, jobPrefix string, repo *Repository, witchPackag

func validateLayer(repo *Repository, pkg *Package) error {

if pkg.Layer == BusinessRulesLayer {
if pkg.Layer == DomainsLayer {
if pkg.Executable {
return errors.New("Business layer " + pkg.Name + " can't be an executble")
}
Expand All @@ -273,7 +273,7 @@ func validateLayer(repo *Repository, pkg *Package) error {
if depPkg.Layer == AdaptersLayer {
return errors.New("business layer " + pkg.Name + "can't depends of adapter layer " + depName)
}
if depPkg.Layer == ExecutablesLayer {
if depPkg.Layer == ApplicationsLayer {
return errors.New("business layer " + pkg.Name + "can't depends of executable layer " + depName)
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/setupPackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func initializeEmptySources(repo *Repository, pkg *Package) error {
err := os.MkdirAll(sourceDir, 0755)
if err == nil {
// TODO
// if pkg.Layer == BusinessRulesLayer {
// err = initializeBusinessRulesLayer(sourceDir, indexTs)
// if pkg.Layer == DomainsLayer {
// err = initializeDomainsLayer(sourceDir, indexTs)
// }
if pkg.Executable {
err = initializeExecutable(sourceDir)
Expand Down
2 changes: 1 addition & 1 deletion internal/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ func Watch() error {
return nil
}

/* var optsTypes bool = opts.Package.Layer != ExecutablesLayer
/* var optsTypes bool = opts.Package.Layer != ApplicationsLayer
if opts.Watch && optsTypes {
return errors.New("cannot build types with watch")
}
Expand Down

0 comments on commit 59e8619

Please sign in to comment.