Skip to content

Add missing documentation for using schematics with array options #33851

Closed
@d-koppenhagen

Description

@d-koppenhagen

📚 Docs or angular.io bug report

Description

Hello! my recently opened issue angular/angular-cli#16104 has been closed (thanks for fixing it!) Unfortunatly I couldn't find any point for how to set multi select options via command line in the docs.
My expectation was to do it this way:

ng add packageName --param=foo,bar,baz

or something similar but I tried out a lot of ways without getting it working.
I expected to find it in the @next branch for angular.io -- maybe in the guards section (https://next.angular.io/cli/generate#guard-command : as --implements is using it) but it seems not to be documented there as well currently.

Playing a bit around, I found out that this seems to be the solution:

ng g g foo-bar --implements="CanActivate, CanLoad"

This should be documented better. However trying to implement this behaviour the same way failed for some reason.
When I configure my schematic this way:

{
  "$schema": "http://json-schema.org/schema",
  "id": "ngx-semantic-version",
  "title": "ngx-semantic-version Schema",
  "description": "configure commitlint, husky, commitizen and standard-version configuration",
  "type": "object",
  "properties": {
    "packages": {
      "type": "array",
      "description": "select the packages that should to be installed and configured",
      "uniqueItems": true,
      "items": {
        "type": "string"
      },
      "default": ["commitlint", "commitizen", "husky", "standard-version"],
      "x-prompt": {
        "message": "What packages do you want to be installed and configured?",
        "type": "list",
        "multiselect": true,
        "items": ["commitlint", "commitizen", "husky", "standard-version"]
      }
    },
  },
  "required": ["packages"]
}

and I run my schematic locally using schematics .:ng-add --debug=false --packages="commitlint, husky", I will receive the following output:

Error: Schematic input does not validate against the Schema: {"packages":"commitlint, husky"}
Errors:

  Data path ".packages" should be array.
    at MapSubscriber.registry.compile.pipe.operators_1.map.result [as project] (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/schema-option-transform.js:31:27)
    at MapSubscriber._next (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/map.js:49:35)
    at MapSubscriber.Subscriber.next (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18)
    at ThrowIfEmptySubscriber._next (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/throwIfEmpty.js:44:26)
    at ThrowIfEmptySubscriber.Subscriber.next (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18)
    at TakeSubscriber._next (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/take.js:54:30)
    at TakeSubscriber.Subscriber.next (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18)
    at MergeMapSubscriber.notifyNext (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/mergeMap.js:92:26)
    at InnerSubscriber._next (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/InnerSubscriber.js:28:21)
    at InnerSubscriber.Subscriber.next (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18)

🔬 Minimal Reproduction

see above descriptions or https://github.com/d-koppenhagen/ngx-semantic-version/tree/ng9

What's the affected URL?**

https://next.angular.io

📷Screenshot

Screen Shot 2019-11-15 at 12 30 35

🔥 Exception or Error

see above image / pasted output.

🌍 Your Environment

Browser info

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions