angular_devkit schematics must be boolean input validation error
See original GitHub issue๐ Bug report
Command (mark with an x
)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- lint
- extract-i18n
- run
- config
- help
- version
- doc
Is this a regression?
i dont know
Description
I am trying to use the schematics cli to generate templates, since the templates are not for angular projects they are for broader use cases.
I am running into an issue when trying to use boolean values in the schematics cli. Whenever I try to pass a value for a boolean property it seems to interpret it as a string instead. โx-promptโ seems to handle it however I was wondering if there is a solution or work around that does not involve using any prompts.
A clear and concise description of the problem...Here is an example cli command that is failing for me. schematics .:test-generate-file --name foo --transform=true
Error: Error: Schematic input does not validate against the Schema: {โtransformโ:โtrueโ,โnameโ:โfooโ} Errors:
Data path โ/transformโ must be boolean. at MapSubscriber.project (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/schema-option-transform.js:30:27) at MapSubscriber._next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/map.js:49:35) at MapSubscriber.Subscriber.next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18) at ThrowIfEmptySubscriber._next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/throwIfEmpty.js:44:26) at ThrowIfEmptySubscriber.Subscriber.next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18) at TakeSubscriber._next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/take.js:54:30) at TakeSubscriber.Subscriber.next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18) at MergeMapSubscriber.notifyNext (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/mergeMap.js:93:26) at SimpleInnerSubscriber._next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/innerSubscribe.js:27:21) at SimpleInnerSubscriber.Subscriber.next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18)
๐ฌ Minimal Reproduction
-
Create a schematic schematics blank --name foo
-
Inside src/foo create a schema.json something like this: { โ$schemaโ: โhttp://json-schema.org/schemaโ, โ$idโ: โfooโ, โtitleโ: โschemaโ, โtypeโ: โobjectโ, โpropertiesโ: { โnameโ: { โdescriptionโ: โuniversal nameโ, โtypeโ: โstringโ, โ$defaultโ: { โ$sourceโ: โargvโ, โindexโ: 0 }, }, โtransformโ: { โtypeโ: โbooleanโ, โdefaultโ: false } }, โrequiredโ: [ โnameโ ], โadditionalPropertiesโ: false }
-
Then in the collection.json set a schema property inside foo { โ$schemaโ: โโฆ/node_modules/@angular-devkit/schematics/collection-schema.jsonโ, โschematicsโ: { โfooโ: { โdescriptionโ: โA blank schematic.โ, โfactoryโ: โ./foo/index#fooโ, โschemaโ: โfoo/schema.jsonโ } } }
-
After that npm run build
-
Then finally run the schematic command to try to run it schematics .:foo --name foo --transform=true
๐ฅ Exception or Error
Error: Schematic input does not validate against the Schema: {"transform":"true","name":"foo"}
Errors:
Data path "/transform" must be boolean.
at MapSubscriber.project (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/schema-option-transform.js:30:27)
at MapSubscriber._next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/map.js:49:35)
at MapSubscriber.Subscriber.next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18)
at ThrowIfEmptySubscriber._next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/throwIfEmpty.js:44:26)
at ThrowIfEmptySubscriber.Subscriber.next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18)
at TakeSubscriber._next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/take.js:54:30)
at TakeSubscriber.Subscriber.next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18)
at MergeMapSubscriber.notifyNext (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/mergeMap.js:93:26)
at SimpleInnerSubscriber._next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/innerSubscribe.js:27:21)
at SimpleInnerSubscriber.Subscriber.next (/home/tokuj/.nvm/versions/node/v14.15.5/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/Subscriber.js:66:18)
๐ Your Environment
Anything else relevant?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
You are correct. Yesterday I found that if you want to set false flag you can do this:
--no-transform
oh wow that worked thank you for the fast response