ui5-community / generator-ui5-project

Generator for UI5-based web-apps which use the official UI5 tooling and support multiple deployment targets such as the SAP Business Technology Platform
Apache License 2.0
33 stars 25 forks source link

Being composable from other generators #5

Closed dh4rry closed 3 years ago

dh4rry commented 3 years ago

I would like to reuse the sub generators e.g. (newwebapp) in my custom generator (wich is a seperate node project not a fork of this one).

For that I use " this.composeWith" method like this (config contains everything that is also be present at that main generator app/index.js:

    async writing() {
        const oConfig = this.config.getAll();
        const oSubGen = Object.assign({}, oConfig);
        oSubGen.isSubgeneratorCall = true;
        oSubGen.cwd = this.destinationRoot();
        oSubGen.modulename = "";
        this.composeWith(require.resolve("generator-template-ui5-project/generators/newwebapp"), oSubGen);
    }

The problem is that the configs are separeted for each generator (so my custom generator cannot add configs to "generator-template-ui5-project" config). At the moment lot of Information can be passed via options, but not all. The newwebapp subgenerater composes opa5 generater and only transfers "namespaceInput" from the config (via this.options.oneTimeConfig) and not from the options.

This will later result in this Error:

TypeError: Cannot read property 'split' of undefined at module.exports.prompting (/mnt/c/Users/hwa/Documents/generator-ui5wrap/node_modules/generator-template-ui5-project/generators/opa5/index.js:21:83)`

IObert commented 3 years ago

I'll close this as the PR is merged.

PS: Do you want to reuse the logic in a private custom generator? It's fine if that's your plan. But in case it's public, I'd be interested to learn about this project as well.

dh4rry commented 3 years ago

The custom generator (at this point of time) only contains internal things (like preset of the namespace, custom favicon ...) and is private. If there will be something relevant for the community, I'm going to share this (via PR or separate (sub) generator project)

IObert commented 3 years ago

Awesome!

IObert commented 3 years ago

I reopen this because I had to revert the commit. There as an issue with the automation test (they essentially didn't run) which is fixed now (c82d213).

My message from the PR:

Sorry, I had to roll back your changes as they broke the generator. It is strange that the automation tests didn't find this.

I'll have a look at the exact cause tomorrow and try to make sure that the tests catch something like this. Can you please address the original issue (SAP/generator-easy-ui5#75) and open another PR?