Skip to content

No option to create workspace only with ng-new #11402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
martzmakes opened this issue Jun 28, 2018 · 4 comments
Closed

No option to create workspace only with ng-new #11402

martzmakes opened this issue Jun 28, 2018 · 4 comments
Labels
area: @angular/cli feature Issue that requests a new feature
Milestone

Comments

@martzmakes
Copy link
Contributor

Bug Report or Feature Request (mark with an x)

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

Area

- [ ] devkit
- [x] schematics

Repro steps

This is more of a conceptual / documentation request... I'm in the process of creating my own collection of schematics to scaffold out a project structure using a mono-repo approach.

The only way to do this at the moment is to run:

ng new asdf
cd asdf
ng g app whatever

but then all of the src/ files remain (and the original angular.json info for a project that is now inconsistently stored). There's no way to create a new repo without the src folder... and when I do this using a custom schematic by essentially duplicating ng-new and removing

schematic('application', applicationOptions),
schematic('application', applicationOptions),

Whenever I run...

$ ng new asdf -c=my-schematic
$ cd asdf
$ ng g app whatever
    {"inlineStyle":false,"inlineTemplate":false,"routing":false,"prefix":"app","style":"css","skipTests":false,"skipPackageJson":false,"name":"whatever"}
CREATE projects/whatever-e2e/protractor.conf.js (752 bytes)
CREATE projects/whatever-e2e/src/app.e2e-spec.ts (304 bytes)
CREATE projects/whatever-e2e/src/app.po.ts (208 bytes)
CREATE projects/whatever-e2e/tsconfig.e2e.json (219 bytes)

Only the e2e files get put into projects/ and the angular.json file remains largely empty:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {},
  "cli": {
    "defaultCollection": "my-schematic"
  }
}

I suspect this has to do with something silently failing in the application schematic or a path being off... but I wanted to check first if there was an easier way.

Desired functionality

Seems like as mono-repo / project-based apps may become more common... there should be an easy way to create a workspace-only repo (no /src application). Or if there is a preferred way to do it, it should be documented. I'd rather not do ng new, remove src and remove "clean" the angular.json file.

Mention any other details that might be useful

I'd be happy to submit a PR for documentation and/or enabling a way to create a project-structure-based app (i.e. no /src folder)

@martzmakes
Copy link
Contributor Author

Maybe I should phrase this as a feature request...

It would be nice if ng generate application checked if there's an existing app in src/ and equivalent tests in e2e. Maybe add that as a flag to the application schematic like --migrate... if that flag is set it will check src/, e2e and if they exist... move them to the projectRoot folder and update the angular.json file.

So... steps would then become:

ng new asdf
cd asdf

yields the typical:

asdf/
    - src/ # project files
    - e2e/ # tests
    - angular.json
    - ...

Next... ng generate application something --migrate would move src/ --> projects/asdf/src/, e2e/ --> projects/asdf-e2e/, and update the angular.json paths.

So the result would be:

asdf/
    - projects/asdf/src/ # original project files, moved from asdf/src/ (and some files shifted to be consistent)
    - projects/asdf-e2e/ # original tests moved from asdf/e2e/
    - projects/something/ # generated from the command with migrate
    - projects/something-e2e/ # tests
    - angular.json # paths updated to reflect move
    - ...

@filipesilva
Copy link
Contributor

Related to #10929

@ngbot ngbot bot added this to the Backlog milestone Jan 24, 2019
@alan-agius4
Copy link
Collaborator

Hi, you can create a workspace without an application using the --create-application=false flag

See the docs for ng new here: https://angular.io/cli/new

If I am misunderstanding your needs kindly let me know.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular/cli feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

4 participants