Skip to content

Commit

Permalink
add-exercise-script-changes: Added usage of the 'configlet create --p…
Browse files Browse the repository at this point in the history
…ractice-exercise'.
  • Loading branch information
SimaDovakin committed Aug 1, 2024
1 parent 18e29d5 commit 4255c77
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions bin/add-exercise
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,15 @@ if [ $# -ne 1 ]; then
exit 1
fi

command -v jq >/dev/null 2>&1 || {
echo >&2 "jq is required but not installed. Please install it and make sure it's in your PATH."
exit 1
}
command -v curl >/dev/null 2>&1 || {
echo >&2 "curl is required but not installed. Please install it and make sure it's in your PATH."
exit 1
}

bin/fetch-configlet

# Add entry for exercise in config.json
slug="${1}"
name=$(echo "${slug}" | sed 's/\b\w/\u&/g')
uuid=$(bin/configlet uuid)
jq --arg slug "${slug}" --arg uuid "${uuid}" --arg name "${name}" \
'.exercises.practice += [{slug: $slug, name: $name, uuid: $uuid, practices: [], prerequisites: [], difficulty: 1}]' \
config.json > config.json.tmp && mv config.json.tmp config.json
bin/configlet create --practice-exercise "${slug}"

# Sync the exercise
bin/configlet sync --update --yes --tests include --filepaths --metadata --docs --exercise "${slug}"

newline=$'\n'
camel_name=$(sed -E 's/-([a-z])/\U\1/g' <<< "${slug}")
exercise_dir="exercises/practice/${slug}"

touch "${exercise_dir}/${camel_name}.u"
touch "${exercise_dir}/${camel_name}.test.u"

mkdir -p "${exercise_dir}/.meta/examples"
touch "${exercise_dir}/.meta/examples/${camel_name}.example.u"

cat <<EOT > "${exercise_dir}/.meta/testLoader.md"
# Testing transcript for ${slug} exercise
Expand Down

0 comments on commit 4255c77

Please sign in to comment.