nstudio / xplat

Cross-platform (xplat) tools for Nx workspaces.
MIT License
366 stars 52 forks source link

feat(core): handling sub directory annotation in the feature name parameter #276

Closed csimpi closed 3 years ago

csimpi commented 3 years ago

feat(core): Handling sub directory annotation in the feature name parameter

nx generate @nstudio/angular:feature --name=dashboard/settings/base-config --platforms=web places the feature files into dashboard/settings subfolders.

NathanWalker commented 3 years ago

@csimpi really appreciate this - several flows I'm putting this through and I wanted to mention that this repo was created prior to introduction of nx-plugin's (an official way of creating Nx plugins: https://nx.dev/latest/angular/nx-plugin/overview) - xplat has been around almost as long as Nx itself. Sometime this summer I may refactor xplat into an nx-plugin structure and simplify the source a bit in the process just to streamline more of it's setup.

csimpi commented 3 years ago

@NathanWalker Thank you. Following NX Plugin patterns seems the best way to do this. Yesterday night I realized the imports are not following the directory pattern, I've found how to fix it, testing it now, and will push a commit if it looks good.

NathanWalker commented 3 years ago

@csimpi thanks again for this - I was able to add some additional things on top with this commit: https://github.com/nstudio/xplat/commit/c635f98f9ae53ab14c9771a44bf438912432bfbf

That provides a new directory option to appear in Nx Console with the feature generator which allows you to specify the name of a directory in features where you want it organized under. Additionally it allows the component generator to then target features created in directories as follows...

For example after generating a feature using a directory:

nx generate @nstudio/angular:feature --name=profile --directory=dashboard/settings --platforms=web=

CREATE libs/xplat/features/src/lib/dashboard/settings/profile/profile.module.ts
CREATE libs/xplat/features/src/lib/dashboard/settings/profile/index.ts
CREATE libs/xplat/web/features/src/lib/dashboard/settings/profile/profile.module.ts
CREATE libs/xplat/web/features/src/lib/dashboard/settings/profile/index.ts
CREATE libs/xplat/web/features/src/lib/dashboard/settings/profile/components/index.ts
CREATE libs/xplat/web/features/src/lib/dashboard/settings/profile/components/profile/profile.component.html
CREATE libs/xplat/web/features/src/lib/dashboard/settings/profile/components/profile/profile.component.ts
UPDATE libs/xplat/features/src/lib/index.ts
UPDATE libs/xplat/web/features/src/lib/index.ts
Screen Shot 2021-08-11 at 3 06 11 PM

You can then create components attached to that nested feature module with:

nx generate @nstudio/angular:component --name=networks --feature=dashboard/settings/profile --platforms=web

CREATE libs/xplat/web/features/src/lib/dashboard/settings/profile/components/networks/networks.component.html
CREATE libs/xplat/web/features/src/lib/dashboard/settings/profile/components/networks/networks.component.ts
UPDATE libs/xplat/web/features/src/lib/dashboard/settings/profile/components/index.ts
Screen Shot 2021-08-11 at 3 08 42 PM

Published with v12.7.0 now. https://github.com/nstudio/xplat/releases/tag/12.7.0

csimpi commented 3 years ago

Awesome, thank you!