jhipster / jhipster-lite

JHipster Lite ⚡ is a development platform to generate, develop & deploy modern web applications & microservices architecture, step by step - using Hexagonal Architecture :gem:
https://lite.jhipster.tech
Apache License 2.0
463 stars 212 forks source link

Manage landscape preset configuration #10239

Closed renanfranca closed 3 months ago

renanfranca commented 3 months ago

I propose saving/reading the preset configuration into a JSON file, similar to how history.json works. Here is what I think the .jhipster/modules/preset.json should look like:

[
  {
    "name": "angular + spring boot",
    "date": "2024-07-09T15:10:00.521252170Z",
    "modules": [
      "init",
      "application-service-hexagonal-architecture-documentation",
      "maven-java",
      "prettier",
      "angular-core",
      "java-base",
      "maven-wrapper",
      "spring-boot",
      "spring-boot-mvc-empty",
      "logs-spy",
      "spring-boot-tomcat"
    ]
  }
]

When applying the selected preset, the properties defined by the landscape interface or default will be used, which is why they won't be stored in the json.

    "properties": {
      "packageName": "com.mycompany.myapp",
      "projectName": "JHipster Sample Application",
      "baseName": "jhipsterSampleApplication",
      "serverPort": 8080,
      "endOfLine": "lf",
      "indentSize": 2,
      "springConfigurationFormat": "yaml"
    },
renanfranca commented 3 months ago

@murdos and @pascalgrimaud: feel free to drop any suggestions or feedback. I am going to work on this issue 😀

I added a TO-DO/Roadmap to the following issue description:

murdos commented 3 months ago

I'm not sure to understand what problem we're trying to solve here.

IMO a preset is something that the landscape should be able to ingest, in order to:

pascalgrimaud commented 3 months ago

It's a good idea to use a json file to load a pre-selected modules. But this json file should belong to JHLite project, and not in .jhipster/modules/preset.json

renanfranca commented 3 months ago

Thank you for the feedback, @murdos and @pascalgrimaud! 😃✌

Short answer: I agree with both of you and will implement loading presets from a JSON file. Here is the JSON file I envision:

[
  {
    "name": "angular + spring boot",
    "modules": [
      "init",
      "application-service-hexagonal-architecture-documentation",
      "maven-java",
      "prettier",
      "angular-core",
      "java-base",
      "maven-wrapper",
      "spring-boot",
      "spring-boot-mvc-empty",
      "logs-spy",
      "spring-boot-tomcat"
    ]
  }
]

I removed the "date": "2024-07-09T15:10:00.521252170Z" attribute because the change commit will have this information.

Long answer:

either have a way to manually load a serialized, pre-configured list of modules that will be selected for generation. The intent here is to save time for users that frequently generated similar projects. The serialized preset could be a json file, but it will not belong to a generated project (so I don't understand the .jhipster/modules/preset.json file).

My intention was to implement something similar to the preset you defined. I had imagined using the alternative landscape interface to allow the creation of new presets via a web application. But how exactly could we add new presets to the generator using the running application? I think it's not possible.

I see another use for presets besides facilitating the generation of repeated projects. I think presets could also function as a tutorial to help users understand how the landscape screen works.