-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edf6b8c
commit 62371c6
Showing
5 changed files
with
281 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Build Stacks Object | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Make Script Executable (If Needed) | ||
run: chmod +x ./utils/build_stacks_array.sh && chmod +x ./utils/build_categories_array.sh | ||
|
||
- name: Run build_stacks_object.sh | ||
run: ./utils/build_stacks_object.sh && ./utils/build_categories_array.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
|
||
source utils/stack_metadata.sh | ||
|
||
build_categories_array() { | ||
# Initialize an empty JSON array for categories | ||
json_output="[]" | ||
|
||
# Iterate over each category | ||
for category in "${!categories_to_stacks[@]}"; do | ||
# Lowercase transformation functions for labels | ||
lowercase_transform() { | ||
echo "$1" | tr '[:upper:]' '[:lower:]' | tr -s ' ' '_' | ||
} | ||
|
||
# Category attributes | ||
category_name=$(lowercase_transform "$category") | ||
category_label="${category//_/ }" # Convert underscores to spaces | ||
category_emoji="${categories_to_emojis[$category]:-Unknown}" | ||
category_description="${categories_descriptions[$category]:-No description available}" | ||
|
||
# Initialize an empty JSON array for stacks within this category | ||
stacks_json="[]" | ||
|
||
# Iterate over stacks assigned to this category | ||
for name in ${categories_to_stacks[$category]}; do | ||
stack_name=$(lowercase_transform "$name") | ||
stack_label="${name//_/ }" # Convert underscores to spaces | ||
stack_description="${stack_descriptions[$name]}" # Stack description | ||
stack_status="${stack_status[$name]:-Unknown}" | ||
|
||
# Create the stack object | ||
stack_item=$(jq -n \ | ||
--arg category_name "${category_name:-Unknown}" \ | ||
--arg name "${stack_name:-Unknown}" \ | ||
--arg stack_label "${stack_label:-Unknown}" \ | ||
--arg description "${stack_description:-Unknown}" \ | ||
--arg status "${stack_status:-Unknown}" \ | ||
'{ | ||
"name": $name, | ||
"type": "stack", | ||
"category_name": $category_name, | ||
"stack_label": $stack_label, | ||
"description": $description, | ||
"status": $status | ||
}') | ||
|
||
# Append stack_item to stacks_json | ||
stacks_json=$(jq -c ". + [$stack_item]" <<< "$stacks_json") | ||
done | ||
|
||
# Create the category object with stacks inside | ||
category_item=$(jq -n \ | ||
--arg name "$category_name" \ | ||
--arg category_label "$category_label" \ | ||
--arg description "$category_description" \ | ||
--arg emoji "$category_emoji" \ | ||
--argjson stacks "$stacks_json" \ | ||
'{ | ||
"name": $name, | ||
"type": "category", | ||
"category_label": $category_label, | ||
"emoji": $emoji, | ||
"description": $description, | ||
"stacks": $stacks | ||
}') | ||
|
||
# Append category_item to json_output | ||
json_output=$(jq -c ". + [$category_item]" <<< "$json_output") | ||
done | ||
|
||
# Output the final JSON array | ||
echo "$json_output" | ||
} | ||
|
||
# Output the final JSON array with status | ||
time build_categories_array | jq '.' > "./stacks/categories.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
|
||
source utils/stack_metadata.sh | ||
|
||
build_stack_array(){ | ||
# Initialize an empty JSON array | ||
json_output="[]" | ||
|
||
# Iterate over each tool | ||
for name in "${!stack_descriptions[@]}"; do | ||
description="${stack_descriptions[$name]}" # Tool description | ||
stack_status="${stack_status[$name]:-Unknown}" | ||
|
||
# Find the category for the current tool | ||
for cat in "${!categories_to_stacks[@]}"; do | ||
if [[ " ${categories_to_stacks[$cat]} " =~ " $name " ]]; then | ||
category="$cat" | ||
break | ||
fi | ||
done | ||
|
||
# Lowercase transformation functions for labels | ||
lowercase_transform() { | ||
echo "$1" | tr '[:upper:]' '[:lower:]' | tr -s ' ' '_' | ||
} | ||
|
||
# Create transformed labels | ||
category_name=$(lowercase_transform "$category") | ||
|
||
category_description="${categories_descriptions[$category]:-No description available}" | ||
category_label="${category//_/ }" # Convert underscores to spaces | ||
category_emoji="${categories_to_emojis[$category]:-Unknown}" | ||
|
||
stack_name=$(lowercase_transform "$name") | ||
stack_label="${name//_/ }" # Convert underscores to spaces | ||
|
||
# Create the stack object with the category_description | ||
stack_item=$(jq -n \ | ||
--arg category_name "$category_name" \ | ||
--arg category_label "$category_label" \ | ||
--arg category_emoji "$category_emoji" \ | ||
--arg category_description "$category_description" \ | ||
--arg stack_name "$stack_name" \ | ||
--arg stack_status "$stack_status" \ | ||
--arg stack_label "$stack_label" \ | ||
--arg stack_description "$description" \ | ||
--arg status "$status" \ | ||
'{ | ||
"stack_name": $stack_name, | ||
"stack_label": $stack_label, | ||
"stack_description": $stack_description, | ||
"stack_status": $stack_status, | ||
"category_emoji": $category_emoji, | ||
"category_name": $category_name, | ||
"category_label": $category_label, | ||
"category_description": $category_description, | ||
}') | ||
|
||
# Append the stack_item to the JSON array | ||
json_output=$(jq -c ". + [$stack_item]" <<< "$json_output") | ||
done | ||
|
||
# Output the final JSON array | ||
echo "$json_output" | ||
} | ||
|
||
# Output the final JSON array with status | ||
time build_stack_array | jq '.' > "./stacks/stacks.json" | ||
|
Oops, something went wrong.