Skip to content
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

replace default server port when property has custom value #8825

Merged
merged 7 commits into from
Feb 3, 2024
Merged

replace default server port when property has custom value #8825

merged 7 commits into from
Feb 3, 2024

Conversation

alerGeek
Copy link
Contributor

@alerGeek alerGeek commented Feb 2, 2024

PR fix frontend properties:

  • replace default value (8080) for Angular Module
  • replace default value (8080) for React Module
  • replace default value (8080) for ThymeLeaf Module

PR fix README.md files/properties for ouath docker image.

Fix #8824

@CLAassistant
Copy link

CLAassistant commented Feb 2, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@murdos murdos left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
I made a few suggestions to simplify things

@@ -132,7 +132,7 @@ public JHipsterModule buildTailwindcssModule(JHipsterModuleProperties properties
.packageJson()
.addDevDependency(packageName("tailwindcss"), COMMON)
.addScript(scriptKey("watch:html"), scriptCommand("onchange 'src/main/resources/templates/**/*.html' -- npm-run-all --serial build:css build:html"))
.addScript(scriptKey("watch:serve"), scriptCommand("browser-sync start --no-inject-changes --proxy localhost:8080 --files 'target/classes/templates' 'target/classes/static'"))
.addScript(scriptKey("watch:serve"), scriptCommand("browser-sync start --no-inject-changes --proxy localhost:%s --files 'target/classes/templates' 'target/classes/static'".formatted(getServerPort(properties))))
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no reason to redefine the default 8080 port in every module, it's already defined in JHipsterServerPort so you can just use:

Suggested change
.addScript(scriptKey("watch:serve"), scriptCommand("browser-sync start --no-inject-changes --proxy localhost:%s --files 'target/classes/templates' 'target/classes/static'".formatted(getServerPort(properties))))
.addScript(scriptKey("watch:serve"), scriptCommand("browser-sync start --no-inject-changes --proxy localhost:%s --files 'target/classes/templates' 'target/classes/static'".formatted(properties.serverPort().get())))

and remove the getServerPort() method below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I was not sure if the serverPort property is generated as well when no spring-boot-mvc-empty module is added. I have removed unnecessary method

@@ -100,11 +101,18 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.in(path("package.json"))
.add(lineBeforeText(CACHE_NEEDLE), jestSonar(properties.indentation()))
.and()
.in(path("proxy.conf.json"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than doing a replacement, you should turn proxy.conf.json to a template that will use the serverPort properties:

  • rename proxy.conf.json in src/main/resources/generator/client/angular/core/ to proxy.conf.json.mustache and replace 8080 by {{serverPort}}
  • change line .add(SOURCE.file("proxy.conf.json"), to("proxy.conf.json")) to .addTemplate(SOURCE.file("proxy.conf.json"), to("proxy.conf.json"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I have did the same to vte.config.ts in React Module. However, as I was not able to add the addTemple without the batch, I had to modify it to:

...
        .batch(SOURCE, to("."))
          .addTemplate("proxy.conf.json")
          .and()
...

@murdos murdos mentioned this pull request Feb 2, 2024
@murdos murdos changed the title replace default server port when property has custom value fix #8824 replace default server port when property has custom value Feb 2, 2024
@alerGeek alerGeek requested a review from murdos February 3, 2024 05:45
@murdos murdos enabled auto-merge February 3, 2024 06:38
Copy link

codecov bot commented Feb 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5f0e8ca) 100.00% compared to head (f6d69a3) 100.00%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##                main     #8825   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity      2819      2819           
===========================================
  Files            719       719           
  Lines          12409     12411    +2     
  Branches         250       250           
===========================================
+ Hits           12409     12411    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@murdos murdos merged commit bf277b0 into jhipster:main Feb 3, 2024
37 checks passed
@murdos
Copy link
Contributor

murdos commented Feb 3, 2024

Congrats @alerGeek for your first contribution :-)

@alerGeek alerGeek deleted the fix/IS-8824-replace-default-server-port-when-property-custom branch February 3, 2024 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants