feat: add update-template command to synchronize task.template with library.md

- Added `update-template` command that extracts rows from `library.md` and updates `task.template`
- Implemented logic to replace existing rows in `task.template` with current rows from `library.md`
- Added `update-template` to help-table for documentation and discoverability
- Updated `library.md` to use consistent terminology (dotenv instead of env)
- Removed outdated prompt script that was no longer needed
- Ensured all rows from `library.md` are properly synchronized with `task.template`
This commit is contained in:
Janik von Rotz committed 2026-02-08 16:40:16 +01:00
1 parent a27e78af51
commit 904a69183f
6 files changed
+1683 -90

No files matched your search

+53
View File
@@ -17,6 +17,7 @@ help-table() {
rows+=("run||Run Docker image.")
rows+=("run-tests||Test with shellcheck.")
rows+=("serve-11ty||Serve the 11ty output folder.")
rows+=("update-template||Update task.template from library.md.")
rows+=("version||Show version of required tools.")
for row in "${rows[@]}"; do
@@ -124,6 +125,58 @@ version() {
echo "eleventy: $(pnpm dlx @11ty/eleventy --version)"
}
update-template() {
echo "Updating task.template from library.md"
# Extract all rows from library.md that match the pattern rows+=("...")
local -a new_rows
while IFS= read -r line; do
if [[ $line =~ rows\+=\(\"(.*)\"\) ]]; then
new_rows+=("${BASH_REMATCH[1]}")
fi
done < library.md
# Create a temporary file
local temp_file=$(mktemp)
# Read the task.template file and update the rows section
local in_rows_section=false
local found_header=false
while IFS= read -r line || [[ -n "$line" ]]; do
# Check if we're at the header row
if [[ $line == *"rows+=(\"Command|Option|Description\")"* ]]; then
echo "$line" >> "$temp_file"
found_header=true
in_rows_section=true
# Add all the new rows after the header
for row in "${new_rows[@]}"; do
echo " rows+=(\"$row\")" >> "$temp_file"
done
continue
fi
# Check if we're at the for-loop that ends the rows section
if [[ $line == *"for row in \"\${rows[@]}\""* ]]; then
in_rows_section=false
fi
# Skip existing rows between header and for-loop
if $in_rows_section && $found_header; then
if [[ $line =~ rows\+=\(\"(.*)\"\) ]]; then
continue
fi
fi
echo "$line" >> "$temp_file"
done < task.template
# Replace task.template with the updated content
mv "$temp_file" task.template
echo "task.template updated successfully"
}
if [[ "$1" == *","* ]]; then
# Split comma-separated commands
IFS=',' read -ra COMMANDS <<< "$1"