Repository navigation
Description
📚 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,bazor 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
🔥 Exception or Error
see above image / pasted output.

Activity
d-koppenhagen commentedon Nov 15, 2019
I tried out some modifications but they lead to the same result:
schema.d.ts:
schema.json:
{ "$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, "minItems": 1, "items": { "enum": ["commitlint", "commitizen", "husky", "standard-version"], "type": "string" }, "default": ["commitlint", "commitizen", "husky", "standard-version"], "x-prompt": "What packages do you want to be installed and configured?" }, }, }d-koppenhagen commentedon Nov 26, 2019
I wonder why it works for
--implementswithin guard creation. Maybe the magic is hidden in theschema.d.tswhich is unfortunately not checked in. But there are two things imported here: https://github.com/angular/angular-cli/blob/9.0.x/packages/schematics/angular/guard/index.ts#L25Would you mind to share the content of
schema.d.ts?d-koppenhagen commentedon Nov 26, 2019
Okay, I just forked the angular-cli project and built it locally. The schema produced for the guard seems to look basically like this:
I tried to copy the schema and implementation into a very simple example repo:
https://github.com/d-koppenhagen/ngx-multi-select-schematic
But the result will be the same as described in the original issue text. Probably it's a bug and not just a not documented feature?
kapunahelewong commentedon May 27, 2020
Update: Docs team would like engineering input here on what exactly to document and/or fix in the current documentation. Thank you!
docs: add how to pass array options to the CLI (#46505)
angular-automatic-lock-bot commentedon Jul 28, 2022
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.