Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG/UX: Feature schematic pathing does not work as expected #104

Open
wojtek-viirtue opened this issue Feb 17, 2022 · 2 comments
Open

BUG/UX: Feature schematic pathing does not work as expected #104

wojtek-viirtue opened this issue Feb 17, 2022 · 2 comments

Comments

@wojtek-viirtue
Copy link

TLDR;

Firstly, the plugin is AWESOME.

However, the feature schematic is too presumptive about pathing in an nx monorepo (that the domains will be in the root of the libs directory).

Given the following feature schematic generator command

nx g @angular-architects/ddd:feature choose-payment-method --directory angular/payment-methods/features --domain payment-methods --noApp

Then the feature should be generated in the angular/payment-methods/features/feature-choose-payment-method directory

Actual: Feature is generated into libs/payment-methods/angular/payment-methods/features/feature-choose-payment-method directory


Reproduction

npx create-nx-workspace my-app --preset=apps --nx-cloud=false

cd my-app

npm install --save-dev @nrwl/angular

npm i @angular-architects/ddd

nx g @angular-architects/ddd:domain payment-methods --directory angular

nx g @angular-architects/ddd:feature choose-payment-method --directory angular/payment-methods/features --domain payment-methods --noApp

Why?

We have an nx monorepo that is a polyglot (c#, python, angular) our apps and libs folders are structured as follows:

apps:
|__angular
|__dotnet
|__python

libs:
|__angular
|__dotnet

Given the domain schematic it was very easy to generate a domain library given the following:

nx g @angular-architects/ddd:domain payment-methods --directory angular --noApp

This created the expected hierarchy of:

libs:
|__angular
   |__payment-methods
      |__domain

(the module name, nx-workspace project ref, were prefixed with "angular", but that's not too painful to fix)

We're hoping to use the same means for generating features, but as stated, it is currently not possible to do so (without some hackery...because I was able to achieve the desired result, but would need to fix too many files to make it a feasible solution)

@angelfraga
Copy link

Hi, I am also facing similar/related issues.

For example, in order to end up with the next workspace tree & imports:

libs
 |__angular
     |__payments-methods
         |__ domain => @company/payment-methods/domain
         |__ features
             |__ choose-payment-method => @company/payment-methods/choose-payment-method
                  |__src
                     |__lib
                     |   |__ ChoosePaymentMethod.module.ts
                     |   |__ ChoosePaymentMethod.component.html
                     |   |__ ChoosePaymentMethod.component.css/scss
                     |   |__ ChoosePaymentMethod.component.ts
                     |__index.ts

I tried to figure out where could be the issue by trying out several configurations.
I guess the problem with the feature generator resides in the fact of joining the directory argument & domain path var in class names, selectors ...

By running the next "hacky" nx command :

nx g @angular-architects/ddd:feature choose-payment-method --directory features --domain angular/payment-methods --noApp --no-prefix

Where --domain angular/payment-methods is the relative path from libs to the parent of the domain folder.
Where --directory features is the relative path from the parent of the domain one.

It will give us the next result:

libs
 |__angular
     |__payments-methods
         |__ domain => @company/payment-methods/domain
         |__ features
             |__ choose-payment-method => @company/payment-methods/choose-payment-method
                  |__src
                     |__lib
                     |   |__ angular-payment-methods-features-choose-payment-method.module.ts
                     |   |__ ChoosePaymentMethod.component.html
                     |   |__ ChoosePaymentMethod.component.css/scss
                     |   |__ ChoosePaymentMethod.component.ts
                     |__index.ts

This command would contain some issues such as:

  • the feature index file has the wrong component import export * from './lib/features-choose-payment-method.component';.
  • the domain index file has the wrong component import export * from './lib/application/features-choose-payment-method.facade';
  • the feature component has the wrong selector 'angular/payment-methods-choose-payment-method'

I am currently working on a version for fixing that issue on my own fork 🤞.

@DuncanBannister
Copy link

I really enjoy this plugin to but I am facing the same issue.

I have a monorepo where I have a ui and server folder. I am trying to add a feature for the ui but it keeps adding my feature and domain to the root libs folder. Has anyone attempted to create a pull request for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants