You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Conditional “X-Prompt” in Angular Schematics #18578
I have the same goal but a different proposal. Instead of increasing the basic schema.json feature-set, I'd rather use a second function-driven API. I believe adding a condition API to a json file will increase the complexity tremendously.
Here's a proposal. It certainly contains lots of flaws and is meant as a start to discuss further possible approaches.
Having an interface in the user code is intentional. Right now, if I am writing a schematic, the input properties are not typed and I need to manage two lists of inputs in parallel (schema.json inputs / schematic factory code input type)
Any thoughts on this? Or maybe disagreement to a TS API? 🙂
I think you are correct that there is potential for the json to become unwieldy. However, the json approach seems like it would be more consistent and simpler to author, for most use cases. Maybe there's a case for beginning with json and allow for more powerful use cases to use what you suggest?
Angular currently uses AJV for validation and running the registry. Looking through the code I cant see it being to difficult to add support for a typed implementation.
With that said I think to add xprompt support its changing the code around this section
Using #22242 as the canonical issue here around the general feature request of "making schematics options more dynamic". Exposing the if/then syntax of JSON schema is probably too specific to this particular dependency and tricky to reason about. Most likely this would like a TypeScript API to prompt users imperatively.
angular-automatic-lock-bot commented on Sep 4, 2022
Activity
[-]Conditional “X-Prompt” in Angular Scehmatics[/-][+]Conditional “X-Prompt” in Angular Schematics[/+]Stupidism commentedon Dec 16, 2020
Any progress or workaround?
kroeder commentedon Aug 23, 2021
I have the same goal but a different proposal. Instead of increasing the basic schema.json feature-set, I'd rather use a second function-driven API. I believe adding a condition API to a json file will increase the complexity tremendously.
Here's a proposal. It certainly contains lots of flaws and is meant as a start to discuss further possible approaches.
collection.json
{ "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json", "dynamic-generate-props": { "description": "Dynamic inputs", "factory": "./dynamic/index#dynamicSchematic", "schema": "./dynamic/schema#conditionalInputs" } } }dynamic/schema.ts#conditionalInputs
Angular framework (pseudo code)
Having an interface in the user code is intentional. Right now, if I am writing a schematic, the input properties are not typed and I need to manage two lists of inputs in parallel (schema.json inputs / schematic factory code input type)
Any thoughts on this? Or maybe disagreement to a TS API? 🙂
tomeustace commentedon Aug 27, 2021
I think you are correct that there is potential for the json to become unwieldy. However, the json approach seems like it would be more consistent and simpler to author, for most use cases. Maybe there's a case for beginning with json and allow for more powerful use cases to use what you suggest?
kroeder commentedon Aug 27, 2021
Exactly! I might have not been clear enough
My intention was to allow two types of schema sources.
Json: easy to use for easy use cases
Ts: advanced use cases, leaving the easy to use area (though, with a good api it could still be easy enough)
angular-robot commentedon Feb 2, 2022
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
Jordan-Hall commentedon Feb 12, 2022
This wouldn't exactly be increasing the schema.json rather than implementing draft-7 of Json schema.
As for your typing solution https://ajv.js.org/guide/schema-language.html#json-type-definition I imagine that would be good enough.
Angular currently uses AJV for validation and running the registry. Looking through the code I cant see it being to difficult to add support for a typed implementation.
With that said I think to add xprompt support its changing the code around this section
angular-cli/packages/angular_devkit/core/src/json/schema/registry.ts
Line 360 in fafb9dd
Jordan-Hall commentedon Feb 12, 2022
@Ankit-sagar32 have you tried this way:
I know officially documentation says it should us const. But AJV says this is the way.
dgp1130 commentedon Aug 4, 2022
Duplicate of #22242
dgp1130 commentedon Aug 4, 2022
Using #22242 as the canonical issue here around the general feature request of "making schematics options more dynamic". Exposing the if/then syntax of JSON schema is probably too specific to this particular dependency and tricky to reason about. Most likely this would like a TypeScript API to prompt users imperatively.
angular-automatic-lock-bot commentedon Sep 4, 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.