Skip to content

Extract preview-middleware client code into separate module #1261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Sep 7, 2023

Conversation

tobiasqueck
Copy link
Contributor

@tobiasqueck tobiasqueck commented Sep 5, 2023

This PR extracts the sandboxInit.js from preview-middleware/templates into a separate private module allowing to test this file and to write it in typescript.

Details

  • new module preview-middleware-client
  • converting preview-middleware/templates/sandboxInit.js to preview-middleware-client/src/flp/init.ts
  • adding jest tests
  • moving the types/sapui5 also into this new module since they will only be required here (and having them centrally caused lots of instability with the ts language server)

@tobiasqueck tobiasqueck requested review from a team as code owners September 5, 2023 15:12
@changeset-bot
Copy link

changeset-bot bot commented Sep 5, 2023

🦋 Changeset detected

Latest commit: 85dd077

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@sap-ux/preview-middleware Patch
@sap-ux-private/preview-middleware-client Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@zdravko-georgiev
Copy link
Contributor

Getting a warning about peer dependencies when doing pnpm install in this branch.
image

Copy link
Contributor

@zdravko-georgiev zdravko-georgiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please take care of the code smells?

@tobiasqueck
Copy link
Contributor Author

Could you please take care of the code smells?

I cannot fix the chaining 'smells' because that is not supported in UI5 :(. I marked them as won't fix.
The cognitive complexity one is bothering me but I would prefer not fixing it in this PR because right now it is just a transformation from js to ts, I didn't change the functionality. To fix this one, I would need to restructure the functionality a bit. @zdravko-georgiev, what do you think? Leave it or fix it? If you prefer, I will fix it.

Screenshot 2023-09-06 at 11 29 07

@zdravko-georgiev
Copy link
Contributor

Could you please take care of the code smells?

I cannot fix the chaining 'smells' because that is not supported in UI5 :(. I marked them as won't fix. The cognitive complexity one is bothering me but I would prefer not fixing it in this PR because right now it is just a transformation from js to ts, I didn't change the functionality. To fix this one, I would need to restructure the functionality a bit. @zdravko-georgiev, what do you think? Leave it or fix it? If you prefer, I will fix it.

Screenshot 2023-09-06 at 11 29 07

@tobiasqueck OK, we can fix it later.

@zdravko-georgiev zdravko-georgiev self-requested a review September 6, 2023 09:42
Copy link
Contributor

@zdravko-georgiev zdravko-georgiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good
Test coverage is sufficient
Manual testing ✅

@tobiasqueck
Copy link
Contributor Author

Getting a warning about peer dependencies when doing pnpm install in this branch. image

That is not caused by my changes, you also see it if you checkout main and modify any dependency e.g. typescript from 4.9.4 to 4.9.5 and then run pnpm i.

@devinea any comment here?

@devinea
Copy link
Member

devinea commented Sep 6, 2023

Getting a warning about peer dependencies when doing pnpm install in this branch. image

That is not caused by my changes, you also see it if you checkout main and modify any dependency e.g. typescript from 4.9.4 to 4.9.5 and then run pnpm i.

@devinea any comment here?

Those dependencies don't have newer versions so the peer dependencies are older than we use. But that seems to work fine for now.

Copy link
Member

@devinea devinea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New module packages/preview-middleware-client/ structure and build scripts look fine.
Code coverage is decent.

Not so obvious why sandboxInit.js was renamed to init.ts ? I preferred the sandboxInit.xx FWIW.

Few other comments / suggestions.

More important one is LICENSE which should be consistent with the other modules.

@voicis voicis self-requested a review September 6, 2023 22:08
voicis
voicis previously approved these changes Sep 6, 2023
Copy link
Contributor

@voicis voicis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked that the concept works for control property editor UI5 code
Code looks good
Test coverage is sufficient

@tobiasqueck
Copy link
Contributor Author

Not so obvious why sandboxInit.js was renamed to init.ts ? I preferred the sandboxInit.xx FWIW.

The sandbox name made sense when it was a standalone file next to the html file, now it is moved into a namespace clearly identifying it as a preview coding. Additionally, that namespace will get a lot of additional files for CPE and ADP, so that it would start looking odd if all of them get a sandbox prefix.

PS: if you insist I can change the namespace from open.ux.preview.client to open.ux.preview.sandbox or so but to be honest I think that would be less descriptive.

Copy link
Contributor

@zdravko-georgiev zdravko-georgiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good
Test coverage is sufficient
Manual testing ✅

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

81.9% 81.9% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@Klaus-Keller Klaus-Keller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also open discussion about usage of private modules: #1231

What I don't like about this approach is to copy code from private modules. However, I had a discussion with @tobiasqueck and here is a proposal:

  • we discourage from using private modules and try to avoid them
  • for exceptional cases (like the one in this PR) we except from the rule and use private modules, but keep the possibility open to publish them at a later point in time

Copy link
Member

@devinea devinea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobiasqueck Thanks for the updates and clarifications.

I'd echo the comments from @Klaus-Keller also.

@tobiasqueck tobiasqueck merged commit a73935c into main Sep 7, 2023
@tobiasqueck tobiasqueck deleted the feat/1149/separate-client-module branch September 7, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants