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

add optional rank at modules domain #11724

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package tech.jhipster.lite.module.domain.resource;

/**
* Represents the maturity and adoption level of JHipster modules.
* Ranks range from experimental to community-validated,
* helping users assess module stability and production readiness.
*/
public enum JHipsterModuleRank {
/**
Copy link
Member

Choose a reason for hiding this comment

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

not sure we should keep all these comments, as we'll need to update them, as soon as there are some change.

For example: as soon as kipe-authorization change his RANK, the comment here won't be correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pascalgrimaud: I agree that the comments weren't timeless. I improved the comment descriptions. I am trying to keep the comments because it is hard to understand rank usage, and I think the enum is the best place to explain it.

Copy link
Contributor

Choose a reason for hiding this comment

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

it is hard to understand rank usage

I'm also a bit sceptical about these rank usages that are very subjective, so I'm curious to see how this will turn out :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my understanding, the ranks are curated by the jhipster lite developers to guide those who are using the tool for the first time. Let's give a try ;)

Copy link
Member

@pascalgrimaud pascalgrimaud Jan 23, 2025

Choose a reason for hiding this comment

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

It will not impact the final user, as we'll always display by default "ALL RANK".

Then, for example, the user can select the RANK_S to display only the most used modules. I don't think he/she'll be unhappy because his prefered module is not displayed in RANK_S, because his module will always be in "ALL RANK", so I'm fine with this

Copy link
Contributor Author

@renanfranca renanfranca Jan 24, 2025

Choose a reason for hiding this comment

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

@pascalgrimaud : when you have the time, please, let me know if I can keep these improved comments. Thanks :)

* Experimental or advanced module requiring specific expertise
*/
RANK_D,

/**
* Module without known production usage
*/
RANK_C,

/**
* Module with at least one confirmed production usage
*/
RANK_B,

/**
* Module with multiple production usages across different projects
* and documented through talks, books or blog posts
*/
RANK_A,

/**
* Production-proven module providing unique features,
* validated by community feedback (10+ endorsements)
*/
RANK_S,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.apache.commons.lang3.builder.ToStringStyle.*;

import java.util.Optional;
import org.apache.commons.lang3.builder.ToStringBuilder;
import tech.jhipster.lite.module.domain.JHipsterModuleFactory;
import tech.jhipster.lite.module.domain.JHipsterModuleSlug;
Expand All @@ -14,6 +15,7 @@ public final class JHipsterModuleResource {
private final JHipsterModuleApiDoc apiDoc;
private final JHipsterModuleOrganization organization;
private final JHipsterModuleTags tags;
private final JHipsterModuleRank rank;
private final JHipsterModuleFactory factory;

private JHipsterModuleResource(JHipsterModuleResourceBuilder builder) {
Expand All @@ -24,6 +26,7 @@ private JHipsterModuleResource(JHipsterModuleResourceBuilder builder) {
apiDoc = builder.apiDoc;
tags = builder.tags;
organization = builder.organization;
rank = Optional.ofNullable(builder.rank).orElse(JHipsterModuleRank.RANK_D);
factory = builder.factory;
}

Expand Down Expand Up @@ -60,6 +63,10 @@ public JHipsterModuleOrganization organization() {
return organization;
}

public JHipsterModuleRank rank() {
return rank;
}

public JHipsterModuleFactory factory() {
return factory;
}
Expand All @@ -86,10 +93,11 @@ private static final class JHipsterModuleResourceBuilder
JHipsterModuleResourceApiDocBuilder,
JHipsterModuleResourceOrganizationBuilder,
JHipsterModuleResourceTagsBuilder,
JHipsterModuleResourceFactoryBuilder {
JHipsterModuleResourceOptionalBuilder {

private JHipsterModuleSlugFactory slug;
private JHipsterModuleApiDoc apiDoc;
private JHipsterModuleRank rank;
private JHipsterModuleFactory factory;
private JHipsterModulePropertiesDefinition propertiesDefinition;

Expand Down Expand Up @@ -125,12 +133,19 @@ public JHipsterModuleResourceTagsBuilder organization(JHipsterModuleOrganization
}

@Override
public JHipsterModuleResourceFactoryBuilder tags(JHipsterModuleTags tags) {
public JHipsterModuleResourceOptionalBuilder tags(JHipsterModuleTags tags) {
this.tags = tags;

return this;
}

@Override
public JHipsterModuleResourceOptionalBuilder rank(JHipsterModuleRank rank) {
this.rank = rank;

return this;
}

@Override
public JHipsterModuleResource factory(JHipsterModuleFactory factory) {
this.factory = factory;
Expand Down Expand Up @@ -168,14 +183,16 @@ default JHipsterModuleResourceTagsBuilder standalone() {
}

public interface JHipsterModuleResourceTagsBuilder {
JHipsterModuleResourceFactoryBuilder tags(JHipsterModuleTags tags);
JHipsterModuleResourceOptionalBuilder tags(JHipsterModuleTags tags);

default JHipsterModuleResourceFactoryBuilder tags(String... tags) {
default JHipsterModuleResourceOptionalBuilder tags(String... tags) {
return tags(JHipsterModuleTags.builder().add(tags).build());
}
}

public interface JHipsterModuleResourceFactoryBuilder {
public interface JHipsterModuleResourceOptionalBuilder {
JHipsterModuleResourceOptionalBuilder rank(JHipsterModuleRank rank);

JHipsterModuleResource factory(JHipsterModuleFactory factory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import tech.jhipster.lite.module.domain.JHipsterModuleFactory;
import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization.JHipsterModuleOrganizationBuilder;
import tech.jhipster.lite.module.domain.resource.JHipsterModuleTags.JHipsterModuleTagsBuilder;
Expand Down Expand Up @@ -76,6 +77,7 @@ public static final class JHipsterTestModuleResourceBuilder {
private JHipsterModuleFactory factory;
private JHipsterModuleTags tags;
private String feature;
private JHipsterModuleRank rank;

private final Collection<JHipsterModuleSlugFactory> moduleDependencies = new ArrayList<>();
private final Collection<JHipsterFeatureSlugFactory> featureDependencies = new ArrayList<>();
Expand Down Expand Up @@ -130,14 +132,21 @@ public JHipsterTestModuleResourceBuilder tags(JHipsterModuleTags tags) {
return this;
}

public JHipsterTestModuleResourceBuilder rank(JHipsterModuleRank rank) {
this.rank = rank;

return this;
}

public JHipsterModuleResource build() {
return JHipsterModuleResource.builder()
JHipsterModuleResource.JHipsterModuleResourceOptionalBuilder builder = JHipsterModuleResource.builder()
.slug(() -> slug)
.propertiesDefinition(propertiesDefinition())
.apiDoc(group, operation)
.organization(buildOrganization())
.tags(tags)
.factory(factory);
.tags(tags);

return Optional.ofNullable(rank).map(builder::rank).orElse(builder).factory(factory);
}

private JHipsterModuleOrganization buildOrganization() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,18 @@ void shouldHaveMeaningfulToString() {

assertThat(resource.toString()).contains("JHipsterModuleResource[", "slug=dummy");
}

@Test
void shouldBuildWithRankedResources() {
var resource = defaultModuleResourceBuilder().rank(JHipsterModuleRank.RANK_S).build();

assertThat(resource.rank()).isEqualTo(JHipsterModuleRank.RANK_S);
}

@Test
void shouldBuildWithDefaultRankedResources() {
var resource = defaultModuleResourceBuilder().build();

assertThat(resource.rank()).isEqualTo(JHipsterModuleRank.RANK_D);
}
}
Loading