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

"New view" generator doesn't work in existing UI5 projects #17

Closed IObert closed 2 years ago

IObert commented 2 years ago

Easy-Ui5 version:

Steps to reproduce the problem:

  1. Clone the sample repo https://github.com/SAP/openui5-sample-app
  2. Run yo easy-ui5 project newview in there.

What is the expected result?

That it prompts the right questions

What happens instead?

Starts with the question "To which module do you want to add a view?"

Any other information? (attach screenshot if possible)

Originally report in the SAP Community

octavonu commented 2 years ago

HI, I am encountering the same issue.

Thank you

yo easy-ui5 project newview image

octavonu commented 2 years ago

Hello @IObert ,

Thank you very much for your update.

Now it is working as desired. One small glitch, the generator doesn't recognise itself...or?

The project was generated with Easy-UI5 for ts. What have I done wrong, I cannot understand.

VG

image

wridgeu commented 2 years ago

Seems like this has something to do with the difference of content within the .yo-rc.json file. Which differentiates between the (technically) two used generators.

Typescript generator (https://github.com/ui5-community/generator-ui5-ts-app)

{
  "generator-ui5-ts-app": {
    "application": "myapp",
    "namespace": "com.myorg",
    "framework": "OpenUI5",
    "frameworkVersion": "1.90.1",
    "author": "Some Name",
    "tstypes": "@openui5/ts-types-esm",
    "tstypesVersion": "1.90.1",
    "appId": "com.myorg.myapp",
    "appURI": "com/myorg/myapp",  
    "setupCompleted": true
  }
}

"Normal" generator (https://github.com/ui5-community/generator-ui5-project)

{
  "generator-template-ui5-project": {
    "projectname": "ui5learning",
    "namespaceUI5": "com.myorg",
    "platform": "Static webserver",
    "viewtype": "XML",
    "ui5libs": "Content delivery network (OpenUI5)",
    "newdir": false,
    "codeassist": true,
    "namespaceURI": "com/myorg",
    "opa5pos": [
      "Main"
    ],
    "opa5Journeys": [
      "Main"
    ],
    "uimodules": [
      "uimodule"
    ],
    "setupCompleted": true
  }
}

The normal generator is looking for a few attributes (e.g. viewtype) and as it can't find any, it starts with the regular prompting as can be seen here https://github.com/ui5-community/generator-ui5-project/blob/main/generators/newview/index.js#L62

Looks to me like an adjustment has to be made within the ts-generator except @IObert would prefer taking this different config into account within the newview subgenerator?

IObert commented 2 years ago

I would say this behavior is intended (at least for now). If we'd support this, there had to be some TS logic in ui5-project as well to make sure to generate TS code when used in the other context. And this would basically merge both plugins in one - which would violate the original design choice that @petermuessig and I made.

But that doesn't mean this decision is set in stone.