SAP / generator-easy-ui5

Meta-generator various project types within the UI5 Universe
https://blogs.sap.com/2021/04/09/easy-ui5-3.0-from-community-contributions-to-community-plugins/
Apache License 2.0
230 stars 72 forks source link

feat: support nesting of generators #141

Closed petermuessig closed 5 months ago

petermuessig commented 6 months ago

Sub generators can include nested generators as a static property which are resolved and installed automatically by Easy UI5 and finally executed in a chain after the root generator and the sub generator.

export default class extends Generator {
    static displayName = "Create a new UI5 application";
    static nestedGenerators = [ "wdi5", "library:app" ];

Just describe the subgenerator name as you would specify it when using Easy UI5 and if you want to address a dedicated generator in the subgenerator, just use the namespace syntax defining the dedicated generator with the :.

petermuessig commented 6 months ago

@nicoschoenteich @vobu - this extension of the Easy UI5 generator allows to configure nested generators in generators to chain the execution. This feature also switches from env.run to composeWith to embed the nested generators into the run of the Easy UI5 generator. But I needed to add a delegator to forward destination root changes, e.g. the typical generators app, ts-app are changing the destination root and this must be delegated to any follow up execution... Therefore, I injected a hidden delegator generator...

petermuessig commented 5 months ago

@nicoschoenteich @vobu I needed to go back to env.run to ensure that the subgenerators make use of their dependencies rather than of the dependencies of the root generator. As I found a good way to intercept the generator executions and to determine the destinationRoot I can also ensure to pass it properly in between the generators.