angular-architects / nx-ddd-plugin

Nx plugin for structuring a monorepo with domains and layers
313 stars 56 forks source link

Directory/path to a domain/feature #12

Closed draylegend closed 3 years ago

draylegend commented 4 years ago

Feature request

Initial situation

Currently a cannot extend the path to domain/feature like this: web/expert.

image

Given

Empty libs folder. The workspace could contain multiple apps for different platforms (web, nativescript, ionic, electron etc.).

Solution

I could image two possible solutions:

In the end we would have a more flexible way to organize the libs folder:

libs:
  web:
    admin:
      domain
      feature
  mobile:
    some-folder:
      domain
      feature
  desktop:
manfredsteyer commented 4 years ago

Yes, you are right. This is currently not possible with this plugin. I think, a solution could be adding a --directory parameter:

ng g @angular-architects/ddd:domain admin --directory web

or we could allow the domain to be a path

ng g @angular-architects/ddd:domain web/admin

Care for a PR?

pascalbe-dev commented 4 years ago

Bringing this one back: After discussing that on #15, we should add this one for feature, domain lib as well. A separate directory option would make it behave similar to the nrwl angular library schematic. 👍

In case of the feature lib, we could go with your proposal for the shared libs, Manfred: ng g @angular-architects/ddd:feature contracts --domain customer --directory some-folder would result in a lib with path: libs/customer/some-folder/feature-contracts.

For the domain path, it would probably make sense to have the following mapping: ng g @angular-architects/ddd:domain customer --directory some-folder would result in a lib with path: libs/some-folder/customer/domain

However, if you add a feature lib to domain lib with a custom directory, the feature lib path should also be dependent on the domain custom directory: ng g @angular-architects/ddd:domain customer --directory some-folder ng g @angular-architects/ddd:feature contracts --domain customer would result in:

libs |- some-folder |-- customer |--- domain |--- feature-contracts

What do you think?

pascalbe-dev commented 3 years ago

@vladimirdrayling @manfredsteyer

benpsnyder commented 3 years ago

Hi all (@pascalbe-dev, @vladimirdrayling, @manfredsteyer, @peterbsmith2) - I implemented this (on my laptop while watching Christmas movies with nieces) according to my own needs. I used --libsDirectory and --appsDirectory instead of --directory because I wanted more flexibility. Code needs better docs and validation but it works at the moment. See #35

I plan to work on this more over the next 2 days, and I am also going to give assignments out to some of our developers within our company to work through bugs we found in the issue queue. We really like the principles of DDD and how this plugin has brought order to our apps in the Nx ecosystem.

benpsnyder commented 3 years ago

Update: worked out a bunch of bugs. We're just working on 1 remaining known issue which should be easy to resolve. Would like to get this peer reviewed ASAP. Thanks... #35

pascalbe-dev commented 3 years ago

Hi @benpsnyder great to see another contributer :)

Regarding your ideas: I think, its a good idea to add an option to configure the app directory. However, I would not change the name of the directory option. For the util, ui library, the current name is directory. In my view, there should be a consistent name for the option across all schematics -> directory. appDirectory makes sense 👍 .

benpsnyder commented 3 years ago

@pascalbe-dev you bet ... I really love the ideas behind DDD and how it is making it easier for me to work consistently with my distributed team when planning what we're building and working within Nx.

I agree with your suggestion for keeping the name of the directory option and using appDirectory as well. Changes have been made...

benpsnyder commented 3 years ago

The Feature schematic is now enhanced; it will take directory, domainDirectory and appDirectory options now so it pairs nicely with the Domain schematic capabilities now. Please review for bugs and suggestions.

benpsnyder commented 3 years ago

Anyone interested in this thread, please check our #37

wizardnet972 commented 3 years ago

Please add directory option.

Because with directory option I can use this structure:

libs
 auth /
  |->  auth-api (node lib)
  |->  auth-ui /
               |-> domain
                   ....
manfredsteyer commented 3 years ago

This PR seems to solve this issue: https://github.com/angular-architects/nx-ddd-plugin/pull/35