angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.73k stars 11.98k forks source link

ng help generators doesn't explain how to use generators #8266

Closed leff closed 5 years ago

leff commented 6 years ago

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.4.9 node: 7.10.1 os: darwin x64 @angular/animations: 4.4.6 @angular/common: 4.4.6 @angular/compiler: 4.4.6 @angular/core: 4.4.6 @angular/forms: 4.4.6 @angular/http: 4.4.6 @angular/platform-browser: 4.4.6 @angular/platform-browser-dynamic: 4.4.6 @angular/router: 4.4.6 @angular/cli: 1.4.9 @angular/compiler-cli: 4.4.6 @angular/language-service: 4.4.6 typescript: 2.3.4

Repro steps.

  1. Type ng help generators

The log given by the failure.

Output:

Available schematics:
    application
    class
    component
    directive
    enum
    guard
    interface
    module
    pipe
    service

ng generate <schematic> <options...>
  Generates and/or modifies files based on a schematic.
  aliases: g
  --dry-run (Boolean) (Default: false) Run through without making any changes.
    aliases: -d, --dryRun
  --force (Boolean) (Default: false) Forces overwriting of files.
    aliases: -f, --force
  --app (String) Specifies app name to use.
    aliases: -a <value>, -app <value>
  --collection (String) Schematics collection to use.
    aliases: -c <value>, --collection <value>
  --lint-fix (Boolean) Use lint to fix files after generation.
    aliases: -lf, --lintFix

This is apparently how to use the generators:

ng generate <schematic> <options...>

The problem is, that <options...> is undefined.

What is really needed is a module name, but it looks like all the --<options> are the options.

If you fail to enter a module name the output looks like this:

$ ng generate component
Cannot read property 'split' of undefined
TypeError: Cannot read property 'split' of undefined
    at Class.run (/Users/jasonb/telnyx/semantic-ui-test/node_modules/@angular/cli/commands/generate.js:109:63)
    at resolve (/Users/jasonb/telnyx/semantic-ui-test/node_modules/@angular/cli/ember-cli/lib/models/command.js:261:20)
    at Class.validateAndRun (/Users/jasonb/telnyx/semantic-ui-test/node_modules/@angular/cli/ember-cli/lib/models/command.js:240:12)
    at Promise.resolve.then.then (/Users/jasonb/telnyx/semantic-ui-test/node_modules/@angular/cli/ember-cli/lib/cli/cli.js:140:24)

Of course, none of the listed options will help on their own. You need to give it a name.

Desired functionality.

  1. Rewrite the ng help generators text to show that you need to provide a name.
  2. Fix the generators themselves to give better error messages.

Mention any other details that might be useful.

filipesilva commented 6 years ago

I think @Brocco was fixing this in https://github.com/angular/angular-cli/pull/8255. Can you confirm @Brocco ?

alan-agius4 commented 5 years ago

Closing as this has been addressed in version 7 RC 2.

angular-automatic-lock-bot[bot] commented 5 years ago

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.