nx
nx copied to clipboard
move generator should support directories and single files
- [ ] I'd be willing to implement this feature (contributing guide)
Description
The move:generator can only move a whole library.
It would be great if we could also move a directory (including all files and subdirectories) or a single file to an existing lib and update all references (e.g. import statements)
Motivation
When working with libraries for some time, they grow in size and after some threshold it makes sense to split the lib up into multiple small libs.
Currently the IDEs have no good support for this kind of move operation: see Stackoverflow: IDE - auto-update imports when moving files between libs/barrels
Suggested Implementation
Enhance the move generator:
- new option:
srcDir
to specify which directory in the src--project
should be moved -
--destination
: should allow a deep path into an existing lib: e.g.shared/my-feature-lib/moved-dir
- The move action should update all references to the moved files in the workspace (this logic already exists in the move generator)
- in addition to that the old directory/file/s should be deleted
- and, if applicable the old directory should be removed from
index.js
files in the src project