angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Rename / remove / move components

Open zpydee opened this issue 10 years ago • 102 comments

Please provide us with the following information:

  1. OS? Mac OSX (El Capitan)
  1. 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?

zpydee avatar May 24 '16 07:05 zpydee

ember-cli has ember destroy for removing items.

And there's an afterUninstall hook that can be used to remove barrel registration.

sWW26 avatar May 24 '16 22:05 sWW26

ember-cli indeed does have those commands, but they currently are not working correctly with the blueprints.

filipesilva avatar May 25 '16 22:05 filipesilva

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.

kylecordes avatar Jun 06 '16 15:06 kylecordes

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.

filipesilva avatar Jun 07 '16 16:06 filipesilva

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.

pramttl avatar Jul 05 '16 05:07 pramttl

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 ?

heysushil avatar Dec 07 '16 06:12 heysushil

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.

leehericks avatar Dec 12 '16 00:12 leehericks

I as well believe a ng destroy would be quite usefull

solanoepalacio avatar Feb 13 '17 13:02 solanoepalacio

+1 to ng destroy or ng remove

Gastalver avatar Mar 13 '17 23:03 Gastalver

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.

antipalindrome avatar Mar 17 '17 00:03 antipalindrome

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.

asifbherani avatar Apr 02 '17 20:04 asifbherani

It will be very useful if we get commands for remove/rename components.

josephjimmy avatar May 13 '17 08:05 josephjimmy

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

sorcamarian avatar May 14 '17 14:05 sorcamarian

+1 to have this feature in the CLI

saad749 avatar May 18 '17 11:05 saad749

Remove option is a must.

LuisJoseSanchez avatar May 22 '17 15:05 LuisJoseSanchez

+1 to have this!

sharikovvladislav avatar May 27 '17 23:05 sharikovvladislav

+1 Strongly suggest to add ng remove r or ng destroy d component/service/pipe and etc.

alenn88 avatar May 28 '17 15:05 alenn88

+1 for this

guzcon avatar May 29 '17 08:05 guzcon

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.

leehericks avatar May 29 '17 08:05 leehericks

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?

tytskyi avatar May 29 '17 09:05 tytskyi