From 8419d8d70c229063a9a545b1b1d860a8a16f649e Mon Sep 17 00:00:00 2001
From: Yauhen Vavilkin <119946365+yauhen-vavilkin@users.noreply.github.com>
Date: Mon, 19 Aug 2024 17:48:40 +0400
Subject: [PATCH] EUREKA-240: adjust readme (#6)
---
README.md | 6 ++--
pom.xml | 4 +--
.../README.md | 11 ++++++
.../md-validator.sh | 34 +++++++++++++++++++
4 files changed, 51 insertions(+), 4 deletions(-)
create mode 100644 scripts/module-descriptor-batch-validator/README.md
create mode 100755 scripts/module-descriptor-batch-validator/md-validator.sh
diff --git a/README.md b/README.md
index 98990cb..ed43dc1 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ It checks the module descriptor template placed in FOLIO modules for issues and
- [Usage](#usage)
- [Non-project usage](#non-project-usage)
- [Validation rules](#validation-rules)
+- [Helpful scripts](#helpful-scripts)
## Features
- Validation: Automatically checks module descriptor for common issues and ensures it adheres to FOLIO standards.
@@ -53,7 +54,7 @@ To disable the fail-fast mode or add custom path to module descriptor file, add
- false
+ false
${project.basedir}/path/to/module-descriptor.json
@@ -71,4 +72,5 @@ The plugin checks the module descriptor for the following issues:
- Endpoint required permissions: `permissionsRequired` array should contain no more than one permission. Also `permissionsRequired` shouldn't contain permission set.
- Permission definition: Checks if the permission is defined in the `permissionSets` section.
-
+## Helpful scripts
+- [module descriptor batch validator](scripts/module-descriptor-batch-validator/README.md)
diff --git a/pom.xml b/pom.xml
index c484aea..7284a31 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@
3.9.6
3.11.0
2.17.0
- 1.5.5-SNAPSHOT
+ 1.5.5
5.10.2
3.25.3
@@ -25,7 +25,7 @@
10.14.2
3.3.1
3.2.5
- 3.11.0
+ 3.14.0
src/main/java/**/model/**/*
diff --git a/scripts/module-descriptor-batch-validator/README.md b/scripts/module-descriptor-batch-validator/README.md
new file mode 100644
index 0000000..1e90267
--- /dev/null
+++ b/scripts/module-descriptor-batch-validator/README.md
@@ -0,0 +1,11 @@
+## Module Descriptor Batch Validator
+This script helps to validate module descriptors for modules gathered in `install.json`.
+
+### Usage
+Place the `md-validator.sh` file next to `install.json` and run the command:
+```bash
+./md-validator.sh
+```
+
+### How it works
+The script parses the `install.json` file, retrieves all module IDs, and downloads the module descriptors sequentially. Then, the plugin validates the module descriptors. It is based on the non-project usage feature of the plugin.
diff --git a/scripts/module-descriptor-batch-validator/md-validator.sh b/scripts/module-descriptor-batch-validator/md-validator.sh
new file mode 100755
index 0000000..7664fe1
--- /dev/null
+++ b/scripts/module-descriptor-batch-validator/md-validator.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+JSON_FILE="install.json"
+BASE_URL="https://folio-registry.dev.folio.org/_/proxy/modules"
+PLUGIN_GROUP_ID="org.folio"
+PLUGIN_ARTIFACT_ID="folio-module-descriptor-validator"
+PLUGIN_VERSION="0.0.1-SNAPSHOT"
+PLUGIN_GOAL="validate"
+
+ids=$(jq -r '.[].id' $JSON_FILE)
+
+for id in $ids; do
+ FILE_URL="$BASE_URL/$id"
+ FILE_PATH="$id.json"
+
+ curl -sS -o $FILE_PATH $FILE_URL
+
+ echo -n "Validation $FILE_PATH started... "
+
+ if [ $? -eq 0 ]; then
+
+ mvn $PLUGIN_GROUP_ID:$PLUGIN_ARTIFACT_ID:$PLUGIN_VERSION:$PLUGIN_GOAL -q -DmoduleDescriptorFile=$FILE_PATH
+
+ rm -f $FILE_PATH
+ echo -ne "\rValidation $FILE_PATH DONE "
+ echo ""
+ else
+ echo "Failed to download $FILE_URL"
+ fi
+done
+
+rm -f $TEMP_POM
+
+echo "All operations completed."