Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add-exercise-script-changes: Added usage of the 'configlet create --practice-exercise'. #136

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading