Skip to content

Include an option to specify the src directory in the ng-new schematic #11753

@ghost

Description

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request

Command (mark with an x)

- [X] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

NPM: v6.1.0
Angular CLI: 6.1.2
Node: 8.11.2
OS: linux x64
Angular:  

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.2
@angular-devkit/core         0.7.2
@angular-devkit/schematics   0.7.2
@schematics/angular          0.7.2
@schematics/update           0.7.2
rxjs                         6.2.2
typescript                   2.7.2

Repro steps

ng new my-project --srcDir src/client --dryRun

The log given by the failure

Schematic input does not validate against the Schema: {"srcDir":"src/client","skipGit":true,"version":"6.1.2","skipInstall":false,"linkCli":false,"commit":true,"newProjectRoot":"projects","inlineStyle":false,"inlineTemplate":false,"routing":false,"prefix":"app","style":"css","skipTests":false}
Errors:

  Data path "" should NOT have additional properties(srcDir).

Desired functionality

It would be great if we could specify a srcDir option to create the src files in a different directory (in my case I would like to create them in the src/client directory).
I followed up the code from the ng-new schematic where the src directory path is being set:

Maybe I'm missing something and this can be done in some other way.I know I can move the contents manually of the src folder to a new src/client folder and update the angular.json file, and everything should work fine, but I'm building my own schematics to generate other files and I need the client code to already be located in a different folder than src.

In previous versions of the angular schematics (i.e. 0.4.6), when calling the application schematic there was this option sourceDir which allowed me to specify the src directory for the generated code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @schematics/angularfeatureLabel used to distinguish feature request from other issuesfeature: insufficient votesLabel to add when the not a sufficient number of votes or comments from unique authors

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions