SAP / open-ux-tools

Enable community collaboration to jointly promote and facilitate best in class tooling capabilities
Apache License 2.0
83 stars 35 forks source link

FEATURE - command to remove the local flpSandbox.html and use the preview-middleware instead #2172

Open tobiasqueck opened 2 months ago

tobiasqueck commented 2 months ago

As a developer, I want to get rid of the flpSandbox.html file in my webapp/test folder and use the on-the-fly generated one from the preview-middleware instead, so that I I don't have to worry about keeping it up-to-date

Description

Currently (but soon to be changed), a generated Fiori application project contains a file at webapp/test/flpSandbox.html that is used to locally preview the application but is not used productively. This file has evolved over time - especially to get it ready for UI5 2.0 - therefore, as an owner of an older project, I need to keep it update to date. In the future, this file will not be generated into new projects anymore, instead it is generated on-the-fly by the preview middleware. This feature request is to allow remove the file and update the configurations of an existing project, so that this file isn't required anymore.

Technical Design

Enhance the @sap-ux/create module with a new command sap-ux delete flp which then

  1. deletes webapp/test/flpSandbox.html and webapp/test/locate-reuse-libs.js
  2. reads from the scripts in the package.json what configuration should be used
  3. adds/updates the configuration of the preview-middleware
  4. updates the scrips in the package.json if required

Acceptance Criteria

GivenWhenThen format (https://martinfowler.com/bliki/GivenWhenThen.html)

Given I have an existing Fiori application project with the deprecated middleware config and an flpSandbox file ... when I execute sap-ux delete flp then then the ui5*.yaml files, and the package.json will change so that they work with the local flpSandbox, and the obsolete files are removed.

Notes

Assuming a project has following scripts in thepackage.json

{
   "start": "fiori run --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false#v2rop-tile\"",
    "start-local": "fiori run --config ./ui5-local.yaml --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false#v2rop-tile\"",
    "build": "ui5 build --config=ui5.yaml --clean-dest --dest dist",
    "start-mock": "fiori run --config ./ui5-mock.yaml --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false#v2rop-tile\"",
    "deploy": "fiori verify",
    "deploy-config": "fiori add deploy-config",
    "start-noflp": "fiori run --open \"index.html?sap-ui-xx-viewCache=false\"",
    "start-variants-management": "fiori run --open \"preview.html?sap-ui-xx-viewCache=false&fiori-tools-rta-mode=true&sap-ui-rta-skip-flex-validation=true#preview-app\""
}

and following configuration in the ui5*.yaml files

- name: fiori-tools-preview
  afterMiddleware: fiori-tools-appreload
    configuration:
      component: v2rop
      ui5Theme: sap_horizon

Then after executing the script, the files will be

{
    "start": "fiori run --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false#v2rop-tile\"",
    "start-local": "fiori run --config ./ui5-local.yaml --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false#v2rop-tile\"",
    "build": "ui5 build --config=ui5.yaml --clean-dest --dest dist",
    "start-mock": "fiori run --config ./ui5-mock.yaml --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false#v2rop-tile\"",
    "deploy": "fiori verify",
    "deploy-config": "fiori add deploy-config",
    "start-noflp": "fiori run --open \"index.html?sap-ui-xx-viewCache=false\"",
    "start-variants-management": "fiori run --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false&fiori-tools-rta-mode=true&sap-ui-rta-skip-flex-validation=true#v2rop-tile\""
}
- name: fiori-tools-preview
  afterMiddleware: fiori-tools-appreload
    configuration:
      flp:
         path: /test/flpSandbox.html
         intent:
            object: v2rop
            action: tile
         theme: sap_horizon

Tasks

cfg74 commented 1 month ago

@tobiasqueck @ytpo-lyne @heimwege some comments.

heimwege commented 1 month ago

@cfg74 If we keep files (and renaming them) we should at least inform the user about the changed name and the fact that they are no longer needed and can be deleted. But what's the value in keeping this file?

What about deleting the existing tests/testsuite glue code and serving this as well? Is this out of scope?

cfg74 commented 1 month ago

@heimwege Yes, information is key. I'm always cautious with files potentially including modifications by the customers, renaming is safe.

Good point about test suite, haven't discussed with @tobiasqueck about this yet or can't remember a decision. Will check with him. Do we have an eject for the test related files? This would be a pre-requisite for transition.

heimwege commented 1 month ago

@cfg74 at least tests are explicitly mentioned in the readme of the create module. So I would say yes. But seems to eject only the html files, not the js files from what I just saw in the code.