Rename / remove / move components
Please provide us with the following information:
- OS? Mac OSX (El Capitan)
- Versions. Please run
ng --version. If there's nothing outputted, please angular-cli: 1.0.0-beta.1 node: 5.7.0 os: darwin x64
It would be really usefull to add cli commands for:
- rm = removing a component
- mv = moving / renaming a component
Unless I am missing it, I don't see that this exists and it would be really useful during refactoring to avoid all the manual updates that come with this process.
Thoughts?
ember-cli has ember destroy for removing items.
And there's an afterUninstall hook that can be used to remove barrel registration.
ember-cli indeed does have those commands, but they currently are not working correctly with the blueprints.
Here's a bit of further feedback. The current way that CLI creates new components and other pieces has the merit of following the nascent style guide. So perhaps this feedback is really for the style guide. It certainly creates quite a lot of duplication and naming. For everything that we add using this tooling, we get N copies of its name across multiple directories and files, with two different variations of the name. When the time comes to rename (which happens quite often in real applications), this adds lots of friction. I suppose there is nothing to be done about it; the decision has already been made that the official style will be to use two different variations of every name (or more) and to spray them across many files. But there certainly is an opportunity for the CLI to ease the trouble that this decision creates.
Somewhat related issue: https://github.com/angular/angular-cli/issues/357
@kylecordes overall refactoring of typescript projects is quite well supported across different IDEs via typescript services. Refactoring a name should operate correctly across the project, and disregarding other variables with the same name.
I'm also not too clear what you mean by "N copies of its name" and "two different variations of every name", but you are right that those are style guide decisions and not CLI decisions - the CLI merely implements the style guide to the best of it's ability.
Renaming a component would be very useful to have CLI feature. I was expecting this feature to be there and saw the CLI help and was disappointed because it wasn't.
I have to rename atleast 5-6 files (*.component.ts, *.scss, *spec.ts, *.service.ts, etc) and then update those files where the component was imported or used. (e.g. app.routes.ts and other files). A quick CLI command for this would be a big timesaver.
I didn't get the solution for - how to remove component by angular-cli . I was tried my examples but still get nothing ! rm and mv didn't worked ?
A ng destroy would be a good opposite of ng generate as the readme introduces generate like ng generate component my-new-component which creates MyNewComponentComponent.
I as well believe a ng destroy would be quite usefull
+1 to ng destroy or ng remove
Just ran into this where I had created a component, imported packages that had the same named components and I was left having to tediously update all the files connected to my previously generated component. A rename would be a godsend.
How do we distroy component as when I try to use ng d c or ng r c it throws the following error: The destroy command is not supported by Angular CLI.
It will be very useful if we get commands for remove/rename components.
As a temporary solution, if you have a clean repository and you want to remove, you can use: git reset -options
https://git-scm.com/docs/git-reset http://stackoverflow.com/questions/9529078/how-do-i-use-git-reset-hard-head-to-revert-to-a-previous-commit
+1 to have this feature in the CLI
Remove option is a must.
+1 to have this!
+1 Strongly suggest to add ng remove r or ng destroy d component/service/pipe and etc.
+1 for this
I can't believe this has been open so long. If you have code to generate, certainly you can delete those same file locations. Manually removing a botched naming of a generated component is a pain.
People that demanding on the feature - you don't realize how complicated it would be to implement. Even advanced IDEs do mistakes when moving components to other folders. Path become rewritten mistakenly broken. Or when doing delete - IDE found too much dependent relation which it cannot handle automatically - so it asks developer to review. Expecting this feature from cli is very optimistic.
Theoretically it would be easier if let's say absolutely prohibit developers to manually edit imports/exports. But who wants frozen file system in their project? And who will really keep this rule in 100% of cases?