Skip to content

Commit dbb2e65

Browse files
committed
test
1 parent 148f9b6 commit dbb2e65

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

.github/workflows/validate-new-plugin-metadata.yml

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,43 @@ jobs:
8080
# Function to validate a URL field (supports single values and arrays)
8181
check_valid_url() {
8282
local field="$1"
83-
local required="${2:-optional}" # Default to "optional" if no second parameter is provided
84-
local value=$(echo "$metadata" | yq ".$field" || true)
83+
local field_type="${2:-single_value}" # Default to "single_value" if no second parameter is provided
84+
local required="${3:-optional}" # Default to "optional" if no third parameter is provided
8585
86-
# If field is missing or empty
87-
if [[ -z "$value" ]]; then
88-
if [[ "$required" == "required" ]]; then
89-
echo "::error file=$metadata_file::'$field' is required but missing"
90-
((errors++))
86+
if [[ "$field_type" == "single_value" ]]; then
87+
local value=$(echo "$metadata" | yq ".$field" || true)
88+
89+
# If field is missing or empty
90+
if [[ -z "$value" ]]; then
91+
if [[ "$required" == "required" ]]; then
92+
echo "::error file=$metadata_file::'$field' is required but missing"
93+
((errors++))
94+
fi
95+
return 0 # Skip validation if it's optional and missing
9196
fi
92-
return 0 # Skip validation if it's optional and missing
93-
fi
97+
else
98+
field_type=$(yq ".${field} | type")
99+
echo "The type of '$field' is: $field_type"
100+
mapfile -t array < <(echo "$metadata" | yq -r ".$field | select(.) | .[]" || echo "")
101+
echo "Array: ${array[@]}"
102+
103+
local non_empty_entries=0
94104
95-
# Handle arrays of URLs (e.g., screenshots)
96-
# Check if the field is an array using yq length check
97-
is_array=$(echo "$metadata" | yq -r ".${field} | length")
98-
99-
if [[ "$is_array" =~ ^[0-9]+$ && "$is_array" -gt 0 ]]; then
100-
# Iterate properly over array elements
101-
for url in $(echo "$metadata" | yq -r ".$field[]" || true); do
102-
if [[ -z "$url" ]]; then # Skip empty values inside arrays
105+
for url in "${array[@]}"; do
106+
if [[ -z "$url" ]]; then
103107
continue
104-
fi
105-
if [[ ! "$url" =~ ^https?:\/\/[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+(:[0-9]{1,5})?(\/.*)?$ ]]; then
106-
echo "::error file=$metadata_file::'$field' contains an invalid URL: $url"
107-
((errors++))
108+
else
109+
if [[ "$url" =~ ^(https?:\/\/[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+(:[0-9]{1,5})?(\/.*)?)$ ]]; then
110+
((non_empty_entries++))
111+
else
112+
echo "::error file=$metadata_file::'$field' contains an invalid URL: $url"
113+
((errors++))
114+
fi
108115
fi
109116
done
110-
else
111-
if [[ ! "$value" =~ ^https?:\/\/[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+(:[0-9]{1,5})?(\/.*)?$ ]]; then
112-
echo "::error file=$metadata_file::'$field' is not a valid URL"
117+
118+
if [[ "$required" == "required" && "$non_empty_entries" -eq 0 ]]; then
119+
echo "::error file=$metadata_file::'$field' is required but missing"
113120
((errors++))
114121
fi
115122
fi
@@ -128,7 +135,6 @@ jobs:
128135
check_valid_url "demo_video_url"
129136
check_valid_url "documentation_url"
130137
check_valid_url "changelog_url"
131-
check_valid_url "screenshots"
132138
133139
# Validate date format (YYYY-MM)
134140
release_date=$(echo "$metadata" | yq '.release_date')

plugins/plugin_metadata_template.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ detailed_description: "" # Full description with features and benefits
1111
# Media & Assets
1212
plugin_logo_url: "" # URL to the plugin logo (512x512 recommended) (if any or fallback to logo_url)
1313
screenshots: # List of screenshots showcasing the plugin (if any)
14-
- "" # e.g., "https://example.com/screenshot1.png"
15-
- ""
14+
- "haha" # e.g., "https://example.com/screenshot1.png"
15+
- "csd"
1616
demo_video_url: "" # Link to a demo or walkthrough video (if any)
1717
documentation_url: "" # Link to the plugin's official documentation (if any)
1818
changelog_url: "" # Link to the changelog (if maintained)
1919

2020
# Contact & Support
2121
x_account_handle: "" # X (formerly known as Twitter) account handle (ie: @GAME_Virtuals)
2222
support_contact: "" # Email or Slack/Discord link for user support
23-
community_url: "" # Forum or community link (if any)
23+
community_url: "haha" # Forum or community link (if any)

0 commit comments

Comments
 (0)