GeezerVison is showing github.com — Boolean options not parsed correctly on schematics cli · Issue #12150 · angular/angular-cli
Boolean options not parsed correctly on schematics cli #12150DescriptionFrom @TinyMan on January 14, 2018 17:11
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Area
- [x] devkit
- [ ] schematics
Versions
Repro steps
> schematics @schematics/angular:module --name test --routing true
The log given by the failure
Schematic input does not validate against the Schema: {"name":"test","routing":"true","path":"app","sourceDir":"src","routingScope":"Child","spec":true,"flat":false,"commonModule":true}
Errors:
.routing should be boolean
Desired functionality
Boolean options should be parsed.
Right now it is true if only --routing is specified but it fails with --routing false or --routing true.
For --routing option it is not really a problem because by default it is false: we can set it to true with --routing.
However it is blocking for custom schematics with boolean option that defaults to true: we can't set it to false.
Mention any other details that might be useful
Only the arguments specified here are parsed as booleans:
https://github.com/angular/devkit/blob/c88d991344a910903c2178b537a919c9da2de03f/packages/angular_devkit/schematics_cli/bin/schematics.ts#L102
After this minimist assigns the string "true" or "false" to the option hence the error.
Copied from original issue: angular/devkit#393 Reacted by Michael Prentice, Vladislav Volkov, softoika, Mathias Boeck, Brian Via, Ben Congdon, Brian Mikinski, wolmeister, Dheepan Raju, janv93 and 1 more Activitydxvladislavvolkov commented on Sep 25, 2018 musou1500 commented on Sep 27, 2018 How about using coerceTypes option?
here is a coercion rules https://github.com/epoberezkin/ajv/blob/master/COERCION.md
The patch will be as follows.
diff --git a/packages/angular_devkit/core/src/json/schema/registry.ts b/packages/angular_devkit/core/src/json/schema/registry.ts
index 06321af8..5638fa08 100644
--- a/packages/angular_devkit/core/src/json/schema/registry.ts
+++ b/packages/angular_devkit/core/src/json/schema/registry.ts
@@ -115,6 +115,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
loadSchema: (uri: string) => this._fetch(uri),
schemaId: 'auto',
passContext: true,
+ coerceTypes: true
});
this._ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));added a commit that references this issue on Mar 2, 2022This issue will close once commit 5330d52 is merged into the 'main' branch.5330d52 angular-automatic-lock-bot commented on Apr 2, 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|