ui5-tooling icon indicating copy to clipboard operation
ui5-tooling copied to clipboard

`ui5 init` generates ui5.yaml with a wrong type: `type: library` instead of `type: application`

Open pubmikeb opened this issue 4 years ago • 4 comments

When I run ui5 init, it generates ui5.yaml with a wrong type: type: library instead of type: application, although in package.json it's written "type": "module".

Expected Behavior

ui5.yaml should contain type: application

Current Behavior

ui5.yaml contains type: library

Steps to Reproduce the Issue

  1. Install ui5-tooling globally
  2. Go in console to the root of the app, where package.json is located
  3. Run ui5 init
  4. I got type: library

Context

  • UI5 Module Version (output of ui5 --version when using the CLI): 2.12.1
  • Node.js Version: v17.0.0-v8-canary202108258414d1aed8
  • npm Version: 7.21.1
  • OS/Platform: Windows 10 21H1 x64
  • Browser (if relevant): not relevant
  • Other information regarding your environment (optional): nothing
{...}

pubmikeb avatar Aug 30 '21 21:08 pubmikeb

The "type" property within package.json is not related to the UI5 Tooling project types. In the package.json, it can be script or module, which refers to the type of JavaScript source files, where UI5 Tooling currently only supports script (at least out-of-the-box).

ui5 init tries to detect an existing project where a webapp folder is a hint for an application and src / test folders are associated with type library. This might not be correct in all cases and is just a basic assumption based on our default folders for those projects.

matz3 avatar Aug 31 '21 06:08 matz3

I assumed type: library is derived either from package.json "type": "module" or from manifest.json "type": "application" inside of the sap.app block. In my case, the UI5 source code is located in src/webapp, so don't know why UI5 Tooling decides type: library and not type: application. In manifest.json it is stated clear: "type": "application".

pubmikeb avatar Aug 31 '21 08:08 pubmikeb

As mentioned above, the type detection is only based on some basic assumptions and currently doesn't do any further analysis of the project files. See https://github.com/SAP/ui5-cli/blob/c33794909152162ed5a0471c3989ad220b2b0f24/lib/init/init.js#L28-L55

This could be improved to cover more cases like the one described by you (e.g. searching for a manifest.json file, detect the type, and configure the folders (e.g. src/webapp instead of the default webapp).

matz3 avatar Aug 31 '21 13:08 matz3

e.g. searching for a manifest.json file, detect the type, and configure the folders (e.g. src/webapp instead of the default webapp

IMO, a developer must provide a correct path to the manifest.json of the UI5 app (no need to guess it, just like npm does with package.json), then UI5 Tooling should derive an app type, based on the type value inside of the sap.app block.

pubmikeb avatar Aug 31 '21 13:08 pubmikeb