From d37b75ee2bedccffc19a1ea03ad493a7d02411ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Marx=20=E3=8B=A1?= Date: Thu, 26 Sep 2024 13:48:41 +0200 Subject: [PATCH] Create modules directory (#260) * create modules directory if missing --- cms-api/pom.xml | 2 +- cms-auth/pom.xml | 2 +- cms-content/pom.xml | 2 +- cms-core/pom.xml | 2 +- cms-extensions/pom.xml | 2 +- cms-filesystem/pom.xml | 2 +- cms-git/pom.xml | 2 +- cms-media/pom.xml | 2 +- cms-sandbox/pom.xml | 2 +- cms-server/pom.xml | 2 +- .../cms/cli/commands/modules/AbstractModuleCommand.java | 7 +++++++ .../cms/cli/commands/modules/GetAllCommand.java | 8 ++++++++ .../condation/cms/cli/commands/modules/GetCommand.java | 9 +++++++++ integration-tests/pom.xml | 2 +- modules-framework/api/pom.xml | 2 +- modules-framework/manager/pom.xml | 2 +- modules-framework/pom.xml | 2 +- modules/example-module/pom.xml | 2 +- modules/pom.xml | 2 +- pom.xml | 2 +- 20 files changed, 41 insertions(+), 17 deletions(-) diff --git a/cms-api/pom.xml b/cms-api/pom.xml index bcde7c92..12929dd6 100644 --- a/cms-api/pom.xml +++ b/cms-api/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-api jar diff --git a/cms-auth/pom.xml b/cms-auth/pom.xml index a4c59730..89ba4617 100644 --- a/cms-auth/pom.xml +++ b/cms-auth/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-auth jar diff --git a/cms-content/pom.xml b/cms-content/pom.xml index d4076ac8..84220660 100644 --- a/cms-content/pom.xml +++ b/cms-content/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-content jar diff --git a/cms-core/pom.xml b/cms-core/pom.xml index 84238b21..9a1d100b 100644 --- a/cms-core/pom.xml +++ b/cms-core/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-core jar diff --git a/cms-extensions/pom.xml b/cms-extensions/pom.xml index 123d1f8d..7b17a4fb 100644 --- a/cms-extensions/pom.xml +++ b/cms-extensions/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-extensions jar diff --git a/cms-filesystem/pom.xml b/cms-filesystem/pom.xml index 11611dd2..87b696c2 100644 --- a/cms-filesystem/pom.xml +++ b/cms-filesystem/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-filesystem jar diff --git a/cms-git/pom.xml b/cms-git/pom.xml index b93363b8..533fa714 100644 --- a/cms-git/pom.xml +++ b/cms-git/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-git jar diff --git a/cms-media/pom.xml b/cms-media/pom.xml index d6ea9d0b..b85e32c3 100644 --- a/cms-media/pom.xml +++ b/cms-media/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-media jar diff --git a/cms-sandbox/pom.xml b/cms-sandbox/pom.xml index 7d622478..5356ec6a 100644 --- a/cms-sandbox/pom.xml +++ b/cms-sandbox/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-sandbox pom diff --git a/cms-server/pom.xml b/cms-server/pom.xml index 8d5ffa55..b8c1b849 100644 --- a/cms-server/pom.xml +++ b/cms-server/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 cms-server jar diff --git a/cms-server/src/main/java/com/condation/cms/cli/commands/modules/AbstractModuleCommand.java b/cms-server/src/main/java/com/condation/cms/cli/commands/modules/AbstractModuleCommand.java index 1eb42a8f..bbfefd65 100644 --- a/cms-server/src/main/java/com/condation/cms/cli/commands/modules/AbstractModuleCommand.java +++ b/cms-server/src/main/java/com/condation/cms/cli/commands/modules/AbstractModuleCommand.java @@ -61,6 +61,13 @@ public static Path getModuleFolder (String module) { return Path.of("modules/" + module); } + public static void createModulesFolder () throws IOException { + var modPath = Path.of("modules/"); + if (!Files.exists(modPath)) { + Files.createDirectories(modPath); + } + } + public static boolean isInstalled(String module) { return Files.exists(getModuleFolder(module)); } diff --git a/cms-server/src/main/java/com/condation/cms/cli/commands/modules/GetAllCommand.java b/cms-server/src/main/java/com/condation/cms/cli/commands/modules/GetAllCommand.java index cace9d23..3cf4eb83 100644 --- a/cms-server/src/main/java/com/condation/cms/cli/commands/modules/GetAllCommand.java +++ b/cms-server/src/main/java/com/condation/cms/cli/commands/modules/GetAllCommand.java @@ -24,6 +24,7 @@ import com.condation.cms.CMSServer; import com.condation.cms.cli.tools.ModulesUtil; import com.condation.cms.extensions.repository.InstallationHelper; +import java.io.IOException; import java.nio.file.Path; import lombok.extern.slf4j.Slf4j; import picocli.CommandLine; @@ -47,6 +48,13 @@ public void run() { return; } + try { + createModulesFolder(); + } catch (IOException ex) { + log.error("", ex); + throw new RuntimeException(ex); + } + var modules = ModulesUtil.getRequiredModules(); log.trace("check required modules: " + modules); if (!ModulesUtil.allInstalled(modules) && !forceUpdate) { diff --git a/cms-server/src/main/java/com/condation/cms/cli/commands/modules/GetCommand.java b/cms-server/src/main/java/com/condation/cms/cli/commands/modules/GetCommand.java index 4d0aadc0..d213865b 100644 --- a/cms-server/src/main/java/com/condation/cms/cli/commands/modules/GetCommand.java +++ b/cms-server/src/main/java/com/condation/cms/cli/commands/modules/GetCommand.java @@ -24,7 +24,9 @@ import com.condation.cms.CMSServer; +import static com.condation.cms.cli.commands.modules.AbstractModuleCommand.createModulesFolder; import com.condation.cms.extensions.repository.InstallationHelper; +import java.io.IOException; import java.nio.file.Path; import lombok.extern.slf4j.Slf4j; import picocli.CommandLine; @@ -54,6 +56,13 @@ public void run() { System.out.println("modules can not be modified in running system"); return; } + + try { + createModulesFolder(); + } catch (IOException ex) { + log.error("", ex); + throw new RuntimeException(ex); + } if (isInstalled(module) && !forceUpdate) { System.err.println("module is already installed, use -f to force an update"); diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index f7471615..b291bd2c 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 integration-tests jar diff --git a/modules-framework/api/pom.xml b/modules-framework/api/pom.xml index 909126e4..362954ff 100644 --- a/modules-framework/api/pom.xml +++ b/modules-framework/api/pom.xml @@ -4,7 +4,7 @@ com.condation.cms.module.framework module-framework - 6.2.0 + 6.2.1 modules-api jar diff --git a/modules-framework/manager/pom.xml b/modules-framework/manager/pom.xml index 4a6429e4..7fc7a988 100644 --- a/modules-framework/manager/pom.xml +++ b/modules-framework/manager/pom.xml @@ -4,7 +4,7 @@ com.condation.cms.module.framework module-framework - 6.2.0 + 6.2.1 modules-manager jar diff --git a/modules-framework/pom.xml b/modules-framework/pom.xml index 8f6e754b..eaee0dfc 100644 --- a/modules-framework/pom.xml +++ b/modules-framework/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 com.condation.cms.module.framework module-framework diff --git a/modules/example-module/pom.xml b/modules/example-module/pom.xml index e9a5f25e..560460eb 100644 --- a/modules/example-module/pom.xml +++ b/modules/example-module/pom.xml @@ -4,7 +4,7 @@ com.condation.cms.modules cms-modules - 6.2.0 + 6.2.1 example-module jar diff --git a/modules/pom.xml b/modules/pom.xml index f786268f..a72eaf52 100644 --- a/modules/pom.xml +++ b/modules/pom.xml @@ -4,7 +4,7 @@ com.condation.cms cms-parent - 6.2.0 + 6.2.1 com.condation.cms.modules cms-modules diff --git a/pom.xml b/pom.xml index 92273067..01c7c8cc 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.condation.cms cms-parent - 6.2.0 + 6.2.1 pom UTF-8