Skip to content

Unnecessary prompts for ng new when using create application false (i.e. Conditional Prompts) #13383

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
DenysVuika opened this issue Jan 8, 2019 · 13 comments · Fixed by #15207
Labels
area: @schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Milestone

Comments

@DenysVuika
Copy link

Bug Report or Feature Request (mark with an x)

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

Command (mark with an x)

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

Versions

CLI: 7.1.4

Repro steps

Generating workspace without application still causes questions about the app:

ng new myapp --create-application=false
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS

CREATE myapp/README.md (1027 bytes)
CREATE myapp/angular.json (135 bytes)
CREATE myapp/package.json (1262 bytes)
CREATE myapp/tsconfig.json (435 bytes)
CREATE myapp/tslint.json (2824 bytes)
CREATE myapp/.editorconfig (246 bytes)
CREATE myapp/.gitignore (576 bytes)

The log given by the failure

Desired functionality

The CLI should not ask questions about application it is not going to generate anyway.

Mention any other details that might be useful

@alan-agius4 alan-agius4 reopened this Jan 8, 2019
@alan-agius4 alan-agius4 added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely area: @schematics/angular labels Jan 8, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jan 8, 2019
@DenysVuika
Copy link
Author

@alan-agius4 you can get the info via

ng new --help

--create-application 
    When true (the default), creates a new initial app project in the new workspace.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jan 8, 2019

@DenysVuika, apologies, re-opened.

@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jan 8, 2019
@Splaktar
Copy link
Contributor

There are actually a range of different issues related to --create-application=false. It needs a good deal of cleanup.

For example, it's not expected that ng new --create-application=false --styles=scss --routing=false would accept the styles and routing options and then completely ignore them. They don't get added to the angular.json, so a subsequent ng g app myapp gets generated with .css files.

If these options aren't compatible with --create-application=false (which I believe is the case since there is no spot to put them in angular.json for an empty workspace), then this should be documented and there should be a warning or error message when trying to use them together.

Here's an empty workspace angular.json for reference:

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

This testing was done with 7.3.6. @alan-agius4 it sure would be nice to get this cleaned up for version 8 where we add --create-application=false to the official docs.

@alan-agius4 alan-agius4 changed the title create-application flag not handled correctly Unnecessary prompts for ng new when using create application false (i.e. Conditional Prompts) Apr 3, 2019
@hmagrini
Copy link

Hello!

@FrozenPandaz and I were discussing another use case for Conditional Prompts on the Nx repo (see nrwl/nx#1211) which could be achievable via Inquirer's when option.

However, we wanted to move that discussion here since the implementation seemed less trivial than we thought for our particular use case. Given the way the x-prompt schema is defined, if we wanted to only ask questions based on previous answers we would need to define "optional" properties on the schematic's schema (example here: nrwl/nx#1211 (comment)).

AFAICT using the when option could also help towards solving the issue described on this ticket without further complexity, but let me know if I should open a separate ticket to specifically address the use case described on the Nx issue :)

@ahasall
Copy link
Contributor

ahasall commented Jun 2, 2019

I think many of issues related to --create-application=false can be solved by moving some prompts from the ng new schematic to the application schematic where they truly belong.

I have started experimenting with this in this draft PR.

Should I continue working on this issue?

ahasall added a commit to ahasall/angular-cli that referenced this issue Jun 2, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jun 2, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jun 2, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jun 7, 2019
…outing and --style

This is the first step towards solving issue related to angular#13383

closes angular#14705
ahasall added a commit to ahasall/angular-cli that referenced this issue Jun 26, 2019
…outing and --style

This is the first step towards solving issue related to angular#13383

closes angular#14705
@roddy
Copy link

roddy commented Jul 14, 2019

Late to the party, but I just experienced this today (I've never used a workspace before). When it prompted me to select the preferred stylesheet format, I assumed that this would be a default automatically applied or inherited by all subsequent projects. This assumption was reinforced when I called generate application and it did not prompt me ... but then the application it created used the default (css) instead of what I selected on the workspace creation (scss).

So while the obvious fix would be to remove the prompts entirely, a potentially useful alternative would be to inherit the workspace's configuration in generated child projects. (Global configuration, as far as I understand, is one of the benefits of using workspaces for multiple projects...)

Just laying this out there; I didn't want to open a new ticket since this one was already open.

@Splaktar
Copy link
Contributor

If this issue is affecting you, please 👍 the first post.

ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 22, 2019
…outing and --style

This is the first step towards solving issue related to angular#13383

closes angular#14705
ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 25, 2019
…outing and --style

This is the first step towards solving issue related to angular#13383

closes angular#14705
vikerman pushed a commit that referenced this issue Jul 29, 2019
…outing and --style

This is the first step towards solving issue related to #13383

closes #14705
@Splaktar
Copy link
Contributor

The application schematic now supports --routing and --style thanks to PR #14638.

Next we need to update the ng new schematic prompting.

@ahasall
Copy link
Contributor

ahasall commented Jul 30, 2019

Yes, I am currently working on it :)

@ahasall
Copy link
Contributor

ahasall commented Jul 30, 2019

I just made a PR #15207 to solve this issue 🙂.

@ahasall
Copy link
Contributor

ahasall commented Jul 30, 2019

For now all unit tests are green but e2e tests are red :(

ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 30, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 30, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 30, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 30, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 31, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 31, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 31, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 31, 2019
ahasall added a commit to ahasall/angular-cli that referenced this issue Jul 31, 2019
@Splaktar
Copy link
Contributor

Splaktar commented Aug 1, 2019

All looks good in the PR now! Thank you.

@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: @schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
6 participants