ui5-tooling
ui5-tooling copied to clipboard
`ui5 init` generates ui5.yaml with a wrong type: `type: library` instead of `type: application`
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
- Install ui5-tooling globally
- Go in console to the root of the app, where package.json is located
- Run
ui5 init - I got
type: library
Context
- UI5 Module Version (output of
ui5 --versionwhen 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
{...}
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.
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".
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).
e.g. searching for a
manifest.jsonfile, detect the type, and configure the folders (e.g.src/webappinstead of the defaultwebapp
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.