ui5-community / ui5-ecosystem-showcase

A repository showcasing the UI5 tooling extensibility to combine OSS tools for UI5 application development.
https://ui5-community.github.io/ui5-ecosystem-showcase/
Other
194 stars 93 forks source link

[cds-plugin-ui5] Plugin also start when mocking a single service #950

Closed ghost closed 9 months ago

ghost commented 9 months ago

Describe the bug When using the mock function from cds: https://cap.cloud.sap/docs/guides/using-services#mock-remote-service-as-odata-service-node-js

The cds-plugin-ui5 also loads.

I would have assumed that the mock function should only provide the "backend ODATA service". I don't know if there is a "flag" or setting to ident that only the mocking is requested.

To Reproduce Steps to reproduce the behavior:

  1. start a "remote" service via "cds mock "
  2. beside the cds server also the ui5 plugin is startet

Expected behavior When mocking a single service only "backend" function should be loaded

petermuessig commented 9 months ago

I found a solution:

        // only for cds serve the cds-plugin-ui5 is active
        if (cds.cli?.command === "serve") {

When using cds serve or watch the cds.cli.command is serve - only then the plugin becomes active!

petermuessig commented 9 months ago

Fix is included in cds-plugin-ui5 version 0.8.1

ghost commented 9 months ago

Hi @petermuessig,

I did check out this changes, But now the plugin will not start at all in my wdi5 test (we start the server via cds.test(__dirname + "/../cap", "--in-memory", "--port", "4004");.

Here are some example what the cds.env looks on the current change

// only for cds serve the cds-plugin-ui5 is active
        if (cds.cli?.command === "serve") {

cli: cds mock s4_payint image

cli cds serve Screenshot 2024-02-19 070604

startet via: cds.test(__dirname + "/../cap", "--in-memory", "--port", "4004"); Screenshot 2024-02-19 070517

I guess:

regards Norbert

petermuessig commented 9 months ago

Hi @nlaenger ,

I think we'll add a fallback strategy - if the cds.cli.command isn't defined, we check the cds.options.service for defining all - this should do the necessary trick for now...