open-ux-tools
open-ux-tools copied to clipboard
TBI - Add options to the writers (considerations for CAP)
Description (include screenshots)
There is a need for more options to be available to determine what files and configs are added to the Fiori apps. In some cases there is a need to prevent certain files being added, or additional data is needed. See comments for details.
Value
Reduces the need to patch or modify the app and it's files post generation.
Architecture Elaboration
Yes
Notes
Tasks
- [ ] Task 1
Issue 1 - metadata.xml
Description : The writing of /localService/metadata.xml is not needed for CAP applications and can be skipped in the writing phase.
Proposal : Add a property to prevent this file being written.
Question : Is the call to the odata service writer required at all? Or we should just prevent the file being written here
Issue 2 - typeRoots
Description : Currently the paths for the type roots are hardcoded. In the case where the node_modules folder containing the required types is in a parent folder, the types are not found resulting in errors in .ts files.
Proposal : Add an additional property e.g projectRoot to the App interface
Issue 3 - proxy middleware + opa tests
Description : If the proxy middleware is not wanted, rather than removing it post generation, provide an option to prevent this being written to the yaml files. The ui5-test-writer would then require additional params, i.e the framework url e.g https://ui5.sap.com and the ui5 version. These would be added diretly to the opaTests.qunit.html
Proposal : Add an additional property e.g addProxyMiddleware to the App options
, which would default to true. In the case that it is false, do not add the proxy middleware config and pass the framework url and ui5version to the ui5-test-writer.
Question : The testsuite.qunit.html uses the qunit-redirect.js which I've been unable to get working without a proxy. So I'm wondering can this work without a proxy, or it should be not written at all in that case.
@devinea @tobiasqueck any feedback is appreciated
@cianmSAP @devinea
I don't think that Issue 2 is properly solvable the way you want to do it (or at all). The types will be in the root of the CAP project if there is only one typescript project or if all projects refer to the very same version. However, if two (or more) projects refer to different versions, then all but the first project will have the types in their local node_modules folder.
So, I don't think using typeRoots at all is a good idea. Could we please revisit why we changed it from types to typeRoots and consider finding a better solution using types.
I am also not to sure about Issue 3. For the normal preview, we decided not to use a local preview script but added a script to the root project starting the CAP server including our project. Shouldn't we follow the same approach for the OPA tests? I'd assume these are also started with the CAP server, just with a different url to be opened.
Question : Is the call to the odata service writer required at all? Or we should just prevent the file being written here
The line isn't executed if no metadata is provided by the caller. See: https://github.com/SAP/open-ux-tools/blob/11bb8fa9148a4162bc7ac32e2fc24b7530fcea32/packages/odata-service-writer/src/index.ts#L106
So, the odata-service-writer, does not need to be modified, just don't provide the metadata when calling it.
Maybe also consider https://github.com/ui5-community/ui5-ecosystem-showcase/tree/main/packages/ui5-middleware-cap for the OPA tests.
I am also not to sure about
Issue 3. For the normal preview, we decided not to use a local preview script but added a script to the root project starting the CAP server including our project. Shouldn't we follow the same approach for the OPA tests? I'd assume these are also started with the CAP server, just with a different url to be opened.
I'm not sure how adding a script to open the file would solve the issue?
The .html files testsuite.qunit.html and opaTests.qunit.html in the ui5-test-writer use scripts with relative paths .. which (corret me if I'm wrong) is assuming that there is a proxy that will leverage the test scripts @ ui5.sap.com or sapui5.hana.ondemand.com
The ui5.yamls for cap is minimal, with no proxy config (I'm trying to prevent it being written rather than remove it post generation in https://github.com/SAP/open-ux-tools/pull/1533).
So the issue being, we are generating these files which point to external files which can't be found without the proxy
I'm not sure how adding a script to open the file would solve the issue?
You are completely correct. I was wrongly assuming that the cds server comes with a UI5 proxying but it doesn't. I got confused about how we handle loading of typescript apps in cap using the new cds-ui5-plugin
Closing as issue 1 has been resolved, and the other two issues are being discussed seperately