From 0a0c8491e100122b4826e6223b6842de39fe2056 Mon Sep 17 00:00:00 2001 From: Renan Meneses de Andrade Franca Date: Fri, 24 May 2024 09:50:03 -0300 Subject: [PATCH 1/2] add javadoc to packageJson API --- .../JHipsterModulePackageJson.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/main/java/tech/jhipster/lite/module/domain/packagejson/JHipsterModulePackageJson.java b/src/main/java/tech/jhipster/lite/module/domain/packagejson/JHipsterModulePackageJson.java index 97450d22445..1d912e83272 100644 --- a/src/main/java/tech/jhipster/lite/module/domain/packagejson/JHipsterModulePackageJson.java +++ b/src/main/java/tech/jhipster/lite/module/domain/packagejson/JHipsterModulePackageJson.java @@ -5,6 +5,11 @@ import tech.jhipster.lite.module.domain.JHipsterModule.JHipsterModuleBuilder; import tech.jhipster.lite.shared.error.domain.Assert; +/** + * This class represents the {@code package.json} configurations for a JHipster module. + * It includes scripts, dependencies, development dependencies, and configurations + * for removing unnecessary dependencies. + */ public final class JHipsterModulePackageJson { private final Scripts scripts; @@ -77,18 +82,40 @@ private JHipsterModulePackageJsonBuilder(JHipsterModuleBuilder module) { this.module = module; } + /** + * Add a script to the {@code package.json} scripts section. + * + * @param key the script key + * @param command the script command + * @return the builder itself + */ public JHipsterModulePackageJsonBuilder addScript(ScriptKey key, ScriptCommand command) { scripts.add(new Script(key, command)); return this; } + /** + * Add a dependency to the {@code package.json} dependencies section. + * + * @param packageName the name of the package + * @param versionSource the version source + * @return the builder itself + */ public JHipsterModulePackageJsonBuilder addDependency(PackageName packageName, VersionSource versionSource) { dependencies.add(PackageJsonDependency.builder().packageName(packageName).versionSource(versionSource).build()); return this; } + /** + * Add a dependency to the {@code package.json} dependencies section with a specific version. + * + * @param packageName the name of the package + * @param versionSource the version source + * @param versionPackageName the name of the package providing the version + * @return the builder itself + */ public JHipsterModulePackageJsonBuilder addDependency( PackageName packageName, VersionSource versionSource, @@ -101,17 +128,39 @@ public JHipsterModulePackageJsonBuilder addDependency( return this; } + /** + * Remove a dependency from the {@code package.json} dependencies section. + * + * @param packageName the name of the package + * @param versionSource the version source + * @return the builder itself + */ public JHipsterModulePackageJsonBuilder removeDependency(PackageName packageName, VersionSource versionSource) { dependenciesToRemove.add(PackageJsonDependency.builder().packageName(packageName).versionSource(versionSource).build()); return this; } + /** + * Add a development dependency to the {@code package.json} devDependencies section. + * + * @param packageName the name of the package + * @param versionSource the version source + * @return the builder itself + */ public JHipsterModulePackageJsonBuilder addDevDependency(PackageName packageName, VersionSource versionSource) { devDependencies.add(PackageJsonDependency.builder().packageName(packageName).versionSource(versionSource).build()); return this; } + /** + * Add a development dependency to the {@code package.json} devDependencies section with a specific version. + * + * @param packageName the name of the package + * @param versionSource the version source + * @param versionPackageName the name of the package providing the version + * @return the builder itself + */ public JHipsterModulePackageJsonBuilder addDevDependency( PackageName packageName, VersionSource versionSource, @@ -124,21 +173,45 @@ public JHipsterModulePackageJsonBuilder addDevDependency( return this; } + /** + * Remove a development dependency from the {@code package.json} devDependencies section. + * + * @param packageName the name of the package + * @param versionSource the version source + * @return the builder itself + */ public JHipsterModulePackageJsonBuilder removeDevDependency(PackageName packageName, VersionSource versionSource) { devDependenciesToRemove.add(PackageJsonDependency.builder().packageName(packageName).versionSource(versionSource).build()); + return this; } + /** + * Add a type to the {@code package.json}. + * + * @param t the type + * @return the builder itself + */ public JHipsterModulePackageJsonBuilder addType(String t) { type = t; return this; } + /** + * Finish building the {@code package.json} configuration and return to the parent module builder. + * + * @return the parent module builder + */ public JHipsterModuleBuilder and() { return module; } + /** + * Build the {@code JHipsterModulePackageJson} instance. + * + * @return a new instance of {@code JHipsterModulePackageJson} + */ public JHipsterModulePackageJson build() { return new JHipsterModulePackageJson(this); } From e2c6d18cff4cae8da6724d1873582b62144b8a03 Mon Sep 17 00:00:00 2001 From: Renan Meneses de Andrade Franca Date: Fri, 24 May 2024 09:57:32 -0300 Subject: [PATCH 2/2] add javadoc to module API --- .../lite/module/domain/JHipsterModule.java | 47 +++++-------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/module/domain/JHipsterModule.java b/src/main/java/tech/jhipster/lite/module/domain/JHipsterModule.java index a1f5d88b21d..309ce04cd2b 100644 --- a/src/main/java/tech/jhipster/lite/module/domain/JHipsterModule.java +++ b/src/main/java/tech/jhipster/lite/module/domain/JHipsterModule.java @@ -16,13 +16,8 @@ import tech.jhipster.lite.module.domain.JHipsterModulePreActions.JHipsterModulePreActionsBuilder; import tech.jhipster.lite.module.domain.buildproperties.JHipsterModuleBuildProperties; import tech.jhipster.lite.module.domain.buildproperties.JHipsterModuleBuildProperties.JHipsterModuleBuildPropertiesBuilder; -import tech.jhipster.lite.module.domain.file.JHipsterDestination; -import tech.jhipster.lite.module.domain.file.JHipsterFilesToDelete; -import tech.jhipster.lite.module.domain.file.JHipsterFilesToMove; -import tech.jhipster.lite.module.domain.file.JHipsterModuleFile; -import tech.jhipster.lite.module.domain.file.JHipsterModuleFiles; +import tech.jhipster.lite.module.domain.file.*; import tech.jhipster.lite.module.domain.file.JHipsterModuleFiles.JHipsterModuleFilesBuilder; -import tech.jhipster.lite.module.domain.file.JHipsterSource; import tech.jhipster.lite.module.domain.gitignore.JHipsterModuleGitIgnore; import tech.jhipster.lite.module.domain.gitignore.JHipsterModuleGitIgnore.JHipsterModuleGitIgnoreBuilder; import tech.jhipster.lite.module.domain.gradleconfiguration.JHipsterModuleGradleConfigurations; @@ -35,13 +30,9 @@ import tech.jhipster.lite.module.domain.gradleplugin.GradleCorePlugin.GradleCorePluginIdBuilder; import tech.jhipster.lite.module.domain.gradleplugin.JHipsterModuleGradlePlugins; import tech.jhipster.lite.module.domain.gradleplugin.JHipsterModuleGradlePlugins.JHipsterModuleGradlePluginBuilder; -import tech.jhipster.lite.module.domain.javabuild.ArtifactId; -import tech.jhipster.lite.module.domain.javabuild.GroupId; -import tech.jhipster.lite.module.domain.javabuild.JHipsterModuleMavenBuildExtensions; +import tech.jhipster.lite.module.domain.javabuild.*; import tech.jhipster.lite.module.domain.javabuild.JHipsterModuleMavenBuildExtensions.JHipsterModuleMavenBuildExtensionsBuilder; -import tech.jhipster.lite.module.domain.javabuild.MavenBuildExtension; import tech.jhipster.lite.module.domain.javabuild.MavenBuildExtension.MavenBuildExtensionGroupIdBuilder; -import tech.jhipster.lite.module.domain.javabuild.VersionSlug; import tech.jhipster.lite.module.domain.javabuildprofile.BuildProfileActivation; import tech.jhipster.lite.module.domain.javabuildprofile.BuildProfileActivation.BuildProfileActivationBuilder; import tech.jhipster.lite.module.domain.javabuildprofile.BuildProfileId; @@ -52,22 +43,9 @@ import tech.jhipster.lite.module.domain.javadependency.JHipsterModuleJavaDependencies.JHipsterModuleJavaDependenciesBuilder; import tech.jhipster.lite.module.domain.javadependency.JavaDependency; import tech.jhipster.lite.module.domain.javadependency.JavaDependency.JavaDependencyGroupIdBuilder; -import tech.jhipster.lite.module.domain.javaproperties.Comment; -import tech.jhipster.lite.module.domain.javaproperties.JHipsterModuleSpringFactories; +import tech.jhipster.lite.module.domain.javaproperties.*; import tech.jhipster.lite.module.domain.javaproperties.JHipsterModuleSpringFactories.JHipsterModuleSpringFactoriesBuilder; -import tech.jhipster.lite.module.domain.javaproperties.JHipsterModuleSpringProperties; import tech.jhipster.lite.module.domain.javaproperties.JHipsterModuleSpringProperties.JHipsterModuleSpringPropertiesBuilder; -import tech.jhipster.lite.module.domain.javaproperties.PropertyKey; -import tech.jhipster.lite.module.domain.javaproperties.PropertyValue; -import tech.jhipster.lite.module.domain.javaproperties.SpringComment; -import tech.jhipster.lite.module.domain.javaproperties.SpringComments; -import tech.jhipster.lite.module.domain.javaproperties.SpringFactories; -import tech.jhipster.lite.module.domain.javaproperties.SpringFactory; -import tech.jhipster.lite.module.domain.javaproperties.SpringFactoryType; -import tech.jhipster.lite.module.domain.javaproperties.SpringProfile; -import tech.jhipster.lite.module.domain.javaproperties.SpringProperties; -import tech.jhipster.lite.module.domain.javaproperties.SpringProperty; -import tech.jhipster.lite.module.domain.javaproperties.SpringPropertyType; import tech.jhipster.lite.module.domain.mavenplugin.JHipsterModuleMavenPlugins; import tech.jhipster.lite.module.domain.mavenplugin.JHipsterModuleMavenPlugins.JHipsterModuleMavenPluginsBuilder; import tech.jhipster.lite.module.domain.mavenplugin.MavenPlugin; @@ -83,17 +61,9 @@ import tech.jhipster.lite.module.domain.postaction.JHipsterModulePostActions.JHipsterModulePostActionsBuilder; import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; import tech.jhipster.lite.module.domain.properties.JHipsterProjectFolder; -import tech.jhipster.lite.module.domain.replacement.FileStartReplacer; -import tech.jhipster.lite.module.domain.replacement.JHipsterModuleMandatoryReplacementsFactory; +import tech.jhipster.lite.module.domain.replacement.*; import tech.jhipster.lite.module.domain.replacement.JHipsterModuleMandatoryReplacementsFactory.JHipsterModuleMandatoryReplacementsFactoryBuilder; -import tech.jhipster.lite.module.domain.replacement.JHipsterModuleOptionalReplacementsFactory; import tech.jhipster.lite.module.domain.replacement.JHipsterModuleOptionalReplacementsFactory.JHipsterModuleOptionalReplacementsFactoryBuilder; -import tech.jhipster.lite.module.domain.replacement.RegexNeedleAfterReplacer; -import tech.jhipster.lite.module.domain.replacement.RegexNeedleBeforeReplacer; -import tech.jhipster.lite.module.domain.replacement.RegexReplacer; -import tech.jhipster.lite.module.domain.replacement.TextNeedleAfterReplacer; -import tech.jhipster.lite.module.domain.replacement.TextNeedleBeforeReplacer; -import tech.jhipster.lite.module.domain.replacement.TextReplacer; import tech.jhipster.lite.module.domain.startupcommand.JHipsterModuleStartupCommands; import tech.jhipster.lite.module.domain.startupcommand.JHipsterModuleStartupCommands.JHipsterModuleStartupCommandsBuilder; import tech.jhipster.lite.module.domain.startupcommand.JHipsterStartupCommands; @@ -628,6 +598,15 @@ public JHipsterModuleMavenBuildExtensionsBuilder mavenBuildExtensions() { return mavenBuildExtensions; } + /** + * Configure the {@code package.json} file for the JHipster module. + *

+ * This method allows you to add scripts, dependencies, and development dependencies + * to the package.json file. It uses a builder pattern to provide a fluent interface for + * configuring the {@code package.json} file. + * + * @return a {@link JHipsterModulePackageJsonBuilder} to continue configuring the package.json + */ public JHipsterModulePackageJsonBuilder packageJson() { return packageJson; }