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

Feature store generator generates incorrect imports and appends directory name to tokens if --name contains directories #18905

Closed
4 tasks
hgschwibbe opened this issue Aug 30, 2023 · 1 comment · Fixed by #18913
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@hgschwibbe
Copy link

hgschwibbe commented Aug 30, 2023

Current Behavior

The following command generates imports that does not exist:

nx g @nx/angular:ngrx-feature-store --name supply-chain/supply-chain --facade true

The feature state was successfully generated in a subdirectory below of the +state directory like previous nx versions did before
(src/app/+state/supply-chain). Now the files below the subdirectory imports from './supply-chain/supply-chain.*' instead of from './supply-chain.*'.

For Example:

import { createAction, props } from '@ngrx/store';
import { SupplyChainSupplyChainEntity } from './supply-chain/supply-chain.models';

export const initSupplyChainSupplyChain = createAction(
  '[SupplyChainSupplyChain Page] Init'
);

export const loadSupplyChainSupplyChainSuccess = createAction(
  '[SupplyChainSupplyChain/API] Load SupplyChainSupplyChain Success',
  props<{ supplyChainSupplyChain: SupplyChainSupplyChainEntity[] }>()
);

export const loadSupplyChainSupplyChainFailure = createAction(
  '[SupplyChainSupplyChain/API] Load SupplyChainSupplyChain Failure',
  props<{ error: any }>()
);

Also the entity name generation took the directory into account:
It generates the entity name SupplyChainSupplyChainEntity instead of SupplyChainEntity.

A workaround might be generating with the --directory parameter, but this overrides the +state root directory. So you have always to prefix it with +state which leads to typing errors:
nx g @nx/angular:ngrx-feature-store --directory +state/supply-chain --name supply-chain --facade true

Its up to you how to fix it:

  • be compatible with the old approach and take paths into account while using the --name parameter
  • or provide an additional --subdirectory parameter that does not override/break the default +state root directory.

Expected Behavior

Imports could be resolved.
Generated code does not prefix everything with the directory names.

Steps to Reproduce

  1. nx g @nx/angular:ngrx-feature-store --name supply-chain/supply-chain --facade true

Nx Report

Node   : 18.17.1
   OS     : linux-x64
   npm    : 9.6.7

   nx (global)        : 16.7.2
   nx                 : 16.7.4
   @nx/js             : 16.7.4
   @nx/jest           : 16.7.4
   @nx/linter         : 16.7.4
   @nx/workspace      : 16.7.4
   @nx/angular        : 16.7.4
   @nx/cypress        : 16.7.4
   @nx/devkit         : 16.7.4
   @nx/eslint-plugin  : 16.7.4
   @nrwl/tao          : 16.7.4
   @nx/webpack        : 16.7.4
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @ngrx/component-store : 16.0.1
   @ngrx/effects         : 16.0.1
   @ngrx/entity          : 16.0.1
   @ngrx/router-store    : 16.0.1
   @ngrx/schematics      : 16.0.1
   @ngrx/store           : 16.0.1
   @ngrx/store-devtools  : 16.0.1

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@hgschwibbe hgschwibbe changed the title Feature store generator generates imports that does not exist Feature store generator generates trash if the name contains directories Aug 30, 2023
@hgschwibbe hgschwibbe changed the title Feature store generator generates trash if the name contains directories Feature store generator generates trash if the name contains directory paths Aug 30, 2023
@hgschwibbe hgschwibbe changed the title Feature store generator generates trash if the name contains directory paths Feature store generator generates gibberish if the name contains directory paths Aug 30, 2023
@hgschwibbe hgschwibbe changed the title Feature store generator generates gibberish if the name contains directory paths Feature store generator generates gibberish if name contains directories Aug 30, 2023
@mandarini mandarini added the scope: angular Issues related to Angular support in Nx label Aug 30, 2023
@Coly010 Coly010 self-assigned this Aug 30, 2023
@Coly010 Coly010 changed the title Feature store generator generates gibberish if name contains directories Feature store generator generates incorrect imports if name contains directories Aug 30, 2023
@Coly010 Coly010 changed the title Feature store generator generates incorrect imports if name contains directories Feature store generator generates incorrect imports and appends directory name to tokens if --name contains directories Aug 30, 2023
@github-actions
Copy link

github-actions bot commented Oct 1, 2023

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants