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

Not possible to change the directory prefix used by the generator commands

Open jusefb opened this issue 10 years ago • 13 comments

OS

Windows 10

Versions.

angular-cli: 1.0.0-beta.19-3 node: 5.10.1 os: darwin x64

Repro steps.

  1. Change the prefix in the angular-cli.json from "app" to "src"
  2. Run ng g component test-component command
  3. You get an error "..../app" could not be found, the angualr-cli.json setting is completely ignored by the generator

jusefb avatar Nov 10 '16 10:11 jusefb

The prefix is relative to src, so, if you set it to src, it actually means src/src.

The generator command fails if you ask it to generate something in a directory that doesn't exist. src/src probably did not exist when you ran that, which is why you are getting the error.

Cheers,

Meligy avatar Nov 10 '16 10:11 Meligy

Hi, thank you for a quick response. Unfortunately no matter what I set the prefix to in the config file the generator still is looking for the "app" prefix. Is there some other property that needs changing?

jusefb avatar Nov 10 '16 10:11 jusefb

That setting controls the selector prefix not the directory. Unfortunately, the "app" directory appears to be hard coded

clydin avatar Nov 10 '16 12:11 clydin

That is what I thought, thanks for confirming it. I think this would be a must have for adding angular-cli to existing projects

jusefb avatar Nov 11 '16 00:11 jusefb

@Brocco we should add base app folder name config to angular-cli.json, what do you think?

We have it hardcoded here (and maybe other places):

https://github.com/angular/angular-cli/blob/master/packages/angular-cli/utilities/dynamic-path-parser.js#L8

Adding it to RC1 because after that it'll be less than ideal to change the config.

filipesilva avatar Nov 21 '16 16:11 filipesilva

@filipesilva I tried changing just that place, but was still having issues so I'm pretty sure it's in other places

lordmat0 avatar Nov 21 '16 18:11 lordmat0

It would be possible to make it configurable, but to clarify prefix is the prefix given to component selectors when they are generated.

Brocco avatar Nov 24 '16 02:11 Brocco

@Brocco Had no idea, it's a little mysterious.

Is there any plans to include what each part of the angular-cli.json file does?

lordmat0 avatar Nov 24 '16 20:11 lordmat0

@lordmat0 there are plans to make blueprints (generate templates) configurable in the future, but it is not there right now.

Brocco avatar Dec 08 '16 04:12 Brocco

@Brocco we should add base app folder name config to angular-cli.json, what do you think?

We have it hardcoded here (and maybe other places):

https://github.com/angular/angular-cli/blob/master/packages/angular-cli/utilities/dynamic-path-parser.js#L8

Adding it to RC1 because after that it'll be less than ideal to change the config.

This issue was closed after Brocco said :

@lordmat0 there are plans to make blueprints (generate templates) configurable in the future, but it is not there right now.

But I don't see an anything resolving what this was primarily created for (namely: being able to change "app" to something else.), and this is the closest hit to what I am experiencing I could find online.

I am running angular cli 1.0.2 and changing name property under the project or app config does not change where my files are generated to. (I just upgraded to 1.1.3 and still can only generate to src/app/ rather than src/<name-in-config>

Perhaps I am using the configuration incorrectly?

ChadFong avatar Jun 26 '17 17:06 ChadFong

I'm building a angular npm library where the library code is inside the ./my-lib folder and the rest around is the angular app generated by angular-cli. Can I use ng g to generate code inside the /my-lib/src folder? Thank you.

skorunka avatar Jan 09 '18 11:01 skorunka

@skorunka I was looking to do the same thing, making a library with ng-packagr

You can create a second 'app' in the angular-cli.json file - in the apps array, and copy the existing app details into it. Give it a "name" e.g. "name": "lib", and you can use the ng generate as follows:

ng generate module my-mod --app=lib

That's the basics of it anyway

briancodes avatar Mar 13 '18 15:03 briancodes

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.